ゴミ箱
Classes | Public Types | Public Member Functions | Protected Member Functions | Friends | List of all members
boost::beast::http::basic_fields< Allocator > Class Template Reference

#include <fields.hpp>

Classes

struct  key_compare
 
class  reader
 
class  value_type
 The type of element used to represent a field. More...
 

Public Types

using allocator_type = Allocator
 The type of allocator used. More...
 
using const_iterator = typename list_t::const_iterator
 A constant iterator to the field sequence. More...
 
using iterator = const_iterator
 A constant iterator to the field sequence. More...
 

Public Member Functions

 ~basic_fields ()
 Destructor. More...
 
 basic_fields ()=default
 Constructor. More...
 
 basic_fields (Allocator const &alloc)
 
 basic_fields (basic_fields &&)
 
 basic_fields (basic_fields &&, Allocator const &alloc)
 
 basic_fields (basic_fields const &)
 Copy constructor. More...
 
 basic_fields (basic_fields const &, Allocator const &alloc)
 
template<class OtherAlloc >
 basic_fields (basic_fields< OtherAlloc > const &)
 Copy constructor. More...
 
template<class OtherAlloc >
 basic_fields (basic_fields< OtherAlloc > const &, Allocator const &alloc)
 
basic_fieldsoperator= (basic_fields &&)
 
basic_fieldsoperator= (basic_fields const &)
 Copy assignment. More...
 
template<class OtherAlloc >
basic_fieldsoperator= (basic_fields< OtherAlloc > const &)
 Copy assignment. More...
 
allocator_type get_allocator () const
 Return a copy of the allocator associated with the container. More...
 
string_view at (field name) const
 
string_view at (string_view name) const
 
string_view operator[] (field name) const
 
string_view operator[] (string_view name) const
 
const_iterator begin () const
 Return a const iterator to the beginning of the field sequence. More...
 
const_iterator end () const
 Return a const iterator to the end of the field sequence. More...
 
const_iterator cbegin () const
 Return a const iterator to the beginning of the field sequence. More...
 
const_iterator cend () const
 Return a const iterator to the end of the field sequence. More...
 
void insert (field name, string_param const &value)
 
void insert (string_view name, string_param const &value)
 
void insert (field name, string_view name_string, string_param const &value)
 
void set (field name, string_param const &value)
 
void set (string_view name, string_param const &value)
 
const_iterator erase (const_iterator pos)
 
std::size_t erase (field name)
 
std::size_t erase (string_view name)
 
void swap (basic_fields &other)
 Swap this container with another. More...
 
std::size_t count (field name) const
 
std::size_t count (string_view name) const
 
const_iterator find (field name) const
 
const_iterator find (string_view name) const
 
std::pair< const_iterator, const_iteratorequal_range (field name) const
 
std::pair< const_iterator, const_iteratorequal_range (string_view name) const
 
key_compare key_comp () const
 Returns a copy of the key comparison function. More...
 
template<class OtherAlloc >
auto operator= (basic_fields< OtherAlloc > const &other) -> basic_fields &
 

Protected Member Functions

string_view get_method_impl () const
 
string_view get_target_impl () const
 
string_view get_reason_impl () const
 
bool get_chunked_impl () const
 
bool get_keep_alive_impl (unsigned version) const
 
void set_method_impl (string_view s)
 
void set_target_impl (string_view s)
 
void set_reason_impl (string_view s)
 
void set_chunked_impl (bool value)
 
void set_content_length_impl (boost::optional< std::uint64_t > const &value)
 
void set_keep_alive_impl (unsigned version, bool keep_alive)
 

Friends

class fields_test
 
template<class OtherAlloc >
class basic_fields
 
template<class Alloc >
void swap (basic_fields< Alloc > &lhs, basic_fields< Alloc > &rhs)
 Swap two field containers. More...
 

Detailed Description

template<class Allocator>
class boost::beast::http::basic_fields< Allocator >

A container for storing HTTP header fields.

This container is designed to store the field value pairs that make up the fields and trailers in an HTTP message. Objects of this type are iterable, with each element holding the field name and field value.

