File indexing completed on 2025-09-18 09:07:54
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_URL_GRAMMAR_DELIM_RULE_HPP
0011 #define BOOST_URL_GRAMMAR_DELIM_RULE_HPP
0012
0013 #include <boost/url/detail/config.hpp>
0014 #include <boost/core/detail/string_view.hpp>
0015 #include <boost/url/grammar/charset.hpp>
0016 #include <boost/url/grammar/error.hpp>
0017 #include <boost/url/grammar/type_traits.hpp>
0018 #include <type_traits>
0019
0020 namespace boost {
0021 namespace urls {
0022 namespace grammar {
0023
0024 namespace implementation_defined {
0025 struct ch_delim_rule
0026 {
0027 using value_type = core::string_view;
0028
0029 constexpr
0030 ch_delim_rule(char ch) noexcept
0031 : ch_(ch)
0032 {
0033 }
0034
0035 BOOST_URL_DECL
0036 system::result<value_type>
0037 parse(
0038 char const*& it,
0039 char const* end) const noexcept;
0040
0041 private:
0042 char ch_;
0043 };
0044 }
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079 constexpr
0080 implementation_defined::ch_delim_rule
0081 delim_rule( char ch ) noexcept
0082 {
0083 return {ch};
0084 }
0085
0086
0087
0088 namespace implementation_defined {
0089 template<class CharSet>
0090 struct cs_delim_rule
0091 {
0092 using value_type = core::string_view;
0093
0094 constexpr
0095 cs_delim_rule(
0096 CharSet const& cs) noexcept
0097 : cs_(cs)
0098 {
0099 }
0100
0101 system::result<value_type>
0102 parse(
0103 char const*& it,
0104 char const* end) const noexcept
0105 {
0106 if(it == end)
0107 {
0108
0109 BOOST_URL_RETURN_EC(
0110 error::need_more);
0111 }
0112 if(! cs_(*it))
0113 {
0114
0115 BOOST_URL_RETURN_EC(
0116 error::mismatch);
0117 }
0118 return core::string_view{
0119 it++, 1 };
0120 }
0121
0122 private:
0123 CharSet cs_;
0124 };
0125 }
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157 template<BOOST_URL_CONSTRAINT(CharSet) CS>
0158 constexpr
0159 typename std::enable_if<
0160 ! std::is_convertible<
0161 CS, char>::value,
0162 implementation_defined::cs_delim_rule<CS>>::type
0163 delim_rule(
0164 CS const& cs) noexcept
0165 {
0166
0167
0168
0169
0170 static_assert(
0171 is_charset<CS>::value,
0172 "CharSet requirements not met");
0173
0174 return implementation_defined::cs_delim_rule<CS>(cs);
0175 }
0176
0177 }
0178 }
0179 }
0180
0181 #endif