Evo C++ Library v0.5.1
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
Char Struct Reference

#include <evo/type.h>

Inheritance diagram for Char:
Inheritance graph
[legend]

Detailed Description

Basic character type (char) – see CharT.

A basic Evo container for single-byte character values.

Char ch('A');

Public Types

enum  Category
 Character category. More...
 
enum  Digit
 Character digit type. More...
 
typedef void EvoNullableType
 Identify as nullable type. More...
 
typedef CharT< char > This
 This non-POD type More...
 
typedef char Type
 Wrapped POD type. More...
 

Public Member Functions

 Char ()
 Constructor. More...
 
 Char (const Char &val)
 Copy constructor. More...
 
 Char (char val)
 Constructor. More...
 
int compare (const Nullable< char > &val) const
 Comparison. More...
 
int compare (char val) const
 Comparison. More...
 
char & denull ()
 Clears null flag and returns value reference. More...
 
bool null () const
 Get whether null. More...
 
 operator SafeBoolType () const
 Safe (explicit) evaluation as bool type. More...
 
bool operator! () const
 Negation operator returns whether null or 0. More...
 
bool operator!= (const Nullable< char > &val) const
 Inequality operator. More...
 
bool operator!= (char val) const
 Inequality operator. More...
 
const char & operator* () const
 Dereference for explicit conversion to underlying type (const). More...
 
char & operator* ()
 Dereference for explicit conversion to underlying type. More...
 
bool operator< (const Nullable< char > &val) const
 Less than operator. More...
 
bool operator< (char val) const
 Less than operator. More...
 
bool operator<= (const Nullable< char > &val) const
 Less than or equal operator. More...
 
bool operator<= (char val) const
 Less than or equal operator. More...
 
Charoperator= (const Char &val)
 Assignment operator. More...
 
Charoperator= (char val)
 Assignment operator. More...
 
Charoperator= (ValNull)
 Assignment operator to set as null. More...
 
bool operator== (const Nullable< char > &val) const
 Equality operator. More...
 
bool operator== (char val) const
 Equality operator. More...
 
bool operator> (const Nullable< char > &val) const
 Greater than operator. More...
 
bool operator> (char val) const
 Greater than operator. More...
 
bool operator>= (const Nullable< char > &val) const
 Greater than or equal operator. More...
 
bool operator>= (char val) const
 Greater than or equal operator. More...
 
Nullable< char > & set ()
 Set as null. More...
 
Nullable< char > & set (const Nullable< char > &src)
 Set as copy of given value. More...
 
Nullable< char > & set (char src)
 Set as given value. More...
 
bool valid () const
 Get whether valid (not null). More...
 
const char & value () const
 Get underlying value (const). More...
 
char & value ()
 Get underlying value. More...
 

Static Public Member Functions

static Category category (char ch)
 Get character category. More...
 
static Digit digit (char ch)
 Get digit type for character. More...
 
static bool isalnum (char ch)
 Check whether alphanumeric (A-Z, a-z, 0-9). More...
 
static bool isalpha (char ch)
 Check whether alphabetic (A-Z, a-z). More...
 
static bool isdigit (char ch)
 Check whether a digit (0-9). More...
 
static bool islower (char ch)
 Check whether lowercase letter (a-z). More...
 
static bool isspace (char ch)
 Check whether whitespace character (space, tab, newline, carrige return). More...
 
static bool isupper (char ch)
 Check whether uppercase letter (A-Z). More...
 

Static Public Attributes

static const int BITS
 Type size in bits (8) More...
 
static const int BYTES
 Type size in bytes, usually 1. More...
 

Member Typedef Documentation

◆ EvoNullableType

typedef void EvoNullableType
inherited

Identify as nullable type.

◆ This

typedef CharT<char > This
inherited

This non-POD type

◆ Type

typedef char Type
inherited

Wrapped POD type.

Member Enumeration Documentation

◆ Category

enum Category
inherited

