pub struct ComponentFormattingOption(/* private fields */);
Expand description

The component formatting options define how the components of an URL will be formatted when written out as text. They can be combined with the options from QUrl::FormattingOptions when used in toString() and toEncoded().

C++ enum: QUrl::ComponentFormattingOption.

C++ documentation:

The component formatting options define how the components of an URL will be formatted when written out as text. They can be combined with the options from QUrl::FormattingOptions when used in toString() and toEncoded().

The values of EncodeReserved and DecodeReserved should not be used together in one call. The behavior is undefined if that happens. They are provided as separate values because the behavior of the "pretty mode" with regards to reserved characters is different on certain components and specially on the full URL.

Full decoding

The FullyDecoded mode is similar to the behavior of the functions returning QString in Qt 4.x, in that every character represents itself and never has any special meaning. This is true even for the percent character ('%'), which should be interpreted to mean a literal percent, not the beginning of a percent-encoded sequence. The same actual character, in all other decoding modes, is represented by the sequence "%25".

Whenever re-applying data obtained with QUrl::FullyDecoded into a QUrl, care must be taken to use the QUrl::DecodedMode parameter to the setters (like setPath() and setUserName()). Failure to do so may cause re-interpretation of the percent character ('%') as the beginning of a percent-encoded sequence.

This mode is quite useful when portions of a URL are used in a non-URL context. For example, to extract the username, password or file paths in an FTP client application, the FullyDecoded mode should be used.

This mode should be used with care, since there are two conditions that cannot be reliably represented in the returned QString. They are:

  • Non-UTF-8 sequences: URLs may contain sequences of percent-encoded characters that do not form valid UTF-8 sequences. Since URLs need to be decoded using UTF-8, any decoder failure will result in the QString containing one or more replacement characters where the sequence existed.
  • Encoded delimiters: URLs are also allowed to make a distinction between a delimiter found in its literal form and its equivalent in percent-encoded form. This is most commonly found in the query, but is permitted in most parts of the URL.

The following example illustrates the problem:

