ADTF  3.18.2
stringutil.h
Go to the documentation of this file.
1 
7 #ifndef _STRINGUTIL_CLASS_HEADER_
8 #define _STRINGUTIL_CLASS_HEADER_
9 
10 #ifdef _MSC_VER
11  #include <sal.h>
12 #endif
13 
14 namespace A_UTILS_NS
15 {
21 class DOEXPORT cStringUtil
22 {
23  public:
25  static const tSize InvalidPos;
27  typedef tUInt64 tHashKey;
28  typedef tUInt32 tHashKey32;
29  protected:
31  static const tChar* m_pcSafeBuffer;
32  public:
33 
55  static tInt Compare(const tChar* str1,
56  const tChar* str2,
57  tSize nPos,
58  tSize nLength);
73  static tInt Compare(const tChar* str1,
74  const tChar* str2,
75  tSize nLength = InvalidPos);
76 
99  static tInt CompareNoCase(const tChar* str1,
100  const tChar* str2,
101  tSize nPos,
102  tSize nLength);
116  static tInt CompareNoCase(const tChar* str1,
117  const tChar* str2,
118  tSize nLength = InvalidPos);
119 
120 
121 
134  static tBool IsEqual(const tChar* str1,
135  const tChar* str2,
136  tSize nPos,
137  tSize nLength);
148  static tBool IsEqual(const tChar* str1,
149  const tChar* str2,
150  tSize nLength = InvalidPos);
151 
152 
153 
165  static tBool IsEqualNoCase(const tChar* str1,
166  const tChar* str2,
167  tSize nPos,
168  tSize nLength);
169 
180  static tBool IsEqualNoCase(const tChar* str1,
181  const tChar* str2,
182  tSize nLength = InvalidPos);
183 
199  static tBool IsInteger(const tChar* strToCheck, tSize nLength = InvalidPos);
200 
201 
215  static tBool IsFloat(const tChar* strToCheck);
216 
224  static tBool IsNumeric(const tChar* strToCheck);
225 
240  static tSize FindFirstOfToken(const tChar* strString, const tChar* strTokenList, tSize szStartPos = 0, tSize nLength = InvalidPos);
241 
256  static tSize RFindFirstOfToken(const tChar* strString, const tChar* strTokenList, tSize szStartPos = InvalidPos, tSize nLength = InvalidPos);
257 
272  static tSize FindFirstNotOfToken(const tChar* strString, const tChar* strTokenList, tSize szStartPos = 0, tSize nLength = InvalidPos);
273 
282  static tBool IsOneOf(tChar cValue, const tChar* strTokenList);
283 
294  static tChar* Repeat(tChar* strDest, tSize szDestSize, tSize nCount, tChar cCharacter);
295 
307  static tChar* PushFront(tChar* strDest, tSize szDestSize, const tChar* strSource, tSize nCount);
308 
319  static tChar* Delete(tChar* strString, tSize nPos, tSize nLength = InvalidPos);
320 
321  public:
322 
333 
345 
355  static tBool IsNumber(tChar c);
356 
368  static const tChar* FromType(tInt32 i32Value,
369  tChar* strBufferResult,
370  tSize szBufferResult,
371  const tChar* strFormat = "");
372 
384  static const tChar* FromType(tUInt32 ui32Value,
385  tChar* strBufferResult,
386  tSize szBufferResult,
387  const tChar* strFormat = "");
388 
399  static const tChar* FromType(tInt64 i64Value,
400  tChar* strBufferResult,
401  tSize szBufferResult,
402  const tChar* strFormat = "");
403 
414  static const tChar* FromType(tUInt64 ui64Value,
415  tChar* strBufferResult,
416  tSize szBufferResult,
417  const tChar* strFormat = "");
418 
429  static const tChar* FromType(tBool bValue,
430  tChar* strBufferResult,
431  tSize szBufferResult,
432  const tChar* strFormat);
433 
444  static const tChar* FromType(tFloat32 f32Value,
445  tChar* strBufferResult,
446  tSize szBufferResult,
447  const tChar* strFormat);
448 
459  static const tChar* FromType(tFloat64 f64Value,
460  tChar* strBufferResult,
461  tSize szBufferResult,
462  const tChar* strFormat);
463 
487  static tResult Format(
488 #ifdef _MSC_VER
489  _Out_writes_z_(szBufferResult)
490 #endif // _MSC_VER
491  tChar* strBufferResult,
492  tSize szBufferResult,
493 #ifdef _MSC_VER
494  _In_z_ _Printf_format_string_
495 #endif // _MSC_VER
496  const tChar* strFormat,
497  ...)
498 #ifdef __GNUC__
499  __attribute__((format(printf, 3, 4)))
500 #endif // __GNUC__
501  ;
502 
503 
510  //static std::string& Escape(std::string& strString);
511 
518  //static std::string& Unescape(std::string& strString);
519 
533  static tVoid ToType(const tChar* strString, tInt32& i32Value);
534 
550  static tVoid ToType(const tChar* strString, tUInt32& ui32Value);
551 
567  static tVoid ToType(const tChar* strString, tInt64& i64Value);
568 
583  static tVoid ToType(const tChar* strString, tUInt64& ui64Value);
584 
598  static tVoid ToType(const tChar* strString, tFloat64& f64Value);
599 
613  static tVoid ToType(const tChar* strString, tFloat32& f32Value);
614 
628  static tVoid ToType(const tChar* strString, tBool& bBool);
629 
641  static tVoid HexToType(const tChar* strString, tInt64& i64Value);
642 
673  static tChar* Copy(tChar* pstrDestination,
674  const tChar* pstrSource,
675  tSize nCount = InvalidPos,
676  tSize nDestinationBufferSize = InvalidPos);
677 
712  static tInt Scan(const tChar* strStringToScan, const tChar* sFormat, ...);
713 
727  static tVoid TrimFunc(tChar* strStringBuffer,
728  tSize nBufferLength,
729  const tBool bLeft,
730  const tBool bRight,
731  const tBool bNumeric);
732 
740  static tSize GetLength(const tChar* pcStr);
741 
749  static tHashKey GetHash(const tChar* strToHash);
750 
758  static tHashKey32 GetHash32(const tChar* strToHash);
759 };
760 
761 } // namespace A_UTILS_NS
762 
763 #endif // _STRINGUTIL_CLASS_HEADER_
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.
uint64_t tUInt64
type definition for unsigned integer values (64bit) (platform and compiler independent type).
String Helper Class.
Definition: stringutil.h:22
static const tChar * FromType(tBool bValue, tChar *strBufferResult, tSize szBufferResult, const tChar *strFormat)
This function creates a new cString object from a boolean value.
static tVoid ToType(const tChar *strString, tFloat64 &f64Value)
This function converts the string to a floating-point value.
static tVoid ToType(const tChar *strString, tInt64 &i64Value)
This function converts the string to an integer value.
static const tSize InvalidPos
used to identicate out of range, invalidpos or default length
Definition: stringutil.h:25
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 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 contain...
static tVoid HexToType(const tChar *strString, tInt64 &i64Value)
This function converts a hexadecimal string representation to an integer value.
static tResult Format(tChar *strBufferResult, tSize szBufferResult, const tChar *strFormat,...)
Write formatted data to a string.
static const tChar * FromType(tInt64 i64Value, tChar *strBufferResult, tSize szBufferResult, const tChar *strFormat="")
This function creates a new cString object from a tInt64 value.
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.
static tVoid ToType(const tChar *strString, tUInt32 &ui32Value)
This function converts the string to an integer value.
static tBool IsNumber(tChar c)
This function checks if a tChar is a number.
static tChar * Delete(tChar *strString, tSize nPos, tSize nLength=InvalidPos)
This function deletes characters from a string.
static tVoid ToType(const tChar *strString, tInt32 &i32Value)
Escape control characters.
static const tChar * FromType(tFloat32 f32Value, tChar *strBufferResult, tSize szBufferResult, const tChar *strFormat)
This function creates a new cString object from a float value.
static tSize GetLength(const tChar *pcStr)
Returns the length of the string.
static tBool IsEqualNoCase(const tChar *str1, const tChar *str2, tSize nPos, tSize nLength)
This function checks if the two strings are equal (case insensitive)
static tBool IsSymbolChar(tChar c)
This function checks if a given tChar value is valid to be used in a symbol name.
static tChar * Copy(tChar *pstrDestination, const tChar *pstrSource, tSize nCount=InvalidPos, tSize nDestinationBufferSize=InvalidPos)
Copies a null terminated string to another string buffer.
static const tChar * FromType(tInt32 i32Value, tChar *strBufferResult, tSize szBufferResult, const tChar *strFormat="")
This function creates a new cString object from a tInt32 value.
tUInt64 tHashKey
Defines the Type for the Hashkey generated with GetHash.
Definition: stringutil.h:27
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 contai...
static tVoid ToType(const tChar *strString, tUInt64 &ui64Value)
This function converts the string to an integer value.
static const tChar * FromType(tUInt32 ui32Value, tChar *strBufferResult, tSize szBufferResult, const tChar *strFormat="")
This function creates a new cString object from a tUInt32 value.
static tInt Compare(const tChar *str1, const tChar *str2, tSize nLength=InvalidPos)
This function compares two given strings using the generic-text function _tcscmp.
static tHashKey GetHash(const tChar *strToHash)
Creates a hash key from the string.
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 co...
static tBool IsEqual(const tChar *str1, const tChar *str2, tSize nLength=InvalidPos)
This function checks if the two strings are equal (case sensitive)
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.
static tBool IsWhiteChar(tChar c)
This function checks if a given tChar value is a whitespace character.
static const tChar * FromType(tFloat64 f64Value, tChar *strBufferResult, tSize szBufferResult, const tChar *strFormat)
This function creates a new cString object from a double value.
static tVoid ToType(const tChar *strString, tBool &bBool)
This function converts the string to a boolean value.
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.
static tBool IsEqual(const tChar *str1, const tChar *str2, tSize nPos, tSize nLength)
This function checks if the two strings are equal (case sensitive)
static tBool IsEqualNoCase(const tChar *str1, const tChar *str2, tSize nLength=InvalidPos)
This function checks if the two strings are equal (case insensitive)
static tVoid ToType(const tChar *strString, tFloat32 &f32Value)
This function converts the string to a floating-point value.
static const tChar * m_pcSafeBuffer
Internally used character buffer.
Definition: stringutil.h:31
static tBool IsOneOf(tChar cValue, const tChar *strTokenList)
Checks if the character is contained in the token list.
static tBool IsNumeric(const tChar *strToCheck)
Check if string content represents a numeric value.
static tChar * Repeat(tChar *strDest, tSize szDestSize, tSize nCount, tChar cCharacter)
Fill a string with a repetitive character sequence.
static const tChar * FromType(tUInt64 ui64Value, tChar *strBufferResult, tSize szBufferResult, const tChar *strFormat="")
This function creates a new cString object from a tUInt64 value.
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 argu...
static tHashKey32 GetHash32(const tChar *strToHash)
Creates a hash key from the string.
ADTF A_UTIL Namespace - Within adtf this is used as adtf::util or adtf_util.
Definition: d_ptr.h:11
std::string format(const char *str_format,...)
printf()-like formatting of an input string.