Character category.

  • Overlapping categories (ex: alphanumeric) can be checked with greater-than (>) comparison:
    bool space = (cat == Char::cSPACE); // Whitespace (space, tab)
    bool symbol = (cat == Char::cSYMBOL); // Symbols (comma, precent, dollar, etc)
    bool digit = (cat == Char::cDIGIT); // Decimal digit (0-9)
    bool uppercase = (cat == Char::cALPHA_U); // Alphabet uppercase (A-Z)
    bool lowercase = (cat == Char::cALPHA_L); // Alphabet lowercase (a-z)
    bool alphanum = (cat > Char::cALPHANUM); // Alphanumeric (0-9, A-Z, a-z)
    bool alpha = (cat > Char::cALPHA); // Alphabet (A-Z, a-z)
    bool printable = (cat > Char::cNONE); // Any printable character
    bool visible = (cat > Char::cSPACE); // Any visible character (printable and not whitespace)

◆ Digit

enum Digit
inherited

Character digit type.

  • Digit types overlap so check with greater-than-or-equal (>=) comparison:
    bool b36 = (dig >= Char::dBASE36); // base 36 digit (0-9, A-Z)
    bool hex = (dig >= Char::dHEX); // hex digit (0-9, A-F)
    bool dec = (dig >= Char::dDECIMAL); // decimal digit (0-9)
    bool oct = (dig >= Char::dOCTAL); // octal digit (0-7)
    bool err = (dig == Char::dHEX); // error: must use operator >= here

Constructor & Destructor Documentation

◆ Char() [1/3]

Char ( )
inline

Constructor.

◆ Char() [2/3]

Char ( const Char val)
inline

Copy constructor.

Parameters
valValue to copy

◆ Char() [3/3]

Char ( char  val)
inline

Constructor.

Parameters
valValue to set

Member Function Documentation

◆ category()

static Category category ( char  ch)
inlinestatic

Get character category.

  • Extended ASCII characters are considered unprintable
Parameters
chCharacter to check
Returns
Category

◆ compare() [1/2]

int compare ( const Nullable< char > &  val) const
inlineinherited

Comparison.

Parameters
valValue to compare to
Returns
Result (<0 if this is less, 0 if equal, >0 if this is greater)

◆ compare() [2/2]

int compare ( char  val) const
inlineinherited

Comparison.

  • If null, the result is always -1 as null compares as less than any non-null value
Parameters
valValue to compare to
Returns
Result (<0 if this is less, 0 if equal, >0 if this is greater)

◆ denull()

char & denull ( )
inlineinherited

Clears null flag and returns value reference.

  • Value is unchanged, POD types default to 0 when null
  • Useful for updating the underlying value by reference
  • Note: Nullable<bool> template specialization returns by value instead of reference
Returns
Whether valid

◆ digit()

static Digit digit ( char  ch)
inlinestatic

Get digit type for character.

  • Extended ASCII characters aren't considered digits
Parameters
chCharacter to check
Returns
Digit type

◆ isalnum()

static bool isalnum ( char  ch)
inlinestatic

Check whether alphanumeric (A-Z, a-z, 0-9).

Parameters
chCharacter to check
Returns
Whether alphanumeric

◆ isalpha()

static bool isalpha ( char  ch)
inlinestatic

Check whether alphabetic (A-Z, a-z).

Parameters
chCharacter to check
Returns
Whether alphabetic

◆ isdigit()

static bool isdigit ( char  ch)
inlinestatic

Check whether a digit (0-9).

Parameters
chCharacter to check
Returns
Whether a digit

◆ islower()

static bool islower ( char  ch)
inlinestatic

Check whether lowercase letter (a-z).

Parameters
chCharacter to check
Returns
Whether lowercase

◆ isspace()

static bool isspace ( char  ch)
inlinestatic

Check whether whitespace character (space, tab, newline, carrige return).

Parameters
chCharacter to check
Returns
Whether whitespace

◆ isupper()

static bool isupper ( char  ch)
inlinestatic

Check whether uppercase letter (A-Z).

Parameters
chCharacter to check
Returns
Whether uppercase

◆ null()

bool null ( ) const
inlineinherited

Get whether null.

Returns
Whether null

◆ operator SafeBoolType()

operator SafeBoolType ( ) const
inlineinherited

Safe (explicit) evaluation as bool type.

  • This is called when object is directly evaluated as a bool, and is equivalent to: !operator!()
  • See SafeBool

◆ operator!()

bool operator! ( ) const
inlineinherited

Negation operator returns whether null or 0.

Returns
Whether null or 0

◆ operator!=() [1/2]

bool operator!= ( const Nullable< char > &  val) const
inlineinherited

Inequality operator.

