userinfo_rule.hpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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_DETAIL_USERINFO_RULE_HPP
  10. #define BOOST_URL_RFC_DETAIL_USERINFO_RULE_HPP
  11. #include <boost/url/detail/config.hpp>
  12. #include <boost/url/error_types.hpp>
  13. #include <boost/url/pct_string_view.hpp>
  14. namespace boost {
  15. namespace urls {
  16. namespace detail {
  17. /** Rule for userinfo
  18. @par BNF
  19. @code
  20. userinfo = user [ ":" [ password ] ]
  21. user = *( unreserved / pct-encoded / sub-delims )
  22. password = *( unreserved / pct-encoded / sub-delims / ":" )
  23. @endcode
  24. @par Specification
  25. <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.1"
  26. >3.2.1. User Information (3986)</a>
  27. */
  28. struct userinfo_rule_t
  29. {
  30. struct value_type
  31. {
  32. pct_string_view user;
  33. pct_string_view password;
  34. bool has_password = false;
  35. };
  36. auto
  37. parse(
  38. char const*& it,
  39. char const* end
  40. ) const noexcept ->
  41. system::result<value_type>;
  42. };
  43. constexpr userinfo_rule_t userinfo_rule{};
  44. } // detail
  45. } // urls
  46. } // boost
  47. #endif