Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:53:28

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/url
0008 //
0009 
0010 #ifndef BOOST_URL_RFC_DETAIL_QUERY_PART_RULE_HPP
0011 #define BOOST_URL_RFC_DETAIL_QUERY_PART_RULE_HPP
0012 
0013 #include <boost/url/detail/config.hpp>
0014 #include <boost/url/error_types.hpp>
0015 #include <boost/url/pct_string_view.hpp>
0016 #include <boost/url/rfc/query_rule.hpp>
0017 #include <boost/url/grammar/parse.hpp>
0018 #include <cstdlib>
0019 
0020 namespace boost {
0021 namespace urls {
0022 namespace detail {
0023 
0024 /** Rule for query-part
0025 
0026     @par BNF
0027     @code
0028     query-part    = [ "?" query ]
0029     @endcode
0030 */
0031 struct query_part_rule_t
0032 {
0033     struct value_type
0034     {
0035         pct_string_view query;
0036         std::size_t count = 0;
0037         bool has_query = false;
0038     };
0039 
0040     auto
0041     parse(
0042         char const*& it,
0043         char const* end
0044             ) const noexcept ->
0045         system::result<value_type>
0046     {
0047         if( it == end ||
0048             *it != '?')
0049             return {};
0050         ++it;
0051         auto rv = grammar::parse(
0052             it, end, query_rule);
0053         if(! rv)
0054             return rv.error();
0055         value_type t;
0056         t.query = rv->buffer();
0057         t.count = rv->size();
0058         t.has_query = true;
0059         return t;
0060     }
0061 };
0062 
0063 constexpr query_part_rule_t query_part_rule{};
0064 
0065 } // detail
0066 } // urls
0067 } // boost
0068 
0069 #endif