Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext
url_base::set_path

Set the path.

Synopsis
url_base&
set_path(
    core::string_view s);
Description

This function sets the path to the string, which may be empty. Reserved characters in the string are percent-escaped in the result.

Remarks

The library may adjust the final result to ensure that no other parts of the url is semantically affected.

Remarks

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.

Example
[link url.ref.boost__urls__url_base.url `url`] u( "http://www.example.com" );

u.set_path( "path/to/file.txt" );

assert( u.path() == "/path/to/file.txt" );
Complexity

Linear in this->size() + s.size().

Exception Safety

Strong guarantee. Calls to allocate may throw.

Parameters

Name

Description

s

The string to set.

BNF
[link url.ref.boost__urls__url_base.path `path`]          = [link url.ref.boost__urls__url_base.path `path`]-abempty    ; begins with "/" or is [link url.ref.boost__urls__url_base.empty `empty`]
              / [link url.ref.boost__urls__url_base.path `path`]-absolute   ; begins with "/" but not "//"
              / [link url.ref.boost__urls__url_base.path `path`]-noscheme   ; begins with a non-colon segment
              / [link url.ref.boost__urls__url_base.path `path`]-rootless   ; begins with a segment
              / [link url.ref.boost__urls__url_base.path `path`]-[link url.ref.boost__urls__url_base.empty `empty`]      ; zero characters

[link url.ref.boost__urls__url_base.path `path`]-abempty  = *( "/" segment )
[link url.ref.boost__urls__url_base.path `path`]-absolute = "/" [ segment-nz *( "/" segment ) ]
[link url.ref.boost__urls__url_base.path `path`]-noscheme = segment-nz-nc *( "/" segment )
[link url.ref.boost__urls__url_base.path `path`]-rootless = segment-nz *( "/" segment )
[link url.ref.boost__urls__url_base.path `path`]-[link url.ref.boost__urls__url_base.empty `empty`]    = 0<pchar>
Specification
See Also

encoded_segments, segments, set_encoded_path, set_path_absolute.


PrevUpHomeNext