Field names are stored as-is, but comparisons are case-insensitive. The container behaves as a std::multiset; there will be a separate value for each occurrence of the same field name. When the container is iterated the fields are presented in the order of insertion, with fields having the same name following each other consecutively.

Meets the requirements of Fields

Template Parameters
AllocatorThe allocator to use. This must meet the requirements of Allocator.

Member Typedef Documentation

template<class Allocator>
using boost::beast::http::basic_fields< Allocator >::allocator_type = Allocator

The type of allocator used.

template<class Allocator>
using boost::beast::http::basic_fields< Allocator >::const_iterator = typename list_t::const_iterator

A constant iterator to the field sequence.

template<class Allocator>
using boost::beast::http::basic_fields< Allocator >::iterator = const_iterator

A constant iterator to the field sequence.

Constructor & Destructor Documentation

template<class Allocator >
boost::beast::http::basic_fields< Allocator >::~basic_fields ( )

Destructor.

template<class Allocator>
boost::beast::http::basic_fields< Allocator >::basic_fields ( )
default

Constructor.

template<class Allocator >
boost::beast::http::basic_fields< Allocator >::basic_fields ( Allocator const &  alloc)
explicit

Constructor.

Parameters
allocThe allocator to use.
template<class Allocator >
boost::beast::http::basic_fields< Allocator >::basic_fields ( basic_fields< Allocator > &&  other)

Move constructor.

The state of the moved-from object is as if constructed using the same allocator.

template<class Allocator >
boost::beast::http::basic_fields< Allocator >::basic_fields ( basic_fields< Allocator > &&  other,
Allocator const &  alloc 
)

Move constructor.

The state of the moved-from object is as if constructed using the same allocator.

Parameters
allocThe allocator to use.
template<class Allocator >
boost::beast::http::basic_fields< Allocator >::basic_fields ( basic_fields< Allocator > const &  other)

Copy constructor.

template<class Allocator >
boost::beast::http::basic_fields< Allocator >::basic_fields ( basic_fields< Allocator > const &  other,
Allocator const &  alloc 
)

Copy constructor.

Parameters
allocThe allocator to use.
template<class Allocator >
template<class OtherAlloc >
boost::beast::http::basic_fields< Allocator >::basic_fields ( basic_fields< OtherAlloc > const &  other)

Copy constructor.

template<class Allocator >
template<class OtherAlloc >
boost::beast::http::basic_fields< Allocator >::basic_fields ( basic_fields< OtherAlloc > const &  other,
Allocator const &  alloc 
)

Copy constructor.

Parameters
allocThe allocator to use.

Member Function Documentation

template<class Allocator >
string_view boost::beast::http::basic_fields< Allocator >::at ( field  name) const

Returns the value for a field, or throws an exception.

If more than one field with the specified name exists, the first field defined by insertion order is returned.

Parameters
nameThe name of the field.
Returns
The field value.
Exceptions
std::out_of_rangeif the field is not found.
template<class Allocator >
string_view boost::beast::http::basic_fields< Allocator >::at ( string_view  name) const

Returns the value for a field, or throws an exception.

If more than one field with the specified name exists, the first field defined by insertion order is returned.

Parameters
nameThe name of the field.
Returns
The field value.
Exceptions
std::out_of_rangeif the field is not found.
template<class Allocator>
const_iterator boost::beast::http::basic_fields< Allocator >::begin ( ) const
inline

Return a const iterator to the beginning of the field sequence.

template<class Allocator>
const_iterator boost::beast::http::basic_fields< Allocator >::cbegin ( ) const
inline

Return a const iterator to the beginning of the field sequence.

template<class Allocator>
const_iterator boost::beast::http::basic_fields< Allocator >::cend ( ) const
inline

Return a const iterator to the end of the field sequence.

template<class Allocator >
std::size_t boost::beast::http::basic_fields< Allocator >::count ( field  name) const
inline

Return the number of fields with the specified name.

Parameters
nameThe field name.
template<class Allocator >
std::size_t boost::beast::http::basic_fields< Allocator >::count ( string_view  name) const

Return the number of fields with the specified name.

Parameters
nameThe field name.
template<class Allocator>
const_iterator boost::beast::http::basic_fields< Allocator >::end ( ) const
inline

