Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext
static_url::set_path

Set if the path is absolute.

Synopsis
static_url&
set_path(
    string_view s);
Description

This function adjusts the path to make it absolute or not, depending on the parameter.

Remarks

If an authority is present, the path is always absolute. In this case, the function has no effect.

Example
url u( "path/to/file.txt" );
assert( u.set_path_absolute( true ) );
assert( u.buffer() == "/path/to/file.txt" );
Postconditions
this->is_path_absolute() == true && this->encoded_path().front() == '/'
Return Value

true on success.

Complexity

Linear in this->size().

BNF
path          = path-abempty    ; begins with "/" or is empty
              / path-absolute   ; begins with "/" but not "//"
              / path-noscheme   ; begins with a non-colon segment
              / path-rootless   ; begins with a segment
              / path-empty      ; zero characters

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

encoded_segments, segments, set_encoded_path, set_path. 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.

Remarks

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

Example
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
path          = path-abempty    ; begins with "/" or is empty
              / path-absolute   ; begins with "/" but not "//"
              / path-noscheme   ; begins with a non-colon segment
              / path-rootless   ; begins with a segment
              / path-empty      ; zero characters

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

encoded_segments, segments, set_encoded_path, set_path_absolute.


PrevUpHomeNext