ADTF
3.18.2
|
String Helper Class. More...
Public Types | |
typedef tUInt64 | tHashKey |
Defines the Type for the Hashkey generated with GetHash. | |
typedef tUInt32 | tHashKey32 |
Static Public Member Functions | |
static tInt | Compare (const tChar *str1, const tChar *str2, tSize nPos, tSize nLength) |
This function compares two given strings using the generic-text function _tcscmp. More... | |
static tInt | Compare (const tChar *str1, const tChar *str2, tSize nLength=InvalidPos) |
This function compares two given strings using the generic-text function _tcscmp. More... | |
static tInt | CompareNoCase (const tChar *str1, const tChar *str2, tSize nPos, tSize nLength) |
This function compares a cString object with another string using the generic-text function _tcsicmp. More... | |
static tInt | CompareNoCase (const tChar *str1, const tChar *str2, tSize nLength=InvalidPos) |
This function compares a cString object with another string using the generic-text function _tcsicmp. More... | |
static tBool | IsEqual (const tChar *str1, const tChar *str2, tSize nPos, tSize nLength) |
This function checks if the two strings are equal (case sensitive) More... | |
static tBool | IsEqual (const tChar *str1, const tChar *str2, tSize nLength=InvalidPos) |
This function checks if the two strings are equal (case sensitive) More... | |
static tBool | IsEqualNoCase (const tChar *str1, const tChar *str2, tSize nPos, tSize nLength) |
This function checks if the two strings are equal (case insensitive) More... | |
static tBool | IsEqualNoCase (const tChar *str1, const tChar *str2, tSize nLength=InvalidPos) |
This function checks if the two strings are equal (case insensitive) More... | |
static tBool | IsInteger (const tChar *strToCheck, tSize nLength=InvalidPos) |
Check if string content represents an integer value. More... | |
static tBool | IsFloat (const tChar *strToCheck) |
Check if string content represents a floating point value. More... | |
static tBool | IsNumeric (const tChar *strToCheck) |
Check if string content represents a numeric value. More... | |
static tSize | FindFirstOfToken (const tChar *strString, const tChar *strTokenList, tSize szStartPos=0, tSize nLength=InvalidPos) |
This function searches the string for the first occurrence of a token (character) that is also contained in the given token list. More... | |
static tSize | RFindFirstOfToken (const tChar *strString, const tChar *strTokenList, tSize szStartPos=InvalidPos, tSize nLength=InvalidPos) |
This function searches the string for the last occurrence of a token (character) that is also contained in the given token list. More... | |
static tSize | FindFirstNotOfToken (const tChar *strString, const tChar *strTokenList, tSize szStartPos=0, tSize nLength=InvalidPos) |
This function searches the string for the first occurrence of a token (character) that is not also contained in the given token list. More... | |
static tBool | IsOneOf (tChar cValue, const tChar *strTokenList) |
Checks if the character is contained in the token list. More... | |
static tChar * | Repeat (tChar *strDest, tSize szDestSize, tSize nCount, tChar cCharacter) |
Fill a string with a repetitive character sequence. More... | |
static tChar * | PushFront (tChar *strDest, tSize szDestSize, const tChar *strSource, tSize nCount) |
This function adds the content of one string to the beginning of another string. More... | |
static tChar * | Delete (tChar *strString, tSize nPos, tSize nLength=InvalidPos) |
This function deletes characters from a string. More... | |
static tBool | IsWhiteChar (tChar c) |
This function checks if a given tChar value is a whitespace character. More... | |
static tBool | IsSymbolChar (tChar c) |
This function checks if a given tChar value is valid to be used in a symbol name. More... | |
static tBool | IsNumber (tChar c) |
This function checks if a tChar is a number. More... | |
static const tChar * | FromType (tInt32 i32Value, tChar *strBufferResult, tSize szBufferResult, const tChar *strFormat="") |
This function creates a new cString object from a tInt32 value. More... | |
static const tChar * | FromType (tUInt32 ui32Value, tChar *strBufferResult, tSize szBufferResult, const tChar *strFormat="") |
This function creates a new cString object from a tUInt32 value. More... | |
static const tChar * | FromType (tInt64 i64Value, tChar *strBufferResult, tSize szBufferResult, const tChar *strFormat="") |
This function creates a new cString object from a tInt64 value. More... | |
static const tChar * | FromType (tUInt64 ui64Value, tChar *strBufferResult, tSize szBufferResult, const tChar *strFormat="") |
This function creates a new cString object from a tUInt64 value. More... | |
static const tChar * | FromType (tBool bValue, tChar *strBufferResult, tSize szBufferResult, const tChar *strFormat) |
This function creates a new cString object from a boolean value. More... | |
static const tChar * | FromType (tFloat32 f32Value, tChar *strBufferResult, tSize szBufferResult, const tChar *strFormat) |
This function creates a new cString object from a float value. More... | |
static const tChar * | FromType (tFloat64 f64Value, tChar *strBufferResult, tSize szBufferResult, const tChar *strFormat) |
This function creates a new cString object from a double value. More... | |
static tResult | Format (tChar *strBufferResult, tSize szBufferResult, const tChar *strFormat,...) |
Write formatted data to a string. More... | |
static tVoid | ToType (const tChar *strString, tInt32 &i32Value) |
Escape control characters. More... | |
static tVoid | ToType (const tChar *strString, tUInt32 &ui32Value) |
This function converts the string to an integer value. More... | |
static tVoid | ToType (const tChar *strString, tInt64 &i64Value) |
This function converts the string to an integer value. More... | |
static tVoid | ToType (const tChar *strString, tUInt64 &ui64Value) |
This function converts the string to an integer value. More... | |
static tVoid | ToType (const tChar *strString, tFloat64 &f64Value) |
This function converts the string to a floating-point value. More... | |
static tVoid | ToType (const tChar *strString, tFloat32 &f32Value) |
This function converts the string to a floating-point value. More... | |
static tVoid | ToType (const tChar *strString, tBool &bBool) |
This function converts the string to a boolean value. More... | |
static tVoid | HexToType (const tChar *strString, tInt64 &i64Value) |
This function converts a hexadecimal string representation to an integer value. More... | |
static tChar * | Copy (tChar *pstrDestination, const tChar *pstrSource, tSize nCount=InvalidPos, tSize nDestinationBufferSize=InvalidPos) |
Copies a null terminated string to another string buffer. More... | |
static tInt | Scan (const tChar *strStringToScan, const tChar *sFormat,...) |
This function reads data from the input string and writes the data into the location(s) given by arguments. More... | |
static tVoid | TrimFunc (tChar *strStringBuffer, tSize nBufferLength, const tBool bLeft, const tBool bRight, const tBool bNumeric) |
This function removes whitespace and redundant zero characters from a string object. More... | |
static tSize | GetLength (const tChar *pcStr) |
Returns the length of the string. More... | |
static tHashKey | GetHash (const tChar *strToHash) |
Creates a hash key from the string. More... | |
static tHashKey32 | GetHash32 (const tChar *strToHash) |
Creates a hash key from the string. More... | |
Static Public Attributes | |
static const tSize | InvalidPos |
used to identicate out of range, invalidpos or default length | |
Static Protected Attributes | |
static const tChar * | m_pcSafeBuffer |
Internally used character buffer. | |
String Helper Class.
Definition at line 21 of file stringutil.h.
|
static |
This function compares two given strings using the generic-text function _tcscmp.
[in] | str1 | first string used for comparison. |
[in] | str2 | second string used for comparison. |
[in] | nLength | amount of characters to be compared. -1 means until end |
0 | The strings are identical. |
<0 | The first string is less than the second one. |
>0 | The first string is greater than the second one. |
This function compares two given strings using the generic-text function _tcscmp.
The generic-text function _tcscmp, which is defined in tChar.H, maps to either strcmp, wcscmp, or _mbscmp depending on the character set that is defined at compile time. Each of these functions performs a case-sensitive comparison of the strings, and is not affected by locale.
[in] | str1 | first string used for comparison. |
[in] | str2 | second string used for comparison. |
[in] | nPos | character position to start the comparison at. |
[in] | nLength | amount of characters to be compared. -1 means until end |
0 | The strings are identical. |
<0 | The first string is less than the second one. |
>0 | The first string is greater than the second one. |
Referenced by string_base< storageT >::Compare(), string_base< storageT >::operator!=(), string_base< storageT >::operator<(), string_base< storageT >::operator<=(), string_base< storageT >::operator==(), string_base< storageT >::operator>(), and string_base< storageT >::operator>=().
|
static |
This function compares a cString object with another string using the generic-text function _tcsicmp.
str1 | [in] First string for comparison. |
str2 | [in] Second string for comparison. |
nLength | [in] Compare only nLength characters. |
0 | The strings are identical (ignoring case). |
<0 | The first string is less than the second one (ignoring case). |
>0 | The first string is greater than the second one (ignoring case). |
|
static |
This function compares a cString object with another string using the generic-text function _tcsicmp.
The generic-text function _tcsicmp, which is defined in tChar.H, maps to either _stricmp, _wcsicmp, _mbsicmp depending on the character set that is defined at compile time. Each of these functions performs a case-insensitive comparison of the strings, and is not affected by locale..
str1 | [in] First string for comparison. |
str2 | [in] Second string for comparison. |
nPos | [in] character position to start the comparison at. |
nLength | [in] Compare only nLength characters. |
0 | The strings are identical (ignoring case). |
<0 | The first string is less than the second one (ignoring case). |
>0 | The first string is greater than the second one (ignoring case). |
Referenced by string_base< storageT >::CompareNoCase(), and string_base< storageT >::IsEqualNoCase().
|
static |
Copies a null terminated string to another string buffer.
This method ensures that the string stored in sDestination is null terminated:
pstrDestination | [out] 0-terminated Destination string. |
pstrSource | [in] 0-terminated Source string. |
nCount | [in] Number of characters to be copied from the source string to the destination string object. |
nDestinationBufferSize | [in] The size of the destination string buffer, no more than this amount of bytes will be copied (including the null byte). -1 = no limit (not recommended, prone to buffer overflows). |
nDestinationBufferSize
is set to at least nCount+1!Referenced by stack_string_base< TSIZE, datastoreType >::append(), stack_string_base< TSIZE, datastoreType >::assign(), and stack_string_data_handler< growinheap_out_of_range >::Resize().
|
static |
This function deletes characters from a string.
[out] | strString | String to delete characters from. |
[in] | nPos | First character position to start deleting from. |
[in] | nLength | Number of characters to delete or -1 to delete all until the end of the string. |
Referenced by stack_string_base< TSIZE, datastoreType >::erase().
|
static |
This function searches the string for the first occurrence of a token (character) that is not also contained in the given token list.
[in] | strString | String to search the token in. |
[in] | strTokenList | Token list to test for a nonmatching token. |
[in] | szStartPos | The index inside the string to begin the search with, or 0 to start from the beginning (default). |
[in] | nLength | Number of characters within the string that should be searched or -1 to search all (default). |
Referenced by stack_string_base< TSIZE, datastoreType >::find_first_not_of().
|
static |
This function searches the string for the first occurrence of a token (character) that is also contained in the given token list.
[in] | strString | String to search the token in. |
[in] | strTokenList | Token list to test for a matching token. |
[in] | szStartPos | The index inside the string to begin the search with, or 0 to start from the beginning (default). |
[in] | nLength | Number of characters within the string that should be searched or -1 to search all (default). |
Referenced by stack_string_base< TSIZE, datastoreType >::find(), and stack_string_base< TSIZE, datastoreType >::find_first_of().
|
static |
Write formatted data to a string.
The Format method formats and stores a series of characters and values in a new cString buffer object. Each argument (if any) is converted and output according to the corresponding format specification in format. The format consists of ordinary characters and has the same form and function as the format argument for printf. If copying occurs between strings that overlap, the behavior is undefined.
For 64-Bit-Integer conversion use lld (Win32, Linux) or I64d (only Win32). lld maps to a long long integer whereas I64d maps to an integer with 64-bit size. The first one may not be typesafe but is portable between Windows and Linux.
strBufferResult | [out] String Buffer to store the formatted data in. |
szBufferResult | [in] Buffer size. |
strFormat | [in] Format control string. |
... | [in] Variable argument list. |
|
static |
This function creates a new cString object from a boolean value.
bValue | [in] Numeric value. |
strBufferResult | [out] String Buffer to store the converted value in. |
szBufferResult | [in] Buffer size. |
strFormat | [in] Format definition (see Format). |
|
static |
This function creates a new cString object from a float value.
f32Value | [in] Numeric value. |
strBufferResult | [out] String Buffer to store the converted value in. |
szBufferResult | [in] Buffer size. |
strFormat | [in] Format definition (see Format). |
|
static |
This function creates a new cString object from a double value.
f64Value | [in] Numeric value. |
strBufferResult | [out] String Buffer to store the converted value in. |
szBufferResult | [in] Buffer size. |
strFormat | [in] Format definition (see Format). |
|
static |
This function creates a new cString object from a tInt32
value.
The numeric data is converted to an unformatted string.
i32Value | [in] Numeric value. |
strBufferResult | [out] String Buffer to store the converted value in. |
szBufferResult | [in] Buffer size. |
strFormat | [in] Format definition (see Format). |
Referenced by string_base< storageT >::ToStringFromType().
|
static |
This function creates a new cString object from a tInt64
value.
i64Value | [in] Numeric value. |
strBufferResult | [out] String Buffer to store the converted value in. |
szBufferResult | [in] Buffer size. |
strFormat | [in] Format definition (see Format). |
|
static |
This function creates a new cString object from a tUInt32
value.
The numeric data is converted to an unformatted string.
ui32Value | [in] Numeric value. |
strBufferResult | [out] String Buffer to store the converted value in. |
szBufferResult | [in] Buffer size. |
strFormat | [in] Format definition (see Format). |
|
static |
This function creates a new cString object from a tUInt64 value.
ui64Value | [in] Numeric value. |
strBufferResult | [out] String Buffer to store the converted value in. |
szBufferResult | [in] Buffer size. |
strFormat | [in] Format definition (see Format). |
Creates a hash key from the string.
[in] | strToHash | The string. |
|
static |
Creates a hash key from the string.
[in] | strToHash | The string. |
Returns the length of the string.
[in] | pcStr | The string. |
Referenced by tFOURCC::tFOURCC(), stack_string_base< TSIZE, datastoreType >::assign(), string_base< storageT >::GetLength(), stack_string_base< TSIZE, datastoreType >::insert(), string_base< storageT >::IsEmpty(), stack_string_base< TSIZE, datastoreType >::length(), and cStringPiece::Set().
This function converts a hexadecimal string representation to an integer value.
A valid hex number has the following representation [+-]? 0? x? {[0-9a-fA-F]*
[in] | strString | String that should be converted. |
[out] | i64Value | Reference to the integer variable that should store the converted integer value or 0 (error case) |
Referenced by string_base< storageT >::HexToType().
|
static |
This function checks if the two strings are equal (case sensitive)
str1 | [in] A null-terminated string to compare. |
str2 | [in] A null-terminated string to compare. |
nLength | [in] Compare only nLength characters. |
This function checks if the two strings are equal (case sensitive)
str1 | [in] A null-terminated string to compare. |
str2 | [in] A null-terminated string to compare. |
nPos | [in] character position to start the comparison at. |
nLength | [in] Compare only nLength characters. |
Referenced by stack_string_base< TSIZE, datastoreType >::find(), and adtf_ddl::access_element::find_index().
|
static |
This function checks if the two strings are equal (case insensitive)
str1 | [in] A null-terminated string to compare. |
str2 | [in] A null-terminated string to compare. |
nLength | [in] Compare only nLength characters. |
|
static |
This function checks if the two strings are equal (case insensitive)
str1 | [in] A null-terminated string to compare. |
str2 | [in] A null-terminated string to compare. |
nPos | [in] character position to start the comparison at. |
nLength | [in] Compare only nLength characters. |
Check if string content represents a floating point value.
Allowed float format [whitespace] [sign] [digits] [.digits] [ {d | D | e | E }[sign]digits] [whitespace] sign is either plus (+) or minus (-) digits (0123456789) The decimal digits may be followed by an exponent, which consists of an introductory letter (d, D, e, or E) and an optionally signed decimal integer.
[in] | strToCheck | String representation that should be checked. |
Referenced by string_base< storageT >::IsFloat().
|
static |
Check if string content represents an integer value.
A hex number will not be identified as an integer value.
[in] | strToCheck | String representation that should be checked. |
[in] | nLength | Check only nLength characters. Default checks complete string. |
Referenced by string_base< storageT >::IsInteger().
This function checks if a tChar is a number.
c | [in] Character to be checked. |
Check if string content represents a numeric value.
[in] | strToCheck | String representation that should be checked. |
Checks if the character is contained in the token list.
[in] | cValue | Character value to search for. |
[in] | strTokenList | Token list to search the character in. |
Referenced by string_base< storageT >::LeftTrim(), and string_base< storageT >::NumTrim().
This function checks if a given tChar value is valid to be used in a symbol name.
c | [in] Character to be checked. |
This function checks if a given tChar value is a whitespace character.
c | [in] Character to be checked. |
Referenced by string_base< storageT >::LeftTrim(), and string_base< storageT >::RightTrim().
|
static |
This function adds the content of one string to the beginning of another string.
[out] | strDest | Destination string to push the string content to. |
[in] | szDestSize | Size of the destination string. |
[in] | strSource | Source string to copy content from. |
[in] | nCount | Number of characters to copy from the source string or -1 to copy all. |
Referenced by stack_string_base< TSIZE, datastoreType >::insert().
Fill a string with a repetitive character sequence.
[out] | strDest | Destination string to store the character sequence in. |
[in] | szDestSize | Size of the destination string. |
[in] | nCount | Number of times the character should be repeated. |
[in] | cCharacter | Character value to repeat. |
Referenced by stack_string_base< TSIZE, datastoreType >::assign().
|
static |
This function searches the string for the last occurrence of a token (character) that is also contained in the given token list.
The search runs backwards.
[in] | strString | String to search the token in. |
[in] | strTokenList | Token list to test for a matching token. |
[in] | szStartPos | The index inside the string to begin the search with, or -1 to start from the end (default). |
[in] | nLength | Number of characters within the string that should be searched or -1 to search all (default). |
Referenced by stack_string_base< TSIZE, datastoreType >::rfind().
This function reads data from the input string and writes the data into the location(s) given by arguments.
Each argument must be a pointer to a variable of a type that corresponds to a type specifier in format. If copying takes place between strings that overlap, the behavior is undefined.
Use following format types: For tInt use "%d" For tUInt use "%u" For tUInt use "%u" For tFloat / tFloat64 use "%lf" For tFloat32 "%f" For tChar String use i.e "%80s" if you want to read 80 characters.
For 64-Bit-Integer (tTimeStamp, tInt64) conversion use lld (Win32, Linux) lld maps to a long long integer. This may not be typesafe but is portable between Windows and Linux.
strStringToScan | [in] Source cString object. |
sFormat | [in] Format of the variables in the Source string. |
... | [out] variables of types for string Format values in corresponding order |
This function converts the string to a boolean value.
Only the following strings will be interpreted as true (not case sensitive): "true","on","1", all other strings will be interpreted as false. If a string is concatenate by a true-literal (and vice versa) it is interpreted as false.
[in] | strString | String that should be converted. |
[out] | bBool | Reference to the boolean variable that should store the converted boolean value or false (error case) |
This function converts the string to a floating-point value.
The string has to be in the following format to be interpreted as a float: [whitespace][sign][digits][(.|,)digits][{d|D|e|E}[sign]digits]. So hex numbers can not be interpreted! Both '.' and ',' are interpreted as decimal point.
[in] | strString | String that should be converted. |
[out] | f32Value | Reference to the float variable that should store the converted floating point value or 0.0 (error case) |
This function converts the string to a floating-point value.
The string has to be in the following format to be interpreted as a float: [whitespace][sign][digits][(.|,)digits][{d|D|e|E}[sign]digits]. So hex numbers can not be interpreted! Both '.' and ',' are interpreted as decimal point.
[in] | strString | String that should be converted. |
[out] | f64Value | Reference to the float variable that should store the converted floating point value or 0.0 (error case) |
Escape control characters.
[in] | strString | String that should be converted. |
[out] | i32Value | Reference to the integer variable that should store the converted integer value or 0 (error case) |
Referenced by string_base< storageT >::ToType().
This function converts the string to an integer value.
The function stops reading at the first character, that is not part of a number. i.e. "123abc" can be converted, but "abc123" not. If the number is written as a hex-number the string can be converted, too. i.e "0x4fff abc". More Information about converting hex-numbers see
[in] | strString | String that should be converted. |
[out] | i64Value | Reference to the integer variable that should store the converted integer value or 0 (error case) |
This function converts the string to an integer value.
The function stops reading at the first character, that is not part of a number. i.e. "123abc" can be converted, but "abc123" not. If the number is written as a hex-number the string can be converted, too. i.e "0x4fff abc". More Information about converting hex-numbers see
[in] | strString | String that should be converted. |
[out] | ui32Value | Reference to the integer variable that should store the converted integer value or 0 (error case) i.e. negative numbers |
This function converts the string to an integer value.
The function stops reading at the first character, that is not part of a number. i.e. "123abc" can be converted, but "abc123" not. If the number is written as a hex-number the string can be converted, too. i.e "0x4fff abc". More Information about converting hex-numbers see
[in] | strString | String that should be converted. |
[out] | ui64Value | Reference to the integer variable that should store the converted integer value or 0 (error case) i.e. negative numbers |
|
static |
This function removes whitespace and redundant zero characters from a string object.
[out] | strStringBuffer | String buffer containing the string that should be trimmed. |
[in] | nBufferLength | Size of the string buffer. |
[in] | bLeft | Whether or not to trim string on left side. |
[in] | bRight | Whether or not to trim string on right side. |
[in] | bNumeric | Whether or not the string content is a numeric value and zero characters should be trimmed. |