boost::urls::segments_ref

A view representing path segments in a URL

Synopsis

Declared in header <boost/url/segments_ref.hpp>

class segments_ref
    : public segments_base;

Types

Name

Description

const_iterator

A Bidirectional iterator to a path segment

const_reference

The reference type

difference_type

A signed integer type used to represent differences.

iterator

A Bidirectional iterator to a path segment

reference

The reference type

size_type

An unsigned integer type used to represent size.

value_type

The value type

Member Functions

Name

Description

assign

Assign segments

back

Return the last segment

begin

Return an iterator to the beginning

buffer

Return the referenced character buffer.

clear

Clear the contents of the container

empty

Return true if there are no segments

end

Return an iterator to the end

erase

Erase segments

front

Return the first segment

insert

Insert segments

is_absolute

Returns true if this references an absolute path.

operator segments_view

Conversion

operator=

Assignment

pop_back

Remove the last segment

push_back

Append a segment

replace

Replace segments

segments_ref [constructor]

Constructor

size

Return the number of segments

url

Return the referenced url

Static Member Functions

Name

Description

max_size

Return the maximum number of characters possible

Description

Objects of this type are used to interpret the path as a bidirectional view of segments, where each segment is a string with percent escapes automatically decoded.

The view does not retain ownership of the elements and instead references the original character buffer. The caller is responsible for ensuring that the lifetime of the buffer extends until it is no longer referenced.

The view is modifiable; calling non-const members causes changes to the referenced url.

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

segments_ref ps = u.segments();

Percent escapes in strings returned when dereferencing iterators are automatically decoded. Reserved characters in strings supplied to modifier functions are automatically percent-escaped.

Changes to the underlying character buffer

can invalidate iterators which reference it. Modifications made through the container invalidate some or all iterators:

  • push_back : Only end().

  • assign , clear , operator= : All elements.

  • erase : Erased elements and all elements after (including end()).

  • insert : All elements at or after the insertion point (including end()).

  • replace : Modified elements and all elements after (including end()).