Webmaster  |  Imprint 
C++ Server Pages
Main  |  License  |  Documentation  |  Download 

Char Class Reference

A lightweight Character class (32 bits). More...

#include <cxxtools/char.h>

List of all members.

Public Member Functions

 Char ()
 Constructs a character with a value of 0.
 Char (char ch)
 Constructs a character using the given char as base for the character value.
 Char (signed char ch)
 Constructs a character using the given 8-bit char as base for the character value.
 Char (unsigned char ch)
 Constructs a character using the given char as base for the character value.
 Char (short val)
 Constructs a character using the given 16-bit integer as base for the character value.
 Char (const int &val)
 Constructs a character using the given 32-bit integer as base for the character value.
 Char (const unsigned int &val)
 Constructs a character using the given 32-bit integer as base for the character value.
 Char (const long value)
 Constructs a character using the given long as base for the character value.
 Char (const unsigned long val)
 Constructs a character using the given long as base for the character value.
char narrow (char def) const
 Narrows this character into an 8-bit char if possible.
Charoperator= (uint32_t value)
 Assigns the given uint32_t as new value for this character.
Charoperator= (const Char &ch)
uint32_t value () const
 Returns the internal value (unsigned 32 bits) of this character.
 operator int () const
 This conversion operator converts the internal value of this character to unsigned 32 bits.
Charoperator-= (const Char &value)
 Substracts the numeric value of this character and the numeric value of the given character and stores the result in this chracater class.
Charoperator+= (const Char &value)
 Sums the numeric value of this character and the numeric value of the given character and stores the result in this chracater class.
Charoperator>>= (const Char &value)
Charoperator<<= (const Char &value)

Static Public Member Functions

static Char null ()

Friends

bool operator== (const Char &a, const Char &b)
 Returns $true$ if the a and b are the same character; $false$ otherwise.
bool operator== (const Char &a, char b)
 Returns $true$ if the a and b are the same character; $false$ otherwise.
bool operator== (const Char &a, int b)
 Returns $true$ if the a and b are the same character; $false$ otherwise.
bool operator!= (const Char &a, const Char &b)
 Returns $true$ if the a and b are not the same character; $false$ otherwise.
bool operator!= (const Char &a, char b)
 Returns $true$ if the a and b are the same character; $false$ otherwise.
bool operator!= (const Char &a, wchar_t b)
 Returns $true$ if the a and b are the same character; $false$ otherwise.
bool operator!= (const Char &a, int b)
 Returns $true$ if the a and b are the same character; $false$ otherwise.
bool operator< (const Char &a, const Char &b)
 Returns $true$ if the numeric value of a is less than the numeric value of b; $false$ otherwise.
bool operator> (const Char &a, const Char &b)
 Returns $true$ if the numeric value of a is greater than the numeric value of b; $false$ otherwise.
bool operator<= (const Char &a, const Char &b)
 Returns $true$ if the numeric value of a is equal or less than the numeric value of b; $false$ otherwise.
bool operator<= (const Char &a, int b)
bool operator>= (const Char &a, const Char &b)
 Returns $true$ if the numeric value of a is equals or greater than the numeric value of b; $false$ otherwise.
bool operator>= (const Char &a, int b)
Char operator+ (const Char &a, const Char &b)
 Sums the numeric value of a and the numeric value of b and returns the sum.
Char operator+ (const Char &a, char ch)
 Sums the numeric value of a and the numeric value of b and returns the sum.
Char operator+ (const Char &a, int ch)
Char operator- (const Char &a, const Char &b)
 Subtracts the numeric value of b from the numeric value of b and returns the result.
Char operator- (const Char &a, char ch)
 Subtracts the numeric value of b from the numeric value of b and returns the result.
Char operator| (const Char &a, const Char &b)
 Does an OR-combination of the numeric value of a and b and returns the result.
Char operator & (const Char &a, const Char &b)
 Does an AND-combination of the numeric value of a and b and returns the result.
Char operator & (const Char &a, int b)


Detailed Description

Unicode characters are 32-bit entities. This class represents such an entity. It is lightweight, so it can be used everywhere. Most compilers treat it like an unsigned int of 32 bits.

