Struct qt_core::q_url::ComponentFormattingOption
source · 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
.
§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
.
§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
§type Output = QFlags<ComponentFormattingOption>
type Output = QFlags<ComponentFormattingOption>
|
operator.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
.
§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 moresource§impl Debug for ComponentFormattingOption
impl Debug for ComponentFormattingOption
source§impl From<ComponentFormattingOption> for QFlags<ComponentFormattingOption>
impl From<ComponentFormattingOption> for QFlags<ComponentFormattingOption>
source§fn from(value: ComponentFormattingOption) -> Self
fn from(value: ComponentFormattingOption) -> Self
source§impl From<ComponentFormattingOption> for c_int
impl From<ComponentFormattingOption> for c_int
source§fn from(value: ComponentFormattingOption) -> Self
fn from(value: ComponentFormattingOption) -> Self
source§impl From<i32> for ComponentFormattingOption
impl From<i32> for ComponentFormattingOption
source§impl PartialEq for ComponentFormattingOption
impl PartialEq for ComponentFormattingOption
source§fn eq(&self, other: &ComponentFormattingOption) -> bool
fn eq(&self, other: &ComponentFormattingOption) -> bool
self
and other
values to be equal, and is used
by ==
.