query_rule.hpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. namespace implementation_defined {
  18. struct query_rule_t
  19. {
  20. using value_type = params_encoded_view;
  21. BOOST_URL_DECL
  22. system::result<value_type>
  23. parse(
  24. char const*& it,
  25. char const* end
  26. ) const noexcept;
  27. };
  28. } // implementation_defined
  29. /** Rule for a query string
  30. @par Value Type
  31. @code
  32. using value_type = params_encoded_view;
  33. @endcode
  34. @par Example
  35. Rules are used with the function @ref grammar::parse.
  36. @code
  37. system::result< params_encoded_view > rv = grammar::parse( "format=web&id=42&compact", query_rule );
  38. @endcode
  39. @par BNF
  40. @code
  41. query = *( pchar / "/" / "?" )
  42. query-params = [ query-param ] *( "&" query-param )
  43. query-param = key [ "=" value ]
  44. key = *qpchar
  45. value = *( qpchar / "=" )
  46. qpchar = unreserved
  47. / pct-encoded
  48. / "!" / "$" / "'" / "(" / ")"
  49. / "*" / "+" / "," / ";"
  50. / ":" / "@" / "/" / "?"
  51. @endcode
  52. @par Specification
  53. @li <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-3.4"
  54. >3.4. Query (rfc3986)</a>
  55. @see
  56. @ref grammar::parse,
  57. @ref params_encoded_view.
  58. */
  59. constexpr implementation_defined::query_rule_t query_rule{};
  60. } // urls
  61. } // boost
  62. #endif