Return a const iterator to the end of the field sequence.

template<class Allocator >
auto boost::beast::http::basic_fields< Allocator >::equal_range ( field  name) const
inline

Returns a range of iterators to the fields with the specified name.

Parameters
nameThe field name.
Returns
A range of iterators to fields with the same name, otherwise an empty range.
template<class Allocator >
auto boost::beast::http::basic_fields< Allocator >::equal_range ( string_view  name) const

Returns a range of iterators to the fields with the specified name.

Parameters
nameThe field name.
Returns
A range of iterators to fields with the same name, otherwise an empty range.
template<class Allocator >
auto boost::beast::http::basic_fields< Allocator >::erase ( const_iterator  pos)

Remove a field.

References and iterators to the erased elements are invalidated. Other references and iterators are not affected.

Parameters
posAn iterator to the element to remove.
Returns
An iterator following the last removed element. If the iterator refers to the last element, the end() iterator is returned.
template<class Allocator >
std::size_t boost::beast::http::basic_fields< Allocator >::erase ( field  name)

Remove all fields with the specified name.

All fields with the same field name are erased from the container. References and iterators to the erased elements are invalidated. Other references and iterators are not affected.

Parameters
nameThe field name.
Returns
The number of fields removed.
template<class Allocator >
std::size_t boost::beast::http::basic_fields< Allocator >::erase ( string_view  name)

Remove all fields with the specified name.

All fields with the same field name are erased from the container. References and iterators to the erased elements are invalidated. Other references and iterators are not affected.

Parameters
nameThe field name.
Returns
The number of fields removed.
template<class Allocator >
auto boost::beast::http::basic_fields< Allocator >::find ( field  name) const
inline

Returns an iterator to the case-insensitive matching field.

If more than one field with the specified name exists, the first field defined by insertion order is returned.

Parameters
nameThe field name.
Returns
An iterator to the matching field, or end() if no match was found.
template<class Allocator >
auto boost::beast::http::basic_fields< Allocator >::find ( string_view  name) const

Returns an iterator to the case-insensitive matching field name.

If more than one field with the specified name exists, the first field defined by insertion order is returned.

Parameters
nameThe field name.
Returns
An iterator to the matching field, or end() if no match was found.
template<class Allocator>
allocator_type boost::beast::http::basic_fields< Allocator >::get_allocator ( ) const
inline

Return a copy of the allocator associated with the container.

template<class Allocator >
bool boost::beast::http::basic_fields< Allocator >::get_chunked_impl ( ) const
protected

Returns the chunked Transfer-Encoding setting

template<class Allocator >
bool boost::beast::http::basic_fields< Allocator >::get_keep_alive_impl ( unsigned  version) const
protected

Returns the keep-alive setting

template<class Allocator >
string_view boost::beast::http::basic_fields< Allocator >::get_method_impl ( ) const
inlineprotected

Returns the request-method string.

Note
Only called for requests.
template<class Allocator >
string_view boost::beast::http::basic_fields< Allocator >::get_reason_impl ( ) const
inlineprotected

Returns the response reason-phrase string.

Note
Only called for responses.
template<class Allocator >
string_view boost::beast::http::basic_fields< Allocator >::get_target_impl ( ) const
inlineprotected

Returns the request-target string.

Note
Only called for requests.
template<class Allocator >
void boost::beast::http::basic_fields< Allocator >::insert ( field  name,
string_param const &  value 
)
inline

Insert a field.

If one or more fields with the same name already exist, the new field will be inserted after the last field with the matching name, in serialization order.

Parameters
nameThe field name.
valueThe value of the field, as a string_param
template<class Allocator >
void boost::beast::http::basic_fields< Allocator >::insert ( string_view  name,
string_param const &  value 
)

Insert a field.

If one or more fields with the same name already exist, the new field will be inserted after the last field with the matching name, in serialization order.

Parameters
nameThe field name.
valueThe value of the field, as a string_param
template<class Allocator >
void boost::beast::http::basic_fields< Allocator >::insert ( field  name,
string_view  name_string,
string_param const &  value 
)

Insert a field.

If one or more fields with the same name already exist, the new field will be inserted after the last field with the matching name, in serialization order.

