7 #ifndef _STRINGTEMPLATE_CLASS_HEADER_
8 #define _STRINGTEMPLATE_CLASS_HEADER_
20 template <
class storageT>
class string_list_base;
29 template <
class storageT>
44 typedef typename _StorageType::iterator
iterator;
157 Set(strValue, szLength);
173 static_assert(std::is_same<value_type, tChar>::value
174 || std::is_same<value_type, tUInt8>::value,
175 "storageT::value_type must be tChar or tUInt8 and specified !!");
265 if (pString !=
nullptr)
638 return Append(strToInsertString, nLength);
662 if (pToInsertString !=
nullptr)
842 return strTmp.
Find(strCompare, nStart);
965 if (
IsEmpty() || nFindSize == 0)
973 nStart =
Find(strFind, nStart);
1002 tSize nReplaceCount = 0;
1007 tSize nStartPos = 0;
1010 nPos =
Find(strOld, nStartPos);
1013 strBuffer.
Append(
Mid(nStartPos, (nPos - nStartPos)));
1014 strBuffer.
Append(strNew);
1015 nStartPos = nPos + nSearchLen;
1031 return nReplaceCount;
1054 tSize nReplacements = 0;
1057 for (; oIt != oItEnd; ++oIt)
1069 return nReplacements;
1107 tSize nFiltered = 0;
1108 for (
tSize nPos = 0; nPos < nSize; ++nPos)
1153 strFirst =
Left(szRight);
1164 strFirst =
Left(szRight);
1180 if (szStringLength == 0
1181 || (strEndsWith.
GetLength() > szStringLength))
1193 return strPart.
IsEqual(strEndsWith);
1311 return (
Compare(strString) == 0);
1322 return (
Compare(strString) != 0);
1333 return (
Compare(strString) < 0);
1344 return (
Compare(strString) > 0);
1356 return (
Compare(strString) <= 0);
1368 return (
Compare(strString) >= 0);
1514 lstSplittedResult.
Clear();
1526 nStartPos = nPos + 1;
1527 nPos =
Find(strToken, nStartPos);
1532 lstSplittedResult.
Append(
Mid(nStartPos, nPos - nStartPos));
1538 nPos += nTokenLen - 1;
1542 if (nStartPos < nToSplitStringSize)
1544 lstSplittedResult.
Append(
Mid(nStartPos));
1579 nPos =
FindToken(strTokenList, nLastPos);
1582 strPart =
Mid(nLastPos);
1591 if (nPos > nLastPos)
1593 strPart =
Mid(nLastPos, nPos - nLastPos);
1596 nLastPos = nPos + 1;
1692 bLastWasZero =
tTrue;
1751 for (
auto it =
begin();
1756 *it =
static_cast<tChar>(::tolower(*it));
1773 for (
auto it =
begin();
1777 *it = ::toupper(
static_cast<tChar>(*it));
1804 tSize szCounter = 0;
1805 while (*ptr !=
'\0' && szCounter < szEnd)
1887 while (*ptr !=
'\0')
2005 return _myType().Set(c, nCount);
2307 tBool bRetValue = 0;
2401 _In_z_ _Printf_format_string_
2406 __attribute__((
format(printf, 1, 2)))
2409 va_list args, args_copy;
2410 va_start(args, strFormat);
2411 va_copy(args_copy, args);
2413 strBuffer.
SetBuffer(
static_cast<size_t>(::std::vsnprintf(
nullptr, 0, strFormat, args_copy)));
2429 template<
typename T>
2434 tSize szCurrentBuffer = 42;
2435 if (szMaxSize < szCurrentBuffer)
2437 szCurrentBuffer = szMaxSize;
2456 return strDestination.
Set(strSource, szLength);
2467 template<
class sT,
class sT2>
2478 return ((str1.
Compare(str2)) < 0);
2487 template<
class sT,
class sT2>
2535 return (str2.
Compare(str1) > 0);
2547 return (str2.
Compare(str1) < 0);
2559 return (str2.
Compare(str1) >= 0);
2571 return (str2.
Compare(str1) <= 0);
2608 return (str2.
Compare(str1) > 0);
2620 return (str2.
Compare(str1) < 0);
2632 return (str2.
Compare(str1) >= 0);
2644 return (str2.
Compare(str1) <= 0);
2680 return (str1.
Compare(str2) < 0);
2692 return (str1.
Compare(str2) > 0);
2704 return (str1.
Compare(str2) <= 0);
2716 return (str1.
Compare(str2) >= 0);
2728 template<
class sT,
class sT2>
2765 #define A_UTILS_DEFAULT_SIZE_OF_STRING 64
char tChar
The tChar defines the type for platform character set (platform and compiler dependent type).
int64_t tInt64
type definition for signed integer values (64bit) (platform and compiler independent type).
int32_t tInt32
type definition for signed integer values (32bit) (platform and compiler independent type).
float tFloat32
type definition for Float32 (32bit float values) (platform and compiler independent type).
void tVoid
The tVoid is always the definition for the void (non-type).
int tInt
type definition for signed integer value (platform and compiler dependent type).
double tFloat64
type definition for Float64 (64bit double values) (platform and compiler independent type).
bool tBool
The tBool defines the type for the Values tTrue and tFalse (platform and compiler dependent).
uint32_t tUInt32
type definition for unsigned integer values (32bit) (platform and compiler independent type).
size_t tSize
type definition for a array size values, map size values etc.
constexpr tSize g_npos
npos size declaration
uint64_t tUInt64
type definition for unsigned integer values (64bit) (platform and compiler independent type).
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.
static tBool IsInteger(const tChar *strToCheck, tSize nLength=InvalidPos)
Check if string content represents an integer value.
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.
static tBool IsFloat(const tChar *strToCheck)
Check if string content represents a floating point value.
static tVoid HexToType(const tChar *strString, tInt64 &i64Value)
This function converts a hexadecimal string representation to an integer value.
static tVoid ToType(const tChar *strString, tInt32 &i32Value)
Escape control characters.
static tSize GetLength(const tChar *pcStr)
Returns the length of the string.
static const tChar * FromType(tInt32 i32Value, tChar *strBufferResult, tSize szBufferResult, const tChar *strFormat="")
This function creates a new cString object from a tInt32 value.
static tBool IsWhiteChar(tChar c)
This function checks if a given tChar value is a whitespace character.
static tBool IsOneOf(tChar cValue, const tChar *strTokenList)
Checks if the character is contained in the token list.
tBool IsEqual(const _myType &strCmp, tSize nPos=0, tSize nLength=InvalidPos) const
This function checks if the two strings are equal (case sensitive)
tVoid ToLower()
This function converts a cStringA object to a lowercase string.
tVoid Trim()
This function removes leading and trailing whitespace characters from a cStringA object.
string_base & operator=(const string_base< T2 > &strValue)
Constructor that initalizes an existing cString object with the spezified string value.
static const tSize InvalidPos
used to identicate out of range, invalidpos or default length
_StorageType::const_reverse_iterator const_reverse_iterator
short typedefinition for cString reverse iterators
_myType & Set(tChar c, tSize nCount)
Assigns a new value to a cStringA object.
tInt32 AsInt32() const
This function converts the string to an integer value.
tBool IsNotEqualNoCase(const _myType &strCmp, tSize nPos=0, tSize nLength=InvalidPos) const
This function checks if the two strings are not equal (case insensitive)
tSize Find(tChar cToFind, tSize nStart=0) const
This function searches the cStringA object for the first match of the specified character.
tVoid LeftTrim(tBool bNumTrim=tFalse)
This function removes leading whitespace characters or leading zero characters from a cStringA object...
tInt64 HexToInt64() const
This function converts a hexadecimal string representation to an integer value.
tVoid ToType(tUInt32 &ui32Value) const
This function converts the string to an integer value.
tVoid ToType(tBool &bValue) const
This function converts the string to a boolean value.
string_base & operator=(const _StorageType &strValue)
The cString assignment (=) operator assigns a new value to the existing cString object.
static _myType FromType(tFloat64 f64Value, const _myType &strFormat=Empty)
This function creates a new cString object from a numeric value.
tBool IsEqualNoCase(const _myType &strCmp, tSize nPos=0, tSize nLength=InvalidPos) const
This function checks if the two strings are equal (case insensitive)
tVoid ToType(tFloat64 &f64Value) const
This function converts the string to a floating-point value.
_myType & Insert(const _myType &strToInsertString, tSize nPos, tSize nLength=InvalidPos)
This function inserts a string into the cStringA object.
tChar & operator[](tSize nIdx)
array access operator
string_base()
Constructor that initializes an empty cStringA object.
tSize Filter(const _myType &strCharList)
This function removes all occurrences of each character given in a token list.
tVoid RightTrim()
This function removes trailing whitespace characters from a cStringA object.
tBool EndsWith(const _myType &strEndsWith, const tBool bNoCase=tFalse) const
This function checks if the string ends with a given postfix.
_StorageType::reverse_iterator reverse_iterator
short typedefinition for cString reverse iterators
static _myType FromType(tInt64 i64Value, const _myType &strFormat=Empty)
This function creates a new cString object from a numeric value.
_StorageType::iterator iterator
short typedefinition for cString iterators
_StorageType m_oStorageBuffer
storage buffer
tInt Compare(const tChar *strString, tSize nPos=0, tSize nLength=InvalidPos) const
This function compares a cStringA object with another string using the generic-text function _tcscmp.
tChar GetAt(tSize nIdx) const
You can think of a cStringA object as an array of characters.
tSize CountString(const _myType &strFind, tSize nStart=0) const
This counts the occurrences of a given substring in a string.
tSize GetMaxBufferSize() const
Return maximum size of string buffer.
const_iterator cbegin() const
Iterator to beginning.
tBool IsNotEmpty() const
This function checks if the string object is not empty.
static _myType Repeat(tChar c, tSize nCount)
Creates a string from a repeated character.
const _myType & operator+=(const _myType &strString)
The += concatenation operator joins characters to the end of this string.
tBool operator>(const tChar *pString) const
Checks if a string is lexicographically smaller than the cStringA object.
tSize Replace(const _myType &strOld, const _myType &strNew, tBool bReplaceAll=tTrue)
This function replaces one substring by another.
static _myType FromType(tBool bValue, const _myType &strFormat=Empty)
This function creates a new cString object from a boolean value.
tBool AsBool() const
This function converts the string to a boolean value.
tSize GetBufferSize() const
Get the size of the internal allocated string buffer.
tBool operator==(const _myType &strString) const
Checks if a string equals the cStringA object.
tUInt32 AsUInt32() const
This function converts the string to an integer value.
tFloat32 AsFloat32() const
This function converts the string to a floating-point value.
const tChar * GetPtr() const
This function returns the current string as an array of characters (c-style)
static _myType FromType(tFloat32 f32Value, const _myType &strFormat=Empty)
This function creates a new cString object from a numeric value.
static _myType & Copy(_myType &strDestination, const _myType &strSource, tSize szLength=InvalidPos)
Copies the value of one StringObject to another Stringobject.
tInt Compare(const _myType &strString, tSize nPos=0, tSize nLength=InvalidPos) const
This function compares a cStringA object with another string using the generic-text function _tcscmp.
_myType & Set(const _myType &strStringToSet, tSize nLength=InvalidPos)
Assigns a new value to a cStringA object.
string_base(const string_base< T2 > &strValue)
Constructor that initalizes an existing cString object with the spezified string value.
string_base< storageT > _myType
definition my type
tBool operator<(const tChar *pString) const
Checks if a string is lexicographically greater than the cStringA object.
tChar * GetBuffer()
This function returns the pointer to the data.
tVoid Split(string_list_base< _myType > &lstSplittedResult, const _myType &strToken) const
This function splits up a single cStringA object into several parts using a token string.
static _myType ToStringFromType(T oValue, const _myType &strFormat)
This function creates a new cString object from a numeric value.
tSize Filter(tChar cChar)
This function removes all occurrences of a given character from a string.
tSize Replace(tChar cOld, tChar cNew, tBool bReplaceAll=tTrue)
This function replaces one character by another.
tVoid ToType(tInt64 &i64Value) const
This function converts the string to an integer value.
tInt CompareNoCase(const _myType &strString, tSize nPos=0, tSize nLength=InvalidPos) const
This function compares a cStringA object with another string using the generic-text function _tcsicmp...
tVoid ToUpper()
This function converts a cStringA object to an uppercase string.
const tChar & operator[](tSize nIdx) const
array access operator
static _myType FromType(tUInt64 ui64Value, const _myType &strFormat=Empty)
This function creates a new cString object from a numeric value.
reverse_iterator rend()
Reverse iterator to end.
tInt64 AsInt64() const
This function converts the string to an integer value.
tSize GetLength() const
This function returns the number of characters in a cStringA object.
_myType Right(tSize nLength) const
Extracts the last (that is, rightmost) nLength characters from the cStringA object and returns a copy...
tBool operator!=(const _myType &strString) const
Checks if a string not equals the cStringA object.
virtual ~string_base()
Destructor.
const_reverse_iterator crbegin() const
Reverse iterator to beginning.
string_base(const _StorageType &strValue)
Constructor that initalizes an existing cString object with the spezified string value.
tBool IsInteger() const
Check if string content represents an integer value.
static _myType FromType(tInt32 i32Value, const _myType &strFormat=Empty)
This function creates a new cString object from a numeric value.
_myType SubString(tSize nPos, tSize nLength=InvalidPos) const
This function extracts a substring of length nLength characters from the cStringA object,...
static _myType Format(const value_type *strFormat,...)
Write formatted data to a string.
const_iterator cend() const
Iterator to end.
tVoid ToType(tInt32 &i32Value) const
This function converts the string to an integer value.
tBool operator<=(const tChar *pString) const
Checks if a string is lexicographically greater than or equal to the cStringA object.
string_base & operator=(const tChar *strValue)
The cString assignment (=) operator assigns a new value to the existing cString object.
_myType Mid(tSize nPos, tSize nLength=InvalidPos) const
This function extracts a substring of length nLength characters from the cStringA object,...
tVoid Clear()
Makes this cStringA object an empty string and frees memory as appropriate.
_StorageType::const_iterator const_iterator
short typedefinition for cString iterators
static _myType FromType(tUInt32 ui32Value, const _myType &strFormat=Empty)
This function creates a new cString object from a numeric value.
tBool StartsWith(const _myType &strStartsWith, const tBool bNoCase=tFalse) const
This function checks if the string starts with a given prefix.
tVoid Split(string_list_base< _myType > &lstSplittedResult, tChar cToken) const
This function splits up a single cStringA object into several parts using a token character.
tVoid NumTrim()
This function removes whitespace and redundant zero characters from a cStringA object.
tBool IsFloat() const
Check if string content represents a floating point value.
string_base & operator=(const tChar &strValue)
The cString assignment (=) operator assigns a new value to the existing cString object.
_myType & Append(const _myType &strString, tSize nLength=InvalidPos)
This function appends a string to the end of the cStringA object.
_StorageType::value_type value_type
definition of value type
tBool IsNotEqual(const _myType &strCmp, tSize nPos=0, tSize nLength=InvalidPos) const
This function checks if the two strings are not equal (case sensitive)
tSize RFind(tChar cChar, tSize nStart=0) const
This function searches the cStringA object for the last match of the specified character.
tBool IsEmpty() const
This function checks if the string object is empty.
tVoid HexToType(tInt64 &i64Value) const
This function converts a hexadecimal string representation to an integer value.
_myType & Append(tChar c)
This function appends one character to the end of the cStringA object.
tVoid SetAt(tSize nIdx, tChar c)
The SetAt member function sets a single character at a specified position.
string_base & operator=(_myType &&strValue)
The cString assignment (=) operator assigns a new value to the existing cString object.
string_base & operator=(const _myType &strValue)
The cString assignment (=) operator assigns a new value to the existing cString object.
string_base(const _myType &strValue)
Constructor that initalizes an existing cString object with the spezified string value.
tVoid DropQuotes()
This function removes quotes from a cStringA object.
const_reverse_iterator crend() const
Reverse iterator to end.
tBool IsNumeric() const
Check if string content represents a numeric value.
string_base(const tChar *strValue)
Constructor that initalizes an existing cString object with the spezified string value.
iterator end()
Iterator to end.
tSize SetBuffer(tSize szSize)
Sets or resizes the internal string buffer.
reverse_iterator rbegin()
Reverse iterator to beginning.
static const _myType Empty
Internally used empty string.
string_base(_myType &&strValue)
Constructor that initalizes an existing cString object with the spezified string value.
tSize FindNotToken(const _myType &strTokenList, tSize nStart=0) const
This function searches a string for the first character that matches none of the characters contained...
_myType & Unescape()
Escape control characters.
tBool operator==(const tChar *pString) const
Checks if a string equals the cStringA object.
iterator begin()
Iterator to beginning.
string_base(const tChar &strValue)
Constructor that initalizes an existing cString object with the spezified string value.
tBool operator>=(const tChar *pString) const
Checks if a string is lexicographically smaller than or equal to the cStringA object.
string_base(const tChar *strValue, tSize szLength)
Constructor that initalizes an existing cString object with the spezified string value.
tVoid ToType(tFloat32 &f32Value) const
This function converts the string to a floating-point value.
tBool operator>=(const _myType &strString) const
Checks if a string is lexicographically smaller than or equal to the cStringA object.
_myType & Escape()
Escape control characters.
tUInt64 AsUInt64() const
This function converts the string to an integer value.
tVoid SplitToken(string_list_base< _myType > &lstList, const _myType &strTokenList) const
Split string using a token list.
tFloat64 AsFloat64() const
This function converts the string to a floating-point value.
tBool operator<=(const _myType &strString) const
Checks if a string is lexicographically greater than or equal to the cStringA object.
_myType Left(tSize nLength) const
Extracts the first (that is, leftmost) nLength characters from the cStringA object and returns a copy...
tVoid ToType(tUInt64 &ui64Value) const
This function converts the string to an integer value.
storageT _StorageType
definition storage type
tBool operator!=(const tChar *pString) const
Checks if a string does not equal the cStringA object.
tSize FindToken(const _myType &strTokenList, tSize nStart=0) const
This function searches a string for the first character that matches any character contained in a tok...
_myType & Set(const tChar *pString, tSize nLength=InvalidPos)
Assigns a new value to a cStringA object.
_myType & Insert(const tChar *pToInsertString, tSize nPos, tSize nLength=InvalidPos)
This function inserts a string into the cStringA object.
_myType & Delete(tSize nPos, tSize nLength=InvalidPos)
This function deletes a substring of length nLength characters from the cStringA object,...
tSize Find(const _myType &strStringToFind, tSize nStart=0, const tBool bNoCase=tFalse) const
This function searches the cStringA object for the first match of a substring.
tResult Append(const storageT &strString)
This function appends one string to the list.
tVoid Clear()
This function cleans up the list and frees all allocated memory blocks.
#define tFalse
Value for tBool.
#define tTrue
Value for tBool.
ADTF A_UTIL Namespace - Within adtf this is used as adtf::util or adtf_util.
string_base_no_case_compare_func< cStackString, cStackString > cStringNoCaseCompareFunc
Compare functor for the cStackString.
simple_pointer_iterator< T >::difference_type operator+(const simple_pointer_iterator< T > &r1, const simple_pointer_iterator< T > &r2)
Define arithmetic + operation between iterators.
bool operator>=(const simple_pointer_iterator< T > &r1, const simple_pointer_iterator< T > &r2)
Define greater or equal to operator between iterators.
tBool operator==(const cMultiArrayIndex &o_A, const cMultiArrayIndex &o_B)
Comparison operator.
string_base< cStackString > cString
cString implementation for a stack string which works on stack if string is lower than A_UTILS_DEFAUL...
stack_string_base< A_UTILS_DEFAULT_SIZE_OF_STRING, growinheap_out_of_range > cStackString
cStackString implementation for a stack string which works on stack if string is lower than A_UTILS_D...
bool operator<(const simple_pointer_iterator< T > &r1, const simple_pointer_iterator< T > &r2)
Define lesser than operator between iterators.
tBool operator!=(const cMultiArrayIndex &o_A, const cMultiArrayIndex &o_B)
Comparison operator.
string_base_compare_func< cStackString, cStackString > cStringCompareFunc
Compare functor for the cStackString.
bool operator>(const simple_pointer_iterator< T > &r1, const simple_pointer_iterator< T > &r2)
Define greater than operator between iterators.
bool operator<=(const simple_pointer_iterator< T > &r1, const simple_pointer_iterator< T > &r2)
Define lesser or equal to operator between iterators.
std::string format(const char *str_format,...)
printf()-like formatting of an input string.
Compare function for stl container e.g.
tBool operator()(const string_base< sT > &str1, const string_base< sT2 > &str2) const
String compare function.
Compare function for stl container e.g.
tBool operator()(const string_base< sT > &str1, const string_base< sT2 > &str2) const
String compare function.