LeechCraft
0.6.70-15082-g543737046d
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 60 of file urloperator.h.
LC::Util::UrlOperator::UrlOperator | ( | QUrl & | url | ) |
Constructs the object modifying the query of url.
[in] | url | The URL to modify. |
Definition at line 27 of file urloperator.cpp.
LC::Util::UrlOperator::~UrlOperator | ( | ) |
Flushes any pending changes to the QUrl query and destroys the UrlOperator.
Definition at line 33 of file urloperator.cpp.
void LC::Util::UrlOperator::Flush | ( | ) |
Flushes any pending changes to the QUrl query.
Definition at line 38 of file urloperator.cpp.
Referenced by operator()().
QUrl LC::Util::UrlOperator::operator() | ( | ) |
Flushes any pending changes to the QUrl query.
Definition at line 70 of file urloperator.cpp.
|
inline |
Definition at line 148 of file urloperator.h.
UrlOperator & LC::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 54 of file urloperator.cpp.
UrlOperator & LC::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 49 of file urloperator.cpp.
UrlOperator & LC::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 43 of file urloperator.cpp.
UrlOperator & LC::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 59 of file urloperator.cpp.
References Flush().
UrlOperator & LC::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 64 of file urloperator.cpp.