Struct qt_core::QUrlQuery

source ·
#[repr(C)]
pub struct QUrlQuery { /* private fields */ }
Expand description

The QUrlQuery class provides a way to manipulate a key-value pairs in a URL's query.

C++ class: QUrlQuery.

C++ documentation:

The QUrlQuery class provides a way to manipulate a key-value pairs in a URL’s query.

It is used to parse the query strings found in URLs like the following:

Query strings like the above are used to transmit options in the URL and are usually decoded into multiple key-value pairs. The one above would contain two entries in its list, with keys "type" and "color". QUrlQuery can also be used to create a query string suitable for use in QUrl::setQuery() from the individual components of the query.

The most common way of parsing a query string is to initialize it in the constructor by passing it the query string. Otherwise, the setQuery() method can be used to set the query to be parsed. That method can also be used to parse a query with non-standard delimiters, after having set them using the setQueryDelimiters() function.

The encoded query string can be obtained again using query(). This will take all the internally-stored items and encode the string using the delimiters.

Implementations§

source§

impl QUrlQuery

source

pub unsafe fn add_query_item( &self, key: impl CastInto<Ref<QString>>, value: impl CastInto<Ref<QString>> )

Appends the pair key = value to the end of the query string of the URL. This method does not overwrite existing items that might exist with the same key.

Calls C++ function: void QUrlQuery::addQueryItem(const QString& key, const QString& value).

C++ documentation:

Appends the pair key = value to the end of the query string of the URL. This method does not overwrite existing items that might exist with the same key.

Note: This method does not treat spaces (ASCII 0x20) and plus ("+") signs as the same, like HTML forms do. If you need spaces to be represented as plus signs, use actual plus signs.

See also hasQueryItem() and queryItemValue().

source

pub unsafe fn all_query_item_values_2a( &self, key: impl CastInto<Ref<QString>>, encoding: QFlags<ComponentFormattingOption> ) -> CppBox<QStringList>

Returns the a list of query string values whose key is equal to key from the URL, using the options specified in encoding to encode the return value. If the key key is not found, this function returns an empty list.

Calls C++ function: QStringList QUrlQuery::allQueryItemValues(const QString& key, QFlags<QUrl::ComponentFormattingOption> encoding = …) const.

C++ documentation:

Returns the a list of query string values whose key is equal to key from the URL, using the options specified in encoding to encode the return value. If the key key is not found, this function returns an empty list.

See also queryItemValue() and addQueryItem().

source

pub unsafe fn all_query_item_values_1a( &self, key: impl CastInto<Ref<QString>> ) -> CppBox<QStringList>

Returns the a list of query string values whose key is equal to key from the URL, using the options specified in encoding to encode the return value. If the key key is not found, this function returns an empty list.

Calls C++ function: QStringList QUrlQuery::allQueryItemValues(const QString& key) const.

C++ documentation:

Returns the a list of query string values whose key is equal to key from the URL, using the options specified in encoding to encode the return value. If the key key is not found, this function returns an empty list.

See also queryItemValue() and addQueryItem().

source

pub unsafe fn clear(&self)

Clears this QUrlQuery object by removing all of the key-value pairs currently stored. If the query delimiters have been changed, this function will leave them with their changed values.

Calls C++ function: void QUrlQuery::clear().

C++ documentation:

Clears this QUrlQuery object by removing all of the key-value pairs currently stored. If the query delimiters have been changed, this function will leave them with their changed values.

See also isEmpty() and setQueryDelimiters().

source

pub unsafe fn copy_from( &self, other: impl CastInto<Ref<QUrlQuery>> ) -> Ref<QUrlQuery>

Copies the contents of the other QUrlQuery object, including the query delimiters.

Calls C++ function: QUrlQuery& QUrlQuery::operator=(const QUrlQuery& other).

C++ documentation:

Copies the contents of the other QUrlQuery object, including the query delimiters.

source

pub unsafe fn default_query_pair_delimiter() -> CppBox<QChar>

Returns the default character for separating keys-value pairs from each other, an ampersand ("&").

Calls C++ function: static QChar QUrlQuery::defaultQueryPairDelimiter().

C++ documentation:

Returns the default character for separating keys-value pairs from each other, an ampersand (“&”).

See also setQueryDelimiters(), queryPairDelimiter(), and defaultQueryValueDelimiter().

source

pub unsafe fn default_query_value_delimiter() -> CppBox<QChar>

Returns the default character for separating keys from values in the query, an equal sign ("=").

Calls C++ function: static QChar QUrlQuery::defaultQueryValueDelimiter().

C++ documentation:

Returns the default character for separating keys from values in the query, an equal sign (“=”).

See also setQueryDelimiters(), queryValueDelimiter(), and defaultQueryPairDelimiter().

source