Parameters
nameThe field name.
name_stringThe literal text corresponding to the field name. If name != field::unknown, then this value must be equal to to_string(name) using a case-insensitive comparison, otherwise the behavior is undefined.
valueThe value of the field, as a string_param
template<class Allocator>
key_compare boost::beast::http::basic_fields< Allocator >::key_comp ( ) const
inline

Returns a copy of the key comparison function.

template<class Allocator >
auto boost::beast::http::basic_fields< Allocator >::operator= ( basic_fields< Allocator > &&  other)

Move assignment.

The state of the moved-from object is as if constructed using the same allocator.

template<class Allocator >
auto boost::beast::http::basic_fields< Allocator >::operator= ( basic_fields< Allocator > const &  other)

Copy assignment.

template<class Allocator>
template<class OtherAlloc >
basic_fields& boost::beast::http::basic_fields< Allocator >::operator= ( basic_fields< OtherAlloc > const &  )

Copy assignment.

template<class Allocator>
template<class OtherAlloc >
auto boost::beast::http::basic_fields< Allocator >::operator= ( basic_fields< OtherAlloc > const &  other) -> basic_fields&
template<class Allocator >
string_view boost::beast::http::basic_fields< Allocator >::operator[] ( field  name) const

Returns the value for a field, or "" if it does not exist.

If more than one field with the specified name exists, the first field defined by insertion order is returned.

Parameters
nameThe name of the field.
template<class Allocator >
string_view boost::beast::http::basic_fields< Allocator >::operator[] ( string_view  name) const

Returns the value for a case-insensitive matching header, or "" if it does not exist.

If more than one field with the specified name exists, the first field defined by insertion order is returned.

Parameters
nameThe name of the field.
template<class Allocator >
void boost::beast::http::basic_fields< Allocator >::set ( field  name,
string_param const &  value 
)

Set a field value, removing any other instances of that field.

First removes any values with matching field names, then inserts the new field value.

Parameters
nameThe field name.
valueThe value of the field, as a string_param
Returns
The field value.
template<class Allocator >
void boost::beast::http::basic_fields< Allocator >::set ( string_view  name,
string_param const &  value 
)

Set a field value, removing any other instances of that field.

First removes any values with matching field names, then inserts the new field value.

Parameters
nameThe field name.
valueThe value of the field, as a string_param
template<class Allocator >
void boost::beast::http::basic_fields< Allocator >::set_chunked_impl ( bool  value)
protected

Adjusts the chunked Transfer-Encoding value

template<class Allocator >
void boost::beast::http::basic_fields< Allocator >::set_content_length_impl ( boost::optional< std::uint64_t > const &  value)
protected

Sets or clears the Content-Length field

template<class Allocator >
void boost::beast::http::basic_fields< Allocator >::set_keep_alive_impl ( unsigned  version,
bool  keep_alive 
)
protected

Adjusts the Connection field

template<class Allocator >
void boost::beast::http::basic_fields< Allocator >::set_method_impl ( string_view  s)
inlineprotected

Set or clear the method string.

Note
Only called for requests.
template<class Allocator >
void boost::beast::http::basic_fields< Allocator >::set_reason_impl ( string_view  s)
inlineprotected

Set or clear the reason string.

Note
Only called for responses.
template<class Allocator >
void boost::beast::http::basic_fields< Allocator >::set_target_impl ( string_view  s)
inlineprotected

Set or clear the target string.

Note
Only called for requests.
template<class Allocator >
void boost::beast::http::basic_fields< Allocator >::swap ( basic_fields< Allocator > &  other)

Swap this container with another.

Return a buffer sequence representing the trailers.

This function returns a buffer sequence holding the serialized representation of the trailer fields promised in the Accept field. Before calling this function the Accept field must contain the exact trailer fields desired. Each field must also exist.

Friends And Related Function Documentation

template<class Allocator>
template<class OtherAlloc >
friend class basic_fields
friend
template<class Allocator>
friend class fields_test
friend
template<class Allocator>
template<class Alloc >
void swap ( basic_fields< Alloc > &  lhs,
basic_fields< Alloc > &  rhs 
)
friend

Swap two field containers.


The documentation for this class was generated from the following files: