set_path_absolute

Set if the path is absolute

Synopsis

bool
set_path_absolute(bool absolute);

Declared in file <include/boost/url/url_base.hpp> on line 1665

Defined in file <src/url_base.cpp> on line 1011

Description

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.

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() == '/'

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