1 /*============================================================================= 2 Copyright (c) 2001-2014 Joel de Guzman 3 4 Distributed under the Boost Software License, Version 1.0. (See accompanying 5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 ==============================================================================*/ 7 #if !defined(BOOST_SPIRIT_X3_CHAR_APRIL_16_2006_1051AM) 8 #define BOOST_SPIRIT_X3_CHAR_APRIL_16_2006_1051AM 9 10 #include <boost/spirit/home/x3/char/any_char.hpp> 11 #include <boost/spirit/home/support/char_encoding/ascii.hpp> 12 #include <boost/spirit/home/support/char_encoding/iso8859_1.hpp> 13 #include <boost/spirit/home/support/char_encoding/standard.hpp> 14 #include <boost/spirit/home/support/char_encoding/standard_wide.hpp> 15 16 namespace boost { namespace spirit { namespace x3 17 { 18 namespace standard 19 { 20 typedef any_char<char_encoding::standard> char_type; 21 constexpr auto char_ = char_type{}; 22 23 constexpr literal_char<char_encoding::standard, unused_type> lit(char ch)24 lit(char ch) 25 { 26 return { ch }; 27 } 28 29 constexpr literal_char<char_encoding::standard, unused_type> lit(wchar_t ch)30 lit(wchar_t ch) 31 { 32 return { ch }; 33 } 34 35 } 36 37 using standard::char_type; 38 using standard::char_; 39 using standard::lit; 40 41 #ifndef BOOST_SPIRIT_NO_STANDARD_WIDE 42 namespace standard_wide 43 { 44 typedef any_char<char_encoding::standard_wide> char_type; 45 constexpr auto char_ = char_type{}; 46 47 constexpr literal_char<char_encoding::standard_wide, unused_type> lit(wchar_t ch)48 lit(wchar_t ch) 49 { 50 return { ch }; 51 } 52 } 53 #endif 54 55 namespace ascii 56 { 57 typedef any_char<char_encoding::ascii> char_type; 58 constexpr auto char_ = char_type{}; 59 60 constexpr literal_char<char_encoding::ascii, unused_type> lit(char ch)61 lit(char ch) 62 { 63 return { ch }; 64 } 65 66 constexpr literal_char<char_encoding::ascii, unused_type> lit(wchar_t ch)67 lit(wchar_t ch) 68 { 69 return { ch }; 70 } 71 } 72 73 namespace iso8859_1 74 { 75 typedef any_char<char_encoding::iso8859_1> char_type; 76 constexpr auto char_ = char_type{}; 77 78 constexpr literal_char<char_encoding::iso8859_1, unused_type> lit(char ch)79 lit(char ch) 80 { 81 return { ch }; 82 } 83 84 constexpr literal_char<char_encoding::iso8859_1, unused_type> lit(wchar_t ch)85 lit(wchar_t ch) 86 { 87 return { ch }; 88 } 89 } 90 91 namespace extension 92 { 93 template <> 94 struct as_parser<char> 95 { 96 typedef literal_char< 97 char_encoding::standard, unused_type> 98 type; 99 100 typedef type value_type; 101 callboost::spirit::x3::extension::as_parser102 static constexpr type call(char ch) 103 { 104 return { ch }; 105 } 106 }; 107 108 #ifndef BOOST_SPIRIT_NO_STANDARD_WIDE 109 template <> 110 struct as_parser<wchar_t> 111 { 112 typedef literal_char< 113 char_encoding::standard_wide, unused_type> 114 type; 115 116 typedef type value_type; 117 callboost::spirit::x3::extension::as_parser118 static constexpr type call(wchar_t ch) 119 { 120 return { ch }; 121 } 122 }; 123 #endif 124 125 template <> 126 struct as_parser<char [2]> 127 { 128 typedef literal_char< 129 char_encoding::standard, unused_type> 130 type; 131 132 typedef type value_type; 133 callboost::spirit::x3::extension::as_parser134 static constexpr type call(char const ch[]) 135 { 136 return { ch[0] }; 137 } 138 }; 139 140 #ifndef BOOST_SPIRIT_NO_STANDARD_WIDE 141 template <> 142 struct as_parser<wchar_t [2]> 143 { 144 typedef literal_char< 145 char_encoding::standard_wide, unused_type> 146 type; 147 148 typedef type value_type; 149 callboost::spirit::x3::extension::as_parser150 static constexpr type call(wchar_t const ch[] ) 151 { 152 return { ch[0] }; 153 } 154 }; 155 #endif 156 157 } 158 159 }}} 160 161 #endif 162