File indexing completed on 2025-01-19 09:47:48
0001
0002
0003
0004
0005
0006
0007
0008 #if !defined(BOOST_SPIRIT_STANDARD_WIDE_NOVEMBER_10_2006_0913AM)
0009 #define BOOST_SPIRIT_STANDARD_WIDE_NOVEMBER_10_2006_0913AM
0010
0011 #if defined(_MSC_VER)
0012 #pragma once
0013 #endif
0014
0015 #include <cwctype>
0016 #include <string>
0017
0018 #include <boost/assert.hpp>
0019 #include <boost/cstdint.hpp>
0020 #include <boost/spirit/home/support/assert_msg.hpp>
0021
0022 #include <boost/type_traits/make_unsigned.hpp>
0023
0024 namespace boost { namespace spirit { namespace traits
0025 {
0026 template <std::size_t N>
0027 struct wchar_t_size
0028 {
0029 BOOST_SPIRIT_ASSERT_MSG(N == 1 || N == 2 || N == 4,
0030 not_supported_size_of_wchar_t, ());
0031 };
0032
0033 template <> struct wchar_t_size<1> { enum { mask = 0xff }; };
0034 template <> struct wchar_t_size<2> { enum { mask = 0xffff }; };
0035 template <> struct wchar_t_size<4> { enum { mask = 0xffffffff }; };
0036
0037 }}}
0038
0039 namespace boost { namespace spirit { namespace char_encoding
0040 {
0041
0042
0043
0044
0045 struct standard_wide
0046 {
0047 typedef wchar_t char_type;
0048 typedef wchar_t classify_type;
0049
0050 template <typename Char>
0051 static typename std::char_traits<Char>::int_type
0052 to_int_type(Char ch)
0053 {
0054 return std::char_traits<Char>::to_int_type(ch);
0055 }
0056
0057 template <typename Char>
0058 static Char
0059 to_char_type(typename std::char_traits<Char>::int_type ch)
0060 {
0061 return std::char_traits<Char>::to_char_type(ch);
0062 }
0063
0064 static bool
0065 ischar(int ch)
0066 {
0067
0068
0069
0070 return (
0071 std::size_t(0) ==
0072 std::size_t(ch & ~traits::wchar_t_size<sizeof(wchar_t)>::mask) ||
0073 std::size_t(~0) ==
0074 std::size_t(ch | traits::wchar_t_size<sizeof(wchar_t)>::mask)
0075 ) != 0;
0076 }
0077
0078 static bool
0079 isalnum(wchar_t ch)
0080 {
0081 using namespace std;
0082 return iswalnum(to_int_type(ch)) != 0;
0083 }
0084
0085 static bool
0086 isalpha(wchar_t ch)
0087 {
0088 using namespace std;
0089 return iswalpha(to_int_type(ch)) != 0;
0090 }
0091
0092 static bool
0093 iscntrl(wchar_t ch)
0094 {
0095 using namespace std;
0096 return iswcntrl(to_int_type(ch)) != 0;
0097 }
0098
0099 static bool
0100 isdigit(wchar_t ch)
0101 {
0102 using namespace std;
0103 return iswdigit(to_int_type(ch)) != 0;
0104 }
0105
0106 static bool
0107 isgraph(wchar_t ch)
0108 {
0109 using namespace std;
0110 return iswgraph(to_int_type(ch)) != 0;
0111 }
0112
0113 static bool
0114 islower(wchar_t ch)
0115 {
0116 using namespace std;
0117 return iswlower(to_int_type(ch)) != 0;
0118 }
0119
0120 static bool
0121 isprint(wchar_t ch)
0122 {
0123 using namespace std;
0124 return iswprint(to_int_type(ch)) != 0;
0125 }
0126
0127 static bool
0128 ispunct(wchar_t ch)
0129 {
0130 using namespace std;
0131 return iswpunct(to_int_type(ch)) != 0;
0132 }
0133
0134 static bool
0135 isspace(wchar_t ch)
0136 {
0137 using namespace std;
0138 return iswspace(to_int_type(ch)) != 0;
0139 }
0140
0141 static bool
0142 isupper(wchar_t ch)
0143 {
0144 using namespace std;
0145 return iswupper(to_int_type(ch)) != 0;
0146 }
0147
0148 static bool
0149 isxdigit(wchar_t ch)
0150 {
0151 using namespace std;
0152 return iswxdigit(to_int_type(ch)) != 0;
0153 }
0154
0155 static bool
0156 isblank BOOST_PREVENT_MACRO_SUBSTITUTION (wchar_t ch)
0157 {
0158 return (ch == L' ' || ch == L'\t');
0159 }
0160
0161
0162
0163
0164
0165 static wchar_t
0166 tolower(wchar_t ch)
0167 {
0168 using namespace std;
0169 return isupper(ch) ?
0170 to_char_type<wchar_t>(towlower(to_int_type(ch))) : ch;
0171 }
0172
0173 static wchar_t
0174 toupper(wchar_t ch)
0175 {
0176 using namespace std;
0177 return islower(ch) ?
0178 to_char_type<wchar_t>(towupper(to_int_type(ch))) : ch;
0179 }
0180
0181 static ::boost::uint32_t
0182 toucs4(wchar_t ch)
0183 {
0184 return static_cast<make_unsigned<wchar_t>::type>(ch);
0185 }
0186 };
0187 }}}
0188
0189 #endif