Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

http::token_list

A list of tokens in a comma separated HTTP field value.

Synopsis

Defined in header <boost/beast/http/rfc7230.hpp>

class token_list
Types

Name

Description

const_iterator

A constant iterator to the list.

value_type

The type of each element in the token list.

Member Functions

Name

Description

begin

Return a const iterator to the beginning of the list.

cbegin

Return a const iterator to the beginning of the list.

cend

Return a const iterator to the end of the list.

end

Return a const iterator to the end of the list.

exists

Return true if a token is present in the list.

token_list

Construct a list.

Description

This container allows iteration of a list of items in a header field value. The input is a comma separated list of tokens. If a parsing error is encountered while iterating the string, the behavior of the container will be as if a string containing only characters up to but excluding the first invalid character was used to construct the list.

BNF
token-list  = *( "," OWS ) token *( OWS "," [ OWS token ] )

To use this class, construct with the string to be parsed and then use http::token_list::begin and http::token_list::end, or range-for to iterate each item:

Example
for(auto const& token : token_list{"apple, pear, banana"})
    std::cout << token << "\n";

Convenience header <boost/beast/http.hpp>


PrevUpHomeNext