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