Parameters
valValue to compare to
Returns
Whether inequal

◆ operator!=() [2/2]

bool operator!= ( char  val) const
inlineinherited

Inequality operator.

  • If null, the result is always true as null is not equal to any non-null value
Parameters
valValue to compare to
Returns
Whether inequal, true if null

◆ operator*() [1/2]

const char & operator* ( ) const
inlineinherited

Dereference for explicit conversion to underlying type (const).

Alternative to value().

Returns
Underlying type value

◆ operator*() [2/2]

char & operator* ( )
inlineinherited

Dereference for explicit conversion to underlying type.

Alternative to value().

Returns
Underlying type value

◆ operator<() [1/2]

bool operator< ( const Nullable< char > &  val) const
inlineinherited

Less than operator.

  • If null, null is less than any non-null value
Parameters
valValue to compare to
Returns
Whether less than val

◆ operator<() [2/2]

bool operator< ( char  val) const
inlineinherited

Less than operator.

  • If null, null is less than any non-null value
Parameters
valValue to compare to
Returns
Whether less than val

◆ operator<=() [1/2]

bool operator<= ( const Nullable< char > &  val) const
inlineinherited

Less than or equal operator.

  • If null, null is less than or equal to any value
Parameters
valValue to compare to
Returns
Whether less than or equal to val, true if null

◆ operator<=() [2/2]

bool operator<= ( char  val) const
inlineinherited

Less than or equal operator.

  • If null, null is less than or equal to any value
Parameters
valValue to compare to
Returns
Whether less than or equal to val, true if null

◆ operator=() [1/3]

Char& operator= ( const Char val)
inline

Assignment operator.

Parameters
valValue to copy
Returns
This

◆ operator=() [2/3]

Char& operator= ( char  val)
inline

Assignment operator.

Parameters
valValue to set
Returns
This

◆ operator=() [3/3]

Char& operator= ( ValNull  )
inline

Assignment operator to set as null.

Returns
This

◆ operator==() [1/2]

bool operator== ( const Nullable< char > &  val) const
inlineinherited

Equality operator.

Parameters
valValue to compare to
Returns
Whether equal

◆ operator==() [2/2]

bool operator== ( char  val) const
inlineinherited

Equality operator.

  • If null, the result is always false as null is not equal to any non-null value
Parameters
valValue to compare to
Returns
Whether equal, false if null

◆ operator>() [1/2]

bool operator> ( const Nullable< char > &  val) const
inlineinherited

Greater than operator.

  • If null, null is not greater than any non-null value
Parameters
valValue to compare to
Returns
Whether greater than val, false if null

◆ operator>() [2/2]

bool operator> ( char  val) const
inlineinherited

Greater than operator.

  • If null, null is not greater than any non-null value
Parameters
valValue to compare to
Returns
Whether greater than val, false if null

◆ operator>=() [1/2]

bool operator>= ( const Nullable< char > &  val) const
inlineinherited

Greater than or equal operator.

  • If null, null is not greater than any non-null value
Parameters
valValue to compare to
Returns
Whether greater than or equal to val

◆ operator>=() [2/2]

bool operator>= ( char  val) const
inlineinherited

Greater than or equal operator.

  • If null, null is not greater than any non-null value
Parameters
valValue to compare to
Returns
Whether greater than or equal to val

◆ set() [1/3]

Nullable<char >& set ( )
inlineinherited

Set as null.

Returns
This

◆ set() [2/3]

Nullable<char >& set ( const Nullable< char > &  src)
inlineinherited

Set as copy of given value.

Parameters
srcSource to copy
Returns
This

◆ set() [3/3]

Nullable<char >& set ( char  src)
inlineinherited

Set as given value.

Parameters
srcSource to set
Returns
This

◆ valid()

bool valid ( ) const
inlineinherited

Get whether valid (not null).

Returns
Whether valid

◆ value() [1/2]

const char & value ( ) const
inlineinherited

Get underlying value (const).

Alternative to operator*().

Returns
Whether valid

◆ value() [2/2]

char & value ( )
inlineinherited

Get underlying value.

Alternative to operator*().

Returns
Whether valid

Member Data Documentation

◆ BITS

const int BITS
staticinherited

Type size in bits (8)

◆ BYTES

const int BYTES
staticinherited

Type size in bytes, usually 1.


The documentation for this struct was generated from the following file: