LeechCraft 0.6.70-16373-g319c272718
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
LC::Util::UrlOperator Class Reference

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.
 
 ~UrlOperator ()
 Flushes any pending changes to the QUrl query and destroys the UrlOperator.
 
void Flush ()
 Flushes any pending changes to the QUrl query.
 
UrlOperatoroperator() (const QString &key, const QString &value)
 Adds a new key = value parameters pair.
 
UrlOperatoroperator() (const QString &key, const QByteArray &value)
 Adds a new key = value parameters pair.
 
UrlOperatoroperator() (const QString &key, const char *value)
 Adds a new key = value parameters pair.
 
UrlOperatoroperator() (const QString &key, int value)
 Adds a new key = value parameters pair.
 
template<typename Key, typename Value>
UrlOperatoroperator() (bool condition, Key &&key, Value &&value)
 
UrlOperatoroperator-= (const QString &key)
 Returns the first query parameter under the key.
 
QUrl operator() ()
 Flushes any pending changes to the QUrl query.
 

Detailed Description

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:

  1. An object of this class is constructed on a (named) QUrl object.
  2. New URL query parameters are added by calling this object with a pair of matching key and value.
  3. Existing URL query parameters are removed via the -= operator.
  4. The URL is updated on UrlOperator object destruction.

Intended usage:

QUrl someUrl { ... };
UrlOperator { someUrl }
("key1", "value1")
("key2", "value2");
Manipulates query part of an QUrl object.
Definition urloperator.h:49

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.

Note
The changes are guaranteed to be applied on UrlOperator object destruction. Nevertheless, they may still be applied earlier on during calls to operator()() and operator-=().

Definition at line 48 of file urloperator.h.

Constructor & Destructor Documentation

◆ UrlOperator()

LC::Util::UrlOperator::UrlOperator ( QUrl & url)

Constructs the object modifying the query of url.

Parameters
[in]urlThe URL to modify.

Definition at line 15 of file urloperator.cpp.

Referenced by operator()(), operator()(), operator()(), operator()(), operator()(), and operator-=().

+ Here is the caller graph for this function:

◆ ~UrlOperator()

LC::Util::UrlOperator::~UrlOperator ( )

Flushes any pending changes to the QUrl query and destroys the UrlOperator.

See also
Flush()
operator()()

Definition at line 21 of file urloperator.cpp.

References Flush().

+ Here is the call graph for this function:

Member Function Documentation

◆ Flush()

void LC::Util::UrlOperator::Flush ( )

Flushes any pending changes to the QUrl query.

Definition at line 26 of file urloperator.cpp.

Referenced by ~UrlOperator(), and operator()().

+ Here is the caller graph for this function:

◆ operator()() [1/6]

QUrl LC::Util::UrlOperator::operator() ( )

Flushes any pending changes to the QUrl query.

Definition at line 58 of file urloperator.cpp.

References Flush().

+ Here is the call graph for this function:

◆ operator()() [2/6]

template<typename Key, typename Value>
UrlOperator & LC::Util::UrlOperator::operator() ( bool condition,
Key && key,
Value && value )
inline

Definition at line 130 of file urloperator.h.

References UrlOperator().

+ Here is the call graph for this function:

◆ operator()() [3/6]

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.

Parameters
[in]keyThe query parameter key.
[in]valueThe query parameter value (a Latin1-string).
Returns
This UrlOperator object.

Definition at line 42 of file urloperator.cpp.

References UrlOperator().

+ Here is the call graph for this function:

◆ operator()() [4/6]

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.

Parameters
[in]keyThe query parameter key.
[in]valueThe query parameter value.
Returns
This UrlOperator object.

Definition at line 37 of file urloperator.cpp.

References UrlOperator().

+ Here is the call graph for this function:

◆ operator()() [5/6]

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.

Parameters
[in]keyThe query parameter key.
[in]valueThe query parameter value.
Returns
This UrlOperator object.

Definition at line 31 of file urloperator.cpp.

References UrlOperator().

+ Here is the call graph for this function:

◆ operator()() [6/6]

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.

Parameters
[in]keyThe query parameter key.
[in]valueThe query parameter value.
Returns
This UrlOperator object.

Definition at line 47 of file urloperator.cpp.

References UrlOperator().

+ Here is the call graph for this function:

◆ operator-=()

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.

Parameters
[in]keyThe query parameter key.
Returns
This UrlOperator object.

Definition at line 52 of file urloperator.cpp.

References UrlOperator().

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: