Base Framework
Classes | Public Types | Static Public Member Functions | Static Public Attributes | List of all members
ASCIITraits Class Reference

ASCII character traits. More...

#include <base/string/ASCIITraits.h>

Classes

struct  CharacterDescriptor
 
class  Compare
 Comparison of characters function object. More...
 
class  CompareCaseless
 Case-less comparison of characters function object. More...
 
class  ToLowerCase
 Lower case conversion function object. More...
 
class  ToUpperCase
 Upper case conversion function object. More...
 

Public Types

enum  Characteristics {
  LOWER = 1, UPPER = 2, ALPHA = LOWER|UPPER, DIGIT = 4,
  ALPHANUM = ALPHA|DIGIT, OCTAL = 8, LOWERHEX = 16, UPPERHEX = 32,
  HEX = LOWERHEX|UPPERHEX, CONTROL = 64, SPACE = 128, ASCII = 256,
  SP = 512, PUNCTUATION = 1024, GRAPH = ALPHANUM|PUNCTUATION, PRINTABLE = SP|GRAPH
}
 

Static Public Member Functions

static bool isAlpha (char value) noexcept
 
static bool isAlphaNum (char value) noexcept
 
static bool isLower (char value) noexcept
 
static bool isUpper (char value) noexcept
 
static bool isDigit (char value) noexcept
 
static bool isOctal (char value) noexcept
 
static bool isLowerHex (char value) noexcept
 
static bool isUpperHex (char value) noexcept
 
static bool isHexDigit (char value) noexcept
 
static bool isSpace (char value) noexcept
 
static bool isPunctuation (char value) noexcept
 
static bool isPrintable (char value) noexcept
 
static bool isGraph (char value) noexcept
 
static bool isControl (char value) noexcept
 
static bool isASCII (char value) noexcept
 
static unsigned char digitToValue (char value) noexcept
 
static char valueToDigit (unsigned int value) noexcept
 
static char valueToDigit (unsigned int value, bool upper) noexcept
 
static char valueToLowerDigit (unsigned int value) noexcept
 
static char valueToUpperDigit (unsigned int value) noexcept
 
static char toLower (char value) noexcept
 
static char toUpper (char value) noexcept
 
static int compare (char left, char right) noexcept
 
static int compareCaseless (char left, char right) noexcept
 

Static Public Attributes

static const char LOWER_DIGITS []
 
static const char UPPER_DIGITS []
 
static const char NUL = '\0'
 
static const char SOH = 0x01
 
static const char STX = 0x02
 
static const char ETX = 0x03
 
static const char EOT = 0x04
 
static const char ENQ = 0x05
 
static const char ACK = 0x06
 
static const char BEL = '\a'
 
static const char BS = '\b'
 
static const char HT = '\t'
 
static const char LF = '\n'
 
static const char VT = '\v'
 
static const char FF = '\f'
 
static const char CR = '\r'
 
static const char SO = 0x0e
 
static const char SI = 0x0f
 
static const char DLE = 0x10
 
static const char DC1 = 0x11
 
static const char DC2 = 0x12
 
static const char DC3 = 0x13
 
static const char DC4 = 0x14
 
static const char NAK = 0x15
 
static const char SYN = 0x16
 
static const char ETB = 0x17
 
static const char CAN = 0x18
 
static const char EM = 0x19
 
static const char SUB = 0x1a
 
static const char ESC = 0x1b
 
static const char FS = 0x1c
 
static const char GS = 0x1d
 
static const char RS = 0x1e
 
static const char US = 0x1f
 
static const char SPC = ' '
 
static const char DEL = 0x7f
 

Detailed Description

ASCII character traits.

This class is a wrapper for the 7-bit ASCII octet manipulators and more. This class does not depend on the current locale of the application.

Version
1.2

Member Enumeration Documentation

◆ Characteristics

Character characteristics.

Enumerator
LOWER 

Any of the characters "abcdefghijklmnopqrstuvwxyz".

UPPER 

Any of the characters "ABCDEFGHIJKLMNOPQRSTUVWXYZ".

ALPHA 

Any upper or lower case letter.

DIGIT 

Any of the characters "0123456789".

ALPHANUM 

A letter or digit.

OCTAL 

Any of the characters "01234567".

LOWERHEX 

A DIGIT or any of the characters "abcdef".

UPPERHEX 

A DIGIT or any of the characters "ABCDEF".

HEX 

Any upper or lower case hexadicimal digit.

CONTROL 

The characters from 0x00 to 0x1f and 0x7f.

SPACE 

Tab, newline, vertical-tab, form-feed, carriage-return, and space.

ASCII 

The octets from 0x00 to 0x7f.

SP 

A simple space ' '.

PUNCTUATION 

Punctuation characters.

GRAPH 

Visible characters.

PRINTABLE 

Printable characters.

Member Function Documentation

◆ compare()

static int ASCIITraits::compare ( char  left,
char  right 
)
inlinestaticnoexcept

