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
.
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
impl ComponentFormattingOption
Sourcepub const PrettyDecoded: ComponentFormattingOption
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
)
Sourcepub const EncodeSpaces: ComponentFormattingOption
pub const EncodeSpaces: ComponentFormattingOption
Leave space characters in their encoded form (“%20”). (C++ enum variant: EncodeSpaces = 1048576
)
Sourcepub const EncodeUnicode: ComponentFormattingOption
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
)
Sourcepub const EncodeDelimiters: ComponentFormattingOption
pub const EncodeDelimiters: ComponentFormattingOption
Sourcepub const EncodeReserved: ComponentFormattingOption
pub const EncodeReserved: ComponentFormattingOption
Sourcepub const DecodeReserved: ComponentFormattingOption
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
)
Sourcepub const FullyEncoded: ComponentFormattingOption
pub const FullyEncoded: ComponentFormattingOption
Sourcepub const FullyDecoded: ComponentFormattingOption
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
impl BitAnd<ComponentFormattingOption> for &QUrlTwoFlagsOfUrlFormattingOptionComponentFormattingOption
Source§fn bitand(
self,
f: ComponentFormattingOption,
) -> CppBox<QUrlTwoFlagsOfUrlFormattingOptionComponentFormattingOption>
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
.
Source§type Output = CppBox<QUrlTwoFlagsOfUrlFormattingOptionComponentFormattingOption>
type Output = CppBox<QUrlTwoFlagsOfUrlFormattingOptionComponentFormattingOption>
&
operator.Source§impl BitOr<ComponentFormattingOption> for &QUrlTwoFlagsOfUrlFormattingOptionComponentFormattingOption
impl BitOr<ComponentFormattingOption> for &QUrlTwoFlagsOfUrlFormattingOptionComponentFormattingOption
Source§fn bitor(
self,
f: ComponentFormattingOption,
) -> CppBox<QUrlTwoFlagsOfUrlFormattingOptionComponentFormattingOption>
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
.
Source§type Output = CppBox<QUrlTwoFlagsOfUrlFormattingOptionComponentFormattingOption>
type Output = CppBox<QUrlTwoFlagsOfUrlFormattingOptionComponentFormattingOption>
|
operator.Source§impl<T: Into<QFlags<ComponentFormattingOption>>> BitOr<T> for ComponentFormattingOption
impl<T: Into<QFlags<ComponentFormattingOption>>> BitOr<T> for ComponentFormattingOption
Source§impl BitXor<ComponentFormattingOption> for &QUrlTwoFlagsOfUrlFormattingOptionComponentFormattingOption
impl BitXor<ComponentFormattingOption> for &QUrlTwoFlagsOfUrlFormattingOptionComponentFormattingOption
Source§fn bitxor(
self,
f: ComponentFormattingOption,
) -> CppBox<QUrlTwoFlagsOfUrlFormattingOptionComponentFormattingOption>
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
.
Source§type Output = CppBox<QUrlTwoFlagsOfUrlFormattingOptionComponentFormattingOption>
type Output = CppBox<QUrlTwoFlagsOfUrlFormattingOptionComponentFormattingOption>
^
operator.Source§impl Clone for ComponentFormattingOption
impl Clone for ComponentFormattingOption
Source§fn clone(&self) -> ComponentFormattingOption
fn clone(&self) -> ComponentFormattingOption
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more