#ifndef WTF_ASCIICType_h
#define WTF_ASCIICType_h
#include "wtf/Assertions.h"
namespace WTF {
template<typename CharType> inline bool isASCII(CharType c)
{
return !(c & ~0x7F);
}
template<typename CharType> inline bool isASCIIAlpha(CharType c)
{
return (c | 0x20) >= 'a' && (c | 0x20) <= 'z';
}
template<typename CharType> inline bool isASCIIDigit(CharType c)
{
return c >= '0' && c <= '9';
}
template<typename CharType> inline bool isASCIIAlphanumeric(CharType c)
{
return isASCIIDigit(c) || isASCIIAlpha(c);
}
template<typename CharType> inline bool isASCIIHexDigit(CharType c)
{
return isASCIIDigit(c) || ((c | 0x20) >= 'a' && (c | 0x20) <= 'f');
}
template<typename CharType> inline bool isASCIILower(CharType c)
{
return c >= 'a' && c <= 'z';
}
template<typename CharType> inline bool isASCIIOctalDigit(CharType c)
{
return (c >= '0') & (c <= '7');
}
template<typename CharType> inline bool isASCIIPrintable(CharType c)
{
return c >= ' ' && c <= '~';
}
template<typename CharType> inline bool isASCIISpace(CharType c)
{
return c <= ' ' && (c == ' ' || (c <= 0xD && c >= 0x9));
}
template<typename CharType> inline bool isASCIIUpper(CharType c)
{
return c >= 'A' && c <= 'Z';
}
template<typename CharType> inline CharType toASCIILower(CharType c)
{
#if defined(_MSC_FULL_VER) && _MSC_FULL_VER == 170060610
return (c >= 'A' && c <= 'Z') ? c + 0x20 : c;
#else
return c | ((c >= 'A' && c <= 'Z') << 5);
#endif
}
template<typename CharType> inline CharType toASCIILowerUnchecked(CharType character)
{
return character | 0x20;
}
template<typename CharType> inline CharType toASCIIUpper(CharType c)
{
return c & ~((c >= 'a' && c <= 'z') << 5);
}
template<typename CharType> inline int toASCIIHexValue(CharType c)
{
ASSERT(isASCIIHexDigit(c));
return c < 'A' ? c - '0' : (c - 'A' + 10) & 0xF;
}
template<typename CharType> inline int toASCIIHexValue(CharType upperValue, CharType lowerValue)
{
ASSERT(isASCIIHexDigit(upperValue) && isASCIIHexDigit(lowerValue));
return ((toASCIIHexValue(upperValue) << 4) & 0xF0) | toASCIIHexValue(lowerValue);
}
inline char lowerNibbleToASCIIHexDigit(char c)
{
char nibble = c & 0xF;
return nibble < 10 ? '0' + nibble : 'A' + nibble - 10;
}
inline char upperNibbleToASCIIHexDigit(char c)
{
char nibble = (c >> 4) & 0xF;
return nibble < 10 ? '0' + nibble : 'A' + nibble - 10;
}
template<typename CharType> inline bool isASCIIAlphaCaselessEqual(CharType cssCharacter, char character)
{
ASSERT(character >= 'a' && character <= 'z');
return LIKELY(toASCIILowerUnchecked(cssCharacter) == character);
}
}
using WTF::isASCII;
using WTF::isASCIIAlpha;
using WTF::isASCIIAlphanumeric;
using WTF::isASCIIDigit;
using WTF::isASCIIHexDigit;
using WTF::isASCIILower;
using WTF::isASCIIOctalDigit;
using WTF::isASCIIPrintable;
using WTF::isASCIISpace;
using WTF::isASCIIUpper;
using WTF::toASCIIHexValue;
using WTF::toASCIILower;
using WTF::toASCIILowerUnchecked;
using WTF::toASCIIUpper;
using WTF::lowerNibbleToASCIIHexDigit;
using WTF::upperNibbleToASCIIHexDigit;
using WTF::isASCIIAlphaCaselessEqual;
#endif