This is the reference documentation of sub-namespace characters
of the ALib C++ Library, which holds types of library module ALib Characters.
Extensive documentation for this module is provided with ALib Module Characters - Programmer's Manual.
Nested Namespaces: | |
namespace | compatibility |
Type Index: | |
struct | AlignedCharArray |
struct | T_CharArray |
struct | T_ZTCharArray |
struct | TT_CharArrayType |
struct | TT_CharOfSize |
struct | TT_ComplementChar |
struct | TT_IsChar |
struct | TT_ZTCharArrayType |
Type Definition Index: | |
using | character = PLATFORM_SPECIFIC |
using | complementChar = PLATFORM_SPECIFIC |
using | nchar = char |
using | strangeChar = PLATFORM_SPECIFIC |
using | wchar = PLATFORM_SPECIFIC |
using | xchar = PLATFORM_SPECIFIC |
Enumeration Index: | |
enum class | AccessType { NONE , Implicit , ExplicitOnly , MutableOnly } |
enum class | ConstructionType { NONE , Implicit , ExplicitOnly } |
Function Index: | |
template<typename TChar > | |
int | Compare (const TChar *lhs, const TChar *rhs, integer cmpLength) |
template<typename TChar > | |
int | CompareIgnoreCase (const TChar *lhs, const TChar *rhs, integer cmpLength) |
template<typename TChar > | |
void | Copy (const TChar *src, integer length, TChar *dest) |
template<typename TChar > | |
bool | Equal (const TChar *lhs, const TChar *rhs, integer cmpLength) |
template<typename TChar , lang::Case sensitivity, typename TRhs > | |
bool | Equal (TChar lhs, TRhs rhs) |
template<typename TChar > | |
void | Fill (TChar *dest, integer length, TChar value) |
template<typename TChar > | |
integer | IndexOfAnyExcluded (const TChar *haystack, integer haystackLength, const TChar *needles, integer needlesLength) |
template<typename TChar > | |
integer | IndexOfAnyExcludedZT (const TChar *haystack, const TChar *needles) |
template<typename TChar > | |
integer | IndexOfAnyIncluded (const TChar *haystack, integer haystackLength, const TChar *needles, integer needlesLength) |
template<typename TChar > | |
integer | IndexOfAnyIncludedZT (const TChar *haystack, const TChar *needles) |
template<typename TChar > | |
integer | IndexOfFirstDifference (const TChar *haystack, integer haystackLength, const TChar *needle, integer needleLength, lang::Case sensitivity) |
template<typename TChar > | |
integer | LastIndexOfAnyExclude (const TChar *haystack, integer startIdx, const TChar *needles, integer needlesLength) |
template<typename TChar > | |
integer | LastIndexOfAnyInclude (const TChar *haystack, integer startIdx, const TChar *needles, integer needlesLength) |
template<typename TChar > | |
integer | Length (const TChar *cstring) |
template<typename TChar > | |
void | Move (const TChar *src, integer length, TChar *dest) |
template<typename TChar > | |
void | Reverse (TChar *src, integer length) |
template<typename TChar > | |
const TChar * | Search (const TChar *haystack, integer haystackLength, TChar needle) |
template<typename TChar > | |
void | ToLower (TChar *src, integer length) |
template<typename TChar > | |
TChar | ToLower (TChar c) |
template<typename TChar > | |
void | ToUpper (TChar *src, integer length) |
template<typename TChar > | |
TChar | ToUpper (TChar c) |
using character = PLATFORM_SPECIFIC |
This type represents a standard ALib character. The width (size) of a character is dependent on the platform and compilation flags.
This is why this type is called a "logical" type. The two other logical character types are complementChar and strangeChar.
Definition at line 130 of file chartraits.hpp.
using complementChar = PLATFORM_SPECIFIC |
This type represents a non-standard ALib character. If alib::character is defined to implement a narrow character type, then this type implements a wide character and vice versa. Note, that the width of a wide character is not defined as well. It might be 2
or 4
bytes wide.
This type is called a "logical" type. The two other logical character types are character and strangeChar.
Definition at line 144 of file chartraits.hpp.
using nchar = char |
This type represents a narrow character in ALib. This is an alias for built-in C++ type char
.
Definition at line 32 of file chartraits.hpp.
using strangeChar = PLATFORM_SPECIFIC |
Besides types alib::character and alib::complementChar, this is the third logical character type defined by ALib.
independent of compiler defaults and optional compiler symbols provided, this type always is equivalent to type xchar
Definition at line 154 of file chartraits.hpp.
using wchar = PLATFORM_SPECIFIC |
This type represents a wide character in ALib. Usually this is an alias for built-in C++ type wchar_t
. As the width of the latter is compiler-specific (the width may vary with different compilers even on the same platform), compiler symbols ALIB_CHARACTERS_SIZEOF_WCHAR may be used to manipulate its width.
Definition at line 54 of file chartraits.hpp.
using xchar = PLATFORM_SPECIFIC |
This type represents a second wide character type which has a width complementary to that of type wchar: If wchar is 2 bytes wide, then this type aliases char32_t
and if its width is 4 bytes, this type aliases char16_t
.
While together with types alib::nchar and alib::wchar it forms the group of "explicit character types", it is always identical to logical type alib::strangeChar.
Definition at line 67 of file chartraits.hpp.
|
strong |
Enumeration of possible values for field Access used with traits types T_CharArray and T_ZTCharArray. The elements of this enumeration indicate if and how the data of an array-like type (which may be non-zero- or zero-terminated) may be accessed.
Enumerator | |
---|---|
NONE | Data may not be received. This value usually indicates that a custom type does not implement a character array at all. Hence, this is the default value of the non-specialized versions of T_CharArray and T_ZTCharArray. |
Implicit | Allows implicit (and explicit) access of the character array data from mutable or constant objects. |
ExplicitOnly | Allows explicit access of the character array data from mutable or constant objects. |
MutableOnly | Allows explicit access of the character array data from mutable objects. |
Definition at line 198 of file chartraits.hpp.
|
strong |
Enumeration of possible values for field Construction used with traits types T_CharArray and T_ZTCharArray. The elements of this enumeration indicate if and how values an array-like type may be constructed from a (non-zero-terminated, respectively zero-terminated) character array.
Enumerator | |
---|---|
NONE | The custom type may not be constructed from character arrays. This is the default value of the non-specialized versions of T_CharArray and T_ZTCharArray but may very well be used with specializations as well. |
Implicit | Allows implicit (and explicit) construction of objects from character array data. |
ExplicitOnly | Allows explicit construction of objects from character array data. |
Definition at line 221 of file chartraits.hpp.
int Compare | ( | const TChar * | lhs, |
const TChar * | rhs, | ||
integer | cmpLength ) |
Compares up to cmpLength characters of two character arrays. Comparison stops if termination character '\0'
is found in one of the arrays.
TChar | One of the six (overlapping) character types. |
lhs | The first array to compare. |
rhs | The second array to compare. |
cmpLength | The number of characters to compare. |
0
if lhs and rhs are equal. Positive value if lhs appears after rhs in lexicographical order. Definition at line 363 of file characters.hpp.
int CompareIgnoreCase | ( | const TChar * | lhs, |
const TChar * | rhs, | ||
integer | cmpLength ) |
Compares two character arrays of equal length ignoring letter case.
TChar | One of the six (overlapping) character types. |
lhs | The first array to compare. |
rhs | The second array to compare. |
cmpLength | The number of characters to compare. |
0
if lhs and rhs are equal. Positive value if lhs appears after rhs in lexicographical order. void Copy | ( | const TChar * | src, |
integer | length, | ||
TChar * | dest ) |
Copies the contents of a character array into another, non-overlapping (!) array.
Note: This method is implemented as an inlined, direct direct call to std::char_traits::copy
.
TChar | One of the six (overlapping) character types. |
src | Pointer to the source array. |
length | The length to copy. |
dest | Pointer to the destination array. |
Definition at line 123 of file characters.hpp.
bool Equal | ( | const TChar * | lhs, |
const TChar * | rhs, | ||
integer | cmpLength ) |
Searches for a difference in two character arrays of equal length.
TChar | One of the six (overlapping) character types. |
lhs | The first array to compare. |
rhs | The second array to compare. |
cmpLength | The number of characters to compare. |
true
if the string arrays have identical contents, false
otherwise. Definition at line 344 of file characters.hpp.
bool Equal | ( | TChar | lhs, |
TRhs | rhs ) |
Compares two characters of arbitrary types.
TChar | One of the six (overlapping) character types. |
sensitivity | Letter case sensitivity of the comparison. |
TRhs | The type of the right hand side letter to compare. |
lhs | The left-hand side character to compare of class template type TChar. |
rhs | The right-hand side character to compare of method template type TCharRhs . |
true
if the given characters are equal, false
otherwise. Definition at line 77 of file characters.hpp.
void Fill | ( | TChar * | dest, |
integer | length, | ||
TChar | value ) |
Sets all elements of the given character array to value value.
TChar | One of the six (overlapping) character types. |
dest | Pointer to the destination array. |
length | The length to fill. |
value | The value to fill the array with. |
integer IndexOfAnyExcluded | ( | const TChar * | haystack, |
integer | haystackLength, | ||
const TChar * | needles, | ||
integer | needlesLength ) |
Returns the index of the first character in haystack which is not included in a given set of needles.
This method searches up to a given maximum index. For a search to the end of the zero-terminated string, use the faster method provided with class CString.
TChar | One of the six (overlapping) character types. |
haystack | Pointer to the start of the string. |
haystackLength | The length of the string or the maximum position to search. If -1 is provided, the length is determined using standard library function strlen (which needs haystack to be zero-terminated). |
needles | Pointer to a set of characters to be searched for. |
needlesLength | The length of the string of needles. If -1 is provided, the length is determined using standard library function strlen (which needs needles to be zero-terminated). |
-1
is returned. integer IndexOfAnyExcludedZT | ( | const TChar * | haystack, |
const TChar * | needles ) |
Same as IndexOfAnyExcluded(const TChar*,integer,const TChar*,integer) but works on zero-terminated strings.
TChar | One of the six (overlapping) character types. |
haystack | Pointer to a zero-terminated character array to search in. |
needles | Pointer to a zero-terminated set of characters to search for. |
-1
is returned. integer IndexOfAnyIncluded | ( | const TChar * | haystack, |
integer | haystackLength, | ||
const TChar * | needles, | ||
integer | needlesLength ) |
Returns the index of the first character in haystack which is included in a given set of needles.
This method searches up to a given maximum index. For a search to the end of the zero-terminated string, use faster method provided with class CString.
TChar | One of the six (overlapping) character types. |
haystack | Pointer to the start of the string. |
haystackLength | The length of the string or the maximum position to search. If -1 is provided, the length is determined using standard library function strlen (which needs haystack to be zero-terminated). |
needles | Pointer to a set of characters to be searched for. |
needlesLength | The length of the string of needles. If -1 is provided, the length is determined using standard library function strlen (which needs needles to be zero-terminated). |
-1
is returned. integer IndexOfAnyIncludedZT | ( | const TChar * | haystack, |
const TChar * | needles ) |
Same as IndexOfAnyIncluded(const TChar*,integer,const TChar*,integer) but works on zero-terminated strings.
TChar | One of the six (overlapping) character types. |
haystack | Pointer to a zero-terminated character array to search in. |
needles | Pointer to a zero-terminated set of characters to search for. |
-1
is returned. integer IndexOfFirstDifference | ( | const TChar * | haystack, |
integer | haystackLength, | ||
const TChar * | needle, | ||
integer | needleLength, | ||
lang::Case | sensitivity ) |
Returns the index of the first character which is not equal within two strings. If haystack starts with needle, then the length of needle is returned.
TChar | One of the six (overlapping) character types. |
haystack | Pointer to the start of the string. |
haystackLength | The length of the string or the maximum position to search. If -1 is provided, the length is determined using standard library function strlen (which needs haystack to be zero-terminated). |
needle | Pointer to the start of the string to compare with. |
needleLength | The length of needle. If -1 is provided, the length is determined using standard library function strlen (which needs needles to be zero-terminated). |
sensitivity | Denotes whether the comparison should be made case-sensitive or not. |
integer LastIndexOfAnyExclude | ( | const TChar * | haystack, |
integer | startIdx, | ||
const TChar * | needles, | ||
integer | needlesLength ) |
Returns the index of the last character in haystack which is not included in a given set of needles.
This method searches backwards from the end of the string.
TChar | One of the six (overlapping) character types. |
haystack | Pointer to the start of the string. |
startIdx | The position to start the search from. This must be smaller than the length of the string and greater or equal to zero. |
needles | Pointer to a set of characters to be searched for. |
needlesLength | The length of the string of needles. If -1 is provided, the length is determined using standard library function strlen (which needs needles to be zero-terminated). |
integer LastIndexOfAnyInclude | ( | const TChar * | haystack, |
integer | startIdx, | ||
const TChar * | needles, | ||
integer | needlesLength ) |
Returns the index of the last character in haystack which is included in a given set of needles.
This method searches backwards from the end of the string.
TChar | One of the six (overlapping) character types. |
haystack | Pointer to the start of the string. |
startIdx | The position to start the search from. This must be smaller than the length of the string and greater or equal to zero. |
needles | Pointer to a set of characters to be searched for. |
needlesLength | The length of the string of needles. If -1 is provided, the length is determined using standard library function strlen (which needs needles to be zero-terminated). |
integer Length | ( | const TChar * | cstring | ) |
Returns the length of a zero-terminated "c-style" character array.
Note: This method is implemented as an inlined, direct direct call to std::char_traits::length
.
TChar | One of the six (overlapping) character types. |
cstring | Pointer to a zero-terminated character array. |
Definition at line 106 of file characters.hpp.
void Move | ( | const TChar * | src, |
integer | length, | ||
TChar * | dest ) |
Copies the contents of a character array into another, possibly overlapping array.
Note: This method is implemented as an inlined, direct direct call to std::char_traits::move
.
TChar | One of the six (overlapping) character types. |
src | Pointer to the source array. |
length | The length to copy. |
dest | Pointer to the destination array, optionally within source. |
Definition at line 140 of file characters.hpp.
void Reverse | ( | TChar * | src, |
integer | length ) |
Reverses the order of the characters.
TChar | One of the six (overlapping) character types. |
src | Pointer to the character array. |
length | The length of the array. |
const TChar * Search | ( | const TChar * | haystack, |
integer | haystackLength, | ||
TChar | needle ) |
Searches the character. Returns a pointer to the location of needle in haystack, respectively nullptr
if not found.
Note: This method is implemented as a direct call to std::memchr
, respectively other character versions of it.
TChar | One of the six (overlapping) character types. |
haystack | Pointer to the start of the string. |
haystackLength | The length of the string or the maximum position to search. |
needle | Character to search. |
nullptr
if not found. Definition at line 182 of file characters.hpp.
void ToLower | ( | TChar * | src, |
integer | length ) |
Converts a character sequence to lower case.
TChar | One of the six (overlapping) character types. |
src | Pointer to the character array. |
length | The length of the array. |
TChar ToLower | ( | TChar | c | ) |
Converts a character to lower case.
TChar | One of the six (overlapping) character types. |
c | The character to convert |
void ToUpper | ( | TChar * | src, |
integer | length ) |
Converts a character sequence to upper case.
TChar | One of the six (overlapping) character types. |
src | Pointer to the character array. |
length | The length of the array. |
TChar ToUpper | ( | TChar | c | ) |
Converts a character to upper case.
TChar | One of the six (overlapping) character types. |
c | The character to convert |