QUrl original(“http://example.com/?q=a%2B%3Db%26c”); QUrl copy(original); copy.setQuery(copy.query(QUrl::FullyDecoded), QUrl::DecodedMode);

qDebug() << original.toString(); // prints: http://example.com/?q=a%2B%3Db%26c qDebug() << copy.toString(); // prints: http://example.com/?q=a+=b&c

If the two URLs were used via HTTP GET, the interpretation by the web server would probably be different. In the first case, it would interpret as one parameter, with a key of "q" and value "a+=b&c". In the second case, it would probably interpret as two parameters, one with a key of "q" and value "a =b", and the second with a key "c" and no value.

This enum was introduced or modified in Qt 5.0.

The ComponentFormattingOptions type is a typedef for QFlags<ComponentFormattingOption>. It stores an OR combination of ComponentFormattingOption values.

See also QUrl::FormattingOptions.

Implementations§

source§

impl ComponentFormattingOption

source

pub fn to_int(&self) -> c_int

source§

impl ComponentFormattingOption

source

pub const PrettyDecoded: ComponentFormattingOption = _

The component is returned in a “pretty form”, with most percent-encoded characters decoded. The exact behavior of PrettyDecoded varies from component to component and may also change from Qt release to Qt release. This is the default. (C++ enum variant: PrettyDecoded = 0)

source

pub const EncodeSpaces: ComponentFormattingOption = _

Leave space characters in their encoded form (“%20”). (C++ enum variant: EncodeSpaces = 1048576)

source

pub const EncodeUnicode: ComponentFormattingOption = _

Leave non-US-ASCII characters encoded in their UTF-8 percent-encoded form (e.g., “%C3%A9” for the U+00E9 codepoint, LATIN SMALL LETTER E WITH ACUTE). (C++ enum variant: EncodeUnicode = 2097152)

source

pub const EncodeDelimiters: ComponentFormattingOption = _

Leave certain delimiters in their encoded form, as would appear in the URL when the full URL is represented as text. The delimiters are affected by this option change from component to component. This flag has no effect in toString() or toEncoded(). (C++ enum variant: EncodeDelimiters = 12582912)

source

pub const EncodeReserved: ComponentFormattingOption = _

Leave US-ASCII characters not permitted in the URL by the specification in their encoded form. This is the default on toString() and toEncoded(). (C++ enum variant: EncodeReserved = 16777216)

source

pub const DecodeReserved: ComponentFormattingOption = _

Decode the US-ASCII characters that the URL specification does not allow to appear in the URL. This is the default on the getters of individual components. (C++ enum variant: DecodeReserved = 33554432)

source

pub const FullyEncoded: ComponentFormattingOption = _

Leave all characters in their properly-encoded form, as this component would appear as part of a URL. When used with toString(), this produces a fully-compliant URL in QString form, exactly equal to the result of toEncoded() (C++ enum variant: FullyEncoded = 32505856)

source

pub const FullyDecoded: ComponentFormattingOption = _

Attempt to decode as much as possible. For individual components of the URL, this decodes every percent encoding sequence, including control characters (U+0000 to U+001F) and UTF-8 sequences found in percent-encoded form. Use of this mode may cause data loss, see below for more information. (C++ enum variant: FullyDecoded = 133169152)

Trait Implementations§

source§

impl BitAnd<ComponentFormattingOption> for &QUrlTwoFlagsOfUrlFormattingOptionComponentFormattingOption

source§

fn bitand( self, f: ComponentFormattingOption ) -> CppBox<QUrlTwoFlagsOfUrlFormattingOptionComponentFormattingOption>

Calls C++ function: QUrlTwoFlags<QUrl::UrlFormattingOption, QUrl::ComponentFormattingOption> QUrlTwoFlags<QUrl::UrlFormattingOption, QUrl::ComponentFormattingOption>::operator&(QUrl::ComponentFormattingOption f) const.

§

type Output = CppBox<QUrlTwoFlagsOfUrlFormattingOptionComponentFormattingOption>

The resulting type after applying the & operator.
source§

impl BitOr<ComponentFormattingOption> for &QUrlTwoFlagsOfUrlFormattingOptionComponentFormattingOption

source§

fn bitor( self, f: ComponentFormattingOption ) -> CppBox<QUrlTwoFlagsOfUrlFormattingOptionComponentFormattingOption>

Calls C++ function: QUrlTwoFlags<QUrl::UrlFormattingOption, QUrl::ComponentFormattingOption> QUrlTwoFlags<QUrl::UrlFormattingOption, QUrl::ComponentFormattingOption>::operator|(QUrl::ComponentFormattingOption f) const.

§

type Output = CppBox<QUrlTwoFlagsOfUrlFormattingOptionComponentFormattingOption>

The resulting type after applying the | operator.
source§

impl<T: Into<QFlags<ComponentFormattingOption>>> BitOr<T> for ComponentFormattingOption

§

type Output = QFlags<ComponentFormattingOption>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: T) -> QFlags<ComponentFormattingOption>

Performs the | operation. Read more
source§

impl BitXor<ComponentFormattingOption> for &QUrlTwoFlagsOfUrlFormattingOptionComponentFormattingOption

source§

fn bitxor( self, f: ComponentFormattingOption ) -> CppBox<QUrlTwoFlagsOfUrlFormattingOptionComponentFormattingOption>

Calls C++ function: QUrlTwoFlags<QUrl::UrlFormattingOption, QUrl::ComponentFormattingOption> QUrlTwoFlags<QUrl::UrlFormattingOption, QUrl::ComponentFormattingOption>::operator^(QUrl::ComponentFormattingOption f) const.

§

type Output = CppBox<QUrlTwoFlagsOfUrlFormattingOptionComponentFormattingOption>

The resulting type after applying the ^ operator.
source§

impl Clone for ComponentFormattingOption

source§

fn clone(&self) -> ComponentFormattingOption

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ComponentFormattingOption

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<ComponentFormattingOption> for QFlags<ComponentFormattingOption>

source§

fn from(value: ComponentFormattingOption) -> Self

Converts to this type from the input type.
source§

impl From<ComponentFormattingOption> for c_int

source§

fn from(value: ComponentFormattingOption) -> Self

Converts to this type from the input type.
source§

impl From<i32> for ComponentFormattingOption

source§

fn from(value: c_int) -> Self

Converts to this type from the input type.
source§

impl PartialEq for ComponentFormattingOption

source§

fn eq(&self, other: &ComponentFormattingOption) -> bool

This method tests for self and other values to be equal, and is used by ==.
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.
source§

impl Copy for ComponentFormattingOption

source§

impl Eq for ComponentFormattingOption

source§

impl StructuralEq for ComponentFormattingOption

source§

impl StructuralPartialEq for ComponentFormattingOption

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.