Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-19 09:47:48

0001 /*=============================================================================
0002     Copyright (c) 2001-2011 Hartmut Kaiser
0003     Copyright (c) 2001-2011 Joel de Guzman
0004 
0005     Distributed under the Boost Software License, Version 1.0. (See accompanying
0006     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0007 =============================================================================*/
0008 #if !defined(BOOST_SPIRIT_STANDARD_APRIL_26_2006_1106PM)
0009 #define BOOST_SPIRIT_STANDARD_APRIL_26_2006_1106PM
0010 
0011 #if defined(_MSC_VER)
0012 #pragma once
0013 #endif
0014 
0015 #include <cctype>
0016 #include <climits>
0017 #include <boost/assert.hpp>
0018 #include <boost/cstdint.hpp>
0019 
0020 namespace boost { namespace spirit { namespace char_encoding
0021 {
0022     ///////////////////////////////////////////////////////////////////////////
0023     //  Test characters for specified conditions (using std functions)
0024     ///////////////////////////////////////////////////////////////////////////
0025     struct standard
0026     {
0027         typedef char char_type;
0028         typedef unsigned char classify_type;
0029 
0030         static bool
0031         isascii_(int ch)
0032         {
0033             return 0 == (ch & ~0x7f);
0034         }
0035 
0036         static bool
0037         ischar(int ch)
0038         {
0039             // uses all 8 bits
0040             // we have to watch out for sign extensions
0041             return (0 == (ch & ~0xff) || ~0 == (ch | 0xff)) != 0;
0042         }
0043 
0044         // *** Note on assertions: The precondition is that the calls to
0045         // these functions do not violate the required range of ch (int)
0046         // which is that strict_ischar(ch) should be true. It is the
0047         // responsibility of the caller to make sure this precondition is not
0048         // violated.
0049 
0050         static bool
0051         strict_ischar(int ch)
0052         {
0053             // ch should be representable as an unsigned char
0054             return ch >= 0 && ch <= UCHAR_MAX;
0055         }
0056 
0057         static bool
0058         isalnum(int ch)
0059         {
0060             BOOST_ASSERT(strict_ischar(ch));
0061             return std::isalnum(ch) != 0;
0062         }
0063 
0064         static bool
0065         isalpha(int ch)
0066         {
0067             BOOST_ASSERT(strict_ischar(ch));
0068             return std::isalpha(ch) != 0;
0069         }
0070 
0071         static bool
0072         isdigit(int ch)
0073         {
0074             BOOST_ASSERT(strict_ischar(ch));
0075             return std::isdigit(ch) != 0;
0076         }
0077 
0078         static bool
0079         isxdigit(int ch)
0080         {
0081             BOOST_ASSERT(strict_ischar(ch));
0082             return std::isxdigit(ch) != 0;
0083         }
0084 
0085         static bool
0086         iscntrl(int ch)
0087         {
0088             BOOST_ASSERT(strict_ischar(ch));
0089             return std::iscntrl(ch) != 0;
0090         }
0091 
0092         static bool
0093         isgraph(int ch)
0094         {
0095             BOOST_ASSERT(strict_ischar(ch));
0096             return std::isgraph(ch) != 0;
0097         }
0098 
0099         static bool
0100         islower(int ch)
0101         {
0102             BOOST_ASSERT(strict_ischar(ch));
0103             return std::islower(ch) != 0;
0104         }
0105 
0106         static bool
0107         isprint(int ch)
0108         {
0109             BOOST_ASSERT(strict_ischar(ch));
0110             return std::isprint(ch) != 0;
0111         }
0112 
0113         static bool
0114         ispunct(int ch)
0115         {
0116             BOOST_ASSERT(strict_ischar(ch));
0117             return std::ispunct(ch) != 0;
0118         }
0119 
0120         static bool
0121         isspace(int ch)
0122         {
0123             BOOST_ASSERT(strict_ischar(ch));
0124             return std::isspace(ch) != 0;
0125         }
0126 
0127         static bool
0128         isblank BOOST_PREVENT_MACRO_SUBSTITUTION (int ch)
0129         {
0130             BOOST_ASSERT(strict_ischar(ch));
0131             return (ch == ' ' || ch == '\t');
0132         }
0133 
0134         static bool
0135         isupper(int ch)
0136         {
0137             BOOST_ASSERT(strict_ischar(ch));
0138             return std::isupper(ch) != 0;
0139         }
0140 
0141     ///////////////////////////////////////////////////////////////////////////////
0142     //  Simple character conversions
0143     ///////////////////////////////////////////////////////////////////////////////
0144 
0145         static int
0146         tolower(int ch)
0147         {
0148             BOOST_ASSERT(strict_ischar(ch));
0149             return std::tolower(ch);
0150         }
0151 
0152         static int
0153         toupper(int ch)
0154         {
0155             BOOST_ASSERT(strict_ischar(ch));
0156             return std::toupper(ch);
0157         }
0158 
0159         static ::boost::uint32_t
0160         toucs4(int ch)
0161         {
0162             BOOST_ASSERT(strict_ischar(ch));
0163             return ch;
0164         }
0165     };
0166 }}}
0167 
0168 #endif