Line data Source code
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 fields_view
23 : : public fields_view_base
24 : {
25 : friend class fields;
26 : template<std::size_t>
27 : friend class static_fields;
28 :
29 : #ifndef BOOST_HTTP_PROTO_DOCS
30 : protected:
31 : #endif
32 :
33 : explicit
34 8 : fields_view(
35 : detail::header const* ph) noexcept
36 8 : : fields_view_base(ph)
37 : {
38 8 : BOOST_ASSERT(ph_->kind ==
39 : detail::kind::fields);
40 8 : }
41 :
42 : public:
43 : /** Constructor
44 :
45 : Default constructed field views
46 : have a zero size.
47 : */
48 8 : fields_view() noexcept
49 8 : : fields_view_base(
50 : detail::header::get_default(
51 8 : detail::kind::fields))
52 : {
53 8 : }
54 :
55 : /** Constructor
56 : */
57 : fields_view(
58 : fields_view const&) noexcept = default;
59 :
60 : /** Assignment
61 : */
62 : fields_view&
63 : operator=(
64 : fields_view const&) noexcept = default;
65 :
66 : //--------------------------------------------
67 :
68 : /** Swap this with another instance
69 : */
70 : void
71 : swap(fields_view& other) noexcept
72 : {
73 : auto ph = ph_;
74 : ph_ = other.ph_;
75 : other.ph_ = ph;
76 : }
77 :
78 : /** Swap two instances
79 : */
80 : friend
81 : void
82 : swap(
83 : fields_view& t0,
84 : fields_view& t1) noexcept
85 : {
86 : t0.swap(t1);
87 : }
88 : };
89 :
90 : } // http_proto
91 : } // boost
92 :
93 : #endif
|