query_rule.hpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. //
  2. // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot 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/boostorg/url
  8. //
  9. #ifndef BOOST_URL_RFC_QUERY_RULE_HPP
  10. #define BOOST_URL_RFC_QUERY_RULE_HPP
  11. #include <boost/url/detail/config.hpp>
  12. #include <boost/url/error_types.hpp>
  13. #include <boost/url/params_encoded_view.hpp>
  14. #include <cstddef>
  15. namespace boost {
  16. namespace urls {
  17. /** Rule for query
  18. @par Value Type
  19. @code
  20. using value_type = params_encoded_view;
  21. @endcode
  22. @par Example
  23. Rules are used with the function @ref grammar::parse.
  24. @code
  25. system::result< params_encoded_view > rv = grammar::parse( "format=web&id=42&compact", query_rule );
  26. @endcode
  27. @par BNF
  28. @code
  29. query = *( pchar / "/" / "?" )
  30. query-params = [ query-param ] *( "&" query-param )
  31. query-param = key [ "=" value ]
  32. key = *qpchar
  33. value = *( qpchar / "=" )
  34. qpchar = unreserved
  35. / pct-encoded
  36. / "!" / "$" / "'" / "(" / ")"
  37. / "*" / "+" / "," / ";"
  38. / ":" / "@" / "/" / "?"
  39. @endcode
  40. @par Specification
  41. @li <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-3.4"
  42. >3.4. Query (rfc3986)</a>
  43. @see
  44. @ref grammar::parse,
  45. @ref params_encoded_view.
  46. */
  47. #ifdef BOOST_URL_DOCS
  48. constexpr __implementation_defined__ query_rule;
  49. #else
  50. struct query_rule_t
  51. {
  52. using value_type = params_encoded_view;
  53. BOOST_URL_DECL
  54. system::result<value_type>
  55. parse(
  56. char const*& it,
  57. char const* end
  58. ) const noexcept;
  59. };
  60. constexpr query_rule_t query_rule{};
  61. #endif
  62. } // urls
  63. } // boost
  64. #endif