ADTF  3.18.2
string.h
Go to the documentation of this file.
1 
7 #ifndef _STRINGTEMPLATE_CLASS_HEADER_
8 #define _STRINGTEMPLATE_CLASS_HEADER_
9 
10 #include <cstdio>
11 #include <cstdarg>
12 #ifdef _MSC_VER
13  #include <sal.h>
14 #endif
15 
16 namespace A_UTILS_NS
17 {
18 
20 template <class storageT> class string_list_base;
21 
29 template <class storageT>
31 {
32  public:// public definitions
33  //StorageType
37  typedef storageT _StorageType;
38 
39  //has to be of type tChar, char or tUInt8
41  typedef typename _StorageType::value_type value_type;
42 
44  typedef typename _StorageType::iterator iterator;
46  typedef typename _StorageType::const_iterator const_iterator;
48  typedef typename _StorageType::reverse_iterator reverse_iterator;
50  typedef typename _StorageType::const_reverse_iterator const_reverse_iterator;
51 
52  public:
54  static const _myType Empty;
56  static const tSize InvalidPos;
57  private:
60 
61  public:
68  {
69  Clear();
70  }
76  string_base(const _myType& strValue)
77  {
78  Set(strValue);
79  }
89  string_base& operator=(const _myType& strValue)
90  {
91  Set(strValue);
92  return *this;
93  }
99  string_base(_myType&& strValue)
100  {
101  Set(strValue);
102  }
105  {
106  Set(strValue);
107  return *this;
108  }
110  template<class T2>
111  string_base(const string_base<T2>& strValue)
112  {
113  Set(strValue.GetPtr());
114  }
116  template<class T2>
118  {
119  Set(strValue.GetPtr());
120  return *this;
121  }
123  string_base(const _StorageType& strValue)
124  {
125  m_oStorageBuffer = strValue;
126  }
129  {
130  m_oStorageBuffer = strValue;
131  return *this;
132  }
134  string_base(const tChar& strValue)
135  {
136  Set(strValue, 1);
137  }
139  string_base& operator=(const tChar& strValue)
140  {
141  Set(strValue, 1);
142  return *this;
143  }
145  string_base(const tChar* strValue)
146  {
147  Set(strValue);
148  }
155  string_base(const tChar* strValue, tSize szLength)
156  {
157  Set(strValue, szLength);
158  }
160  string_base& operator=(const tChar* strValue)
161  {
162  Set(strValue);
163  return *this;
164  }
170  virtual ~string_base()
171  {
172  //value_type must be tChar or tUInt8
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 !!");
176  }
177 
180  {
181  return m_oStorageBuffer.begin();
182  }
185  {
186  return m_oStorageBuffer.end();
187  }
190  {
191  return m_oStorageBuffer.rbegin();
192  }
195  {
196  return m_oStorageBuffer.rend();
197  }
200  {
201  return m_oStorageBuffer.cbegin();
202  }
205  {
206  return m_oStorageBuffer.cend();
207  }
210  {
211  return m_oStorageBuffer.crbegin();
212  }
215  {
216  return m_oStorageBuffer.crend();
217  }
218 
225  {
226  m_oStorageBuffer.clear();
227  }
228 
240  _myType& Set(const _myType& strStringToSet, tSize nLength = InvalidPos)
241  {
242  if (nLength == InvalidPos)
243  {
244  m_oStorageBuffer.assign(strStringToSet.m_oStorageBuffer);
245  }
246  else
247  {
248  m_oStorageBuffer.assign(strStringToSet.m_oStorageBuffer, 0, nLength);
249  }
250  return *this;
251  }
252 
263  _myType& Set(const tChar* pString, tSize nLength = InvalidPos)
264  {
265  if (pString != nullptr)
266  {
267  if (nLength == InvalidPos)
268  {
269  m_oStorageBuffer.assign(pString);
270  }
271  else
272  {
273  m_oStorageBuffer.assign(pString, nLength);
274  }
275  }
276  return *this;
277  }
278 
289  _myType& Set(tChar c, tSize nCount)
290  {
291  if (nCount > 0 && nCount != InvalidPos)
292  {
293  m_oStorageBuffer.assign(nCount, c);
294  }
295 
296  return *this;
297  }
298 
309  tSize GetLength() const
310  {
311  return cStringUtil::GetLength(GetPtr());
312  }
313 
329  {
330  if (szSize != InvalidPos)
331  {
332  m_oStorageBuffer.resize(szSize);
333  if (GetBufferSize() >= szSize)
334  {
335  return szSize;
336  }
337  else
338  {
339  return InvalidPos;
340  }
341  }
342  else
343  {
344  return szSize;
345  }
346  }
347 
357  {
358  return m_oStorageBuffer.capacity();
359  }
360 
377  tChar GetAt(tSize nIdx) const
378  {
379  if (nIdx >= GetLength())
380  {
381  return '\0';
382  }
383  return m_oStorageBuffer[nIdx];
384  }
385 
399  {
400  if (nIdx >= GetLength())
401  {
402  return;
403  }
404  m_oStorageBuffer[nIdx] = c;
405  }
406 
414  const tChar& operator[](tSize nIdx) const
415  {
416  return m_oStorageBuffer[nIdx];
417  }
418 
427  {
428  return m_oStorageBuffer[nIdx];
429  }
430 
431 
432 
441  tBool IsEmpty() const
442  {
443  return (cStringUtil::GetLength(GetPtr()) == 0);
444  }
445 
455  {
456  return !IsEmpty();
457  }
458 
467  const tChar* GetPtr() const
468  {
469  return m_oStorageBuffer.c_str();
470  }
471 
481  {
482  return m_oStorageBuffer.data();
483  }
484 
497  _myType& Append(const _myType& strString, tSize nLength = InvalidPos)
498  {
499  tSize szLength = GetLength();
500  if (szLength < m_oStorageBuffer.length())
501  {
502  //we will insert if the buffer is damaged by the 0-termination append cheese of STL
503  if (nLength == InvalidPos)
504  {
505  m_oStorageBuffer.insert(szLength, strString.m_oStorageBuffer, 0, strString.GetLength());
506  }
507  else
508  {
509  m_oStorageBuffer.insert(szLength, strString.m_oStorageBuffer, 0, nLength);
510  }
511  }
512  else
513  {
514  if (nLength == InvalidPos)
515  {
516  m_oStorageBuffer.append(strString.m_oStorageBuffer);
517  }
518  else
519  {
520  m_oStorageBuffer.append(strString.m_oStorageBuffer, 0, nLength);
521  }
522  }
523  return *this;
524  }
525 
538  {
539  if (c != '\0')
540  {
541  //strange handling within the STL append will append to the Buffer!! not to the string
542  //0-Termination will be damaged !!
543  tSize szLastPos = GetLength();
544  if (m_oStorageBuffer.length() > szLastPos)
545  {
546  m_oStorageBuffer[szLastPos] = c;
547  if (m_oStorageBuffer.length() > (szLastPos+1))
548  {
549  m_oStorageBuffer[szLastPos+1] = '\0';
550  }
551  else
552  {
553  m_oStorageBuffer.append(1, '\0');
554  }
555  }
556  else
557  {
558  m_oStorageBuffer.append(1, c);
559  }
560  }
561  return *this;
562  }
563 
578  _myType& Delete(tSize nPos, tSize nLength = InvalidPos)
579  {
580  if (nPos == InvalidPos)
581  {
582  nPos = 0;
583  }
584  // nothing to delete in an emtpy string
585  if (IsEmpty())
586  {
587  //do nothing
588  }
589  else if (nPos == 0 && nLength == InvalidPos)
590  {
591  Clear();
592  }
593  else if (nLength == InvalidPos)
594  {
595  if (nPos < GetLength())
596  {
597  m_oStorageBuffer.erase(nPos);
598  }
599  else
600  {
601  //do nothing
602  }
603  }
604  else if (nPos == 0)
605  {
606  m_oStorageBuffer.erase(0, nLength);
607  }
608  else
609  {
610  if (nPos < GetLength())
611  {
612  m_oStorageBuffer.erase(nPos, nLength);
613  }
614  else
615  {
616  //do nothing
617  }
618  }
619  return *this;
620  }
621 
634  _myType& Insert(const _myType& strToInsertString, tSize nPos, tSize nLength = InvalidPos)
635  {
636  if (nPos == InvalidPos || nPos >= GetLength())
637  {
638  return Append(strToInsertString, nLength);
639  }
640  else
641  {
642  m_oStorageBuffer.insert(nPos, strToInsertString.m_oStorageBuffer, 0, nLength);
643  return *this;
644  }
645  }
646 
647 
660  _myType& Insert(const tChar* pToInsertString, tSize nPos, tSize nLength = InvalidPos)
661  {
662  if (pToInsertString != nullptr)
663  {
664  return Insert(_myType(pToInsertString), nPos, nLength);
665  }
666  return *this;
667  }
668 
689  tInt Compare(const _myType& strString,
690  tSize nPos = 0,
691  tSize nLength = InvalidPos) const
692  {
693  return cStringUtil::Compare(GetPtr(), strString.GetPtr(), nPos, nLength);
694  }
710  tInt Compare(const tChar* strString,
711  tSize nPos = 0,
712  tSize nLength = InvalidPos) const
713  {
714  return cStringUtil::Compare(GetPtr(), strString, nPos, nLength);
715  }
716 
738  tInt CompareNoCase(const _myType& strString,
739  tSize nPos = 0,
740  tSize nLength = InvalidPos) const
741  {
742  return cStringUtil::CompareNoCase(GetPtr(), strString.GetPtr(), nPos, nLength);
743  }
744 
755  tBool IsEqual(const _myType &strCmp,
756  tSize nPos = 0,
757  tSize nLength = InvalidPos) const
758  {
759  return(Compare(strCmp, nPos, nLength) == 0) ? tTrue : tFalse;
760  }
761 
762 
773  tBool IsEqualNoCase(const _myType &strCmp,
774  tSize nPos = 0,
775  tSize nLength = InvalidPos) const
776  {
777  return(cStringUtil::CompareNoCase(GetPtr(), strCmp.GetPtr(), nPos, nLength) == 0) ? tTrue : tFalse;
778  }
779 
790  tBool IsNotEqual(const _myType &strCmp,
791  tSize nPos = 0,
792  tSize nLength = InvalidPos) const
793  {
794  return(Compare(strCmp, nPos, nLength) == 0) ? tFalse : tTrue;
795  }
796 
797 
809  tSize nPos = 0,
810  tSize nLength = InvalidPos) const
811  {
812  return(CompareNoCase(strCmp, nPos, nLength) == 0) ? tFalse : tTrue;
813  }
814 
831  tSize Find(const _myType& strStringToFind,
832  tSize nStart = 0,
833  const tBool bNoCase = tFalse) const
834  {
835  if (bNoCase)
836  {
837  _myType strTmp, strCompare;
838  strTmp = *this;
839  strTmp.ToLower();
840  strCompare = *this;
841  strCompare.ToLower();
842  return strTmp.Find(strCompare, nStart);
843  }
844 
845  return m_oStorageBuffer.find(strStringToFind.m_oStorageBuffer, nStart);
846  }
863  tSize Find(tChar cToFind, tSize nStart = 0) const
864  {
865  return Find(_myType(cToFind), nStart, tFalse);
866  }
867 
884  tSize RFind(tChar cChar, tSize nStart = 0) const
885  {
886  if (nStart == 0)
887  {
888  return m_oStorageBuffer.rfind(cChar);
889  }
890 
891  return m_oStorageBuffer.rfind(cChar, GetLength() - nStart);
892  }
893 
908  tSize FindToken(const _myType& strTokenList, tSize nStart = 0) const
909  {
910  if (IsEmpty())
911  {
912  return InvalidPos;
913  }
914 
915  if (nStart == 0)
916  {
917  return m_oStorageBuffer.find_first_of(strTokenList.m_oStorageBuffer);
918  }
919 
920  return m_oStorageBuffer.find_first_of(strTokenList.m_oStorageBuffer, nStart);
921  }
922 
937  tSize FindNotToken(const _myType& strTokenList, tSize nStart = 0) const
938  {
939  if (IsEmpty())
940  {
941  return InvalidPos;
942  }
943 
944  if (nStart == 0)
945  {
946  return m_oStorageBuffer.find_first_not_of(strTokenList.m_oStorageBuffer);
947  }
948 
949  return m_oStorageBuffer.find_first_not_of(strTokenList.m_oStorageBuffer, nStart);
950  }
951 
962  tSize CountString(const _myType& strFind, tSize nStart = 0) const
963  {
964  tSize nFindSize = strFind.GetLength();
965  if (IsEmpty() || nFindSize == 0)
966  {
967  return InvalidPos;
968  }
969 
970  tSize nCnt = 0;
971  while (nStart != InvalidPos)
972  {
973  nStart = Find(strFind, nStart);
974  if (nStart != InvalidPos)
975  {
976  nStart += nFindSize;
977  nCnt++;
978  }
979  }
980  return nCnt;
981  }
982 
995  tSize Replace(const _myType& strOld, const _myType& strNew, tBool bReplaceAll = tTrue)
996  {
997  if (IsEmpty() || strOld.IsEmpty())
998  {
999  return 0;
1000  }
1001 
1002  tSize nReplaceCount = 0;
1003 
1004  _myType strBuffer;
1005  tSize nSearchLen = strOld.GetLength();
1006  tSize nPos;
1007  tSize nStartPos = 0;
1008  do
1009  {
1010  nPos = Find(strOld, nStartPos);
1011  if (nPos != InvalidPos)
1012  {
1013  strBuffer.Append(Mid(nStartPos, (nPos - nStartPos)));
1014  strBuffer.Append(strNew);
1015  nStartPos = nPos + nSearchLen;
1016  nReplaceCount++;
1017  if (!bReplaceAll)
1018  {
1019  strBuffer.Append(Mid(nStartPos));
1020  break;
1021  }
1022  }
1023  else
1024  {
1025  strBuffer.Append(Mid(nStartPos));
1026  }
1027 
1028  } while (nPos != InvalidPos);
1029 
1030  m_oStorageBuffer.swap(strBuffer.m_oStorageBuffer);
1031  return nReplaceCount;
1032  }
1033 
1047  tSize Replace(tChar cOld, tChar cNew,tBool bReplaceAll = tTrue)
1048  {
1049  if (IsEmpty())
1050  {
1051  return 0;
1052  }
1053 
1054  tSize nReplacements = 0;
1055  _myType::iterator oIt = begin();
1056  _myType::iterator oItEnd = end();
1057  for (; oIt != oItEnd; ++oIt)
1058  {
1059  if (*oIt == cOld)
1060  {
1061  *oIt = cNew;
1062  ++nReplacements;
1063  if (!bReplaceAll)
1064  {
1065  break;
1066  }
1067  }
1068  }
1069  return nReplacements;
1070  }
1071 
1082  {
1083  return Filter(_myType(cChar));
1084  }
1085 
1097  tSize Filter(const _myType& strCharList)
1098  {
1099  if (IsEmpty())
1100  {
1101  return 0;
1102  }
1103 
1104  tSize nSize = GetLength();
1105  _myType strTmp;
1106  strTmp.SetBuffer(nSize);
1107  tSize nFiltered = 0;
1108  for (tSize nPos = 0; nPos < nSize; ++nPos)
1109  {
1110  tChar cCurrent = GetAt(nPos);
1111  if (strCharList.Find(cCurrent) == InvalidPos)
1112  {
1113  strTmp.Append(cCurrent);
1114  }
1115  else
1116  {
1117  ++nFiltered;
1118  }
1119  }
1120 
1121  m_oStorageBuffer.swap(strTmp.m_oStorageBuffer);
1122  return nFiltered;
1123  }
1124 
1131  tBool StartsWith(const _myType& strStartsWith, const tBool bNoCase = tFalse) const
1132  {
1133  if (strStartsWith.IsEmpty() || strStartsWith.GetLength() > GetLength())
1134  {
1135  return tFalse;
1136  }
1137 
1138  if (bNoCase)
1139  {
1140  return (CompareNoCase(strStartsWith, 0, strStartsWith.GetLength()) == 0);
1141  }
1142  else
1143  {
1144  return (Compare(strStartsWith, 0, strStartsWith.GetLength()) == 0);
1145  }
1146  }
1147 
1148  tSize RSplitByToken(const tChar cToken, _myType& strFirst, _myType& strSecond) const
1149  {
1150  tSize szRight = RFind(cToken);
1151  if (szRight != InvalidPos)
1152  {
1153  strFirst = Left(szRight);
1154  strSecond = Right(GetLength() - (szRight + 1));
1155  }
1156  return szRight;
1157  }
1158 
1159  tSize SplitByToken(const tChar cToken, _myType& strFirst, _myType& strSecond) const
1160  {
1161  tSize szRight = Find(cToken);
1162  if (szRight != InvalidPos)
1163  {
1164  strFirst = Left(szRight);
1165  strSecond = Right(GetLength() - (szRight + 1));
1166  }
1167  return szRight;
1168  }
1169 
1176  tBool EndsWith(const _myType& strEndsWith, const tBool bNoCase = tFalse) const
1177  {
1178  //@TODO: Compare can be done without new memory allocation!!
1179  tSize szStringLength = GetLength();
1180  if (szStringLength == 0
1181  || (strEndsWith.GetLength() > szStringLength))
1182  {
1183  return tFalse;
1184  }
1185 
1186  _myType strPart = Right(strEndsWith.GetLength());
1187  if (bNoCase)
1188  {
1189  return strPart.IsEqualNoCase(strEndsWith);
1190  }
1191  else
1192  {
1193  return strPart.IsEqual(strEndsWith);
1194  }
1195  }
1196 
1208  operator const tChar*() const
1209  {
1210  return GetPtr();
1211  }
1212 
1213 
1214 
1215 
1216 
1228  const _myType& operator+= (const _myType& strString)
1229  {
1230  Append(strString);
1231  return *this;
1232  }
1233 
1240  tBool operator==(const tChar* pString) const
1241  {
1242  return (cStringUtil::Compare(GetPtr(), pString) == 0);
1243  }
1244 
1251  tBool operator!=(const tChar* pString) const
1252  {
1253  return (cStringUtil::Compare(GetPtr(), pString) != 0);
1254  }
1255 
1262  tBool operator< (const tChar* pString) const
1263  {
1264  return (cStringUtil::Compare(GetPtr(), pString) < 0);
1265  }
1266 
1273  tBool operator> (const tChar* pString) const
1274  {
1275  return (cStringUtil::Compare(GetPtr(), pString) > 0);
1276  }
1277 
1285  tBool operator<=(const tChar* pString) const
1286  {
1287  return (cStringUtil::Compare(GetPtr(), pString) <= 0);
1288  }
1289 
1297  tBool operator>=(const tChar* pString) const
1298  {
1299  return (cStringUtil::Compare(GetPtr(), pString) >= 0);
1300  }
1301 
1302 
1309  tBool operator==(const _myType& strString) const
1310  {
1311  return (Compare(strString) == 0);
1312  }
1313 
1320  tBool operator!=(const _myType& strString) const
1321  {
1322  return (Compare(strString) != 0);
1323  }
1324 
1331  tBool operator< (const _myType& strString) const
1332  {
1333  return (Compare(strString) < 0);
1334  }
1335 
1342  tBool operator> (const _myType& strString) const
1343  {
1344  return (Compare(strString) > 0);
1345  }
1346 
1354  tBool operator<=(const _myType& strString) const
1355  {
1356  return (Compare(strString) <= 0);
1357  }
1358 
1366  tBool operator>=(const _myType& strString) const
1367  {
1368  return (Compare(strString) >= 0);
1369  }
1370 
1387  _myType SubString(tSize nPos, tSize nLength = InvalidPos) const
1388  {
1389  if (nPos > GetLength())
1390  {
1391  return Empty;
1392  }
1393  return m_oStorageBuffer.substr(nPos, nLength);
1394  }
1395 
1396 
1397 
1415  _myType Mid(tSize nPos, tSize nLength = InvalidPos) const
1416  {
1417  if (IsEmpty() || nPos >= GetLength() || nPos == InvalidPos)
1418  {
1419  return Empty;
1420  }
1421  _myType strRes;
1422  if (nLength == InvalidPos)
1423  {
1424  strRes = SubString(nPos);
1425  }
1426  else
1427  {
1428  strRes = SubString(nPos, nLength);
1429  }
1430  return strRes;
1431  }
1432 
1448  _myType Left(tSize nLength) const
1449  {
1450  return SubString(0, nLength);
1451  }
1452 
1468  _myType Right(tSize nLength) const
1469  {
1470  tSize nPos = (GetLength() - nLength);
1471  if (GetLength() < nLength)
1472  {
1473  nPos = 0;
1474  }
1475  else
1476  {
1477  nPos = GetLength() - nLength;
1478  }
1479  return SubString(nPos, nLength);
1480  }
1481 
1482 
1483 
1495  tVoid Split(string_list_base<_myType>& lstSplittedResult, tChar cToken) const
1496  {
1497  Split(lstSplittedResult, _myType(cToken));
1498  }
1499 
1512  tVoid Split(string_list_base<_myType>& lstSplittedResult, const _myType& strToken) const
1513  {
1514  lstSplittedResult.Clear();
1515  if (IsEmpty())
1516  {
1517  return;
1518  }
1519 
1520  tSize nTokenLen = strToken.GetLength();
1521  tSize nPos = InvalidPos;
1522  tSize nStartPos;
1523  tSize nToSplitStringSize = GetLength();
1524  do
1525  {
1526  nStartPos = nPos + 1;
1527  nPos = Find(strToken, nStartPos);
1528  if (nPos != InvalidPos)
1529  {
1530  if (nPos != 0)
1531  {
1532  lstSplittedResult.Append(Mid(nStartPos, nPos - nStartPos));
1533  }
1534  else
1535  {
1536  lstSplittedResult.Append(_myType(""));
1537  }
1538  nPos += nTokenLen - 1;
1539  }
1540  else
1541  {
1542  if (nStartPos < nToSplitStringSize)
1543  {
1544  lstSplittedResult.Append(Mid(nStartPos));
1545  }
1546  else if (EndsWith(strToken))
1547  {
1548  lstSplittedResult.Append(_myType(""));
1549  }
1550  break;
1551  }
1552  } while (nPos != InvalidPos);
1553  }
1554 
1555 
1569  tVoid SplitToken(string_list_base<_myType>& lstList, const _myType& strTokenList) const
1570  {
1571  lstList.Clear();
1572 
1573  _myType strPart;
1574 
1575  tSize nLastPos = 0;
1576  tSize nPos = 0;
1577  while (nPos != InvalidPos)
1578  {
1579  nPos = FindToken(strTokenList, nLastPos);
1580  if (nPos == InvalidPos)
1581  {
1582  strPart = Mid(nLastPos);
1583  if (strPart.IsNotEmpty())
1584  {
1585  lstList.Append(strPart);
1586  }
1587  break;
1588  }
1589  else
1590  {
1591  if (nPos > nLastPos)
1592  {
1593  strPart = Mid(nLastPos, nPos - nLastPos);
1594  lstList.Append(strPart);
1595  }
1596  nLastPos = nPos + 1;
1597  }
1598  }
1599  }
1600 
1608  {
1609  LeftTrim();
1610  RightTrim();
1611  }
1612 
1623  {
1624  tSize szLength = 0;
1625  tBool bLast0 = tFalse;
1626  iterator it = begin();
1627  for (;
1628  it != end() && (cStringUtil::IsWhiteChar(*it) || (bNumTrim && *it == '0'));
1629  it++)
1630  {
1631  if (*it == '0')
1632  {
1633  bLast0 = tTrue;
1634  }
1635  else
1636  {
1637  bLast0 = tFalse;
1638  }
1639  szLength++;
1640  }
1641  if (it != end() && bNumTrim && bLast0 && cStringUtil::IsOneOf(*it,".,"))
1642  {
1643  szLength--;
1644  }
1645  Delete(0, szLength);
1646  }
1647 
1653  {
1654  tSize szLength = 0;
1655  for (reverse_iterator it = rbegin();
1656  it != rend() && cStringUtil::IsWhiteChar(*it);
1657  it++)
1658  {
1659  szLength++;
1660  }
1661  Delete(GetLength() - szLength, InvalidPos);
1662  }
1663 
1671  {
1672  //@TODO : should be optimized
1673  LeftTrim(tTrue);
1674  RightTrim();
1675 
1676  if (IsEmpty())
1677  {
1678  return;
1679  }
1680 
1681  tSize nPoint = FindToken(_myType(".,"));
1682  if (nPoint != InvalidPos)
1683  {
1684  tSize nPos = GetLength() - 1;
1685  tChar c;
1686  tBool bLastWasZero = tFalse;
1687  while (nPos != InvalidPos)
1688  {
1689  c = GetAt(nPos);
1690  if (c == '0')
1691  {
1692  bLastWasZero = tTrue;
1693  }
1694  else if (c == ' ')
1695  {
1696  bLastWasZero = tFalse;
1697  }
1698  else
1699  {
1700  if (cStringUtil::IsOneOf(c, ".,") && bLastWasZero) // keep trailing zero
1701  {
1702  nPos++;
1703  }
1704 
1705  break;
1706  }
1707  nPos--;
1708  }
1709  Delete(nPos + 1);
1710  }
1711  }
1712 
1720  {
1721  if (IsEmpty())
1722  {
1723  return;
1724  }
1725 
1726  tSize nEndPos = GetLength() - 1;
1727 
1728  if (*rbegin() == '\"' || *rbegin() == '\'')
1729  {
1730  Delete(nEndPos, 1);
1731  }
1732 
1733  if (*begin() == '\"' || *begin() == '\'')
1734  {
1735  Delete(0, 1);
1736  }
1737  }
1738 
1746  {
1747  if (IsEmpty())
1748  {
1749  return;
1750  }
1751  for (auto it = begin();
1752  it != end();
1753  ++it)
1754  {
1755  // tolower delivers an int, but we can assume that it fits into char
1756  *it = static_cast<tChar>(::tolower(*it));
1757  }
1758 
1759  }
1760 
1768  {
1769  if (IsEmpty())
1770  {
1771  return;
1772  }
1773  for (auto it = begin();
1774  it != end();
1775  ++it)
1776  {
1777  *it = ::toupper(static_cast<tChar>(*it));
1778  }
1779  }
1780 
1788  {
1789  //@TODO : this needs to be rework using stack!!
1790  if (IsEmpty())
1791  {
1792  return *this;
1793  }
1794 
1795  _myType oTemp;
1796  oTemp.SetBuffer(GetLength() * 2 + 1);
1797 
1798  iterator ptr2 = oTemp.begin();
1799  const tChar* ptr = GetPtr();
1800 
1801  tChar c1, c2;
1802  tBool bEscaped;
1803  tSize szEnd = oTemp.GetBufferSize();
1804  tSize szCounter = 0;
1805  while (*ptr != '\0' && szCounter < szEnd)
1806  {
1807  c1 = *ptr;
1808  bEscaped = tTrue;
1809  switch (c1)
1810  {
1811  case '\a':
1812  c2 = 'a';
1813  break;
1814  case '\b':
1815  c2 = 'b';
1816  break;
1817  case '\f':
1818  c2 = 'f';
1819  break;
1820  case '\n':
1821  c2 = 'n';
1822  break;
1823  case '\r':
1824  c2 = 'r';
1825  break;
1826  case '\t':
1827  c2 = 't';
1828  break;
1829  case '\v':
1830  c2 = 'v';
1831  break;
1832  case '\'':
1833  c2 = '\'';
1834  break;
1835  case '\"':
1836  c2 = '\"';
1837  break;
1838  case '\\':
1839  c2 = '\\';
1840  break;
1841  case '\?':
1842  c2 = '\?';
1843  break;
1844  default:
1845  c2 = c1;
1846  bEscaped = tFalse;
1847  break;
1848  }
1849 
1850  if (bEscaped)
1851  {
1852  *(ptr2++) = '\\';
1853  }
1854 
1855  *(ptr2++) = c2;
1856 
1857  ptr++;
1858  }
1859 
1860  *ptr2 = '\0';
1861 
1862  Set(oTemp);
1863  return *this;
1864  }
1865 
1873  {
1874  //@TODO : this needs to be rework using stack only!!
1875  if (IsEmpty())
1876  {
1877  return (*this);
1878  }
1879 
1880  _myType oTemp;
1881  oTemp.SetBuffer(GetLength() + 1);
1882 
1883  iterator ptr2 = oTemp.begin();
1884  const tChar* ptr = GetPtr();
1885 
1886  tChar c1, c2;
1887  while (*ptr != '\0')
1888  {
1889  if (*ptr != '\\')
1890  {
1891  *(ptr2++) = *ptr;
1892  }
1893  else
1894  {
1895  ptr++;
1896  c1 = *ptr;
1897  switch (c1)
1898  {
1899  case 'a':
1900  c2 = '\a';
1901  break;
1902  case 'b':
1903  c2 = '\b';
1904  break;
1905  case 'f':
1906  c2 = '\f';
1907  break;
1908  case 'n':
1909  c2 = '\n';
1910  break;
1911  case 'r':
1912  c2 = '\r';
1913  break;
1914  case 't':
1915  c2 = '\t';
1916  break;
1917  case 'v':
1918  c2 = '\v';
1919  break;
1920  case '\'':
1921  c2 = '\'';
1922  break;
1923  case '\"':
1924  c2 = '\"';
1925  break;
1926  case '\\':
1927  c2 = '\\';
1928  break;
1929  case '\?':
1930  c2 = '\?';
1931  break;
1932  default:
1933  c2 = *ptr;
1934  break;
1935  }
1936 
1937  *(ptr2++) = c2;
1938  }
1939 
1940  ptr++;
1941  }
1942  *ptr2 = '\0';
1943 
1944  Set(oTemp);
1945  return *this;
1946  }
1947 
1958  {
1959  return cStringUtil::IsInteger(GetPtr());
1960  }
1961 
1974  tBool IsFloat() const
1975  {
1976  return cStringUtil::IsFloat(GetPtr());
1977  }
1978 
1989  {
1990  return (IsInteger() || IsFloat());
1991  }
1992 
1993  public:
1994 
2003  static _myType Repeat(tChar c, tSize nCount)
2004  {
2005  return _myType().Set(c, nCount);
2006  }
2007 
2008 
2020  tInt32 AsInt32() const
2021  {
2022  tInt32 nRetValue = 0;
2023  ToType(nRetValue);
2024  return nRetValue;
2025  }
2037  tVoid ToType(tInt32& i32Value) const
2038  {
2039  cStringUtil::ToType(GetPtr(), i32Value);
2040  }
2041 
2050  static _myType FromType(tInt32 i32Value, const _myType& strFormat = Empty)
2051  {
2052  return _myType(ToStringFromType(i32Value, strFormat.m_oStorageBuffer));
2053  }
2054 
2067  {
2068  tUInt32 nRetValue = 0;
2069  ToType(nRetValue);
2070  return nRetValue;
2071  }
2084  tVoid ToType(tUInt32& ui32Value) const
2085  {
2086  cStringUtil::ToType(GetPtr(), ui32Value);
2087  }
2088 
2097  static _myType FromType(tUInt32 ui32Value, const _myType& strFormat = Empty)
2098  {
2099  return ToStringFromType(ui32Value, strFormat.m_oStorageBuffer);
2100  }
2101 
2102 
2115  tInt64 AsInt64() const
2116  {
2117  tInt64 nRetValue = 0;
2118  ToType(nRetValue);
2119  return nRetValue;
2120  }
2134  tVoid ToType(tInt64& i64Value) const
2135  {
2136  cStringUtil::ToType(GetPtr(), i64Value);
2137  }
2138 
2148  static _myType FromType(tInt64 i64Value, const _myType& strFormat = Empty)
2149  {
2150  return ToStringFromType(i64Value, strFormat.m_oStorageBuffer);
2151  }
2152 
2165  {
2166  tUInt64 nRetValue = 0;
2167  ToType(nRetValue);
2168  return nRetValue;
2169  }
2182  tVoid ToType(tUInt64& ui64Value) const
2183  {
2184  cStringUtil::ToType(GetPtr(), ui64Value);
2185  }
2186 
2196  static _myType FromType(tUInt64 ui64Value, const _myType& strFormat = Empty)
2197  {
2198  return ToStringFromType(ui64Value, strFormat);
2199  }
2200 
2213  {
2214  tFloat64 fRetValue = 0;
2215  ToType(fRetValue);
2216  return fRetValue;
2217  }
2229  tVoid ToType(tFloat64& f64Value) const
2230  {
2231  cStringUtil::ToType(GetPtr(), f64Value);
2232  }
2233 
2243  static _myType FromType(tFloat64 f64Value, const _myType& strFormat = Empty)
2244  {
2245  return ToStringFromType(f64Value, strFormat);
2246  }
2247 
2260  {
2261  tFloat32 fRetValue = 0;
2262  ToType(fRetValue);
2263  return fRetValue;
2264  }
2276  tVoid ToType(tFloat32& f32Value) const
2277  {
2278  cStringUtil::ToType(GetPtr(), f32Value);
2279  }
2280 
2290  static _myType FromType(tFloat32 f32Value, const _myType& strFormat = Empty)
2291  {
2292  return ToStringFromType(f32Value, strFormat);
2293  }
2294 
2305  tBool AsBool() const
2306  {
2307  tBool bRetValue = 0;
2308  ToType(bRetValue);
2309  return bRetValue;
2310  }
2322  tVoid ToType(tBool& bValue) const
2323  {
2324  cStringUtil::ToType(GetPtr(), bValue);
2325  }
2326 
2336  static _myType FromType(tBool bValue, const _myType& strFormat = Empty)
2337  {
2338  return ToStringFromType(bValue, strFormat);
2339  }
2340 
2341 
2349  {
2350  tInt64 nRetValue = 0;
2351  HexToType(nRetValue);
2352  return nRetValue;
2353  }
2354 
2361  {
2362  return m_oStorageBuffer.max_size();
2363  }
2364 
2375  tVoid HexToType(tInt64& i64Value) const
2376  {
2377  cStringUtil::HexToType(GetPtr(), i64Value);
2378  }
2379 
2399  static inline _myType Format(
2400 #ifdef _MSC_VER
2401  _In_z_ _Printf_format_string_
2402 #endif // _MSC_VER
2403  const value_type* strFormat,
2404  ...)
2405 #ifdef __GNUC__
2406  __attribute__((format(printf, 1, 2)))
2407 #endif // __GNUC__
2408  {
2409  va_list args, args_copy;
2410  va_start(args, strFormat);
2411  va_copy(args_copy, args);
2412  _myType strBuffer;
2413  strBuffer.SetBuffer(static_cast<size_t>(::std::vsnprintf(nullptr, 0, strFormat, args_copy)));
2414  va_end(args_copy);
2415  ::std::vsnprintf(strBuffer.GetBuffer(), strBuffer.GetBufferSize() + 1, strFormat, args);
2416  va_end(args);
2417  return strBuffer;
2418  }
2419 
2429  template<typename T>
2430  static _myType ToStringFromType(T oValue, const _myType& strFormat)
2431  {
2432  _myType strResult;
2433  tSize szMaxSize = strResult.GetMaxBufferSize();
2434  tSize szCurrentBuffer = 42;
2435  if (szMaxSize < szCurrentBuffer)
2436  {
2437  szCurrentBuffer = szMaxSize;
2438  }
2439  strResult.SetBuffer(szCurrentBuffer);
2440  cStringUtil::FromType(oValue, strResult.GetBuffer(), strResult.GetBufferSize(), strFormat.GetPtr());
2441  return strResult;
2442  }
2443 
2454  static _myType& Copy(_myType& strDestination, const _myType& strSource, tSize szLength = InvalidPos)
2455  {
2456  return strDestination.Set(strSource, szLength);
2457  }
2458 
2459 };
2460 
2461 template <typename T> const string_base<T> string_base<T>::Empty;
2462 template <typename T> const tSize string_base<T>::InvalidPos = g_npos;
2463 
2467 template<class sT, class sT2>
2469 {
2476  tBool operator()(const string_base<sT>& str1, const string_base<sT2>& str2) const
2477  {
2478  return ((str1.Compare(str2)) < 0);
2479  }
2480 };
2481 
2482 
2483 
2487 template<class sT, class sT2>
2489 {
2496  tBool operator()(const string_base<sT>& str1, const string_base<sT2>& str2) const
2497  {
2498  return ((str1.CompareNoCase(str2)) < 0);
2499  }
2500 };
2501 
2508 template<class sT>
2509 tBool operator==(const tChar* str1, const string_base<sT>& str2)
2510 {
2511  return str2.IsEqual(str1);
2512 }
2513 
2520 template<class sT>
2521 tBool operator!=(const tChar* str1, const string_base<sT>& str2)
2522 {
2523  return str2.IsNotEqual(str1);
2524 }
2525 
2532 template<class sT>
2533 tBool operator<(const tChar* str1, const string_base<sT>& str2)
2534 {
2535  return (str2.Compare(str1) > 0);
2536 }
2537 
2544 template<class sT>
2545 tBool operator>(const tChar* str1, const string_base<sT>& str2)
2546 {
2547  return (str2.Compare(str1) < 0);
2548 }
2549 
2556 template<class sT>
2557 tBool operator<=(const tChar* str1, const string_base<sT>& str2)
2558 {
2559  return (str2.Compare(str1) >= 0);
2560 }
2561 
2568 template<class sT>
2569 tBool operator>=(const tChar* str1, const string_base<sT>& str2)
2570 {
2571  return (str2.Compare(str1) <= 0);
2572 }
2573 
2574 
2581 template<class sT>
2582 tBool operator==(const std::string& str1, const string_base<sT>& str2)
2583 {
2584  return str2.IsEqual(str1);
2585 }
2586 
2593 template<class sT>
2594 tBool operator!=(const std::string& str1, const string_base<sT>& str2)
2595 {
2596  return str2.IsNotEqual(str1);
2597 }
2598 
2605 template<class sT>
2606 tBool operator<(const std::string& str1, const string_base<sT>& str2)
2607 {
2608  return (str2.Compare(str1) > 0);
2609 }
2610 
2617 template<class sT>
2618 tBool operator>(const std::string& str1, const string_base<sT>& str2)
2619 {
2620  return (str2.Compare(str1) < 0);
2621 }
2622 
2629 template<class sT>
2630 tBool operator<=(const std::string& str1, const string_base<sT>& str2)
2631 {
2632  return (str2.Compare(str1) >= 0);
2633 }
2634 
2641 template<class sT>
2642 tBool operator>=(const std::string& str1, const string_base<sT>& str2)
2643 {
2644  return (str2.Compare(str1) <= 0);
2645 }
2646 
2653 template<class sT>
2654 tBool operator==(const string_base<sT>& str1, const std::string& str2)
2655 {
2656  return str1.IsEqual(str2);
2657 }
2658 
2665 template<class sT>
2666 tBool operator!=(const string_base<sT>& str1, const std::string& str2)
2667 {
2668  return str1.IsNotEqual(str2);
2669 }
2670 
2677 template<class sT>
2678 tBool operator<(const string_base<sT>& str1, const std::string& str2)
2679 {
2680  return (str1.Compare(str2) < 0);
2681 }
2682 
2689 template<class sT>
2690 tBool operator>(const string_base<sT>& str1, const std::string& str2)
2691 {
2692  return (str1.Compare(str2) > 0);
2693 }
2694 
2701 template<class sT>
2702 tBool operator<=(const string_base<sT>& str1, const std::string& str2)
2703 {
2704  return (str1.Compare(str2) <= 0);
2705 }
2706 
2713 template<class sT>
2714 tBool operator>=(const string_base<sT>& str1, const std::string& str2)
2715 {
2716  return (str1.Compare(str2) >= 0);
2717 }
2718 
2728 template<class sT, class sT2>
2730 {
2731  return string_base<sT>(str1).Append(str2);
2732 }
2733 
2743 template<class sT>
2745 {
2746  return string_base<sT>(str1).Append(str2);
2747 }
2748 
2758 template<class sT>
2760 {
2761  return string_base<sT>(str1).Append(str2);
2762 }
2763 
2765 #define A_UTILS_DEFAULT_SIZE_OF_STRING 64
2772 
2779 
2790 } // namespace A_UTILS_NS
2791 
2792 
2793 
2794 
2795 #endif // _STRINGTEMPLATE_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).
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.
String Class.
Definition: string.h:31
tBool IsEqual(const _myType &strCmp, tSize nPos=0, tSize nLength=InvalidPos) const
This function checks if the two strings are equal (case sensitive)
Definition: string.h:755
tVoid ToLower()
This function converts a cStringA object to a lowercase string.
Definition: string.h:1745
tVoid Trim()
This function removes leading and trailing whitespace characters from a cStringA object.
Definition: string.h:1607
string_base & operator=(const string_base< T2 > &strValue)
Constructor that initalizes an existing cString object with the spezified string value.
Definition: string.h:117
static const tSize InvalidPos
used to identicate out of range, invalidpos or default length
Definition: string.h:56
_StorageType::const_reverse_iterator const_reverse_iterator
short typedefinition for cString reverse iterators
Definition: string.h:50
_myType & Set(tChar c, tSize nCount)
Assigns a new value to a cStringA object.
Definition: string.h:289
tInt32 AsInt32() const
This function converts the string to an integer value.
Definition: string.h:2020
tBool IsNotEqualNoCase(const _myType &strCmp, tSize nPos=0, tSize nLength=InvalidPos) const
This function checks if the two strings are not equal (case insensitive)
Definition: string.h:808
tSize Find(tChar cToFind, tSize nStart=0) const
This function searches the cStringA object for the first match of the specified character.
Definition: string.h:863
tVoid LeftTrim(tBool bNumTrim=tFalse)
This function removes leading whitespace characters or leading zero characters from a cStringA object...
Definition: string.h:1622
tInt64 HexToInt64() const
This function converts a hexadecimal string representation to an integer value.
Definition: string.h:2348
tVoid ToType(tUInt32 &ui32Value) const
This function converts the string to an integer value.
Definition: string.h:2084
tVoid ToType(tBool &bValue) const
This function converts the string to a boolean value.
Definition: string.h:2322
string_base & operator=(const _StorageType &strValue)
The cString assignment (=) operator assigns a new value to the existing cString object.
Definition: string.h:128
static _myType FromType(tFloat64 f64Value, const _myType &strFormat=Empty)
This function creates a new cString object from a numeric value.
Definition: string.h:2243
tBool IsEqualNoCase(const _myType &strCmp, tSize nPos=0, tSize nLength=InvalidPos) const
This function checks if the two strings are equal (case insensitive)
Definition: string.h:773
tVoid ToType(tFloat64 &f64Value) const
This function converts the string to a floating-point value.
Definition: string.h:2229
_myType & Insert(const _myType &strToInsertString, tSize nPos, tSize nLength=InvalidPos)
This function inserts a string into the cStringA object.
Definition: string.h:634
tChar & operator[](tSize nIdx)
array access operator
Definition: string.h:426
string_base()
Constructor that initializes an empty cStringA object.
Definition: string.h:67
tSize Filter(const _myType &strCharList)
This function removes all occurrences of each character given in a token list.
Definition: string.h:1097
tVoid RightTrim()
This function removes trailing whitespace characters from a cStringA object.
Definition: string.h:1652
tBool EndsWith(const _myType &strEndsWith, const tBool bNoCase=tFalse) const
This function checks if the string ends with a given postfix.
Definition: string.h:1176
_StorageType::reverse_iterator reverse_iterator
short typedefinition for cString reverse iterators
Definition: string.h:48
static _myType FromType(tInt64 i64Value, const _myType &strFormat=Empty)
This function creates a new cString object from a numeric value.
Definition: string.h:2148
_StorageType::iterator iterator
short typedefinition for cString iterators
Definition: string.h:44
_StorageType m_oStorageBuffer
storage buffer
Definition: string.h:59
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.
Definition: string.h:710
tChar GetAt(tSize nIdx) const
You can think of a cStringA object as an array of characters.
Definition: string.h:377
tSize CountString(const _myType &strFind, tSize nStart=0) const
This counts the occurrences of a given substring in a string.
Definition: string.h:962
tSize GetMaxBufferSize() const
Return maximum size of string buffer.
Definition: string.h:2360
const_iterator cbegin() const
Iterator to beginning.
Definition: string.h:199
tBool IsNotEmpty() const
This function checks if the string object is not empty.
Definition: string.h:454
static _myType Repeat(tChar c, tSize nCount)
Creates a string from a repeated character.
Definition: string.h:2003
const _myType & operator+=(const _myType &strString)
The += concatenation operator joins characters to the end of this string.
Definition: string.h:1228
tBool operator>(const tChar *pString) const
Checks if a string is lexicographically smaller than the cStringA object.
Definition: string.h:1273
tSize Replace(const _myType &strOld, const _myType &strNew, tBool bReplaceAll=tTrue)
This function replaces one substring by another.
Definition: string.h:995
static _myType FromType(tBool bValue, const _myType &strFormat=Empty)
This function creates a new cString object from a boolean value.
Definition: string.h:2336
tBool AsBool() const
This function converts the string to a boolean value.
Definition: string.h:2305
tSize GetBufferSize() const
Get the size of the internal allocated string buffer.
Definition: string.h:356
tBool operator==(const _myType &strString) const
Checks if a string equals the cStringA object.
Definition: string.h:1309
tUInt32 AsUInt32() const
This function converts the string to an integer value.
Definition: string.h:2066
tFloat32 AsFloat32() const
This function converts the string to a floating-point value.
Definition: string.h:2259
const tChar * GetPtr() const
This function returns the current string as an array of characters (c-style)
Definition: string.h:467
static _myType FromType(tFloat32 f32Value, const _myType &strFormat=Empty)
This function creates a new cString object from a numeric value.
Definition: string.h:2290
static _myType & Copy(_myType &strDestination, const _myType &strSource, tSize szLength=InvalidPos)
Copies the value of one StringObject to another Stringobject.
Definition: string.h:2454
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.
Definition: string.h:689
_myType & Set(const _myType &strStringToSet, tSize nLength=InvalidPos)
Assigns a new value to a cStringA object.
Definition: string.h:240
string_base(const string_base< T2 > &strValue)
Constructor that initalizes an existing cString object with the spezified string value.
Definition: string.h:111
string_base< storageT > _myType
definition my type
Definition: string.h:35
tBool operator<(const tChar *pString) const
Checks if a string is lexicographically greater than the cStringA object.
Definition: string.h:1262
tChar * GetBuffer()
This function returns the pointer to the data.
Definition: string.h:480
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.
Definition: string.h:1512
static _myType ToStringFromType(T oValue, const _myType &strFormat)
This function creates a new cString object from a numeric value.
Definition: string.h:2430
tSize Filter(tChar cChar)
This function removes all occurrences of a given character from a string.
Definition: string.h:1081
tSize Replace(tChar cOld, tChar cNew, tBool bReplaceAll=tTrue)
This function replaces one character by another.
Definition: string.h:1047
tVoid ToType(tInt64 &i64Value) const
This function converts the string to an integer value.
Definition: string.h:2134
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...
Definition: string.h:738
tVoid ToUpper()
This function converts a cStringA object to an uppercase string.
Definition: string.h:1767
const tChar & operator[](tSize nIdx) const
array access operator
Definition: string.h:414
static _myType FromType(tUInt64 ui64Value, const _myType &strFormat=Empty)
This function creates a new cString object from a numeric value.
Definition: string.h:2196
reverse_iterator rend()
Reverse iterator to end.
Definition: string.h:194
tInt64 AsInt64() const
This function converts the string to an integer value.
Definition: string.h:2115
tSize GetLength() const
This function returns the number of characters in a cStringA object.
Definition: string.h:309
_myType Right(tSize nLength) const
Extracts the last (that is, rightmost) nLength characters from the cStringA object and returns a copy...
Definition: string.h:1468
tBool operator!=(const _myType &strString) const
Checks if a string not equals the cStringA object.
Definition: string.h:1320
virtual ~string_base()
Destructor.
Definition: string.h:170
const_reverse_iterator crbegin() const
Reverse iterator to beginning.
Definition: string.h:209
string_base(const _StorageType &strValue)
Constructor that initalizes an existing cString object with the spezified string value.
Definition: string.h:123
tBool IsInteger() const
Check if string content represents an integer value.
Definition: string.h:1957
static _myType FromType(tInt32 i32Value, const _myType &strFormat=Empty)
This function creates a new cString object from a numeric value.
Definition: string.h:2050
_myType SubString(tSize nPos, tSize nLength=InvalidPos) const
This function extracts a substring of length nLength characters from the cStringA object,...
Definition: string.h:1387
static _myType Format(const value_type *strFormat,...)
Write formatted data to a string.
Definition: string.h:2399
const_iterator cend() const
Iterator to end.
Definition: string.h:204
tVoid ToType(tInt32 &i32Value) const
This function converts the string to an integer value.
Definition: string.h:2037
tBool operator<=(const tChar *pString) const
Checks if a string is lexicographically greater than or equal to the cStringA object.
Definition: string.h:1285
string_base & operator=(const tChar *strValue)
The cString assignment (=) operator assigns a new value to the existing cString object.
Definition: string.h:160
_myType Mid(tSize nPos, tSize nLength=InvalidPos) const
This function extracts a substring of length nLength characters from the cStringA object,...
Definition: string.h:1415
tVoid Clear()
Makes this cStringA object an empty string and frees memory as appropriate.
Definition: string.h:224
_StorageType::const_iterator const_iterator
short typedefinition for cString iterators
Definition: string.h:46
static _myType FromType(tUInt32 ui32Value, const _myType &strFormat=Empty)
This function creates a new cString object from a numeric value.
Definition: string.h:2097
tBool StartsWith(const _myType &strStartsWith, const tBool bNoCase=tFalse) const
This function checks if the string starts with a given prefix.
Definition: string.h:1131
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.
Definition: string.h:1495
tVoid NumTrim()
This function removes whitespace and redundant zero characters from a cStringA object.
Definition: string.h:1670
tBool IsFloat() const
Check if string content represents a floating point value.
Definition: string.h:1974
string_base & operator=(const tChar &strValue)
The cString assignment (=) operator assigns a new value to the existing cString object.
Definition: string.h:139
_myType & Append(const _myType &strString, tSize nLength=InvalidPos)
This function appends a string to the end of the cStringA object.
Definition: string.h:497
_StorageType::value_type value_type
definition of value type
Definition: string.h:41
tBool IsNotEqual(const _myType &strCmp, tSize nPos=0, tSize nLength=InvalidPos) const
This function checks if the two strings are not equal (case sensitive)
Definition: string.h:790
tSize RFind(tChar cChar, tSize nStart=0) const
This function searches the cStringA object for the last match of the specified character.
Definition: string.h:884
tBool IsEmpty() const
This function checks if the string object is empty.
Definition: string.h:441
tVoid HexToType(tInt64 &i64Value) const
This function converts a hexadecimal string representation to an integer value.
Definition: string.h:2375
_myType & Append(tChar c)
This function appends one character to the end of the cStringA object.
Definition: string.h:537
tVoid SetAt(tSize nIdx, tChar c)
The SetAt member function sets a single character at a specified position.
Definition: string.h:398
string_base & operator=(_myType &&strValue)
The cString assignment (=) operator assigns a new value to the existing cString object.
Definition: string.h:104
string_base & operator=(const _myType &strValue)
The cString assignment (=) operator assigns a new value to the existing cString object.
Definition: string.h:89
string_base(const _myType &strValue)
Constructor that initalizes an existing cString object with the spezified string value.
Definition: string.h:76
tVoid DropQuotes()
This function removes quotes from a cStringA object.
Definition: string.h:1719
const_reverse_iterator crend() const
Reverse iterator to end.
Definition: string.h:214
tBool IsNumeric() const
Check if string content represents a numeric value.
Definition: string.h:1988
string_base(const tChar *strValue)
Constructor that initalizes an existing cString object with the spezified string value.
Definition: string.h:145
iterator end()
Iterator to end.
Definition: string.h:184
tSize SetBuffer(tSize szSize)
Sets or resizes the internal string buffer.
Definition: string.h:328
reverse_iterator rbegin()
Reverse iterator to beginning.
Definition: string.h:189
static const _myType Empty
Internally used empty string.
Definition: string.h:54
string_base(_myType &&strValue)
Constructor that initalizes an existing cString object with the spezified string value.
Definition: string.h:99
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...
Definition: string.h:937
_myType & Unescape()
Escape control characters.
Definition: string.h:1872
tBool operator==(const tChar *pString) const
Checks if a string equals the cStringA object.
Definition: string.h:1240
iterator begin()
Iterator to beginning.
Definition: string.h:179
string_base(const tChar &strValue)
Constructor that initalizes an existing cString object with the spezified string value.
Definition: string.h:134
tBool operator>=(const tChar *pString) const
Checks if a string is lexicographically smaller than or equal to the cStringA object.
Definition: string.h:1297
string_base(const tChar *strValue, tSize szLength)
Constructor that initalizes an existing cString object with the spezified string value.
Definition: string.h:155
tVoid ToType(tFloat32 &f32Value) const
This function converts the string to a floating-point value.
Definition: string.h:2276
tBool operator>=(const _myType &strString) const
Checks if a string is lexicographically smaller than or equal to the cStringA object.
Definition: string.h:1366
_myType & Escape()
Escape control characters.
Definition: string.h:1787
tUInt64 AsUInt64() const
This function converts the string to an integer value.
Definition: string.h:2164
tVoid SplitToken(string_list_base< _myType > &lstList, const _myType &strTokenList) const
Split string using a token list.
Definition: string.h:1569
tFloat64 AsFloat64() const
This function converts the string to a floating-point value.
Definition: string.h:2212
tBool operator<=(const _myType &strString) const
Checks if a string is lexicographically greater than or equal to the cStringA object.
Definition: string.h:1354
_myType Left(tSize nLength) const
Extracts the first (that is, leftmost) nLength characters from the cStringA object and returns a copy...
Definition: string.h:1448
tVoid ToType(tUInt64 &ui64Value) const
This function converts the string to an integer value.
Definition: string.h:2182
storageT _StorageType
definition storage type
Definition: string.h:37
tBool operator!=(const tChar *pString) const
Checks if a string does not equal the cStringA object.
Definition: string.h:1251
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...
Definition: string.h:908
_myType & Set(const tChar *pString, tSize nLength=InvalidPos)
Assigns a new value to a cStringA object.
Definition: string.h:263
_myType & Insert(const tChar *pToInsertString, tSize nPos, tSize nLength=InvalidPos)
This function inserts a string into the cStringA object.
Definition: string.h:660
_myType & Delete(tSize nPos, tSize nLength=InvalidPos)
This function deletes a substring of length nLength characters from the cStringA object,...
Definition: string.h:578
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.
Definition: string.h:831
forward declaration
Definition: stringlist.h:21
tResult Append(const storageT &strString)
This function appends one string to the list.
Definition: stringlist.h:277
tVoid Clear()
This function cleans up the list and frees all allocated memory blocks.
Definition: stringlist.h:259
#define tFalse
Value for tBool.
Definition: constants.h:60
#define tTrue
Value for tBool.
Definition: constants.h:62
ADTF A_UTIL Namespace - Within adtf this is used as adtf::util or adtf_util.
Definition: d_ptr.h:11
string_base_no_case_compare_func< cStackString, cStackString > cStringNoCaseCompareFunc
Compare functor for the cStackString.
Definition: string.h:2789
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...
Definition: string.h:2778
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...
Definition: string.h:2771
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.
Definition: string.h:2784
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.
Definition: string.h:2469
tBool operator()(const string_base< sT > &str1, const string_base< sT2 > &str2) const
String compare function.
Definition: string.h:2476
Compare function for stl container e.g.
Definition: string.h:2489
tBool operator()(const string_base< sT > &str1, const string_base< sT2 > &str2) const
String compare function.
Definition: string.h:2496