This class provides methods for testing/classification, converting to and from other formats, comparing and case-converting. To convert a character or number to a instance of this class use one of the constructors provided. To check the type of the character use one of the method starting with "is", like isLetter() or isDigit(). To compare lower- or upper-case use isUpper() and isLower(). To compare two characters the corresponding operators are overloaded accordingly. Addition and substraction is supported as well. Comparison of numeric values (>, <, ==) is supported when using these operators.

The classification methods operate on the full range of Unicode characters. All methods return $true$ if the character is a certain type of character. These methods are are wrappers around category() which return the Unicode-defined category of each character.

Comparison is critical in Unicode as it covers the characters of the entire world where characters which look the same may be different in the thinking of numeric values (aka positions in the Unicode table) Comparing characters will compare based purely on the numeric Unicode value (code point) of the characters. Upper- and lower-casing using upper() and lower() will only work if the character has a well-defined upper/lower-case equivalent.

See also:
Category

Member Function Documentation

char narrow ( char  def  )  const

If the character can not be converted into an 8-bit char because its value is greater than 255, the defaultCharacter which is passed to this method is returned.

If this character is equal or lower than 255 the character is cast to char.

Parameters:
def The default character which is returned if this character can not be narrowed
Returns:
An 8-bit char which is a narrowed representation of this character object or the default character if this character object's value is out of range (>255).

Char& operator= ( uint32_t  value  ) 

Parameters:
value The new 32-bit value for this character.
Returns:
A reference to this object to allow concatination of operations.

uint32_t value (  )  const

Returns:
The 32-bit-value of this character.

operator int (  )  const

As the internal value also is an unsigned 32-bit value, the internal value of this character ist returned.

Returns:
The character converted to unsigned 32-bit.

Char& operator-= ( const Char value  ) 

Parameters:
value This character's numeric value is subtracted from this' character numeric value.
Returns:
A reference to this character class.

References Char::_value.

Char& operator+= ( const Char value  ) 

Parameters:
value This character's numeric value is added to this' character numeric value.
Returns:
A reference to this character class.

References Char::_value.


Friends And Related Function Documentation

bool operator== ( const Char a,
const Char b 
) [friend]

Returns:
$true$ if the a and b are the same character; $false$ otherwise.

bool operator== ( const Char a,
char  b 
) [friend]

Returns:
$true$ if the a and b are the same character; $false$ otherwise.

bool operator== ( const Char a,
int  b 
) [friend]

Returns:
$true$ if the a and b are the same character; $false$ otherwise.

bool operator!= ( const Char a,
const Char b 
) [friend]

Returns:
$true$ if the a and b are not the same character; $false$ otherwise.

bool operator!= ( const Char a,
char  b 
) [friend]

Returns:
$true$ if the a and b are the same character; $false$ otherwise.

bool operator!= ( const Char a,
wchar_t  b 
) [friend]

Returns:
$true$ if the a and b are the same character; $false$ otherwise.

bool operator!= ( const Char a,
int  b 
) [friend]

Returns:
$true$ if the a and b are the same character; $false$ otherwise.

bool operator< ( const Char a,
const Char b 
) [friend]

Returns:
$true$ if the numeric value of a is less than the numeric value of b; $false$ otherwise.

bool operator> ( const Char a,
const Char b 
) [friend]

Returns:
$true$ if the numeric value of a is greater than the numeric value of b; $false$ otherwise.

bool operator<= ( const Char a,
const Char b 
) [friend]

Returns:
$true$ if the numeric value of a is equal or less than the numeric value of b; $false$ otherwise.

bool operator>= ( const Char a,
const Char b 
) [friend]

Returns:
$true$ if the numeric value of a is equals or greater than the numeric value of b; $false$ otherwise.

Char operator+ ( const Char a,
const Char b 
) [friend]

Returns:
The sum of the numeric values of a and b.

Char operator+ ( const Char a,
char  ch 
) [friend]

Returns:
The sum of the numeric values of a and b.

Char operator- ( const Char a,
const Char b 
) [friend]

Returns:
The substraction of the numeric values of b from a.

Char operator- ( const Char a,
char  ch 
) [friend]

Returns:
The substraction of the numeric values of b from a.

Char operator| ( const Char a,
const Char b 
) [friend]

Returns:
The OR-combination of the numeric values of a and b.

Char operator & ( const Char a,
const Char b 
) [friend]

Returns:
The AND-combination of the numeric values of a and b.

Copyright © 2008 The Tntnet Development Team
Tntnet 1.6