This utility struct provides static methods working with character arrays of different underlying type.
The struct is similar to type traits struct std::char_traits
of the C++ standard library and for methods that are existing there already, just inline forwarding methods are defined here.
Definition at line 52 of file chararray.hpp.
#include <chararray.hpp>
Public Static Method Index: | |
static int | Compare (const TChar *lhs, const TChar *rhs, integer cmpLength) |
static int | CompareIgnoreCase (const TChar *lhs, const TChar *rhs, integer cmpLength) |
static void | Copy (const TChar *src, integer length, TChar *dest) |
static ALIB_WARNINGS_RESTORE bool | Equal (const TChar *lhs, const TChar *rhs, integer cmpLength) |
template<lang::Case sensitivity, typename TRhs > | |
static bool | Equal (TChar lhs, TRhs rhs) |
static void | Fill (TChar *dest, integer length, TChar value) |
static integer | IndexOfAnyExcluded (const TChar *haystack, integer haystackLength, const TChar *needles, integer needlesLength) |
static integer | IndexOfAnyExcludedZT (const TChar *haystack, const TChar *needles) |
static ALIB_WARNINGS_ALLOW_UNSAFE_BUFFER_USAGE integer | IndexOfAnyIncluded (const TChar *haystack, integer haystackLength, const TChar *needles, integer needlesLength) |
static integer | IndexOfAnyIncludedZT (const TChar *haystack, const TChar *needles) |
static integer | IndexOfFirstDifference (const TChar *haystack, integer haystackLength, const TChar *needle, integer needleLength, lang::Case sensitivity) |
static integer | LastIndexOfAnyExclude (const TChar *haystack, integer startIdx, const TChar *needles, integer needlesLength) |
static integer | LastIndexOfAnyInclude (const TChar *haystack, integer startIdx, const TChar *needles, integer needlesLength) |
static integer | Length (const TChar *cstring) |
static void | Move (const TChar *src, integer length, TChar *dest) |
static ALIB_WARNINGS_ALLOW_UNSAFE_BUFFER_USAGE void | Reverse (TChar *src, integer length) |
static ALIB_WARNINGS_RESTORE const TChar * | Search (const TChar *haystack, integer haystackLength, TChar needle) |
static void | ToLower (TChar *src, integer length) |
static TChar | ToLower (TChar c) |
static void | ToUpper (TChar *src, integer length) |
static TChar | ToUpper (TChar c) |
|
inlinestatic |
Compares up to cmpLength characters of two character arrays. Comparison stops if termination character '\0'
is found in one of the arrays.
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 380 of file chararray.hpp.
|
static |
Compares two character arrays of equal length ignoring letter case.
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.
|
inlinestatic |
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
.
src | Pointer to the source array. |
length | The length to copy. |
dest | Pointer to the destination array. |
Definition at line 112 of file chararray.hpp.
|
inlinestatic |
Searches for a difference in two character arrays of equal length.
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 361 of file chararray.hpp.
|
inlinestatic |
Compares two characters of arbitrary 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 67 of file chararray.hpp.
|
static |
Sets all elements of the given character array to value value .
dest | Pointer to the destination array. |
length | The length to fill. |
value | The value to fill the array with. |
|
static |
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 faster method provided with class CString .
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 % C 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 % C function strlen (which needs needles to be zero terminated). |
-1
is returned.
|
static |
Same as IndexOfAnyExcluded(const TChar*,integer,const TChar*,integer) but works on zero-terminated strings.
haystack | Pointer to zero-terminated character array to search in. |
needles | Pointer to zero-terminated set of characters to search for. |
-1
is returned.
|
static |
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 .
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 % C 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 % C function strlen (which needs needles to be zero terminated). |
-1
is returned.
|
static |
Same as IndexOfAnyIncluded(const TChar*,integer,const TChar*,integer) but works on zero-terminated strings.
haystack | Pointer to zero-terminated character array to search in. |
needles | Pointer to zero-terminated set of characters to search for. |
-1
is returned.
|
static |
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.
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 % C 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 % C function strlen (which needs needles to be zero terminated). |
sensitivity | Denotes whether the comparison should be made case sensitive or not. |
|
static |
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.
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 % C function strlen (which needs needles to be zero terminated). |
|
static |
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.
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 % C function strlen (which needs needles to be zero terminated). |
|
inlinestatic |
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
.
cstring | Pointer to zero-terminated character array. |
Definition at line 96 of file chararray.hpp.
|
inlinestatic |
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
.
src | Pointer to the source array. |
length | The length to copy. |
dest | Pointer to the destination array, optionally within source. |
Definition at line 128 of file chararray.hpp.
|
static |
Reverses the order of the characters.
src | Pointer to the character array. |
length | The length of the array. |
|
inlinestatic |
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.
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 205 of file chararray.hpp.
|
static |
Converts a character sequence to lower case.
src | Pointer to the character array. |
length | The length of the array. |
|
static |
Converts a character to lower case.
c | The character to convert |
|
static |
Converts a character sequence to upper case.
src | Pointer to the character array. |
length | The length of the array. |
|
static |
Converts a character to upper case.
c | The character to convert |