Compares the specified characters (less than (negative), equal (0), and greater than (positive).

◆ compareCaseless()

static int ASCIITraits::compareCaseless ( char  left,
char  right 
)
inlinestaticnoexcept

Compares the specified characters ignoring the case (less than (negative), equal (0), and greater than (positive).

◆ digitToValue()

static unsigned char ASCIITraits::digitToValue ( char  value)
inlinestaticnoexcept

Returns the value of the specified character. The character must be a digit approved by isDigit(), isOctal(), isLowerHex(), isUpperHex(), or isHexDigit(). If the character is not a digit an unspecified value is returned.

Examples
testsuite/http.cpp.

◆ isAlpha()

static bool ASCIITraits::isAlpha ( char  value)
inlinestaticnoexcept

Returns true if the character an alphabetic character.

◆ isAlphaNum()

static bool ASCIITraits::isAlphaNum ( char  value)
inlinestaticnoexcept

Returns true if the character an alphabetic character or a digit.

◆ isASCII()

static bool ASCIITraits::isASCII ( char  value)
inlinestaticnoexcept

Returns true if the character is an ASCII character (i.e. the octets from 0x00 to 0x7f).

Examples
testsuite/http.cpp.

◆ isControl()

static bool ASCIITraits::isControl ( char  value)
inlinestaticnoexcept

Returns true if the character is a control character (the octets from 0x00 to 0x1f).

Examples
testsuite/http.cpp, and testsuite/sax.cpp.

◆ isDigit()

static bool ASCIITraits::isDigit ( char  value)
inlinestaticnoexcept

Returns true if the character is a digit.

Examples
testsuite/http.cpp.

◆ isGraph()

static bool ASCIITraits::isGraph ( char  value)
inlinestaticnoexcept

Returns true if the character is a visible character.

Examples
testsuite/http.cpp.

◆ isHexDigit()

static bool ASCIITraits::isHexDigit ( char  value)
inlinestaticnoexcept

Returns true if the character is a hex digit (either lower or upper hex digit).

Examples
testsuite/http.cpp.

◆ isLower()

static bool ASCIITraits::isLower ( char  value)
inlinestaticnoexcept

Returns true if the character is lowercase.

◆ isLowerHex()

static bool ASCIITraits::isLowerHex ( char  value)
inlinestaticnoexcept

Returns true if the character is a lower hex digit (any of the characters "0123456789abcdef").

◆ isOctal()

static bool ASCIITraits::isOctal ( char  value)
inlinestaticnoexcept

Returns true if the character is an octal digit.

◆ isPrintable()

static bool ASCIITraits::isPrintable ( char  value)
inlinestaticnoexcept

Returns true if the character is printable.

Examples
testsuite/IEEE1394.cpp.

◆ isPunctuation()

static bool ASCIITraits::isPunctuation ( char  value)
inlinestaticnoexcept

Returns true if the character is a punctuation mark.

◆ isSpace()

static bool ASCIITraits::isSpace ( char  value)
inlinestaticnoexcept

Returns true if the character is a white space (tab '\t', newline '\n', vertical-tab '\v', form-feed '\f', carriage-return '\r', and space ' ').

◆ isUpper()

static bool ASCIITraits::isUpper ( char  value)
inlinestaticnoexcept

Returns true if the character is uppercase.

◆ isUpperHex()

static bool ASCIITraits::isUpperHex ( char  value)
inlinestaticnoexcept

Returns true if the character is an upper hex digit (any of the characters "0123456789ABCDEF").

◆ toLower()

static char ASCIITraits::toLower ( char  value)
inlinestaticnoexcept

Returns the lower case representation of the character.

◆ toUpper()

static char ASCIITraits::toUpper ( char  value)
inlinestaticnoexcept

Returns the upper case representation of the character.

◆ valueToDigit() [1/2]

static char ASCIITraits::valueToDigit ( unsigned int  value)
inlinestaticnoexcept

Returns the character representation of the specified value. An unspecified value is returned if the argument falls outside the range [0..15].

◆ valueToDigit() [2/2]

static char ASCIITraits::valueToDigit ( unsigned int  value,
bool  upper 
)
inlinestaticnoexcept

Returns the character representation of the specified value. An unspecified value is returned if the argument falls outside the range [0..15].

Parameters
valueThe value of the digit.
upperSelects upper case if true otherwise lower case.

◆ valueToLowerDigit()

static char ASCIITraits::valueToLowerDigit ( unsigned int  value)
inlinestaticnoexcept

Returns the character representation of the specified value. An unspecified value is returned if the argument falls outside the range [0..15].

◆ valueToUpperDigit()

static char ASCIITraits::valueToUpperDigit ( unsigned int  value)
inlinestaticnoexcept

Returns the character representation of the specified value. An unspecified value is returned if the argument falls outside the range [0..15].

Member Data Documentation

◆ LOWER_DIGITS

const char ASCIITraits::LOWER_DIGITS[]
static

Array of all digits (lower case) in ascending order of corresponding value.

◆ UPPER_DIGITS

const char ASCIITraits::UPPER_DIGITS[]
static

Array of all digits (upper case) in ascending order of corresponding value.