File indexing completed on 2025-01-31 10:02:34
0001
0002
0003
0004
0005
0006
0007 #if !defined(BOOST_SPIRIT_X3_CHAR_CLASS_APRIL_16_2006_1051AM)
0008 #define BOOST_SPIRIT_X3_CHAR_CLASS_APRIL_16_2006_1051AM
0009
0010 #include <boost/spirit/home/x3/char/char_parser.hpp>
0011 #include <boost/spirit/home/x3/char/detail/cast_char.hpp>
0012 #include <boost/spirit/home/support/char_encoding/standard.hpp>
0013 #include <boost/spirit/home/support/char_encoding/standard_wide.hpp>
0014 #include <boost/spirit/home/support/char_encoding/ascii.hpp>
0015 #include <boost/spirit/home/support/char_encoding/iso8859_1.hpp>
0016 #include <boost/spirit/home/x3/char/char_class_tags.hpp>
0017 namespace boost { namespace spirit { namespace x3
0018 {
0019
0020 template <typename Encoding>
0021 struct char_class_base
0022 {
0023 typedef typename Encoding::classify_type char_type;
0024
0025 #define BOOST_SPIRIT_X3_CLASSIFY(name) \
0026 template <typename Char> \
0027 static bool \
0028 is(name##_tag, Char ch) \
0029 { \
0030 return Encoding::is##name \
0031 BOOST_PREVENT_MACRO_SUBSTITUTION \
0032 (detail::cast_char<char_type>(ch)); \
0033 } \
0034
0035
0036 BOOST_SPIRIT_X3_CLASSIFY(char)
0037 BOOST_SPIRIT_X3_CLASSIFY(alnum)
0038 BOOST_SPIRIT_X3_CLASSIFY(alpha)
0039 BOOST_SPIRIT_X3_CLASSIFY(digit)
0040 BOOST_SPIRIT_X3_CLASSIFY(xdigit)
0041 BOOST_SPIRIT_X3_CLASSIFY(cntrl)
0042 BOOST_SPIRIT_X3_CLASSIFY(graph)
0043 BOOST_SPIRIT_X3_CLASSIFY(lower)
0044 BOOST_SPIRIT_X3_CLASSIFY(print)
0045 BOOST_SPIRIT_X3_CLASSIFY(punct)
0046 BOOST_SPIRIT_X3_CLASSIFY(space)
0047 BOOST_SPIRIT_X3_CLASSIFY(blank)
0048 BOOST_SPIRIT_X3_CLASSIFY(upper)
0049
0050 #undef BOOST_SPIRIT_X3_CLASSIFY
0051 };
0052
0053 template <typename Encoding, typename Tag>
0054 struct char_class
0055 : char_parser<char_class<Encoding, Tag>>
0056 {
0057 typedef Encoding encoding;
0058 typedef Tag tag;
0059 typedef typename Encoding::char_type char_type;
0060 typedef char_type attribute_type;
0061 static bool const has_attribute = true;
0062
0063 template <typename Char, typename Context>
0064 bool test(Char ch, Context const& context) const
0065 {
0066 return encoding::ischar(ch)
0067 && char_class_base<Encoding>::is(
0068 get_case_compare<Encoding>(context).get_char_class_tag(tag()), ch);
0069 }
0070 };
0071
0072 #define BOOST_SPIRIT_X3_CHAR_CLASS(encoding, name) \
0073 typedef char_class<char_encoding::encoding, name##_tag> name##_type; \
0074 constexpr name##_type name = name##_type(); \
0075
0076
0077 #define BOOST_SPIRIT_X3_CHAR_CLASSES(encoding) \
0078 namespace encoding \
0079 { \
0080 BOOST_SPIRIT_X3_CHAR_CLASS(encoding, alnum) \
0081 BOOST_SPIRIT_X3_CHAR_CLASS(encoding, alpha) \
0082 BOOST_SPIRIT_X3_CHAR_CLASS(encoding, digit) \
0083 BOOST_SPIRIT_X3_CHAR_CLASS(encoding, xdigit) \
0084 BOOST_SPIRIT_X3_CHAR_CLASS(encoding, cntrl) \
0085 BOOST_SPIRIT_X3_CHAR_CLASS(encoding, graph) \
0086 BOOST_SPIRIT_X3_CHAR_CLASS(encoding, lower) \
0087 BOOST_SPIRIT_X3_CHAR_CLASS(encoding, print) \
0088 BOOST_SPIRIT_X3_CHAR_CLASS(encoding, punct) \
0089 BOOST_SPIRIT_X3_CHAR_CLASS(encoding, space) \
0090 BOOST_SPIRIT_X3_CHAR_CLASS(encoding, blank) \
0091 BOOST_SPIRIT_X3_CHAR_CLASS(encoding, upper) \
0092 } \
0093
0094
0095 BOOST_SPIRIT_X3_CHAR_CLASSES(standard)
0096 #ifndef BOOST_SPIRIT_NO_STANDARD_WIDE
0097 BOOST_SPIRIT_X3_CHAR_CLASSES(standard_wide)
0098 #endif
0099 BOOST_SPIRIT_X3_CHAR_CLASSES(ascii)
0100 BOOST_SPIRIT_X3_CHAR_CLASSES(iso8859_1)
0101
0102 #undef BOOST_SPIRIT_X3_CHAR_CLASS
0103 #undef BOOST_SPIRIT_X3_CHAR_CLASSES
0104
0105 using standard::alnum_type;
0106 using standard::alpha_type;
0107 using standard::digit_type;
0108 using standard::xdigit_type;
0109 using standard::cntrl_type;
0110 using standard::graph_type;
0111 using standard::lower_type;
0112 using standard::print_type;
0113 using standard::punct_type;
0114 using standard::space_type;
0115 using standard::blank_type;
0116 using standard::upper_type;
0117
0118 using standard::alnum;
0119 using standard::alpha;
0120 using standard::digit;
0121 using standard::xdigit;
0122 using standard::cntrl;
0123 using standard::graph;
0124 using standard::lower;
0125 using standard::print;
0126 using standard::punct;
0127 using standard::space;
0128 using standard::blank;
0129 using standard::upper;
0130 }}}
0131
0132 #endif