PageRenderTime 47ms CodeModel.GetById 10ms app.highlight 32ms RepoModel.GetById 1ms app.codeStats 1ms

/Src/Dependencies/Boost/boost/spirit/home/support/char_encoding/unicode.hpp

http://hadesmem.googlecode.com/
C++ Header | 339 lines | 266 code | 40 blank | 33 comment | 4 complexity | 9645262f6d41a2cf39eed82bab846c07 MD5 | raw file
  1/*=============================================================================
  2    Copyright (c) 2001-2011 Hartmut Kaiser
  3    Copyright (c) 2001-2011 Joel de Guzman
  4
  5    Distributed under the Boost Software License, Version 1.0. (See accompanying
  6    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7=============================================================================*/
  8#if !defined(BOOST_SPIRIT_UNICODE_1_JANUARY_12_2010_0728PM)
  9#define BOOST_SPIRIT_UNICODE_1_JANUARY_12_2010_0728PM
 10
 11#if defined(_MSC_VER)
 12#pragma once
 13#endif
 14
 15#include <boost/cstdint.hpp>
 16#include <boost/spirit/home/support/char_encoding/unicode/query.hpp>
 17
 18namespace boost { namespace spirit { namespace char_encoding
 19{
 20    ///////////////////////////////////////////////////////////////////////////
 21    //  Test characters for specified conditions (using iso8859-1)
 22    ///////////////////////////////////////////////////////////////////////////
 23    struct unicode
 24    {
 25        typedef ::boost::uint32_t char_type;
 26
 27    ///////////////////////////////////////////////////////////////////////////
 28    //  Posix stuff
 29    ///////////////////////////////////////////////////////////////////////////
 30        static bool
 31        isascii_(char_type ch)
 32        {
 33            return 0 == (ch & ~0x7f);
 34        }
 35
 36        static bool
 37        ischar(char_type ch)
 38        {
 39            // unicode code points in the range 0x00 to 0x10FFFF
 40            return ch <= 0x10FFFF;
 41        }
 42
 43        static bool
 44        isalnum(char_type ch)
 45        {
 46            return ucd::is_alphanumeric(ch);
 47        }
 48
 49        static bool
 50        isalpha(char_type ch)
 51        {
 52            return ucd::is_alphabetic(ch);
 53        }
 54
 55        static bool
 56        isdigit(char_type ch)
 57        {
 58            return ucd::is_decimal_number(ch);
 59        }
 60
 61        static bool
 62        isxdigit(char_type ch)
 63        {
 64            return ucd::is_hex_digit(ch);
 65        }
 66
 67        static bool
 68        iscntrl(char_type ch)
 69        {
 70            return ucd::is_control(ch);
 71        }
 72
 73        static bool
 74        isgraph(char_type ch)
 75        {
 76            return ucd::is_graph(ch);
 77        }
 78
 79        static bool
 80        islower(char_type ch)
 81        {
 82            return ucd::is_lowercase(ch);
 83        }
 84
 85        static bool
 86        isprint(char_type ch)
 87        {
 88            return ucd::is_print(ch);
 89        }
 90
 91        static bool
 92        ispunct(char_type ch)
 93        {
 94            return ucd::is_punctuation(ch);
 95        }
 96
 97        static bool
 98        isspace(char_type ch)
 99        {
100            return ucd::is_white_space(ch);
101        }
102
103        static int
104        isblank BOOST_PREVENT_MACRO_SUBSTITUTION (char_type ch)
105        {
106            return ucd::is_blank(ch);
107        }
108
109        static bool
110        isupper(char_type ch)
111        {
112            return ucd::is_uppercase(ch);
113        }
114
115    ///////////////////////////////////////////////////////////////////////////
116    //  Simple character conversions
117    ///////////////////////////////////////////////////////////////////////////
118
119        static char_type
120        tolower(char_type ch)
121        {
122            return ucd::to_lowercase(ch);
123        }
124
125        static char_type
126        toupper(char_type ch)
127        {
128            return ucd::to_uppercase(ch);
129        }
130
131        static ::boost::uint32_t
132        toucs4(char_type ch)
133        {
134            return ch;
135        }
136
137    ///////////////////////////////////////////////////////////////////////////
138    //  Major Categories
139    ///////////////////////////////////////////////////////////////////////////
140#define BOOST_SPIRIT_MAJOR_CATEGORY(name)                                       \
141        static bool                                                             \
142        is_##name(char_type ch)                                                 \
143        {                                                                       \
144            return ucd::get_major_category(ch) == ucd::properties::name;        \
145        }                                                                       \
146        /***/
147
148        BOOST_SPIRIT_MAJOR_CATEGORY(letter)
149        BOOST_SPIRIT_MAJOR_CATEGORY(mark)
150        BOOST_SPIRIT_MAJOR_CATEGORY(number)
151        BOOST_SPIRIT_MAJOR_CATEGORY(separator)
152        BOOST_SPIRIT_MAJOR_CATEGORY(other)
153        BOOST_SPIRIT_MAJOR_CATEGORY(punctuation)
154        BOOST_SPIRIT_MAJOR_CATEGORY(symbol)
155
156    ///////////////////////////////////////////////////////////////////////////
157    //  General Categories
158    ///////////////////////////////////////////////////////////////////////////
159#define BOOST_SPIRIT_CATEGORY(name)                                             \
160        static bool                                                             \
161        is_##name(char_type ch)                                                 \
162        {                                                                       \
163            return ucd::get_category(ch) == ucd::properties::name;              \
164        }                                                                       \
165        /***/
166
167        BOOST_SPIRIT_CATEGORY(uppercase_letter)
168        BOOST_SPIRIT_CATEGORY(lowercase_letter)
169        BOOST_SPIRIT_CATEGORY(titlecase_letter)
170        BOOST_SPIRIT_CATEGORY(modifier_letter)
171        BOOST_SPIRIT_CATEGORY(other_letter)
172
173        BOOST_SPIRIT_CATEGORY(nonspacing_mark)
174        BOOST_SPIRIT_CATEGORY(enclosing_mark)
175        BOOST_SPIRIT_CATEGORY(spacing_mark)
176
177        BOOST_SPIRIT_CATEGORY(decimal_number)
178        BOOST_SPIRIT_CATEGORY(letter_number)
179        BOOST_SPIRIT_CATEGORY(other_number)
180
181        BOOST_SPIRIT_CATEGORY(space_separator)
182        BOOST_SPIRIT_CATEGORY(line_separator)
183        BOOST_SPIRIT_CATEGORY(paragraph_separator)
184
185        BOOST_SPIRIT_CATEGORY(control)
186        BOOST_SPIRIT_CATEGORY(format)
187        BOOST_SPIRIT_CATEGORY(private_use)
188        BOOST_SPIRIT_CATEGORY(surrogate)
189        BOOST_SPIRIT_CATEGORY(unassigned)
190
191        BOOST_SPIRIT_CATEGORY(dash_punctuation)
192        BOOST_SPIRIT_CATEGORY(open_punctuation)
193        BOOST_SPIRIT_CATEGORY(close_punctuation)
194        BOOST_SPIRIT_CATEGORY(connector_punctuation)
195        BOOST_SPIRIT_CATEGORY(other_punctuation)
196        BOOST_SPIRIT_CATEGORY(initial_punctuation)
197        BOOST_SPIRIT_CATEGORY(final_punctuation)
198
199        BOOST_SPIRIT_CATEGORY(math_symbol)
200        BOOST_SPIRIT_CATEGORY(currency_symbol)
201        BOOST_SPIRIT_CATEGORY(modifier_symbol)
202        BOOST_SPIRIT_CATEGORY(other_symbol)
203
204    ///////////////////////////////////////////////////////////////////////////
205    //  Derived Categories
206    ///////////////////////////////////////////////////////////////////////////
207#define BOOST_SPIRIT_DERIVED_CATEGORY(name)                                     \
208        static bool                                                             \
209        is_##name(char_type ch)                                                 \
210        {                                                                       \
211            return ucd::is_##name(ch);                                          \
212        }                                                                       \
213        /***/
214
215        BOOST_SPIRIT_DERIVED_CATEGORY(alphabetic)
216        BOOST_SPIRIT_DERIVED_CATEGORY(uppercase)
217        BOOST_SPIRIT_DERIVED_CATEGORY(lowercase)
218        BOOST_SPIRIT_DERIVED_CATEGORY(white_space)
219        BOOST_SPIRIT_DERIVED_CATEGORY(hex_digit)
220        BOOST_SPIRIT_DERIVED_CATEGORY(noncharacter_code_point)
221        BOOST_SPIRIT_DERIVED_CATEGORY(default_ignorable_code_point)
222
223    ///////////////////////////////////////////////////////////////////////////
224    //  Scripts
225    ///////////////////////////////////////////////////////////////////////////
226#define BOOST_SPIRIT_SCRIPT(name)                                               \
227        static bool                                                             \
228        is_##name(char_type ch)                                                 \
229        {                                                                       \
230            return ucd::get_script(ch) == ucd::properties::name;                \
231        }                                                                       \
232        /***/
233
234        BOOST_SPIRIT_SCRIPT(arabic)
235        BOOST_SPIRIT_SCRIPT(imperial_aramaic)
236        BOOST_SPIRIT_SCRIPT(armenian)
237        BOOST_SPIRIT_SCRIPT(avestan)
238        BOOST_SPIRIT_SCRIPT(balinese)
239        BOOST_SPIRIT_SCRIPT(bamum)
240        BOOST_SPIRIT_SCRIPT(bengali)
241        BOOST_SPIRIT_SCRIPT(bopomofo)
242        BOOST_SPIRIT_SCRIPT(braille)
243        BOOST_SPIRIT_SCRIPT(buginese)
244        BOOST_SPIRIT_SCRIPT(buhid)
245        BOOST_SPIRIT_SCRIPT(canadian_aboriginal)
246        BOOST_SPIRIT_SCRIPT(carian)
247        BOOST_SPIRIT_SCRIPT(cham)
248        BOOST_SPIRIT_SCRIPT(cherokee)
249        BOOST_SPIRIT_SCRIPT(coptic)
250        BOOST_SPIRIT_SCRIPT(cypriot)
251        BOOST_SPIRIT_SCRIPT(cyrillic)
252        BOOST_SPIRIT_SCRIPT(devanagari)
253        BOOST_SPIRIT_SCRIPT(deseret)
254        BOOST_SPIRIT_SCRIPT(egyptian_hieroglyphs)
255        BOOST_SPIRIT_SCRIPT(ethiopic)
256        BOOST_SPIRIT_SCRIPT(georgian)
257        BOOST_SPIRIT_SCRIPT(glagolitic)
258        BOOST_SPIRIT_SCRIPT(gothic)
259        BOOST_SPIRIT_SCRIPT(greek)
260        BOOST_SPIRIT_SCRIPT(gujarati)
261        BOOST_SPIRIT_SCRIPT(gurmukhi)
262        BOOST_SPIRIT_SCRIPT(hangul)
263        BOOST_SPIRIT_SCRIPT(han)
264        BOOST_SPIRIT_SCRIPT(hanunoo)
265        BOOST_SPIRIT_SCRIPT(hebrew)
266        BOOST_SPIRIT_SCRIPT(hiragana)
267        BOOST_SPIRIT_SCRIPT(katakana_or_hiragana)
268        BOOST_SPIRIT_SCRIPT(old_italic)
269        BOOST_SPIRIT_SCRIPT(javanese)
270        BOOST_SPIRIT_SCRIPT(kayah_li)
271        BOOST_SPIRIT_SCRIPT(katakana)
272        BOOST_SPIRIT_SCRIPT(kharoshthi)
273        BOOST_SPIRIT_SCRIPT(khmer)
274        BOOST_SPIRIT_SCRIPT(kannada)
275        BOOST_SPIRIT_SCRIPT(kaithi)
276        BOOST_SPIRIT_SCRIPT(tai_tham)
277        BOOST_SPIRIT_SCRIPT(lao)
278        BOOST_SPIRIT_SCRIPT(latin)
279        BOOST_SPIRIT_SCRIPT(lepcha)
280        BOOST_SPIRIT_SCRIPT(limbu)
281        BOOST_SPIRIT_SCRIPT(linear_b)
282        BOOST_SPIRIT_SCRIPT(lisu)
283        BOOST_SPIRIT_SCRIPT(lycian)
284        BOOST_SPIRIT_SCRIPT(lydian)
285        BOOST_SPIRIT_SCRIPT(malayalam)
286        BOOST_SPIRIT_SCRIPT(mongolian)
287        BOOST_SPIRIT_SCRIPT(meetei_mayek)
288        BOOST_SPIRIT_SCRIPT(myanmar)
289        BOOST_SPIRIT_SCRIPT(nko)
290        BOOST_SPIRIT_SCRIPT(ogham)
291        BOOST_SPIRIT_SCRIPT(ol_chiki)
292        BOOST_SPIRIT_SCRIPT(old_turkic)
293        BOOST_SPIRIT_SCRIPT(oriya)
294        BOOST_SPIRIT_SCRIPT(osmanya)
295        BOOST_SPIRIT_SCRIPT(phags_pa)
296        BOOST_SPIRIT_SCRIPT(inscriptional_pahlavi)
297        BOOST_SPIRIT_SCRIPT(phoenician)
298        BOOST_SPIRIT_SCRIPT(inscriptional_parthian)
299        BOOST_SPIRIT_SCRIPT(rejang)
300        BOOST_SPIRIT_SCRIPT(runic)
301        BOOST_SPIRIT_SCRIPT(samaritan)
302        BOOST_SPIRIT_SCRIPT(old_south_arabian)
303        BOOST_SPIRIT_SCRIPT(saurashtra)
304        BOOST_SPIRIT_SCRIPT(shavian)
305        BOOST_SPIRIT_SCRIPT(sinhala)
306        BOOST_SPIRIT_SCRIPT(sundanese)
307        BOOST_SPIRIT_SCRIPT(syloti_nagri)
308        BOOST_SPIRIT_SCRIPT(syriac)
309        BOOST_SPIRIT_SCRIPT(tagbanwa)
310        BOOST_SPIRIT_SCRIPT(tai_le)
311        BOOST_SPIRIT_SCRIPT(new_tai_lue)
312        BOOST_SPIRIT_SCRIPT(tamil)
313        BOOST_SPIRIT_SCRIPT(tai_viet)
314        BOOST_SPIRIT_SCRIPT(telugu)
315        BOOST_SPIRIT_SCRIPT(tifinagh)
316        BOOST_SPIRIT_SCRIPT(tagalog)
317        BOOST_SPIRIT_SCRIPT(thaana)
318        BOOST_SPIRIT_SCRIPT(thai)
319        BOOST_SPIRIT_SCRIPT(tibetan)
320        BOOST_SPIRIT_SCRIPT(ugaritic)
321        BOOST_SPIRIT_SCRIPT(vai)
322        BOOST_SPIRIT_SCRIPT(old_persian)
323        BOOST_SPIRIT_SCRIPT(cuneiform)
324        BOOST_SPIRIT_SCRIPT(yi)
325        BOOST_SPIRIT_SCRIPT(inherited)
326        BOOST_SPIRIT_SCRIPT(common)
327        BOOST_SPIRIT_SCRIPT(unknown)
328
329#undef BOOST_SPIRIT_MAJOR_CATEGORY
330#undef BOOST_SPIRIT_CATEGORY
331#undef BOOST_SPIRIT_DERIVED_CATEGORY
332#undef BOOST_SPIRIT_SCRIPT
333
334    };
335
336}}}
337
338#endif
339