pub unsafe fn has_query_item(&self, key: impl CastInto<Ref<QString>>) -> bool

Returns true if there is a query string pair whose key is equal to key from the URL.

Calls C++ function: bool QUrlQuery::hasQueryItem(const QString& key) const.

C++ documentation:

Returns true if there is a query string pair whose key is equal to key from the URL.

See also addQueryItem() and queryItemValue().

source

pub unsafe fn is_detached(&self) -> bool

Calls C++ function: bool QUrlQuery::isDetached() const.

source

pub unsafe fn is_empty(&self) -> bool

Returns true if this QUrlQuery object contains no key-value pairs, such as after being default-constructed or after parsing an empty query string.

Calls C++ function: bool QUrlQuery::isEmpty() const.

C++ documentation:

Returns true if this QUrlQuery object contains no key-value pairs, such as after being default-constructed or after parsing an empty query string.

See also setQuery() and clear().

source

pub unsafe fn new() -> CppBox<QUrlQuery>

Constructs an empty QUrlQuery object. A query can be set afterwards by calling setQuery() or items can be added by using addQueryItem().

Calls C++ function: [constructor] void QUrlQuery::QUrlQuery().

C++ documentation:

Constructs an empty QUrlQuery object. A query can be set afterwards by calling setQuery() or items can be added by using addQueryItem().

See also setQuery() and addQueryItem().

source

pub unsafe fn from_q_url(url: impl CastInto<Ref<QUrl>>) -> CppBox<QUrlQuery>

Constructs a QUrlQuery object and parses the query string found in the url URL, using the default query delimiters. To parse a query string using other delimiters, you should first set them using setQueryDelimiters() and then set the query with setQuery().

Calls C++ function: [constructor] void QUrlQuery::QUrlQuery(const QUrl& url).

C++ documentation:

Constructs a QUrlQuery object and parses the query string found in the url URL, using the default query delimiters. To parse a query string using other delimiters, you should first set them using setQueryDelimiters() and then set the query with setQuery().

See also QUrl::query().

source

pub unsafe fn from_q_string( query_string: impl CastInto<Ref<QString>> ) -> CppBox<QUrlQuery>

Constructs a QUrlQuery object and parses the queryString query string, using the default query delimiters. To parse a query string using other delimiters, you should first set them using setQueryDelimiters() and then set the query with setQuery().

Calls C++ function: [constructor] void QUrlQuery::QUrlQuery(const QString& queryString).

C++ documentation:

Constructs a QUrlQuery object and parses the queryString query string, using the default query delimiters. To parse a query string using other delimiters, you should first set them using setQueryDelimiters() and then set the query with setQuery().

source

pub unsafe fn new_copy( other: impl CastInto<Ref<QUrlQuery>> ) -> CppBox<QUrlQuery>

Copies the contents of the other QUrlQuery object, including the query delimiters.

Calls C++ function: [constructor] void QUrlQuery::QUrlQuery(const QUrlQuery& other).

C++ documentation:

Copies the contents of the other QUrlQuery object, including the query delimiters.

source

pub unsafe fn query_1a( &self, encoding: QFlags<ComponentFormattingOption> ) -> CppBox<QString>

Returns the reconstructed query string, formed from the key-value pairs currently stored in this QUrlQuery object and separated by the query delimiters chosen for this object. The keys and values are encoded using the options given by the encoding parameter.

Calls C++ function: QString QUrlQuery::query(QFlags<QUrl::ComponentFormattingOption> encoding = …) const.

C++ documentation:

Returns the reconstructed query string, formed from the key-value pairs currently stored in this QUrlQuery object and separated by the query delimiters chosen for this object. The keys and values are encoded using the options given by the encoding parameter.

For this function, the only ambiguous delimiter is the hash ("#"), as in URLs it is used to separate the query string from the fragment that may follow.

The order of the key-value pairs in the returned string is exactly the same as in the original query.

See also setQuery(), QUrl::setQuery(), QUrl::fragment(), and Encoding.

source

pub unsafe fn query_0a(&self) -> CppBox<QString>

Returns the reconstructed query string, formed from the key-value pairs currently stored in this QUrlQuery object and separated by the query delimiters chosen for this object. The keys and values are encoded using the options given by the encoding parameter.

Calls C++ function: QString QUrlQuery::query() const.

C++ documentation:

Returns the reconstructed query string, formed from the key-value pairs currently stored in this QUrlQuery object and separated by the query delimiters chosen for this object. The keys and values are encoded using the options given by the encoding parameter.

For this function, the only ambiguous delimiter is the hash ("#"), as in URLs it is used to separate the query string from the fragment that may follow.

The order of the key-value pairs in the returned string is exactly the same as in the original query.

See also setQuery(), QUrl::setQuery(), QUrl::fragment(), and Encoding.

