File indexing completed on 2025-01-18 09:53:27
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
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056 #ifdef BOOST_URL_DOCS
0057 constexpr
0058 __implementation_defined__
0059 delim_rule( char ch ) noexcept;
0060 #else
0061 struct ch_delim_rule
0062 {
0063 using value_type = core::string_view;
0064
0065 constexpr
0066 ch_delim_rule(char ch) noexcept
0067 : ch_(ch)
0068 {
0069 }
0070
0071 BOOST_URL_DECL
0072 system::result<value_type>
0073 parse(
0074 char const*& it,
0075 char const* end) const noexcept;
0076
0077 private:
0078 char ch_;
0079 };
0080
0081 constexpr
0082 ch_delim_rule
0083 delim_rule( char ch ) noexcept
0084 {
0085 return ch_delim_rule(ch);
0086 }
0087 #endif
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120 #ifdef BOOST_URL_DOCS
0121 template<class CharSet>
0122 constexpr
0123 __implementation_defined__
0124 delim_rule( CharSet const& cs ) noexcept;
0125 #else
0126 template<class CharSet>
0127 struct cs_delim_rule
0128 {
0129 using value_type = core::string_view;
0130
0131 constexpr
0132 cs_delim_rule(
0133 CharSet const& cs) noexcept
0134 : cs_(cs)
0135 {
0136 }
0137
0138 system::result<value_type>
0139 parse(
0140 char const*& it,
0141 char const* end) const noexcept
0142 {
0143 if(it == end)
0144 {
0145
0146 BOOST_URL_RETURN_EC(
0147 error::need_more);
0148 }
0149 if(! cs_(*it))
0150 {
0151
0152 BOOST_URL_RETURN_EC(
0153 error::mismatch);
0154 }
0155 return core::string_view{
0156 it++, 1 };
0157 }
0158
0159 private:
0160 CharSet cs_;
0161 };
0162
0163 template<class CharSet>
0164 constexpr
0165 typename std::enable_if<
0166 ! std::is_convertible<
0167 CharSet, char>::value,
0168 cs_delim_rule<CharSet>>::type
0169 delim_rule(
0170 CharSet const& cs) noexcept
0171 {
0172
0173
0174
0175
0176 static_assert(
0177 is_charset<CharSet>::value,
0178 "CharSet requirements not met");
0179
0180 return cs_delim_rule<CharSet>(cs);
0181 }
0182 #endif
0183
0184 }
0185 }
0186 }
0187
0188 #endif