ALib C++ Library
Library Version: 2412 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
alib::characters Namespace Reference

Description:

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)
 

Type Definition Details:

◆ character

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.

See also
For details, see chapter 2. Character Types of the Programmer's Manual of module ALib Characters.

Definition at line 130 of file chartraits.hpp.

◆ complementChar

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.

See also
For details, see chapter 2. Character Types of the Programmer's Manual of module ALib Characters.

Definition at line 144 of file chartraits.hpp.

◆ nchar

using nchar = char

This type represents a narrow character in ALib. This is an alias for built-in C++ type char.

See also
For details, see chapter 2. Character Types of the Programmer's Manual of module ALib Characters.

Definition at line 32 of file chartraits.hpp.

◆ strangeChar

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

See also
For details, see chapter 2. Character Types of the Programmer's Manual of module ALib Characters.

Definition at line 154 of file chartraits.hpp.

◆ wchar

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.

See also
For details, see chapter 2. Character Types of the Programmer's Manual of module ALib Characters.

Definition at line 54 of file chartraits.hpp.

◆ xchar

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.

See also
For details, see chapter 2. Character Types of the Programmer's Manual of module ALib Characters.

Definition at line 67 of file chartraits.hpp.

Enumeration Details:

◆ AccessType

enum class AccessType
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.

◆ ConstructionType

enum class ConstructionType
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.

Function Details:

◆ Compare()

template<typename TChar >
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.

Template Parameters
TCharOne of the six (overlapping) character types.
Parameters
lhsThe first array to compare.
rhsThe second array to compare.
cmpLengthThe number of characters to compare.
Returns
Negative value if lhs appears before rhs in lexicographical order. 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.

◆ CompareIgnoreCase()

template<typename TChar >
int CompareIgnoreCase ( const TChar * lhs,
const TChar * rhs,
integer cmpLength )

Compares two character arrays of equal length ignoring letter case.

Template Parameters
TCharOne of the six (overlapping) character types.
Parameters
lhsThe first array to compare.
rhsThe second array to compare.
cmpLengthThe number of characters to compare.
Returns
Negative value if lhs appears before rhs in lexicographical order. 0 if lhs and rhs are equal. Positive value if lhs appears after rhs in lexicographical order.

◆ Copy()

template<typename TChar >
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.

Template Parameters
TCharOne of the six (overlapping) character types.
Parameters
srcPointer to the source array.
lengthThe length to copy.
destPointer to the destination array.

Definition at line 123 of file characters.hpp.

◆ Equal() [1/2]

template<typename TChar >
bool Equal ( const TChar * lhs,
const TChar * rhs,
integer cmpLength )

Searches for a difference in two character arrays of equal length.

Template Parameters
TCharOne of the six (overlapping) character types.
Parameters
lhsThe first array to compare.
rhsThe second array to compare.
cmpLengthThe number of characters to compare.
Returns
true if the string arrays have identical contents, false otherwise.

Definition at line 344 of file characters.hpp.

◆ Equal() [2/2]

template<typename TChar , lang::Case sensitivity, typename TRhs >
bool Equal ( TChar lhs,
TRhs rhs )

Compares two characters of arbitrary types.

Template Parameters
TCharOne of the six (overlapping) character types.
sensitivityLetter case sensitivity of the comparison.
TRhsThe type of the right hand side letter to compare.
Parameters
lhsThe left-hand side character to compare of class template type TChar.
rhsThe right-hand side character to compare of method template type TCharRhs .
Returns
true if the given characters are equal, false otherwise.

Definition at line 77 of file characters.hpp.

Here is the call graph for this function:

◆ Fill()

template<typename TChar >
void Fill ( TChar * dest,
integer length,
TChar value )

Sets all elements of the given character array to value value.

Template Parameters
TCharOne of the six (overlapping) character types.
Parameters
destPointer to the destination array.
lengthThe length to fill.
valueThe value to fill the array with.

◆ IndexOfAnyExcluded()

template<typename TChar >
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.

Template Parameters
TCharOne of the six (overlapping) character types.
Parameters
haystackPointer to the start of the string.
haystackLengthThe 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).
needlesPointer to a set of characters to be searched for.
needlesLengthThe 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).
Returns
The index of the first character that is not included in needles. If all characters of haystack are included in needles, -1 is returned.

◆ IndexOfAnyExcludedZT()

template<typename TChar >
integer IndexOfAnyExcludedZT ( const TChar * haystack,
const TChar * needles )

Same as IndexOfAnyExcluded(const TChar*,integer,const TChar*,integer) but works on zero-terminated strings.

