#include <boost/cstdint.hpp>
#include <boost/spirit/home/support/assert_msg.hpp>
+#include <boost/type_traits/make_unsigned.hpp>
+
namespace boost { namespace spirit { namespace traits
{
template <std::size_t N>
) != 0; // any wchar_t, but no other bits set
}
- // *** Note on assertions: The precondition is that the calls to
- // these functions do not violate the required range of ch (type int)
- // which is that strict_ischar(ch) should be true. It is the
- // responsibility of the caller to make sure this precondition is not
- // violated.
-
- static bool
- strict_ischar(int ch)
- {
- // ch should be representable as a wchar_t
- return ch >= WCHAR_MIN && ch <= WCHAR_MAX;
- }
-
static bool
isalnum(wchar_t ch)
{
using namespace std;
- BOOST_ASSERT(strict_ischar(ch));
return iswalnum(to_int_type(ch)) != 0;
}
isalpha(wchar_t ch)
{
using namespace std;
- BOOST_ASSERT(strict_ischar(ch));
return iswalpha(to_int_type(ch)) != 0;
}
iscntrl(wchar_t ch)
{
using namespace std;
- BOOST_ASSERT(strict_ischar(ch));
return iswcntrl(to_int_type(ch)) != 0;
}
isdigit(wchar_t ch)
{
using namespace std;
- BOOST_ASSERT(strict_ischar(ch));
return iswdigit(to_int_type(ch)) != 0;
}
isgraph(wchar_t ch)
{
using namespace std;
- BOOST_ASSERT(strict_ischar(ch));
return iswgraph(to_int_type(ch)) != 0;
}
islower(wchar_t ch)
{
using namespace std;
- BOOST_ASSERT(strict_ischar(ch));
return iswlower(to_int_type(ch)) != 0;
}
ispunct(wchar_t ch)
{
using namespace std;
- BOOST_ASSERT(strict_ischar(ch));
return iswpunct(to_int_type(ch)) != 0;
}
isspace(wchar_t ch)
{
using namespace std;
- BOOST_ASSERT(strict_ischar(ch));
return iswspace(to_int_type(ch)) != 0;
}
isupper(wchar_t ch)
{
using namespace std;
- BOOST_ASSERT(strict_ischar(ch));
return iswupper(to_int_type(ch)) != 0;
}
isxdigit(wchar_t ch)
{
using namespace std;
- BOOST_ASSERT(strict_ischar(ch));
return iswxdigit(to_int_type(ch)) != 0;
}
static bool
isblank BOOST_PREVENT_MACRO_SUBSTITUTION (wchar_t ch)
{
- BOOST_ASSERT(strict_ischar(ch));
return (ch == L' ' || ch == L'\t');
}
tolower(wchar_t ch)
{
using namespace std;
- BOOST_ASSERT(strict_ischar(ch));
return isupper(ch) ?
to_char_type<wchar_t>(towlower(to_int_type(ch))) : ch;
}
toupper(wchar_t ch)
{
using namespace std;
- BOOST_ASSERT(strict_ischar(ch));
return islower(ch) ?
to_char_type<wchar_t>(towupper(to_int_type(ch))) : ch;
}
static ::boost::uint32_t
- toucs4(int ch)
+ toucs4(wchar_t ch)
{
- BOOST_ASSERT(strict_ischar(ch));
- return ch;
+ return static_cast<make_unsigned<wchar_t>::type>(ch);
}
};
}}}