2 // Copyright (c) 2016-2017 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/beast/core/detail/empty_base_optimization.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 beast::detail::
46 empty_base_optimization<Policy>
48 basic_parsed_list const* list_ = nullptr;
49 char const* it_ = nullptr;
50 typename Policy::value_type v_;
55 typename Policy::value_type;
56 using reference = value_type const&;
57 using pointer = value_type const*;
58 using difference_type = std::ptrdiff_t;
59 using iterator_category =
60 std::forward_iterator_tag;
62 const_iterator() = default;
66 const_iterator const& other) const
69 other.list_ == list_ &&
75 const_iterator const& other) const
77 return ! (*this == other);
108 friend class basic_parsed_list;
111 basic_parsed_list const& list, bool at_end)
113 , it_(at_end ? nullptr :
132 /// Construct a list from a string
134 basic_parsed_list(string_view s)
139 /// Return a const iterator to the beginning of the list
140 const_iterator begin() const;
142 /// Return a const iterator to the end of the list
143 const_iterator end() const;
145 /// Return a const iterator to the beginning of the list
146 const_iterator cbegin() const;
148 /// Return a const iterator to the end of the list
149 const_iterator cend() const;
152 template<class Policy>
155 basic_parsed_list<Policy>::
159 return const_iterator{*this, false};
162 template<class Policy>
165 basic_parsed_list<Policy>::
169 return const_iterator{*this, true};
172 template<class Policy>
175 basic_parsed_list<Policy>::
179 return const_iterator{*this, false};
182 template<class Policy>
185 basic_parsed_list<Policy>::
189 return const_iterator{*this, true};