source

pub unsafe fn query_item_value_2a( &self, key: impl CastInto<Ref<QString>>, encoding: QFlags<ComponentFormattingOption> ) -> CppBox<QString>

Returns the query value associated with key key from the URL, using the options specified in encoding to encode the return value. If the key key is not found, this function returns an empty string. If you need to distinguish between an empty value and a non-existent key, you should check for the key's presence first using hasQueryItem().

Calls C++ function: QString QUrlQuery::queryItemValue(const QString& key, QFlags<QUrl::ComponentFormattingOption> encoding = …) const.

C++ documentation:

Returns the query value associated with key key from the URL, using the options specified in encoding to encode the return value. If the key key is not found, this function returns an empty string. If you need to distinguish between an empty value and a non-existent key, you should check for the key’s presence first using hasQueryItem().

If the key key is multiply defined, this function will return the first one found, in the order they were present in the query string or added using addQueryItem().

See also addQueryItem(), allQueryItemValues(), and Encoding.

source

pub unsafe fn query_item_value_1a( &self, key: impl CastInto<Ref<QString>> ) -> CppBox<QString>

Returns the query value associated with key key from the URL, using the options specified in encoding to encode the return value. If the key key is not found, this function returns an empty string. If you need to distinguish between an empty value and a non-existent key, you should check for the key's presence first using hasQueryItem().

Calls C++ function: QString QUrlQuery::queryItemValue(const QString& key) const.

C++ documentation:

Returns the query value associated with key key from the URL, using the options specified in encoding to encode the return value. If the key key is not found, this function returns an empty string. If you need to distinguish between an empty value and a non-existent key, you should check for the key’s presence first using hasQueryItem().

If the key key is multiply defined, this function will return the first one found, in the order they were present in the query string or added using addQueryItem().

See also addQueryItem(), allQueryItemValues(), and Encoding.

source

pub unsafe fn query_items_1a( &self, encoding: QFlags<ComponentFormattingOption> ) -> CppBox<QListOfQPairOfQStringQString>

Returns the query string of the URL, as a map of keys and values, using the options specified in encoding to encode the items. The order of the elements is the same as the one found in the query string or set with setQueryItems().

Calls C++ function: QList<QPair<QString, QString>> QUrlQuery::queryItems(QFlags<QUrl::ComponentFormattingOption> encoding = …) const.

C++ documentation:

Returns the query string of the URL, as a map of keys and values, using the options specified in encoding to encode the items. The order of the elements is the same as the one found in the query string or set with setQueryItems().

See also setQueryItems() and Encoding.

source

pub unsafe fn query_items_0a(&self) -> CppBox<QListOfQPairOfQStringQString>

Returns the query string of the URL, as a map of keys and values, using the options specified in encoding to encode the items. The order of the elements is the same as the one found in the query string or set with setQueryItems().

Calls C++ function: QList<QPair<QString, QString>> QUrlQuery::queryItems() const.

C++ documentation:

Returns the query string of the URL, as a map of keys and values, using the options specified in encoding to encode the items. The order of the elements is the same as the one found in the query string or set with setQueryItems().

See also setQueryItems() and Encoding.

source

pub unsafe fn query_pair_delimiter(&self) -> CppBox<QChar>

Returns the character used to delimit between keys-value pairs when reconstructing the query string in query() or when parsing in setQuery().

Calls C++ function: QChar QUrlQuery::queryPairDelimiter() const.

C++ documentation:

Returns the character used to delimit between keys-value pairs when reconstructing the query string in query() or when parsing in setQuery().

See also setQueryDelimiters() and queryValueDelimiter().

source

pub unsafe fn query_value_delimiter(&self) -> CppBox<QChar>

Returns the character used to delimit between keys and values when reconstructing the query string in query() or when parsing in setQuery().

Calls C++ function: QChar QUrlQuery::queryValueDelimiter() const.

C++ documentation:

Returns the character used to delimit between keys and values when reconstructing the query string in query() or when parsing in setQuery().

See also setQueryDelimiters() and queryPairDelimiter().

source

pub unsafe fn remove_all_query_items(&self, key: impl CastInto<Ref<QString>>)

Removes all the query string pairs whose key is equal to key from the URL.

Calls C++ function: void QUrlQuery::removeAllQueryItems(const QString& key).

C++ documentation:

Removes all the query string pairs whose key is equal to key from the URL.

See also removeQueryItem().

source

pub unsafe fn remove_query_item(&self, key: impl CastInto<Ref<QString>>)

Removes the query string pair whose key is equal to key from the URL. If there are multiple items with a key equal to key, it removes the first item in the order they were present in the query string or added with addQueryItem().

Calls C++ function: void QUrlQuery::removeQueryItem(const QString& key).

C++ documentation:

