Line data Source code
1 : //
2 : // Copyright (c) 2019 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_DETAIL_ARRAY_OF_BUFFERS_HPP
11 : #define BOOST_HTTP_PROTO_DETAIL_ARRAY_OF_BUFFERS_HPP
12 :
13 : #include <boost/buffers/const_buffer.hpp>
14 : #include <boost/buffers/mutable_buffer.hpp>
15 :
16 : namespace boost {
17 : namespace http_proto {
18 : namespace detail {
19 :
20 : template<bool isConst>
21 : class array_of_buffers
22 : {
23 : public:
24 : using value_type = typename
25 : std::conditional<isConst,
26 : buffers::const_buffer,
27 : buffers::mutable_buffer>::type;
28 : using iterator = value_type*;
29 : using const_iterator = iterator;
30 :
31 86 : array_of_buffers() = default;
32 : array_of_buffers(
33 : array_of_buffers const&) = default;
34 : array_of_buffers& operator=(
35 : array_of_buffers const&) = default;
36 :
37 : array_of_buffers(
38 : value_type* p,
39 : std::size_t n) noexcept;
40 :
41 : bool empty() const noexcept;
42 : value_type* data() const noexcept;
43 : std::size_t size() const noexcept;
44 : std::size_t capacity() const noexcept;
45 : value_type& operator[](std::size_t) const noexcept;
46 : void consume(std::size_t n);
47 : void reset(std::size_t n);
48 :
49 : iterator begin() const noexcept;
50 : iterator end() const noexcept;
51 :
52 : private:
53 : value_type* o_ = nullptr;
54 : value_type* p_ = nullptr;
55 : std::size_t n_ = 0;
56 : std::size_t c_ = 0;
57 : };
58 :
59 : using array_of_const_buffers =
60 : array_of_buffers<true>;
61 :
62 : using array_of_mutable_buffers =
63 : array_of_buffers<true>;
64 :
65 : } // detail
66 : } // http_proto
67 : } // boost
68 :
69 : #include <boost/http_proto/detail/impl/array_of_buffers.hpp>
70 :
71 : #endif
|