| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // | ||
| 2 | // Copyright (c) 2021 Vinnie Falco (vinnie.falco@gmail.com) | ||
| 3 | // Copyright (c) 2024 Christian Mazakas | ||
| 4 | // | ||
| 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
| 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
| 7 | // | ||
| 8 | // Official repository: https://github.com/cppalliance/http_proto | ||
| 9 | // | ||
| 10 | |||
| 11 | #ifndef BOOST_HTTP_PROTO_FIELDS_HPP | ||
| 12 | #define BOOST_HTTP_PROTO_FIELDS_HPP | ||
| 13 | |||
| 14 | #include <boost/http_proto/detail/config.hpp> | ||
| 15 | #include <boost/http_proto/fields_base.hpp> | ||
| 16 | #include <boost/http_proto/fields_view.hpp> | ||
| 17 | #include <boost/core/detail/string_view.hpp> | ||
| 18 | #include <initializer_list> | ||
| 19 | |||
| 20 | namespace boost { | ||
| 21 | namespace http_proto { | ||
| 22 | |||
| 23 | /** A modifiable container of HTTP fields | ||
| 24 | */ | ||
| 25 | class fields final | ||
| 26 | : public fields_base | ||
| 27 | { | ||
| 28 | public: | ||
| 29 | |||
| 30 | //-------------------------------------------- | ||
| 31 | // | ||
| 32 | // Special Members | ||
| 33 | // | ||
| 34 | //-------------------------------------------- | ||
| 35 | |||
| 36 | /** Constructor | ||
| 37 | |||
| 38 | Default-constructed fields have no | ||
| 39 | name-value pairs. | ||
| 40 | */ | ||
| 41 | BOOST_HTTP_PROTO_DECL | ||
| 42 | fields() noexcept; | ||
| 43 | |||
| 44 | /** Constructor | ||
| 45 | */ | ||
| 46 | BOOST_HTTP_PROTO_DECL | ||
| 47 | explicit | ||
| 48 | fields( | ||
| 49 | core::string_view s); | ||
| 50 | |||
| 51 | /** Constructor | ||
| 52 | */ | ||
| 53 | BOOST_HTTP_PROTO_DECL | ||
| 54 | explicit | ||
| 55 | fields( | ||
| 56 | std::size_t initial_size); | ||
| 57 | |||
| 58 | /** Constructor | ||
| 59 | */ | ||
| 60 | BOOST_HTTP_PROTO_DECL | ||
| 61 | explicit | ||
| 62 | fields( | ||
| 63 | std::size_t initial_size, | ||
| 64 | std::size_t max_capacity); | ||
| 65 | |||
| 66 | /** Constructor | ||
| 67 | */ | ||
| 68 | BOOST_HTTP_PROTO_DECL | ||
| 69 | fields(fields&& other) noexcept; | ||
| 70 | |||
| 71 | /** Constructor | ||
| 72 | */ | ||
| 73 | BOOST_HTTP_PROTO_DECL | ||
| 74 | fields(fields const& other); | ||
| 75 | |||
| 76 | /** Constructor | ||
| 77 | */ | ||
| 78 | BOOST_HTTP_PROTO_DECL | ||
| 79 | fields(fields_view const& other); | ||
| 80 | |||
| 81 | /** Assignment | ||
| 82 | */ | ||
| 83 | BOOST_HTTP_PROTO_DECL | ||
| 84 | fields& | ||
| 85 | operator=(fields&& f) noexcept; | ||
| 86 | |||
| 87 | /** Assignment | ||
| 88 | */ | ||
| 89 | fields& | ||
| 90 | 5 | operator=(fields const& f) noexcept | |
| 91 | { | ||
| 92 | 5 | copy_impl(*f.ph_); | |
| 93 | 5 | return *this; | |
| 94 | } | ||
| 95 | |||
| 96 | /** Assignment | ||
| 97 | */ | ||
| 98 | fields& | ||
| 99 | 4 | operator=(fields_view const& f) | |
| 100 | { | ||
| 101 | 4 | copy_impl(*f.ph_); | |
| 102 | 4 | return *this; | |
| 103 | } | ||
| 104 | |||
| 105 | /** Conversion | ||
| 106 | */ | ||
| 107 | 4 | operator fields_view() const noexcept | |
| 108 | { | ||
| 109 | 4 | return fields_view(ph_); | |
| 110 | } | ||
| 111 | |||
| 112 | //-------------------------------------------- | ||
| 113 | // | ||
| 114 | // Modifiers | ||
| 115 | // | ||
| 116 | //-------------------------------------------- | ||
| 117 | |||
| 118 | /** Swap this with another instance | ||
| 119 | */ | ||
| 120 | void | ||
| 121 | 10 | swap(fields& other) noexcept | |
| 122 | { | ||
| 123 | 10 | h_.swap(other.h_); | |
| 124 | 10 | } | |
| 125 | |||
| 126 | /** Swap two instances | ||
| 127 | */ | ||
| 128 | // hidden friend | ||
| 129 | friend | ||
| 130 | void | ||
| 131 | swap( | ||
| 132 | fields& t0, | ||
| 133 | fields& t1) noexcept | ||
| 134 | { | ||
| 135 | t0.swap(t1); | ||
| 136 | } | ||
| 137 | }; | ||
| 138 | |||
| 139 | } // http_proto | ||
| 140 | } // boost | ||
| 141 | |||
| 142 | #endif | ||
| 143 |