![]() |
LeechCraft
0.6.70-10870-g558588d6ec
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, const QByteArray &value) |
Adds a new key = value parameters pair. More... | |
UrlOperator & | operator() (const QString &key, const char *value) |
Adds a new key = value parameters pair. More... | |
UrlOperator & | operator() (const QString &key, int value) |
Adds a new key = value parameters pair. More... | |
template<typename Key , typename Value > | |
UrlOperator & | operator() (bool condition, Key &&key, Value &&value) |
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:
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 69 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 42 of file urloperator.cpp.
References Flush().
void LeechCraft::Util::UrlOperator::Flush | ( | ) |
Flushes any pending changes to the QUrl query.
Definition at line 47 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 52 of file urloperator.cpp.
UrlOperator & LeechCraft::Util::UrlOperator::operator() | ( | const QString & | key, |
const QByteArray & | 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.
This overload is provided for convenience and efficiency.
[in] | key | The query parameter key. |
[in] | value | The query parameter value. |
Definition at line 58 of file urloperator.cpp.
UrlOperator & LeechCraft::Util::UrlOperator::operator() | ( | const QString & | key, |
const char * | 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 value is considered to be a Latin1-string.
This overload is provided for convenience and efficiency.
[in] | key | The query parameter key. |
[in] | value | The query parameter value (a Latin1-string). |
Definition at line 63 of file urloperator.cpp.
UrlOperator & LeechCraft::Util::UrlOperator::operator() | ( | const QString & | key, |
int | 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.
This overload is provided for convenience and efficiency.
[in] | key | The query parameter key. |
[in] | value | The query parameter value. |
Definition at line 68 of file urloperator.cpp.
|
inline |
Definition at line 151 of file urloperator.h.
QUrl LeechCraft::Util::UrlOperator::operator() | ( | ) |
Flushes any pending changes to the QUrl query.
Definition at line 79 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 73 of file urloperator.cpp.