Removes the query string pair whose key is equal to key from the URL. If there are multiple items with a key equal to key, it removes the first item in the order they were present in the query string or added with addQueryItem().

See also removeAllQueryItems().

source

pub unsafe fn set_query(&self, query_string: impl CastInto<Ref<QString>>)

Parses the query string in queryString and sets the internal items to the values found there. If any delimiters have been specified with setQueryDelimiters(), this function will use them instead of the default delimiters to parse the string.

Calls C++ function: void QUrlQuery::setQuery(const QString& queryString).

C++ documentation:

Parses the query string in queryString and sets the internal items to the values found there. If any delimiters have been specified with setQueryDelimiters(), this function will use them instead of the default delimiters to parse the string.

See also query().

source

pub unsafe fn set_query_delimiters( &self, value_delimiter: impl CastInto<Ref<QChar>>, pair_delimiter: impl CastInto<Ref<QChar>> )

Sets the characters used for delimiting between keys and values, and between key-value pairs in the URL's query string. The default value delimiter is '=' and the default pair delimiter is '&'.

Calls C++ function: void QUrlQuery::setQueryDelimiters(QChar valueDelimiter, QChar pairDelimiter).

C++ documentation:

Sets the characters used for delimiting between keys and values, and between key-value pairs in the URL’s query string. The default value delimiter is ‘=’ and the default pair delimiter is ‘&’.

valueDelimiter will be used for separating keys from values, and pairDelimiter will be used to separate key-value pairs. Any occurrences of these delimiting characters in the encoded representation of the keys and values of the query string are percent encoded when returned in query().

If valueDelimiter is set to '(' and pairDelimiter is ')', the above query string would instead be represented like this:

http://www.example.com/cgi-bin/drawgraph.cgi?type(pie)color(green)

Note: Non-standard delimiters should be chosen from among what RFC 3986 calls "sub-delimiters". They are:

sub-delims = “!” / “$” / “&” / “’” / “(” / “)” / “*” / “+” / “,” / “;” / “=”

Use of other characters is not supported and may result in unexpected behaviour. This method does not verify that you passed a valid delimiter.

See also queryValueDelimiter() and queryPairDelimiter().

source

pub unsafe fn set_query_items( &self, query: impl CastInto<Ref<QListOfQPairOfQStringQString>> )

Sets the items in this QUrlQuery object to query. The order of the elements in query is preserved.

Calls C++ function: void QUrlQuery::setQueryItems(const QList<QPair<QString, QString>>& query).

C++ documentation:

Sets the items in this QUrlQuery object to query. The order of the elements in query is preserved.

Note: This method does not treat spaces (ASCII 0x20) and plus ("+") signs as the same, like HTML forms do. If you need spaces to be represented as plus signs, use actual plus signs.

See also queryItems() and isEmpty().

source

pub unsafe fn swap(&self, other: impl CastInto<Ref<QUrlQuery>>)

Swaps this URL query instance with other. This function is very fast and never fails.

Calls C++ function: void QUrlQuery::swap(QUrlQuery& other).

C++ documentation:

Swaps this URL query instance with other. This function is very fast and never fails.

source

pub unsafe fn to_string_1a( &self, encoding: QFlags<ComponentFormattingOption> ) -> CppBox<QString>

Returns this QUrlQuery as a QString. encoding can be used to specify the URL string encoding of the return value.

Calls C++ function: QString QUrlQuery::toString(QFlags<QUrl::ComponentFormattingOption> encoding = …) const.

C++ documentation:

Returns this QUrlQuery as a QString. encoding can be used to specify the URL string encoding of the return value.

source

pub unsafe fn to_string_0a(&self) -> CppBox<QString>

Returns this QUrlQuery as a QString. encoding can be used to specify the URL string encoding of the return value.

Calls C++ function: QString QUrlQuery::toString() const.

C++ documentation:

Returns this QUrlQuery as a QString. encoding can be used to specify the URL string encoding of the return value.

Trait Implementations§

source§

impl CppDeletable for QUrlQuery

source§

unsafe fn delete(&self)

Destroys this QUrlQuery object.

Calls C++ function: [destructor] void QUrlQuery::~QUrlQuery().

C++ documentation:

Destroys this QUrlQuery object.

source§

impl PartialEq<Ref<QUrlQuery>> for QUrlQuery

source§

fn eq(&self, other: &Ref<QUrlQuery>) -> bool

Returns true if this object and the other object contain the same contents, in the same order, and use the same query delimiters.

Calls C++ function: bool QUrlQuery::operator==(const QUrlQuery& other) const.

C++ documentation:

Returns true if this object and the other object contain the same contents, in the same order, and use the same query delimiters.

1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, U> CastInto<U> for T
where U: CastFrom<T>,

source§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> StaticUpcast<T> for T

source§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.