![]() |
LeechCraft
0.6.70-3565-g2d86529
Modular cross-platform feature rich live environment.
|
Manipulates query part of an QUrl object. More...
#include "urloperator.h"
Public Member Functions | |
UrlOperator (QUrl &url) | |
Constructs the object modifying the query of url. More... | |
~UrlOperator () | |
Flushes any pending changes to the QUrl query and destroys the UrlOperator. More... | |
void | Flush () |
Flushes any pending changes to the QUrl query. More... | |
UrlOperator & | operator() (const QString &key, const QString &value) |
Adds a new key = value parameters pair. More... | |
UrlOperator & | operator-= (const QString &key) |
Returns the first query parameter under the key. More... | |
QUrl | operator() () |
Flushes any pending changes to the QUrl query. More... | |
Manipulates query part of an QUrl object.
This class abstracts away differences between Qt4 and Qt5 QUrl and QUrlQuery handling, and it should be used in all new code instead of direct calls to Qt API.
This class is used as follows:
pair of matching key and value.
Intended usage:
Here, an unnamed UrlOperator object is created that is valid only inside the corresponding expression, thus the changes to someUrl
are visible immediately after executing that line.
Definition at line 73 of file urloperator.h.
LeechCraft::Util::UrlOperator::UrlOperator | ( | QUrl & | url | ) |
Constructs the object modifying the query of url.
[in] | url | The URL to modify. |
Definition at line 36 of file urloperator.cpp.
LeechCraft::Util::UrlOperator::~UrlOperator | ( | ) |
Flushes any pending changes to the QUrl query and destroys the UrlOperator.
Definition at line 44 of file urloperator.cpp.
References Flush().
void LeechCraft::Util::UrlOperator::Flush | ( | ) |
Flushes any pending changes to the QUrl query.
Definition at line 49 of file urloperator.cpp.
Referenced by operator()(), and ~UrlOperator().
UrlOperator & LeechCraft::Util::UrlOperator::operator() | ( | const QString & | key, |
const QString & | value | ||
) |
Adds a new key = value parameters pair.
If the URL already contains this key, a new value is added in addition to the already existing one.
The key/value pair is encoded before it is added to the query. The key and value are also encoded into UTF-8. Both key and value are URL-encoded as well. So, this function is analogous in effect to standard relevant Qt APIs.
[in] | key | The query parameter key. |
[in] | value | The query parameter value. |
Definition at line 56 of file urloperator.cpp.
QUrl LeechCraft::Util::UrlOperator::operator() | ( | ) |
Flushes any pending changes to the QUrl query.
Definition at line 78 of file urloperator.cpp.
References Flush().
UrlOperator & LeechCraft::Util::UrlOperator::operator-= | ( | const QString & | key | ) |
Returns the first query parameter under the key.
If no such parameters exist, this function does nothing.
[in] | key | The query parameter key. |
Definition at line 67 of file urloperator.cpp.