| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // | ||
| 2 | // Copyright (c) 2021 Vinnie Falco (vinnie.falco@gmail.com) | ||
| 3 | // | ||
| 4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
| 5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
| 6 | // | ||
| 7 | // Official repository: https://github.com/cppalliance/http_proto | ||
| 8 | // | ||
| 9 | |||
| 10 | #ifndef BOOST_HTTP_PROTO_FIELDS_VIEW_HPP | ||
| 11 | #define BOOST_HTTP_PROTO_FIELDS_VIEW_HPP | ||
| 12 | |||
| 13 | #include <boost/http_proto/detail/config.hpp> | ||
| 14 | #include <boost/http_proto/fields_view_base.hpp> | ||
| 15 | #include <boost/assert.hpp> | ||
| 16 | |||
| 17 | namespace boost { | ||
| 18 | namespace http_proto { | ||
| 19 | |||
| 20 | /** A read-only, forward range of HTTP fields | ||
| 21 | */ | ||
| 22 | class BOOST_SYMBOL_VISIBLE | ||
| 23 | fields_view | ||
| 24 | : public fields_view_base | ||
| 25 | { | ||
| 26 | friend class fields; | ||
| 27 | template<std::size_t> | ||
| 28 | friend class static_fields; | ||
| 29 | |||
| 30 | #ifndef BOOST_HTTP_PROTO_DOCS | ||
| 31 | protected: | ||
| 32 | #endif | ||
| 33 | |||
| 34 | explicit | ||
| 35 | 8 | fields_view( | |
| 36 | detail::header const* ph) noexcept | ||
| 37 | 8 | : fields_view_base(ph) | |
| 38 | { | ||
| 39 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
|
8 | BOOST_ASSERT(ph_->kind == |
| 40 | detail::kind::fields); | ||
| 41 | 8 | } | |
| 42 | |||
| 43 | public: | ||
| 44 | /** Constructor | ||
| 45 | |||
| 46 | Default constructed field views | ||
| 47 | have a zero size. | ||
| 48 | */ | ||
| 49 | 8 | fields_view() noexcept | |
| 50 | 8 | : fields_view_base( | |
| 51 | detail::header::get_default( | ||
| 52 | 8 | detail::kind::fields)) | |
| 53 | { | ||
| 54 | 8 | } | |
| 55 | |||
| 56 | /** Constructor | ||
| 57 | */ | ||
| 58 | fields_view( | ||
| 59 | fields_view const&) noexcept = default; | ||
| 60 | |||
| 61 | /** Assignment | ||
| 62 | */ | ||
| 63 | fields_view& | ||
| 64 | operator=( | ||
| 65 | fields_view const&) noexcept = default; | ||
| 66 | |||
| 67 | //-------------------------------------------- | ||
| 68 | |||
| 69 | /** Swap this with another instance | ||
| 70 | */ | ||
| 71 | void | ||
| 72 | swap(fields_view& other) noexcept | ||
| 73 | { | ||
| 74 | auto ph = ph_; | ||
| 75 | ph_ = other.ph_; | ||
| 76 | other.ph_ = ph; | ||
| 77 | } | ||
| 78 | |||
| 79 | /** Swap two instances | ||
| 80 | */ | ||
| 81 | friend | ||
| 82 | void | ||
| 83 | swap( | ||
| 84 | fields_view& t0, | ||
| 85 | fields_view& t1) noexcept | ||
| 86 | { | ||
| 87 | t0.swap(t1); | ||
| 88 | } | ||
| 89 | }; | ||
| 90 | |||
| 91 | } // http_proto | ||
| 92 | } // boost | ||
| 93 | |||
| 94 | #endif | ||
| 95 |