Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:29:30

0001 //
0002 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
0003 //
0004 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0005 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 //
0007 // Official repository: https://github.com/boostorg/beast
0008 //
0009 
0010 #ifndef BOOST_BEAST_HTTP_IMPL_RFC7230_HPP
0011 #define BOOST_BEAST_HTTP_IMPL_RFC7230_HPP
0012 
0013 #include <boost/beast/http/detail/rfc7230.hpp>
0014 #include <iterator>
0015 
0016 namespace boost {
0017 namespace beast {
0018 namespace http {
0019 
0020 class param_list::const_iterator
0021 {
0022     using iter_type = string_view::const_iterator;
0023 
0024     std::string s_;
0025     detail::param_iter pi_;
0026 
0027 public:
0028     using value_type = param_list::value_type;
0029     using pointer = value_type const*;
0030     using reference = value_type const&;
0031     using difference_type = std::ptrdiff_t;
0032     using iterator_category = std::input_iterator_tag;
0033 
0034     const_iterator() = default;
0035 
0036     bool
0037     operator==(const_iterator const& other) const
0038     {
0039         return
0040             other.pi_.it == pi_.it &&
0041             other.pi_.last == pi_.last &&
0042             other.pi_.first == pi_.first;
0043     }
0044 
0045     bool
0046     operator!=(const_iterator const& other) const
0047     {
0048         return !(*this == other);
0049     }
0050 
0051     reference
0052     operator*() const
0053     {
0054         return pi_.v;
0055     }
0056 
0057     pointer
0058     operator->() const
0059     {
0060         return &*(*this);
0061     }
0062 
0063     const_iterator&
0064     operator++()
0065     {
0066         increment();
0067         return *this;
0068     }
0069 
0070     const_iterator
0071     operator++(int)
0072     {
0073         auto temp = *this;
0074         ++(*this);
0075         return temp;
0076     }
0077 
0078 private:
0079     friend class param_list;
0080 
0081     const_iterator(iter_type first, iter_type last)
0082     {
0083         pi_.it = first;
0084         pi_.first = first;
0085         pi_.last = last;
0086         increment();
0087     }
0088 
0089     BOOST_BEAST_DECL
0090     static
0091     void
0092     unquote(string_view sr, std::string & s);
0093 
0094     BOOST_BEAST_DECL
0095     void
0096     increment();
0097 };
0098 
0099 inline
0100 auto
0101 param_list::
0102 begin() const ->
0103     const_iterator
0104 {
0105     return const_iterator{s_.begin(), s_.end()};
0106 }
0107 
0108 inline
0109 auto
0110 param_list::
0111 end() const ->
0112     const_iterator
0113 {
0114     return const_iterator{s_.end(), s_.end()};
0115 }
0116 
0117 inline
0118 auto
0119 param_list::
0120 cbegin() const ->
0121     const_iterator
0122 {
0123     return const_iterator{s_.begin(), s_.end()};
0124 }
0125 
0126 inline
0127 auto
0128 param_list::
0129 cend() const ->
0130     const_iterator
0131 {
0132     return const_iterator{s_.end(), s_.end()};
0133 }
0134 
0135 //------------------------------------------------------------------------------
0136 
0137 class ext_list::const_iterator
0138 {
0139     ext_list::value_type v_;
0140     iter_type it_;
0141     iter_type first_;
0142     iter_type last_;
0143 
0144 public:
0145     using value_type = ext_list::value_type;
0146     using pointer = value_type const*;
0147     using reference = value_type const&;
0148     using difference_type = std::ptrdiff_t;
0149     using iterator_category = std::forward_iterator_tag;
0150 
0151     const_iterator() = default;
0152 
0153     bool
0154     operator==(const_iterator const& other) const
0155     {
0156         return
0157             other.it_ == it_ &&
0158             other.first_ == first_ &&
0159             other.last_ == last_;
0160     }
0161 
0162     bool
0163     operator!=(const_iterator const& other) const
0164     {
0165         return !(*this == other);
0166     }
0167 
0168     reference
0169     operator*() const
0170     {
0171         return v_;
0172     }
0173 
0174     pointer
0175     operator->() const
0176     {
0177         return &*(*this);
0178     }
0179 
0180     const_iterator&
0181     operator++()
0182     {
0183         increment();
0184         return *this;
0185     }
0186 
0187     const_iterator
0188     operator++(int)
0189     {
0190         auto temp = *this;
0191         ++(*this);
0192         return temp;
0193     }
0194 
0195 private:
0196     friend class ext_list;
0197 
0198     const_iterator(iter_type begin, iter_type end)
0199     {
0200         it_ = begin;
0201         first_ = begin;
0202         last_ = end;
0203         increment();
0204     }
0205 
0206     BOOST_BEAST_DECL
0207     void
0208     increment();
0209 };
0210 
0211 inline
0212 auto
0213 ext_list::
0214 begin() const ->
0215     const_iterator
0216 {
0217     return const_iterator{s_.begin(), s_.end()};
0218 }
0219 
0220 inline
0221 auto
0222 ext_list::
0223 end() const ->
0224     const_iterator
0225 {
0226     return const_iterator{s_.end(), s_.end()};
0227 }
0228 
0229 inline
0230 auto
0231 ext_list::
0232 cbegin() const ->
0233     const_iterator
0234 {
0235     return const_iterator{s_.begin(), s_.end()};
0236 }
0237 
0238 inline
0239 auto
0240 ext_list::
0241 cend() const ->
0242     const_iterator
0243 {
0244     return const_iterator{s_.end(), s_.end()};
0245 }
0246 
0247 
0248 //------------------------------------------------------------------------------
0249 
0250 class token_list::const_iterator
0251 {
0252     token_list::value_type v_;
0253     iter_type it_;
0254     iter_type first_;
0255     iter_type last_;
0256 
0257 public:
0258     using value_type = token_list::value_type;
0259     using pointer = value_type const*;
0260     using reference = value_type const&;
0261     using difference_type = std::ptrdiff_t;
0262     using iterator_category = std::forward_iterator_tag;
0263 
0264     const_iterator() = default;
0265 
0266     bool
0267     operator==(const_iterator const& other) const
0268     {
0269         return
0270             other.it_ == it_ &&
0271             other.first_ == first_ &&
0272             other.last_ == last_;
0273     }
0274 
0275     bool
0276     operator!=(const_iterator const& other) const
0277     {
0278         return !(*this == other);
0279     }
0280 
0281     reference
0282     operator*() const
0283     {
0284         return v_;
0285     }
0286 
0287     pointer
0288     operator->() const
0289     {
0290         return &*(*this);
0291     }
0292 
0293     const_iterator&
0294     operator++()
0295     {
0296         increment();
0297         return *this;
0298     }
0299 
0300     const_iterator
0301     operator++(int)
0302     {
0303         auto temp = *this;
0304         ++(*this);
0305         return temp;
0306     }
0307 
0308 private:
0309     friend class token_list;
0310 
0311     const_iterator(iter_type begin, iter_type end)
0312     {
0313         it_ = begin;
0314         first_ = begin;
0315         last_ = end;
0316         increment();
0317     }
0318 
0319     BOOST_BEAST_DECL
0320     void
0321     increment();
0322 };
0323 
0324 inline
0325 auto
0326 token_list::
0327 begin() const ->
0328     const_iterator
0329 {
0330     return const_iterator{s_.begin(), s_.end()};
0331 }
0332 
0333 inline
0334 auto
0335 token_list::
0336 end() const ->
0337     const_iterator
0338 {
0339     return const_iterator{s_.end(), s_.end()};
0340 }
0341 
0342 inline
0343 auto
0344 token_list::
0345 cbegin() const ->
0346     const_iterator
0347 {
0348     return const_iterator{s_.begin(), s_.end()};
0349 }
0350 
0351 inline
0352 auto
0353 token_list::
0354 cend() const ->
0355     const_iterator
0356 {
0357     return const_iterator{s_.end(), s_.end()};
0358 }
0359 
0360 template<class Policy>
0361 bool
0362 validate_list(detail::basic_parsed_list<
0363     Policy> const& list)
0364 {
0365     auto const last = list.end();
0366     auto it = list.begin();
0367     if(it.error())
0368         return false;
0369     while(it != last)
0370     {
0371         ++it;
0372         if(it.error())
0373             return false;
0374         if(it == last)
0375             break;
0376     }
0377     return true;
0378 }
0379 
0380 } // http
0381 } // beast
0382 } // boost
0383 
0384 #ifdef BOOST_BEAST_HEADER_ONLY
0385 #include <boost/beast/http/impl/rfc7230.ipp>
0386 #endif
0387 
0388 #endif
0389