2 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
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)
7 // Official repository: https://github.com/boostorg/beast
10 #ifndef BOOST_BEAST_HTTP_DETAIL_BASIC_PARSED_LIST_HPP
11 #define BOOST_BEAST_HTTP_DETAIL_BASIC_PARSED_LIST_HPP
13 #include <boost/beast/core/string.hpp>
14 #include <boost/core/empty_value.hpp>
23 /** A list parser which presents the sequence as a container.
25 template<class Policy>
26 class basic_parsed_list
31 /// The type of policy this list uses for parsing.
32 using policy_type = Policy;
34 /// The type of each element in the list.
35 using value_type = typename Policy::value_type;
37 /// A constant iterator to a list element.
38 #if BOOST_BEAST_DOXYGEN
39 using const_iterator = __implementation_defined__;
45 : private boost::empty_value<Policy>
47 basic_parsed_list const* list_ = nullptr;
48 char const* it_ = nullptr;
49 typename Policy::value_type v_;
54 typename Policy::value_type;
55 using reference = value_type const&;
56 using pointer = value_type const*;
57 using difference_type = std::ptrdiff_t;
58 using iterator_category =
59 std::forward_iterator_tag;
61 const_iterator() = default;
65 const_iterator const& other) const
68 other.list_ == list_ &&
74 const_iterator const& other) const
76 return ! (*this == other);
107 friend class basic_parsed_list;
110 basic_parsed_list const& list, bool at_end)
112 , it_(at_end ? nullptr :
131 /// Construct a list from a string
133 basic_parsed_list(string_view s)
138 /// Return a const iterator to the beginning of the list
139 const_iterator begin() const;
141 /// Return a const iterator to the end of the list
142 const_iterator end() const;
144 /// Return a const iterator to the beginning of the list
145 const_iterator cbegin() const;
147 /// Return a const iterator to the end of the list
148 const_iterator cend() const;
151 template<class Policy>
154 basic_parsed_list<Policy>::
158 return const_iterator{*this, false};
161 template<class Policy>
164 basic_parsed_list<Policy>::
168 return const_iterator{*this, true};
171 template<class Policy>
174 basic_parsed_list<Policy>::
178 return const_iterator{*this, false};
181 template<class Policy>
184 basic_parsed_list<Policy>::
188 return const_iterator{*this, true};