Template Parameters
TCharOne of the six (overlapping) character types.
Parameters
haystackPointer to a zero-terminated character array to search in.
needlesPointer to a zero-terminated set of characters to search for.
Returns
The index of the first character that is not included in needles. If all characters of haystack are included in needles, -1 is returned.

◆ IndexOfAnyIncluded()

template<typename TChar >
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.

Template Parameters
TCharOne of the six (overlapping) character types.
Parameters
haystackPointer to the start of the string.
haystackLengthThe 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).
needlesPointer to a set of characters to be searched for.
needlesLengthThe 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).
Returns
The index of the first character found that is included in needles. If no character of haystack is included in needles, -1 is returned.

◆ IndexOfAnyIncludedZT()

template<typename TChar >
integer IndexOfAnyIncludedZT ( const TChar * haystack,
const TChar * needles )

Same as IndexOfAnyIncluded(const TChar*,integer,const TChar*,integer) but works on zero-terminated strings.

Template Parameters
TCharOne of the six (overlapping) character types.
Parameters
haystackPointer to a zero-terminated character array to search in.
needlesPointer to a zero-terminated set of characters to search for.
Returns
The index of the first character found that is included in needles. If no character of haystack is included in needles, -1 is returned.

◆ IndexOfFirstDifference()

template<typename TChar >
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.

Template Parameters
TCharOne of the six (overlapping) character types.
Parameters
haystackPointer to the start of the string.
haystackLengthThe 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).
needlePointer to the start of the string to compare with.
needleLengthThe length of needle. If -1 is provided, the length is determined using standard library function strlen (which needs needles to be zero-terminated).
sensitivityDenotes whether the comparison should be made case-sensitive or not.
Returns
The index of the first character found which is not equal in given strings.

◆ LastIndexOfAnyExclude()

template<typename TChar >
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.

Template Parameters
TCharOne of the six (overlapping) character types.
Parameters
haystackPointer to the start of the string.
startIdxThe position to start the search from. This must be smaller than the length of the string and greater or equal to zero.
needlesPointer to a set of characters to be searched for.
needlesLengthThe 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).
Returns
The index of the first character found which is included in the given set of characters. If nothing is found, -1 is returned.

◆ LastIndexOfAnyInclude()

template<typename TChar >
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.

Template Parameters
TCharOne of the six (overlapping) character types.
Parameters
haystackPointer to the start of the string.
startIdxThe position to start the search from. This must be smaller than the length of the string and greater or equal to zero.
needlesPointer to a set of characters to be searched for.
needlesLengthThe 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).
Returns
The index of the first character found which is included in the given set of characters. If nothing is found, -1 is returned.

◆ Length()

template<typename TChar >
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.

Template Parameters
TCharOne of the six (overlapping) character types.
Parameters
cstringPointer to a zero-terminated character array.
Returns
The length of the string.

Definition at line 106 of file characters.hpp.

◆ Move()

template<typename TChar >
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.

Template Parameters
TCharOne of the six (overlapping) character types.
Parameters
srcPointer to the source array.
lengthThe length to copy.
destPointer to the destination array, optionally within source.

Definition at line 140 of file characters.hpp.

◆ Reverse()

template<typename TChar >
void Reverse ( TChar * src,
integer length )

Reverses the order of the characters.

Template Parameters
TCharOne of the six (overlapping) character types.
Parameters
srcPointer to the character array.
lengthThe length of the array.

◆ Search()

template<typename TChar >
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.

Template Parameters
TCharOne of the six (overlapping) character types.
Parameters
haystackPointer to the start of the string.
haystackLengthThe length of the string or the maximum position to search.
needleCharacter to search.
Returns
The pointer to the first occurrence of needle respectively nullptr if not found.

Definition at line 182 of file characters.hpp.

◆ ToLower() [1/2]

template<typename TChar >
void ToLower ( TChar * src,
integer length )

Converts a character sequence to lower case.

Template Parameters
TCharOne of the six (overlapping) character types.
Parameters
srcPointer to the character array.
lengthThe length of the array.

◆ ToLower() [2/2]

template<typename TChar >
TChar ToLower ( TChar c)

Converts a character to lower case.

Template Parameters
TCharOne of the six (overlapping) character types.
Parameters
cThe character to convert
Returns
The lower case version of the given character.

◆ ToUpper() [1/2]

template<typename TChar >
void ToUpper ( TChar * src,
integer length )

Converts a character sequence to upper case.

Template Parameters
TCharOne of the six (overlapping) character types.
Parameters
srcPointer to the character array.
lengthThe length of the array.

◆ ToUpper() [2/2]

template<typename TChar >
TChar ToUpper ( TChar c)

Converts a character to upper case.

Template Parameters
TCharOne of the six (overlapping) character types.
Parameters
cThe character to convert
Returns
The upper case version of the given character.