File indexing completed on 2025-01-18 09:40:48
0001 #ifndef BOOST_METAPARSE_V1_CPP98_STRING_HPP
0002 #define BOOST_METAPARSE_V1_CPP98_STRING_HPP
0003
0004
0005
0006
0007
0008
0009 #include <boost/metaparse/v1/cpp98/fwd/string.hpp>
0010 #include <boost/metaparse/v1/string_tag.hpp>
0011 #include <boost/metaparse/v1/impl/string_iterator.hpp>
0012 #include <boost/metaparse/v1/cpp98/impl/empty_string.hpp>
0013 #include <boost/metaparse/v1/cpp98/impl/size.hpp>
0014 #include <boost/metaparse/v1/cpp98/impl/pop_front.hpp>
0015 #include <boost/metaparse/v1/cpp98/impl/push_front_c.hpp>
0016 #include <boost/metaparse/v1/cpp98/impl/push_back_c.hpp>
0017 #include <boost/metaparse/v1/cpp98/impl/pop_back.hpp>
0018
0019 #include <boost/preprocessor/arithmetic/sub.hpp>
0020 #include <boost/preprocessor/punctuation/comma_if.hpp>
0021 #include <boost/preprocessor/repetition/enum.hpp>
0022 #include <boost/preprocessor/repetition/enum_params.hpp>
0023 #include <boost/preprocessor/repetition/repeat_from_to.hpp>
0024 #include <boost/preprocessor/tuple/eat.hpp>
0025
0026 #include <boost/type_traits/is_same.hpp>
0027
0028
0029
0030
0031
0032 namespace boost
0033 {
0034 namespace metaparse
0035 {
0036 namespace v1
0037 {
0038 template <BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, int C)>
0039 struct string
0040 {
0041 typedef string type;
0042 typedef string_tag tag;
0043 };
0044 }
0045 }
0046 }
0047
0048
0049
0050
0051
0052 namespace boost
0053 {
0054 namespace mpl
0055 {
0056
0057 template <class S>
0058 struct push_back_impl;
0059
0060 template <>
0061 struct push_back_impl<boost::metaparse::v1::string_tag>
0062 {
0063 typedef push_back_impl type;
0064
0065 template <class S, class C>
0066 struct apply :
0067 boost::metaparse::v1::impl::push_back_c<
0068 typename S::type,
0069 C::type::value
0070 >
0071 {};
0072 };
0073
0074
0075 template <class S>
0076 struct pop_back_impl;
0077
0078 template <>
0079 struct pop_back_impl<boost::metaparse::v1::string_tag>
0080 {
0081 typedef pop_back_impl type;
0082
0083 template <class S>
0084 struct apply : boost::metaparse::v1::impl::pop_back<S> {};
0085 };
0086
0087
0088 template <class S>
0089 struct push_front_impl;
0090
0091 template <>
0092 struct push_front_impl<boost::metaparse::v1::string_tag>
0093 {
0094 typedef push_front_impl type;
0095
0096 template <class S, class C>
0097 struct apply :
0098 boost::metaparse::v1::impl::push_front_c<
0099 typename S::type,
0100 C::type::value
0101 >
0102 {};
0103 };
0104
0105
0106 template <class S>
0107 struct pop_front_impl;
0108
0109 template <>
0110 struct pop_front_impl<boost::metaparse::v1::string_tag>
0111 {
0112 typedef pop_front_impl type;
0113
0114 template <class S>
0115 struct apply : boost::metaparse::v1::impl::pop_front<S> {};
0116 };
0117
0118
0119 template <class S>
0120 struct clear_impl;
0121
0122 template <>
0123 struct clear_impl<boost::metaparse::v1::string_tag>
0124 {
0125 typedef clear_impl type;
0126
0127 template <class S>
0128 struct apply : boost::metaparse::v1::string<> {};
0129 };
0130
0131
0132 template <class S>
0133 struct begin_impl;
0134
0135 template <>
0136 struct begin_impl<boost::metaparse::v1::string_tag>
0137 {
0138 typedef begin_impl type;
0139
0140 template <class S>
0141 struct apply :
0142 boost::metaparse::v1::impl::string_iterator<typename S::type, 0>
0143 {};
0144 };
0145
0146
0147 template <class S>
0148 struct end_impl;
0149
0150 template <>
0151 struct end_impl<boost::metaparse::v1::string_tag>
0152 {
0153 typedef end_impl type;
0154
0155 template <class S>
0156 struct apply :
0157 boost::metaparse::v1::impl::string_iterator<
0158 typename S::type,
0159 boost::metaparse::v1::impl::size<typename S::type>::type::value
0160 >
0161 {};
0162 };
0163
0164
0165 template <class A, class B>
0166 struct equal_to_impl;
0167
0168 template <>
0169 struct equal_to_impl<
0170 boost::metaparse::v1::string_tag,
0171 boost::metaparse::v1::string_tag
0172 >
0173 {
0174 typedef equal_to_impl type;
0175
0176 template <class A, class B>
0177 struct apply : boost::is_same<typename A::type, typename B::type> {};
0178 };
0179
0180 template <class T>
0181 struct equal_to_impl<boost::metaparse::v1::string_tag, T>
0182 {
0183 typedef equal_to_impl type;
0184
0185 template <class, class>
0186 struct apply : false_ {};
0187 };
0188
0189 template <class T>
0190 struct equal_to_impl<T, boost::metaparse::v1::string_tag> :
0191 equal_to_impl<boost::metaparse::v1::string_tag, T>
0192 {};
0193
0194
0195 template <class S>
0196 struct c_str;
0197
0198 template <BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, int C)>
0199 struct c_str<
0200 boost::metaparse::v1::string<
0201 BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, C)
0202 >
0203 >
0204 {
0205 typedef c_str type;
0206 static const char value[BOOST_METAPARSE_LIMIT_STRING_SIZE + 1];
0207 };
0208
0209 template <BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, int C)>
0210 const char
0211 c_str<
0212 boost::metaparse::v1::string<
0213 BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, C)
0214 >
0215 >::value[BOOST_METAPARSE_LIMIT_STRING_SIZE + 1]
0216 = {BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, C), 0};
0217
0218 template <>
0219 struct c_str<boost::metaparse::v1::string<> > :
0220 boost::metaparse::v1::impl::empty_string<>
0221 {
0222 typedef c_str type;
0223 };
0224
0225 #ifdef BOOST_METAPARSE_STRING_CASE
0226 # error BOOST_METAPARSE_STRING_CASE is already defined
0227 #endif
0228 #define BOOST_METAPARSE_STRING_CASE(z, n, unused) \
0229 template <BOOST_PP_ENUM_PARAMS(n, int C)> \
0230 struct \
0231 c_str< \
0232 boost::metaparse::v1::string< \
0233 BOOST_PP_ENUM_PARAMS(n, C) BOOST_PP_COMMA_IF(n) \
0234 BOOST_PP_ENUM( \
0235 BOOST_PP_SUB(BOOST_METAPARSE_LIMIT_STRING_SIZE, n), \
0236 BOOST_NO_CHAR BOOST_PP_TUPLE_EAT(3), \
0237 ~ \
0238 ) \
0239 > \
0240 > \
0241 { \
0242 typedef c_str type; \
0243 static const char value[n + 1]; \
0244 }; \
0245 \
0246 template <BOOST_PP_ENUM_PARAMS(n, int C)> \
0247 const char c_str< \
0248 boost::metaparse::v1::string< \
0249 BOOST_PP_ENUM_PARAMS(n, C) BOOST_PP_COMMA_IF(n) \
0250 BOOST_PP_ENUM( \
0251 BOOST_PP_SUB(BOOST_METAPARSE_LIMIT_STRING_SIZE, n), \
0252 BOOST_NO_CHAR BOOST_PP_TUPLE_EAT(3), \
0253 ~ \
0254 ) \
0255 > \
0256 >::value[n + 1] = {BOOST_PP_ENUM_PARAMS(n, C) BOOST_PP_COMMA_IF(n) 0};
0257
0258 BOOST_PP_REPEAT_FROM_TO(
0259 1,
0260 BOOST_METAPARSE_LIMIT_STRING_SIZE,
0261 BOOST_METAPARSE_STRING_CASE,
0262 ~
0263 )
0264
0265 #undef BOOST_METAPARSE_STRING_CASE
0266 }
0267 }
0268
0269 #define BOOST_METAPARSE_V1_CONFIG_NO_BOOST_METAPARSE_STRING 1
0270
0271 #endif
0272