File indexing completed on 2025-01-18 09:53:28
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_URL_RFC_IMPL_PCT_ENCODED_RULE_HPP
0011 #define BOOST_URL_RFC_IMPL_PCT_ENCODED_RULE_HPP
0012
0013 #include <boost/url/grammar/charset.hpp>
0014 #include <boost/url/grammar/error.hpp>
0015 #include <boost/url/grammar/hexdig_chars.hpp>
0016
0017 namespace boost {
0018 namespace urls {
0019
0020 namespace detail {
0021
0022 template<class CharSet>
0023 auto
0024 parse_encoded(
0025 char const*& it,
0026 char const* end,
0027 CharSet const& cs) noexcept ->
0028 system::result<pct_string_view>
0029 {
0030 auto const start = it;
0031 std::size_t n = 0;
0032 char const* it0;
0033 skip:
0034 it0 = it;
0035 it = grammar::find_if_not(
0036 it0, end, cs);
0037 n += it - it0;
0038 if(it == end)
0039 goto finish;
0040 if(*it != '%')
0041 goto finish;
0042 for(;;)
0043 {
0044 ++it;
0045 if(it == end)
0046 {
0047
0048 BOOST_URL_RETURN_EC(
0049 grammar::error::invalid);
0050 }
0051 auto r = grammar::hexdig_value(*it);
0052 if(r < 0)
0053 {
0054
0055 BOOST_URL_RETURN_EC(
0056 grammar::error::invalid);
0057 }
0058 ++it;
0059 if(it == end)
0060 {
0061
0062 BOOST_URL_RETURN_EC(
0063 grammar::error::invalid);
0064 }
0065 r = grammar::hexdig_value(*it);
0066 if(r < 0)
0067 {
0068
0069 BOOST_URL_RETURN_EC(
0070 grammar::error::invalid);
0071 }
0072 ++n;
0073 ++it;
0074 if(it == end)
0075 break;
0076 if(*it != '%')
0077 goto skip;
0078 }
0079 finish:
0080 return make_pct_string_view_unsafe(
0081 start, it - start, n);
0082 }
0083
0084 }
0085
0086
0087
0088 template<class CharSet>
0089 auto
0090 pct_encoded_rule_t<CharSet>::
0091 parse(
0092 char const*& it,
0093 char const* end) const noexcept ->
0094 system::result<value_type>
0095 {
0096 return detail::parse_encoded(
0097 it, end, cs_);
0098 }
0099
0100 }
0101 }
0102
0103 #endif