1 /*=============================================================================
2 Copyright (c) 2001-2011 Hartmut Kaiser
3 Copyright (c) 2001-2011 Joel de Guzman
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
16 #include <boost/assert.hpp>
17 #include <boost/cstdint.hpp>
19 namespace boost { namespace spirit { namespace char_encoding
21 ///////////////////////////////////////////////////////////////////////////
22 // Test characters for specified conditions (using std functions)
23 ///////////////////////////////////////////////////////////////////////////
26 typedef char char_type;
27 typedef unsigned char classify_type;
32 return 0 == (ch & ~0x7f);
39 // we have to watch out for sign extensions
40 return (0 == (ch & ~0xff) || ~0 == (ch | 0xff)) != 0;
43 // *** Note on assertions: The precondition is that the calls to
44 // these functions do not violate the required range of ch (int)
45 // which is that strict_ischar(ch) should be true. It is the
46 // responsibility of the caller to make sure this precondition is not
52 // ch should be representable as an unsigned char
53 return ch >= 0 && ch <= UCHAR_MAX;
59 BOOST_ASSERT(strict_ischar(ch));
60 return std::isalnum(ch) != 0;
66 BOOST_ASSERT(strict_ischar(ch));
67 return std::isalpha(ch) != 0;
73 BOOST_ASSERT(strict_ischar(ch));
74 return std::isdigit(ch) != 0;
80 BOOST_ASSERT(strict_ischar(ch));
81 return std::isxdigit(ch) != 0;
87 BOOST_ASSERT(strict_ischar(ch));
88 return std::iscntrl(ch) != 0;
94 BOOST_ASSERT(strict_ischar(ch));
95 return std::isgraph(ch) != 0;
101 BOOST_ASSERT(strict_ischar(ch));
102 return std::islower(ch) != 0;
108 BOOST_ASSERT(strict_ischar(ch));
109 return std::isprint(ch) != 0;
115 BOOST_ASSERT(strict_ischar(ch));
116 return std::ispunct(ch) != 0;
122 BOOST_ASSERT(strict_ischar(ch));
123 return std::isspace(ch) != 0;
127 isblank BOOST_PREVENT_MACRO_SUBSTITUTION (int ch)
129 BOOST_ASSERT(strict_ischar(ch));
130 return (ch == ' ' || ch == '\t');
136 BOOST_ASSERT(strict_ischar(ch));
137 return std::isupper(ch) != 0;
140 ///////////////////////////////////////////////////////////////////////////////
141 // Simple character conversions
142 ///////////////////////////////////////////////////////////////////////////////
147 BOOST_ASSERT(strict_ischar(ch));
148 return std::tolower(ch);
154 BOOST_ASSERT(strict_ischar(ch));
155 return std::toupper(ch);
158 static ::boost::uint32_t
161 BOOST_ASSERT(strict_ischar(ch));