![]() |
Home | Libraries | People | FAQ | More |
Set if the path is absolute.
url& set_path( core::string_view s);
This function adjusts the path to make it absolute or not, depending on the parameter.
If an authority is present, the path is always absolute. In this case, the function has no effect.
[link url.ref.boost__urls__url.url `url`] u( "path/to/file.txt" ); assert( u.set_path_absolute( true ) ); assert( u.buffer() == "/path/to/file.txt" );
this->[link url.ref.boost__urls__url.is_path_absolute `is_path_absolute`]() == true && this->[link url.ref.boost__urls__url.encoded_path `encoded_path`]().[link url.ref.boost__urls__pct_string_view.front `front`]() == '/'
true on success.
Linear in this->size()
.
[link url.ref.boost__urls__url.path `path`] = [link url.ref.boost__urls__url.path `path`]-abempty ; begins with "/" or is [link url.ref.boost__urls__url.empty `empty`] / [link url.ref.boost__urls__url.path `path`]-absolute ; begins with "/" but not "//" / [link url.ref.boost__urls__url.path `path`]-noscheme ; begins with a non-colon segment / [link url.ref.boost__urls__url.path `path`]-rootless ; begins with a segment / [link url.ref.boost__urls__url.path `path`]-[link url.ref.boost__urls__url.empty `empty`] ; zero characters [link url.ref.boost__urls__url.path `path`]-abempty = *( "/" segment ) [link url.ref.boost__urls__url.path `path`]-absolute = "/" [ segment-nz *( "/" segment ) ] [link url.ref.boost__urls__url.path `path`]-noscheme = segment-nz-nc *( "/" segment ) [link url.ref.boost__urls__url.path `path`]-rootless = segment-nz *( "/" segment ) [link url.ref.boost__urls__url.path `path`]-[link url.ref.boost__urls__url.empty `empty`] = 0<pchar>
encoded_segments
, segments
, set_encoded_path
, /root/project/libs/url/include/boost/url/url.hpp
Set the path. This function sets the path to the string, which may be empty.
Reserved characters in the string are percent-escaped in the result.
The library may adjust the final result to ensure that no other parts of the url is semantically affected.
This function does not encode '' chars, which are unreserved
for paths but reserved for path segments. If a path segment should include
encoded ''s to differentiate it from path separators, the functions
set_encoded_path
or segments
should be used instead.
[link url.ref.boost__urls__url.url `url`] u( "http://www.example.com" ); u.set_path( "path/to/file.txt" ); assert( u.path() == "/path/to/file.txt" );
Linear in this->size() + s.size()
.
Strong guarantee. Calls to allocate may throw.
Name |
Description |
---|---|
|
The string to set. |
[link url.ref.boost__urls__url.path `path`] = [link url.ref.boost__urls__url.path `path`]-abempty ; begins with "/" or is [link url.ref.boost__urls__url.empty `empty`] / [link url.ref.boost__urls__url.path `path`]-absolute ; begins with "/" but not "//" / [link url.ref.boost__urls__url.path `path`]-noscheme ; begins with a non-colon segment / [link url.ref.boost__urls__url.path `path`]-rootless ; begins with a segment / [link url.ref.boost__urls__url.path `path`]-[link url.ref.boost__urls__url.empty `empty`] ; zero characters [link url.ref.boost__urls__url.path `path`]-abempty = *( "/" segment ) [link url.ref.boost__urls__url.path `path`]-absolute = "/" [ segment-nz *( "/" segment ) ] [link url.ref.boost__urls__url.path `path`]-noscheme = segment-nz-nc *( "/" segment ) [link url.ref.boost__urls__url.path `path`]-rootless = segment-nz *( "/" segment ) [link url.ref.boost__urls__url.path `path`]-[link url.ref.boost__urls__url.empty `empty`] = 0<pchar>
encoded_segments
, segments
, set_encoded_path
, /root/project/libs/url/include/boost/url/url.hpp