Struct qt_core::q_url::ParsingMode
source · pub struct ParsingMode(/* private fields */);
Expand description
The parsing mode controls the way QUrl parses strings.
C++ enum: QUrl::ParsingMode
.
The parsing mode controls the way QUrl parses strings.
In TolerantMode, the parser has the following behaviour:
- Spaces and "%20": unencoded space characters will be accepted and will be treated as equivalent to "%20".
- Single "%" characters: Any occurrences of a percent character "%" not followed by exactly two hexadecimal characters (e.g., "13% coverage.html") will be replaced by "%25". Note that one lone "%" character will trigger the correction mode for all percent characters.
- Reserved and unreserved characters: An encoded URL should only contain a few characters as literals; all other characters should be percent-encoded. In TolerantMode, these characters will be accepted if they are found in the URL: space / double-quote / "<" / ">" / "" / "^" / "`" / "{" / "|" / "}" Those same characters can be decoded again by passing QUrl::DecodeReserved to toString() or toEncoded(). In the getters of individual components, those characters are often returned in decoded form.
When in StrictMode, if a parsing error is found, isValid() will return false
and errorString() will return a message describing the error. If more than one error is detected, it is undefined which error gets reported.
Note that TolerantMode is not usually enough for parsing user input, which often contains more errors and expectations than the parser can deal with. When dealing with data coming directly from the user -- as opposed to data coming from data-transfer sources, such as other programs -- it is recommended to use fromUserInput().
See also fromUserInput(), setUrl(), toString(), toEncoded(), and QUrl::FormattingOptions.
Implementations§
source§impl ParsingMode
impl ParsingMode
sourcepub const TolerantMode: ParsingMode = _
pub const TolerantMode: ParsingMode = _
QUrl will try to correct some common errors in URLs. This mode is useful for parsing URLs coming from sources not known to be strictly standards-conforming. (C++ enum variant: TolerantMode = 0
)
sourcepub const StrictMode: ParsingMode = _
pub const StrictMode: ParsingMode = _
Only valid URLs are accepted. This mode is useful for general URL validation. (C++ enum variant: StrictMode = 1
)
sourcepub const DecodedMode: ParsingMode = _
pub const DecodedMode: ParsingMode = _
QUrl will interpret the URL component in the fully-decoded form, where percent characters stand for themselves, not as the beginning of a percent-encoded sequence. This mode is only valid for the setters setting components of a URL; it is not permitted in the QUrl constructor, in fromEncoded() or in setUrl(). For more information on this mode, see the documentation for QUrl::FullyDecoded. (C++ enum variant: DecodedMode = 2
)
Trait Implementations§
source§impl Clone for ParsingMode
impl Clone for ParsingMode
source§fn clone(&self) -> ParsingMode
fn clone(&self) -> ParsingMode
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ParsingMode
impl Debug for ParsingMode
source§impl From<ParsingMode> for c_int
impl From<ParsingMode> for c_int
source§fn from(value: ParsingMode) -> Self
fn from(value: ParsingMode) -> Self
source§impl From<i32> for ParsingMode
impl From<i32> for ParsingMode
source§impl PartialEq for ParsingMode
impl PartialEq for ParsingMode
source§fn eq(&self, other: &ParsingMode) -> bool
fn eq(&self, other: &ParsingMode) -> bool
self
and other
values to be equal, and is used
by ==
.