#include <cxxtools/char.h>
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. | |
| Char & | operator= (uint32_t value) |
| Assigns the given uint32_t as new value for this character. | |
| Char & | operator= (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. | |
| Char & | operator-= (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. | |
| Char & | operator+= (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. | |
| Char & | operator>>= (const Char &value) |
| Char & | operator<<= (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) |
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.
| 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.
| def | The default character which is returned if this character can not be narrowed |
| Char& operator= | ( | uint32_t | value | ) |
| value | The new 32-bit value for this character. |
| uint32_t value | ( | ) | const |
| operator int | ( | ) | const |
As the internal value also is an unsigned 32-bit value, the internal value of this character ist returned.
| value | This character's numeric value is subtracted from this' character numeric value. |
References Char::_value.
| value | This character's numeric value is added to this' character numeric value. |
References Char::_value.
| bool operator== | ( | const Char & | a, | |
| char | b | |||
| ) | [friend] |
| bool operator== | ( | const Char & | a, | |
| int | b | |||
| ) | [friend] |
| bool operator!= | ( | const Char & | a, | |
| char | b | |||
| ) | [friend] |
| bool operator!= | ( | const Char & | a, | |
| wchar_t | b | |||
| ) | [friend] |
| bool operator!= | ( | const Char & | a, | |
| int | b | |||
| ) | [friend] |