]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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_STANDARD_APRIL_26_2006_1106PM) | |
9 | #define BOOST_SPIRIT_STANDARD_APRIL_26_2006_1106PM | |
10 | ||
11 | #if defined(_MSC_VER) | |
12 | #pragma once | |
13 | #endif | |
14 | ||
15 | #include <cctype> | |
16 | #include <boost/cstdint.hpp> | |
17 | ||
18 | namespace boost { namespace spirit { namespace char_encoding | |
19 | { | |
20 | /////////////////////////////////////////////////////////////////////////// | |
21 | // Test characters for specified conditions (using std functions) | |
22 | /////////////////////////////////////////////////////////////////////////// | |
23 | struct standard | |
24 | { | |
25 | typedef char char_type; | |
26 | ||
27 | static bool | |
28 | isascii_(int ch) | |
29 | { | |
30 | return 0 == (ch & ~0x7f); | |
31 | } | |
32 | ||
33 | static bool | |
34 | ischar(int ch) | |
35 | { | |
36 | // uses all 8 bits | |
37 | // we have to watch out for sign extensions | |
38 | return (0 == (ch & ~0xff) || ~0 == (ch | 0xff)) ? true : false; | |
39 | } | |
40 | ||
41 | static bool | |
42 | isalnum(int ch) | |
43 | { | |
44 | return std::isalnum(ch) ? true : false; | |
45 | } | |
46 | ||
47 | static bool | |
48 | isalpha(int ch) | |
49 | { | |
50 | return std::isalpha(ch) ? true : false; | |
51 | } | |
52 | ||
53 | static bool | |
54 | isdigit(int ch) | |
55 | { | |
56 | return std::isdigit(ch) ? true : false; | |
57 | } | |
58 | ||
59 | static bool | |
60 | isxdigit(int ch) | |
61 | { | |
62 | return std::isxdigit(ch) ? true : false; | |
63 | } | |
64 | ||
65 | static bool | |
66 | iscntrl(int ch) | |
67 | { | |
68 | return std::iscntrl(ch) ? true : false; | |
69 | } | |
70 | ||
71 | static bool | |
72 | isgraph(int ch) | |
73 | { | |
74 | return std::isgraph(ch) ? true : false; | |
75 | } | |
76 | ||
77 | static bool | |
78 | islower(int ch) | |
79 | { | |
80 | return std::islower(ch) ? true : false; | |
81 | } | |
82 | ||
83 | static bool | |
84 | isprint(int ch) | |
85 | { | |
86 | return std::isprint(ch) ? true : false; | |
87 | } | |
88 | ||
89 | static bool | |
90 | ispunct(int ch) | |
91 | { | |
92 | return std::ispunct(ch) ? true : false; | |
93 | } | |
94 | ||
95 | static bool | |
96 | isspace(int ch) | |
97 | { | |
98 | return std::isspace(ch) ? true : false; | |
99 | } | |
100 | ||
101 | static bool | |
102 | isblank BOOST_PREVENT_MACRO_SUBSTITUTION (int ch) | |
103 | { | |
104 | return (ch == ' ' || ch == '\t'); | |
105 | } | |
106 | ||
107 | static bool | |
108 | isupper(int ch) | |
109 | { | |
110 | return std::isupper(ch) ? true : false; | |
111 | } | |
112 | ||
113 | /////////////////////////////////////////////////////////////////////////////// | |
114 | // Simple character conversions | |
115 | /////////////////////////////////////////////////////////////////////////////// | |
116 | ||
117 | static int | |
118 | tolower(int ch) | |
119 | { | |
120 | return std::tolower(ch); | |
121 | } | |
122 | ||
123 | static int | |
124 | toupper(int ch) | |
125 | { | |
126 | return std::toupper(ch); | |
127 | } | |
128 | ||
129 | static ::boost::uint32_t | |
130 | toucs4(int ch) | |
131 | { | |
132 | return ch; | |
133 | } | |
134 | }; | |
135 | }}} | |
136 | ||
137 | #endif | |
138 |