ADTF
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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
16namespace A_UTILS_NS
17{
18
20template <class storageT> class string_list_base;
21
29template <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 }
71
76 string_base(const _myType& strValue)
77 {
78 Set(strValue);
79 }
80
89 string_base& operator=(const _myType& strValue)
90 {
91 if (this != &strValue)
92 {
93 Set(strValue);
94 }
95 return *this;
96 }
97
103 {
104 Set(strValue);
105 }
106
108 {
109 if (this != &strValue)
110 {
111 Set(strValue);
112 }
113 return *this;
114 }
115
116 template<class T2>
118 {
119 Set(strValue.GetPtr());
120 }
121
122 template<class T2>
124 {
125 Set(strValue.GetPtr());
126 return *this;
127 }
128
129 string_base(const _StorageType& strValue)
130 {
131 m_oStorageBuffer = strValue;
132 }
133
135 {
136 m_oStorageBuffer = strValue;
137 return *this;
138 }
139
140 string_base(const tChar& strValue)
141 {
142 Set(strValue, 1);
143 }
144
145 string_base& operator=(const tChar& strValue)
146 {
147 Set(strValue, 1);
148 return *this;
149 }
150
151 string_base(const tChar* strValue)
152 {
153 Set(strValue);
154 }
155
161 string_base(const tChar* strValue, tSize szLength)
162 {
163 Set(strValue, szLength);
164 }
165
166 string_base& operator=(const tChar* strValue)
167 {
168 Set(strValue);
169 return *this;
170 }
171
176 virtual ~string_base()
177 {
178 //value_type must be tChar or tUInt8
179 static_assert(std::is_same<value_type, tChar>::value
180 || std::is_same<value_type, tUInt8>::value,
181 "storageT::value_type must be tChar or tUInt8 and specified !!");
182 }
183
186 {
187 return m_oStorageBuffer.begin();
188 }
189
191 {
192 return m_oStorageBuffer.end();
193 }
194
196 {
197 return m_oStorageBuffer.rbegin();
198 }
199
201 {
202 return m_oStorageBuffer.rend();
203 }
204
206 {
207 return m_oStorageBuffer.cbegin();
208 }
209
211 {
212 return m_oStorageBuffer.cend();
213 }
214
216 {
217 return m_oStorageBuffer.crbegin();
218 }
219
221 {
222 return m_oStorageBuffer.crend();
223 }
224
231 {
232 m_oStorageBuffer.clear();
233 }
234
246 _myType& Set(const _myType& strStringToSet, tSize nLength = InvalidPos)
247 {
248 if (nLength == InvalidPos)
249 {
250 m_oStorageBuffer.assign(strStringToSet.m_oStorageBuffer);
251 }
252 else
253 {
254 m_oStorageBuffer.assign(strStringToSet.m_oStorageBuffer, 0, nLength);
255 }
256 return *this;
257 }
258
269 _myType& Set(const tChar* pString, tSize nLength = InvalidPos)
270 {
271 if (pString != nullptr)
272 {
273 if (nLength == InvalidPos)
274 {
275 m_oStorageBuffer.assign(pString);
276 }
277 else
278 {
279 m_oStorageBuffer.assign(pString, nLength);
280 }
281 }
282 return *this;
283 }
284
295 _myType& Set(tChar c, tSize nCount)
296 {
297 if (nCount > 0 && nCount != InvalidPos)
298 {
299 m_oStorageBuffer.assign(nCount, c);
300 }
301
302 return *this;
303 }
304
316 {
318 }
319
335 {
336 if (szSize != InvalidPos)
337 {
338 m_oStorageBuffer.resize(szSize);
339 if (GetBufferSize() >= szSize)
340 {
341 return szSize;
342 }
343 else
344 {
345 return InvalidPos;
346 }
347 }
348 else
349 {
350 return szSize;
351 }
352 }
353
363 {
364 return m_oStorageBuffer.capacity();
365 }
366
383 tChar GetAt(tSize nIdx) const
384 {
385 if (nIdx >= GetLength())
386 {
387 return '\0';
388 }
389 return m_oStorageBuffer[nIdx];
390 }
391
405 {
406 if (nIdx >= GetLength())
407 {
408 return;
409 }
410 m_oStorageBuffer[nIdx] = c;
411 }
412
420 const tChar& operator[](tSize nIdx) const
421 {
422 return m_oStorageBuffer[nIdx];
423 }
424
433 {
434 return m_oStorageBuffer[nIdx];
435 }
436
437
438
448 {
449 return (cStringUtil::GetLength(GetPtr()) == 0);
450 }
451
461 {
462 return !IsEmpty();
463 }
464
473 const tChar* GetPtr() const
474 {
475 return m_oStorageBuffer.c_str();
476 }
477
487 {
488 return m_oStorageBuffer.data();
489 }
490
503 _myType& Append(const _myType& strString, tSize nLength = InvalidPos)
504 {
505 tSize szLength = GetLength();
506 if (szLength < m_oStorageBuffer.length())
507 {
508 //we will insert if the buffer is damaged by the 0-termination append cheese of STL
509 if (nLength == InvalidPos)
510 {
511 m_oStorageBuffer.insert(szLength, strString.m_oStorageBuffer, 0, strString.GetLength());
512 }
513 else
514 {
515 m_oStorageBuffer.insert(szLength, strString.m_oStorageBuffer, 0, nLength);
516 }
517 }
518 else
519 {
520 if (nLength == InvalidPos)
521 {
522 m_oStorageBuffer.append(strString.m_oStorageBuffer);
523 }
524 else
525 {
526 m_oStorageBuffer.append(strString.m_oStorageBuffer, 0, nLength);
527 }
528 }
529 return *this;
530 }
531
544 {
545 if (c != '\0')
546 {
547 //strange handling within the STL append will append to the Buffer!! not to the string
548 //0-Termination will be damaged !!
549 tSize szLastPos = GetLength();
550 if (m_oStorageBuffer.length() > szLastPos)
551 {
552 m_oStorageBuffer[szLastPos] = c;
553 if (m_oStorageBuffer.length() > (szLastPos+1))
554 {
555 m_oStorageBuffer[szLastPos+1] = '\0';
556 }
557 else
558 {
559 m_oStorageBuffer.append(1, '\0');
560 }
561 }
562 else
563 {
564 m_oStorageBuffer.append(1, c);
565 }
566 }
567 return *this;
568 }
569
585 {
586 if (nPos == InvalidPos)
587 {
588 nPos = 0;
589 }
590 // nothing to delete in an emtpy string
591 if (IsEmpty())
592 {
593 //do nothing
594 }
595 else if (nPos == 0 && nLength == InvalidPos)
596 {
597 Clear();
598 }
599 else if (nLength == InvalidPos)
600 {
601 if (nPos < GetLength())
602 {
603 m_oStorageBuffer.erase(nPos);
604 }
605 else
606 {
607 //do nothing
608 }
609 }
610 else if (nPos == 0)
611 {
612 m_oStorageBuffer.erase(0, nLength);
613 }
614 else
615 {
616 if (nPos < GetLength())
617 {
618 m_oStorageBuffer.erase(nPos, nLength);
619 }
620 else
621 {
622 //do nothing
623 }
624 }
625 return *this;
626 }
627
640 _myType& Insert(const _myType& strToInsertString, tSize nPos, tSize nLength = InvalidPos)
641 {
642 if (nPos == InvalidPos || nPos >= GetLength())
643 {
644 return Append(strToInsertString, nLength);
645 }
646 else
647 {
648 m_oStorageBuffer.insert(nPos, strToInsertString.m_oStorageBuffer, 0, nLength);
649 return *this;
650 }
651 }
652
653
666 _myType& Insert(const tChar* pToInsertString, tSize nPos, tSize nLength = InvalidPos)
667 {
668 if (pToInsertString != nullptr)
669 {
670 return Insert(_myType(pToInsertString), nPos, nLength);
671 }
672 return *this;
673 }
674
695 tInt Compare(const _myType& strString,
696 tSize nPos = 0,
697 tSize nLength = InvalidPos) const
698 {
699 return cStringUtil::Compare(GetPtr(), strString.GetPtr(), nPos, nLength);
700 }
701
716 tInt Compare(const tChar* strString,
717 tSize nPos = 0,
718 tSize nLength = InvalidPos) const
719 {
720 return cStringUtil::Compare(GetPtr(), strString, nPos, nLength);
721 }
722
744 tInt CompareNoCase(const _myType& strString,
745 tSize nPos = 0,
746 tSize nLength = InvalidPos) const
747 {
748 return cStringUtil::CompareNoCase(GetPtr(), strString.GetPtr(), nPos, nLength);
749 }
750
761 tBool IsEqual(const _myType &strCmp,
762 tSize nPos = 0,
763 tSize nLength = InvalidPos) const
764 {
765 return(Compare(strCmp, nPos, nLength) == 0) ? tTrue : tFalse;
766 }
767
768
780 tSize nPos = 0,
781 tSize nLength = InvalidPos) const
782 {
783 return(cStringUtil::CompareNoCase(GetPtr(), strCmp.GetPtr(), nPos, nLength) == 0) ? tTrue : tFalse;
784 }
785
796 tBool IsNotEqual(const _myType &strCmp,
797 tSize nPos = 0,
798 tSize nLength = InvalidPos) const
799 {
800 return(Compare(strCmp, nPos, nLength) == 0) ? tFalse : tTrue;
801 }
802
803
815 tSize nPos = 0,
816 tSize nLength = InvalidPos) const
817 {
818 return(CompareNoCase(strCmp, nPos, nLength) == 0) ? tFalse : tTrue;
819 }
820
837 tSize Find(const _myType& strStringToFind,
838 tSize nStart = 0,
839 const tBool bNoCase = tFalse) const
840 {
841 if (bNoCase)
842 {
843 _myType strTmp, strCompare;
844 strTmp = *this;
845 strTmp.ToLower();
846 strCompare = *this;
847 strCompare.ToLower();
848 return strTmp.Find(strCompare, nStart);
849 }
850
851 return m_oStorageBuffer.find(strStringToFind.m_oStorageBuffer, nStart);
852 }
853
869 tSize Find(tChar cToFind, tSize nStart = 0) const
870 {
871 return Find(_myType(cToFind), nStart, tFalse);
872 }
873
890 tSize RFind(tChar cChar, tSize nStart = 0) const
891 {
892 if (nStart == 0)
893 {
894 return m_oStorageBuffer.rfind(cChar);
895 }
896
897 return m_oStorageBuffer.rfind(cChar, GetLength() - nStart);
898 }
899
914 tSize FindToken(const _myType& strTokenList, tSize nStart = 0) const
915 {
916 if (IsEmpty())
917 {
918 return InvalidPos;
919 }
920
921 if (nStart == 0)
922 {
923 return m_oStorageBuffer.find_first_of(strTokenList.m_oStorageBuffer);
924 }
925
926 return m_oStorageBuffer.find_first_of(strTokenList.m_oStorageBuffer, nStart);
927 }
928
943 tSize FindNotToken(const _myType& strTokenList, tSize nStart = 0) const
944 {
945 if (IsEmpty())
946 {
947 return InvalidPos;
948 }
949
950 if (nStart == 0)
951 {
952 return m_oStorageBuffer.find_first_not_of(strTokenList.m_oStorageBuffer);
953 }
954
955 return m_oStorageBuffer.find_first_not_of(strTokenList.m_oStorageBuffer, nStart);
956 }
957
968 tSize CountString(const _myType& strFind, tSize nStart = 0) const
969 {
970 tSize nFindSize = strFind.GetLength();
971 if (IsEmpty() || nFindSize == 0)
972 {
973 return InvalidPos;
974 }
975
976 tSize nCnt = 0;
977 while (nStart != InvalidPos)
978 {
979 nStart = Find(strFind, nStart);
980 if (nStart != InvalidPos)
981 {
982 nStart += nFindSize;
983 nCnt++;
984 }
985 }
986 return nCnt;
987 }
988
1001 tSize Replace(const _myType& strOld, const _myType& strNew, tBool bReplaceAll = tTrue)
1002 {
1003 if (IsEmpty() || strOld.IsEmpty())
1004 {
1005 return 0;
1006 }
1007
1008 tSize nReplaceCount = 0;
1009
1010 _myType strBuffer;
1011 tSize nSearchLen = strOld.GetLength();
1012 tSize nPos;
1013 tSize nStartPos = 0;
1014 do
1015 {
1016 nPos = Find(strOld, nStartPos);
1017 if (nPos != InvalidPos)
1018 {
1019 strBuffer.Append(Mid(nStartPos, (nPos - nStartPos)));
1020 strBuffer.Append(strNew);
1021 nStartPos = nPos + nSearchLen;
1022 nReplaceCount++;
1023 if (!bReplaceAll)
1024 {
1025 strBuffer.Append(Mid(nStartPos));
1026 break;
1027 }
1028 }
1029 else
1030 {
1031 strBuffer.Append(Mid(nStartPos));
1032 }
1033
1034 } while (nPos != InvalidPos);
1035
1036 m_oStorageBuffer.swap(strBuffer.m_oStorageBuffer);
1037 return nReplaceCount;
1038 }
1039
1053 tSize Replace(tChar cOld, tChar cNew,tBool bReplaceAll = tTrue)
1054 {
1055 if (IsEmpty())
1056 {
1057 return 0;
1058 }
1059
1060 tSize nReplacements = 0;
1061 _myType::iterator oIt = begin();
1062 _myType::iterator oItEnd = end();
1063 for (; oIt != oItEnd; ++oIt)
1064 {
1065 if (*oIt == cOld)
1066 {
1067 *oIt = cNew;
1068 ++nReplacements;
1069 if (!bReplaceAll)
1070 {
1071 break;
1072 }
1073 }
1074 }
1075 return nReplacements;
1076 }
1077
1088 {
1089 return Filter(_myType(cChar));
1090 }
1091
1103 tSize Filter(const _myType& strCharList)
1104 {
1105 if (IsEmpty())
1106 {
1107 return 0;
1108 }
1109
1110 tSize nSize = GetLength();
1111 _myType strTmp;
1112 strTmp.SetBuffer(nSize);
1113 tSize nFiltered = 0;
1114 for (tSize nPos = 0; nPos < nSize; ++nPos)
1115 {
1116 tChar cCurrent = GetAt(nPos);
1117 if (strCharList.Find(cCurrent) == InvalidPos)
1118 {
1119 strTmp.Append(cCurrent);
1120 }
1121 else
1122 {
1123 ++nFiltered;
1124 }
1125 }
1126
1128 return nFiltered;
1129 }
1130
1137 tBool StartsWith(const _myType& strStartsWith, const tBool bNoCase = tFalse) const
1138 {
1139 if (strStartsWith.IsEmpty() || strStartsWith.GetLength() > GetLength())
1140 {
1141 return tFalse;
1142 }
1143
1144 if (bNoCase)
1145 {
1146 return (CompareNoCase(strStartsWith, 0, strStartsWith.GetLength()) == 0);
1147 }
1148 else
1149 {
1150 return (Compare(strStartsWith, 0, strStartsWith.GetLength()) == 0);
1151 }
1152 }
1153
1154 tSize RSplitByToken(const tChar cToken, _myType& strFirst, _myType& strSecond) const
1155 {
1156 tSize szRight = RFind(cToken);
1157 if (szRight != InvalidPos)
1158 {
1159 strFirst = Left(szRight);
1160 strSecond = Right(GetLength() - (szRight + 1));
1161 }
1162 return szRight;
1163 }
1164
1165 tSize SplitByToken(const tChar cToken, _myType& strFirst, _myType& strSecond) const
1166 {
1167 tSize szRight = Find(cToken);
1168 if (szRight != InvalidPos)
1169 {
1170 strFirst = Left(szRight);
1171 strSecond = Right(GetLength() - (szRight + 1));
1172 }
1173 return szRight;
1174 }
1175
1182 tBool EndsWith(const _myType& strEndsWith, const tBool bNoCase = tFalse) const
1183 {
1184 //@TODO: Compare can be done without new memory allocation!!
1185 tSize szStringLength = GetLength();
1186 if (szStringLength == 0
1187 || (strEndsWith.GetLength() > szStringLength))
1188 {
1189 return tFalse;
1190 }
1191
1192 _myType strPart = Right(strEndsWith.GetLength());
1193 if (bNoCase)
1194 {
1195 return strPart.IsEqualNoCase(strEndsWith);
1196 }
1197 else
1198 {
1199 return strPart.IsEqual(strEndsWith);
1200 }
1201 }
1202
1214 operator const tChar*() const
1215 {
1216 return GetPtr();
1217 }
1218
1219
1220
1221
1222
1234 const _myType& operator+= (const _myType& strString)
1235 {
1236 Append(strString);
1237 return *this;
1238 }
1239
1246 tBool operator==(const tChar* pString) const
1247 {
1248 return (cStringUtil::Compare(GetPtr(), pString) == 0);
1249 }
1250
1257 tBool operator!=(const tChar* pString) const
1258 {
1259 return (cStringUtil::Compare(GetPtr(), pString) != 0);
1260 }
1261
1268 tBool operator< (const tChar* pString) const
1269 {
1270 return (cStringUtil::Compare(GetPtr(), pString) < 0);
1271 }
1272
1279 tBool operator> (const tChar* pString) const
1280 {
1281 return (cStringUtil::Compare(GetPtr(), pString) > 0);
1282 }
1283
1291 tBool operator<=(const tChar* pString) const
1292 {
1293 return (cStringUtil::Compare(GetPtr(), pString) <= 0);
1294 }
1295
1303 tBool operator>=(const tChar* pString) const
1304 {
1305 return (cStringUtil::Compare(GetPtr(), pString) >= 0);
1306 }
1307
1308
1315 tBool operator==(const _myType& strString) const
1316 {
1317 return (Compare(strString) == 0);
1318 }
1319
1326 tBool operator!=(const _myType& strString) const
1327 {
1328 return (Compare(strString) != 0);
1329 }
1330
1337 tBool operator< (const _myType& strString) const
1338 {
1339 return (Compare(strString) < 0);
1340 }
1341
1348 tBool operator> (const _myType& strString) const
1349 {
1350 return (Compare(strString) > 0);
1351 }
1352
1360 tBool operator<=(const _myType& strString) const
1361 {
1362 return (Compare(strString) <= 0);
1363 }
1364
1372 tBool operator>=(const _myType& strString) const
1373 {
1374 return (Compare(strString) >= 0);
1375 }
1376
1393 _myType SubString(tSize nPos, tSize nLength = InvalidPos) const
1394 {
1395 if (nPos > GetLength())
1396 {
1397 return Empty;
1398 }
1399 return m_oStorageBuffer.substr(nPos, nLength);
1400 }
1401
1402
1403
1421 _myType Mid(tSize nPos, tSize nLength = InvalidPos) const
1422 {
1423 if (IsEmpty() || nPos >= GetLength() || nPos == InvalidPos)
1424 {
1425 return Empty;
1426 }
1427 _myType strRes;
1428 if (nLength == InvalidPos)
1429 {
1430 strRes = SubString(nPos);
1431 }
1432 else
1433 {
1434 strRes = SubString(nPos, nLength);
1435 }
1436 return strRes;
1437 }
1438
1454 _myType Left(tSize nLength) const
1455 {
1456 return SubString(0, nLength);
1457 }
1458
1474 _myType Right(tSize nLength) const
1475 {
1476 tSize nPos = (GetLength() - nLength);
1477 if (GetLength() < nLength)
1478 {
1479 nPos = 0;
1480 }
1481 else
1482 {
1483 nPos = GetLength() - nLength;
1484 }
1485 return SubString(nPos, nLength);
1486 }
1487
1488
1489
1501 tVoid Split(string_list_base<_myType>& lstSplittedResult, tChar cToken) const
1502 {
1503 Split(lstSplittedResult, _myType(cToken));
1504 }
1505
1518 tVoid Split(string_list_base<_myType>& lstSplittedResult, const _myType& strToken) const
1519 {
1520 lstSplittedResult.Clear();
1521 if (IsEmpty())
1522 {
1523 return;
1524 }
1525
1526 tSize nTokenLen = strToken.GetLength();
1527 tSize nPos = InvalidPos;
1528 tSize nStartPos;
1529 tSize nToSplitStringSize = GetLength();
1530 do
1531 {
1532 nStartPos = nPos + 1;
1533 nPos = Find(strToken, nStartPos);
1534 if (nPos != InvalidPos)
1535 {
1536 if (nPos != 0)
1537 {
1538 lstSplittedResult.Append(Mid(nStartPos, nPos - nStartPos));
1539 }
1540 else
1541 {
1542 lstSplittedResult.Append(_myType(""));
1543 }
1544 nPos += nTokenLen - 1;
1545 }
1546 else
1547 {
1548 if (nStartPos < nToSplitStringSize)
1549 {
1550 lstSplittedResult.Append(Mid(nStartPos));
1551 }
1552 else if (EndsWith(strToken))
1553 {
1554 lstSplittedResult.Append(_myType(""));
1555 }
1556 break;
1557 }
1558 } while (nPos != InvalidPos);
1559 }
1560
1561
1575 tVoid SplitToken(string_list_base<_myType>& lstList, const _myType& strTokenList) const
1576 {
1577 lstList.Clear();
1578
1579 _myType strPart;
1580
1581 tSize nLastPos = 0;
1582 tSize nPos = 0;
1583 while (nPos != InvalidPos)
1584 {
1585 nPos = FindToken(strTokenList, nLastPos);
1586 if (nPos == InvalidPos)
1587 {
1588 strPart = Mid(nLastPos);
1589 if (strPart.IsNotEmpty())
1590 {
1591 lstList.Append(strPart);
1592 }
1593 break;
1594 }
1595 else
1596 {
1597 if (nPos > nLastPos)
1598 {
1599 strPart = Mid(nLastPos, nPos - nLastPos);
1600 lstList.Append(strPart);
1601 }
1602 nLastPos = nPos + 1;
1603 }
1604 }
1605 }
1606
1614 {
1615 LeftTrim();
1616 RightTrim();
1617 }
1618
1629 {
1630 tSize szLength = 0;
1631 tBool bLast0 = tFalse;
1632 iterator it = begin();
1633 for (;
1634 it != end() && (cStringUtil::IsWhiteChar(*it) || (bNumTrim && *it == '0'));
1635 it++)
1636 {
1637 if (*it == '0')
1638 {
1639 bLast0 = tTrue;
1640 }
1641 else
1642 {
1643 bLast0 = tFalse;
1644 }
1645 szLength++;
1646 }
1647 if (it != end() && bNumTrim && bLast0 && cStringUtil::IsOneOf(*it,".,"))
1648 {
1649 szLength--;
1650 }
1651 Delete(0, szLength);
1652 }
1653
1659 {
1660 tSize szLength = 0;
1661 for (reverse_iterator it = rbegin();
1662 it != rend() && cStringUtil::IsWhiteChar(*it);
1663 it++)
1664 {
1665 szLength++;
1666 }
1667 Delete(GetLength() - szLength, InvalidPos);
1668 }
1669
1677 {
1678 //@TODO : should be optimized
1679 LeftTrim(tTrue);
1680 RightTrim();
1681
1682 if (IsEmpty())
1683 {
1684 return;
1685 }
1686
1687 tSize nPoint = FindToken(_myType(".,"));
1688 if (nPoint != InvalidPos)
1689 {
1690 tSize nPos = GetLength() - 1;
1691 tChar c;
1692 tBool bLastWasZero = tFalse;
1693 while (nPos != InvalidPos)
1694 {
1695 c = GetAt(nPos);
1696 if (c == '0')
1697 {
1698 bLastWasZero = tTrue;
1699 }
1700 else if (c == ' ')
1701 {
1702 bLastWasZero = tFalse;
1703 }
1704 else
1705 {
1706 if (cStringUtil::IsOneOf(c, ".,") && bLastWasZero) // keep trailing zero
1707 {
1708 nPos++;
1709 }
1710
1711 break;
1712 }
1713 nPos--;
1714 }
1715 Delete(nPos + 1);
1716 }
1717 }
1718
1726 {
1727 if (IsEmpty())
1728 {
1729 return;
1730 }
1731
1732 tSize nEndPos = GetLength() - 1;
1733
1734 if (*rbegin() == '\"' || *rbegin() == '\'')
1735 {
1736 Delete(nEndPos, 1);
1737 }
1738
1739 if (*begin() == '\"' || *begin() == '\'')
1740 {
1741 Delete(0, 1);
1742 }
1743 }
1744
1752 {
1753 if (IsEmpty())
1754 {
1755 return;
1756 }
1757 for (auto it = begin();
1758 it != end();
1759 ++it)
1760 {
1761 // tolower delivers an int, but we can assume that it fits into char
1762 *it = static_cast<tChar>(::tolower(*it));
1763 }
1764
1765 }
1766
1774 {
1775 if (IsEmpty())
1776 {
1777 return;
1778 }
1779 for (auto it = begin();
1780 it != end();
1781 ++it)
1782 {
1783 *it = ::toupper(static_cast<tChar>(*it));
1784 }
1785 }
1786
1794 {
1795 //@TODO : this needs to be rework using stack!!
1796 if (IsEmpty())
1797 {
1798 return *this;
1799 }
1800
1801 _myType oTemp;
1802 oTemp.SetBuffer(GetLength() * 2 + 1);
1803
1804 iterator ptr2 = oTemp.begin();
1805 const tChar* ptr = GetPtr();
1806
1807 tChar c1, c2;
1808 tBool bEscaped;
1809 tSize szEnd = oTemp.GetBufferSize();
1810 tSize szCounter = 0;
1811 while (*ptr != '\0' && szCounter < szEnd)
1812 {
1813 c1 = *ptr;
1814 bEscaped = tTrue;
1815 switch (c1)
1816 {
1817 case '\a':
1818 c2 = 'a';
1819 break;
1820 case '\b':
1821 c2 = 'b';
1822 break;
1823 case '\f':
1824 c2 = 'f';
1825 break;
1826 case '\n':
1827 c2 = 'n';
1828 break;
1829 case '\r':
1830 c2 = 'r';
1831 break;
1832 case '\t':
1833 c2 = 't';
1834 break;
1835 case '\v':
1836 c2 = 'v';
1837 break;
1838 case '\'':
1839 c2 = '\'';
1840 break;
1841 case '\"':
1842 c2 = '\"';
1843 break;
1844 case '\\':
1845 c2 = '\\';
1846 break;
1847 case '\?':
1848 c2 = '\?';
1849 break;
1850 default:
1851 c2 = c1;
1852 bEscaped = tFalse;
1853 break;
1854 }
1855
1856 if (bEscaped)
1857 {
1858 *(ptr2++) = '\\';
1859 }
1860
1861 *(ptr2++) = c2;
1862
1863 ptr++;
1864 }
1865
1866 *ptr2 = '\0';
1867
1868 Set(oTemp);
1869 return *this;
1870 }
1871
1879 {
1880 //@TODO : this needs to be rework using stack only!!
1881 if (IsEmpty())
1882 {
1883 return (*this);
1884 }
1885
1886 _myType oTemp;
1887 oTemp.SetBuffer(GetLength() + 1);
1888
1889 iterator ptr2 = oTemp.begin();
1890 const tChar* ptr = GetPtr();
1891
1892 tChar c1, c2;
1893 while (*ptr != '\0')
1894 {
1895 if (*ptr != '\\')
1896 {
1897 *(ptr2++) = *ptr;
1898 }
1899 else
1900 {
1901 ptr++;
1902 c1 = *ptr;
1903 switch (c1)
1904 {
1905 case 'a':
1906 c2 = '\a';
1907 break;
1908 case 'b':
1909 c2 = '\b';
1910 break;
1911 case 'f':
1912 c2 = '\f';
1913 break;
1914 case 'n':
1915 c2 = '\n';
1916 break;
1917 case 'r':
1918 c2 = '\r';
1919 break;
1920 case 't':
1921 c2 = '\t';
1922 break;
1923 case 'v':
1924 c2 = '\v';
1925 break;
1926 case '\'':
1927 c2 = '\'';
1928 break;
1929 case '\"':
1930 c2 = '\"';
1931 break;
1932 case '\\':
1933 c2 = '\\';
1934 break;
1935 case '\?':
1936 c2 = '\?';
1937 break;
1938 default:
1939 c2 = *ptr;
1940 break;
1941 }
1942
1943 *(ptr2++) = c2;
1944 }
1945
1946 ptr++;
1947 }
1948 *ptr2 = '\0';
1949
1950 Set(oTemp);
1951 return *this;
1952 }
1953
1964 {
1966 }
1967
1981 {
1982 return cStringUtil::IsFloat(GetPtr());
1983 }
1984
1995 {
1996 return (IsInteger() || IsFloat());
1997 }
1998
1999 public:
2000
2009 static _myType Repeat(tChar c, tSize nCount)
2010 {
2011 return _myType().Set(c, nCount);
2012 }
2013
2014
2027 {
2028 tInt32 nRetValue = 0;
2029 ToType(nRetValue);
2030 return nRetValue;
2031 }
2032
2043 tVoid ToType(tInt32& i32Value) const
2044 {
2045 cStringUtil::ToType(GetPtr(), i32Value);
2046 }
2047
2056 static _myType FromType(tInt32 i32Value, const _myType& strFormat = Empty)
2057 {
2058 return _myType(ToStringFromType(i32Value, strFormat.m_oStorageBuffer));
2059 }
2060
2073 {
2074 tUInt32 nRetValue = 0;
2075 ToType(nRetValue);
2076 return nRetValue;
2077 }
2078
2090 tVoid ToType(tUInt32& ui32Value) const
2091 {
2092 cStringUtil::ToType(GetPtr(), ui32Value);
2093 }
2094
2103 static _myType FromType(tUInt32 ui32Value, const _myType& strFormat = Empty)
2104 {
2105 return ToStringFromType(ui32Value, strFormat.m_oStorageBuffer);
2106 }
2107
2108
2122 {
2123 tInt64 nRetValue = 0;
2124 ToType(nRetValue);
2125 return nRetValue;
2126 }
2127
2140 tVoid ToType(tInt64& i64Value) const
2141 {
2142 cStringUtil::ToType(GetPtr(), i64Value);
2143 }
2144
2154 static _myType FromType(tInt64 i64Value, const _myType& strFormat = Empty)
2155 {
2156 return ToStringFromType(i64Value, strFormat.m_oStorageBuffer);
2157 }
2158
2171 {
2172 tUInt64 nRetValue = 0;
2173 ToType(nRetValue);
2174 return nRetValue;
2175 }
2176
2188 tVoid ToType(tUInt64& ui64Value) const
2189 {
2190 cStringUtil::ToType(GetPtr(), ui64Value);
2191 }
2192
2202 static _myType FromType(tUInt64 ui64Value, const _myType& strFormat = Empty)
2203 {
2204 return ToStringFromType(ui64Value, strFormat);
2205 }
2206
2219 {
2220 tFloat64 fRetValue = 0;
2221 ToType(fRetValue);
2222 return fRetValue;
2223 }
2224
2235 tVoid ToType(tFloat64& f64Value) const
2236 {
2237 cStringUtil::ToType(GetPtr(), f64Value);
2238 }
2239
2249 static _myType FromType(tFloat64 f64Value, const _myType& strFormat = Empty)
2250 {
2251 return ToStringFromType(f64Value, strFormat);
2252 }
2253
2266 {
2267 tFloat32 fRetValue = 0;
2268 ToType(fRetValue);
2269 return fRetValue;
2270 }
2271
2282 tVoid ToType(tFloat32& f32Value) const
2283 {
2284 cStringUtil::ToType(GetPtr(), f32Value);
2285 }
2286
2296 static _myType FromType(tFloat32 f32Value, const _myType& strFormat = Empty)
2297 {
2298 return ToStringFromType(f32Value, strFormat);
2299 }
2300
2312 {
2313 tBool bRetValue = 0;
2314 ToType(bRetValue);
2315 return bRetValue;
2316 }
2317
2328 tVoid ToType(tBool& bValue) const
2329 {
2330 cStringUtil::ToType(GetPtr(), bValue);
2331 }
2332
2342 static _myType FromType(tBool bValue, const _myType& strFormat = Empty)
2343 {
2344 return ToStringFromType(bValue, strFormat);
2345 }
2346
2347
2355 {
2356 tInt64 nRetValue = 0;
2357 HexToType(nRetValue);
2358 return nRetValue;
2359 }
2360
2367 {
2368 return m_oStorageBuffer.max_size();
2369 }
2370
2381 tVoid HexToType(tInt64& i64Value) const
2382 {
2383 cStringUtil::HexToType(GetPtr(), i64Value);
2384 }
2385
2405 static inline _myType Format(
2406#ifdef _MSC_VER
2407 _In_z_ _Printf_format_string_
2408#endif // _MSC_VER
2409 const value_type* strFormat,
2410 ...)
2411#ifdef __GNUC__
2412 __attribute__((format(printf, 1, 2)))
2413#endif // __GNUC__
2414 {
2415 va_list args, args_copy;
2416 va_start(args, strFormat);
2417 va_copy(args_copy, args);
2418 _myType strBuffer;
2419 strBuffer.SetBuffer(static_cast<size_t>(::std::vsnprintf(nullptr, 0, strFormat, args_copy)));
2420 va_end(args_copy);
2421 ::std::vsnprintf(strBuffer.GetBuffer(), strBuffer.GetBufferSize() + 1, strFormat, args);
2422 va_end(args);
2423 return strBuffer;
2424 }
2425
2435 template<typename T>
2436 static _myType ToStringFromType(T oValue, const _myType& strFormat)
2437 {
2438 _myType strResult;
2439 tSize szMaxSize = strResult.GetMaxBufferSize();
2440 tSize szCurrentBuffer = 42;
2441 if (szMaxSize < szCurrentBuffer)
2442 {
2443 szCurrentBuffer = szMaxSize;
2444 }
2445 strResult.SetBuffer(szCurrentBuffer);
2446 cStringUtil::FromType(oValue, strResult.GetBuffer(), strResult.GetBufferSize(), strFormat.GetPtr());
2447 return strResult;
2448 }
2449
2460 static _myType& Copy(_myType& strDestination, const _myType& strSource, tSize szLength = InvalidPos)
2461 {
2462 return strDestination.Set(strSource, szLength);
2463 }
2464
2465};
2466
2467template <typename T> const string_base<T> string_base<T>::Empty;
2468template <typename T> const tSize string_base<T>::InvalidPos = g_npos;
2469
2473template<class sT, class sT2>
2475{
2482 tBool operator()(const string_base<sT>& str1, const string_base<sT2>& str2) const
2483 {
2484 return ((str1.Compare(str2)) < 0);
2485 }
2486};
2487
2488
2489
2493template<class sT, class sT2>
2495{
2502 tBool operator()(const string_base<sT>& str1, const string_base<sT2>& str2) const
2503 {
2504 return ((str1.CompareNoCase(str2)) < 0);
2505 }
2506};
2507
2514template<class sT>
2515tBool operator==(const tChar* str1, const string_base<sT>& str2)
2516{
2517 return str2.IsEqual(str1);
2518}
2519
2526template<class sT>
2527tBool operator!=(const tChar* str1, const string_base<sT>& str2)
2528{
2529 return str2.IsNotEqual(str1);
2530}
2531
2538template<class sT>
2539tBool operator<(const tChar* str1, const string_base<sT>& str2)
2540{
2541 return (str2.Compare(str1) > 0);
2542}
2543
2550template<class sT>
2551tBool operator>(const tChar* str1, const string_base<sT>& str2)
2552{
2553 return (str2.Compare(str1) < 0);
2554}
2555
2562template<class sT>
2563tBool operator<=(const tChar* str1, const string_base<sT>& str2)
2564{
2565 return (str2.Compare(str1) >= 0);
2566}
2567
2574template<class sT>
2575tBool operator>=(const tChar* str1, const string_base<sT>& str2)
2576{
2577 return (str2.Compare(str1) <= 0);
2578}
2579
2580
2587template<class sT>
2588tBool operator==(const std::string& str1, const string_base<sT>& str2)
2589{
2590 return str2.IsEqual(str1);
2591}
2592
2599template<class sT>
2600tBool operator!=(const std::string& str1, const string_base<sT>& str2)
2601{
2602 return str2.IsNotEqual(str1);
2603}
2604
2611template<class sT>
2612tBool operator<(const std::string& str1, const string_base<sT>& str2)
2613{
2614 return (str2.Compare(str1) > 0);
2615}
2616
2623template<class sT>
2624tBool operator>(const std::string& str1, const string_base<sT>& str2)
2625{
2626 return (str2.Compare(str1) < 0);
2627}
2628
2635template<class sT>
2636tBool operator<=(const std::string& str1, const string_base<sT>& str2)
2637{
2638 return (str2.Compare(str1) >= 0);
2639}
2640
2647template<class sT>
2648tBool operator>=(const std::string& str1, const string_base<sT>& str2)
2649{
2650 return (str2.Compare(str1) <= 0);
2651}
2652
2659template<class sT>
2660tBool operator==(const string_base<sT>& str1, const std::string& str2)
2661{
2662 return str1.IsEqual(str2);
2663}
2664
2671template<class sT>
2672tBool operator!=(const string_base<sT>& str1, const std::string& str2)
2673{
2674 return str1.IsNotEqual(str2);
2675}
2676
2683template<class sT>
2684tBool operator<(const string_base<sT>& str1, const std::string& str2)
2685{
2686 return (str1.Compare(str2) < 0);
2687}
2688
2695template<class sT>
2696tBool operator>(const string_base<sT>& str1, const std::string& str2)
2697{
2698 return (str1.Compare(str2) > 0);
2699}
2700
2707template<class sT>
2708tBool operator<=(const string_base<sT>& str1, const std::string& str2)
2709{
2710 return (str1.Compare(str2) <= 0);
2711}
2712
2719template<class sT>
2720tBool operator>=(const string_base<sT>& str1, const std::string& str2)
2721{
2722 return (str1.Compare(str2) >= 0);
2723}
2724
2734template<class sT, class sT2>
2736{
2737 return string_base<sT>(str1).Append(str2);
2738}
2739
2749template<class sT>
2751{
2752 return string_base<sT>(str1).Append(str2);
2753}
2754
2764template<class sT>
2766{
2767 return string_base<sT>(str1).Append(str2);
2768}
2769
2771#define A_UTILS_DEFAULT_SIZE_OF_STRING 64
2777typedef stack_string_base < A_UTILS_DEFAULT_SIZE_OF_STRING, growinheap_out_of_range > cStackString;
2778
2785
2796} // namespace A_UTILS_NS
2797
2798
2799
2800
2801#endif // _STRINGTEMPLATE_CLASS_HEADER_
unsigned long tUInt32
type definition for unsigned integer values (32bit) (platform and compiler independent type).
signed long tInt32
type definition for signed integer values (32bit) (platform and compiler independent type).
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).
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).
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 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 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 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:761
tVoid ToLower()
This function converts a cStringA object to a lowercase string.
Definition string.h:1751
string_base & operator=(const _myType &strValue)
The cString assignment (=) operator assigns a new value to the existing cString object.
Definition string.h:89
tVoid Trim()
This function removes leading and trailing whitespace characters from a cStringA object.
Definition string.h:1613
_StorageType::const_reverse_iterator const_reverse_iterator
short typedefinition for cString reverse iterators
Definition string.h:50
tInt32 AsInt32() const
This function converts the string to an integer value.
Definition string.h:2026
const tChar * GetPtr() const
This function returns the current string as an array of characters (c-style)
Definition string.h:473
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:814
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:869
tVoid LeftTrim(tBool bNumTrim=tFalse)
This function removes leading whitespace characters or leading zero characters from a cStringA object...
Definition string.h:1628
static _myType & Copy(_myType &strDestination, const _myType &strSource, tSize szLength=InvalidPos)
Copies the value of one StringObject to another Stringobject.
Definition string.h:2460
tChar & operator[](tSize nIdx)
array access operator
Definition string.h:432
tInt64 HexToInt64() const
This function converts a hexadecimal string representation to an integer value.
Definition string.h:2354
tVoid ToType(tUInt32 &ui32Value) const
This function converts the string to an integer value.
Definition string.h:2090
tVoid ToType(tBool &bValue) const
This function converts the string to a boolean value.
Definition string.h:2328
static _myType FromType(tFloat64 f64Value, const _myType &strFormat=Empty)
This function creates a new cString object from a numeric value.
Definition string.h:2249
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:779
tVoid ToType(tFloat64 &f64Value) const
This function converts the string to a floating-point value.
Definition string.h:2235
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:1103
tVoid RightTrim()
This function removes trailing whitespace characters from a cStringA object.
Definition string.h:1658
tBool EndsWith(const _myType &strEndsWith, const tBool bNoCase=tFalse) const
This function checks if the string ends with a given postfix.
Definition string.h:1182
_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:2154
string_base & operator=(_myType &&strValue)
The cString assignment (=) operator assigns a new value to the existing cString object.
Definition string.h:107
_StorageType::iterator iterator
short typedefinition for cString iterators
Definition string.h:44
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:716
tChar GetAt(tSize nIdx) const
You can think of a cStringA object as an array of characters.
Definition string.h:383
tSize CountString(const _myType &strFind, tSize nStart=0) const
This counts the occurrences of a given substring in a string.
Definition string.h:968
tSize GetMaxBufferSize() const
Return maximum size of string buffer.
Definition string.h:2366
const_iterator cbegin() const
Iterator to beginning.
Definition string.h:205
_myType & Append(tChar c)
This function appends one character to the end of the cStringA object.
Definition string.h:543
tBool IsNotEmpty() const
This function checks if the string object is not empty.
Definition string.h:460
static _myType Repeat(tChar c, tSize nCount)
Creates a string from a repeated character.
Definition string.h:2009
tBool operator>(const tChar *pString) const
Checks if a string is lexicographically smaller than the cStringA object.
Definition string.h:1279
tSize Replace(const _myType &strOld, const _myType &strNew, tBool bReplaceAll=tTrue)
This function replaces one substring by another.
Definition string.h:1001
static _myType FromType(tBool bValue, const _myType &strFormat=Empty)
This function creates a new cString object from a boolean value.
Definition string.h:2342
tBool AsBool() const
This function converts the string to a boolean value.
Definition string.h:2311
tSize GetBufferSize() const
Get the size of the internal allocated string buffer.
Definition string.h:362
tBool operator==(const _myType &strString) const
Checks if a string equals the cStringA object.
Definition string.h:1315
tUInt32 AsUInt32() const
This function converts the string to an integer value.
Definition string.h:2072
tFloat32 AsFloat32() const
This function converts the string to a floating-point value.
Definition string.h:2265
static _myType FromType(tFloat32 f32Value, const _myType &strFormat=Empty)
This function creates a new cString object from a numeric value.
Definition string.h:2296
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:695
string_base & operator=(const _StorageType &strValue)
The cString assignment (=) operator assigns a new value to the existing cString object.
Definition string.h:134
string_base(const string_base< T2 > &strValue)
Constructor that initalizes an existing cString object with the spezified string value.
Definition string.h:117
_myType & Append(const _myType &strString, tSize nLength=InvalidPos)
This function appends a string to the end of the cStringA object.
Definition string.h:503
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:1268
_myType & Set(const _myType &strStringToSet, tSize nLength=InvalidPos)
Assigns a new value to a cStringA object.
Definition string.h:246
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:1518
static _myType ToStringFromType(T oValue, const _myType &strFormat)
This function creates a new cString object from a numeric value.
Definition string.h:2436
tSize Filter(tChar cChar)
This function removes all occurrences of a given character from a string.
Definition string.h:1087
_myType & Set(tChar c, tSize nCount)
Assigns a new value to a cStringA object.
Definition string.h:295
tSize Replace(tChar cOld, tChar cNew, tBool bReplaceAll=tTrue)
This function replaces one character by another.
Definition string.h:1053
tVoid ToType(tInt64 &i64Value) const
This function converts the string to an integer value.
Definition string.h:2140
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:744
tVoid ToUpper()
This function converts a cStringA object to an uppercase string.
Definition string.h:1773
static _myType FromType(tUInt64 ui64Value, const _myType &strFormat=Empty)
This function creates a new cString object from a numeric value.
Definition string.h:2202
_myType & Insert(const tChar *pToInsertString, tSize nPos, tSize nLength=InvalidPos)
This function inserts a string into the cStringA object.
Definition string.h:666
reverse_iterator rend()
Reverse iterator to end.
Definition string.h:200
tChar * GetBuffer()
This function returns the pointer to the data.
Definition string.h:486
tInt64 AsInt64() const
This function converts the string to an integer value.
Definition string.h:2121
tSize GetLength() const
This function returns the number of characters in a cStringA object.
Definition string.h:315
_myType Right(tSize nLength) const
Extracts the last (that is, rightmost) nLength characters from the cStringA object and returns a copy...
Definition string.h:1474
tBool operator!=(const _myType &strString) const
Checks if a string not equals the cStringA object.
Definition string.h:1326
virtual ~string_base()
Destructor.
Definition string.h:176
const_reverse_iterator crbegin() const
Reverse iterator to beginning.
Definition string.h:215
string_base(const _StorageType &strValue)
Constructor that initalizes an existing cString object with the spezified string value.
Definition string.h:129
tBool IsInteger() const
Check if string content represents an integer value.
Definition string.h:1963
const tChar & operator[](tSize nIdx) const
array access operator
Definition string.h:420
static _myType FromType(tInt32 i32Value, const _myType &strFormat=Empty)
This function creates a new cString object from a numeric value.
Definition string.h:2056
_myType SubString(tSize nPos, tSize nLength=InvalidPos) const
This function extracts a substring of length nLength characters from the cStringA object,...
Definition string.h:1393
static _myType Format(const value_type *strFormat,...)
Write formatted data to a string.
Definition string.h:2405
const_iterator cend() const
Iterator to end.
Definition string.h:210
tVoid ToType(tInt32 &i32Value) const
This function converts the string to an integer value.
Definition string.h:2043
tBool operator<=(const tChar *pString) const
Checks if a string is lexicographically greater than or equal to the cStringA object.
Definition string.h:1291
_myType Mid(tSize nPos, tSize nLength=InvalidPos) const
This function extracts a substring of length nLength characters from the cStringA object,...
Definition string.h:1421
_myType & Delete(tSize nPos, tSize nLength=InvalidPos)
This function deletes a substring of length nLength characters from the cStringA object,...
Definition string.h:584
tVoid Clear()
Makes this cStringA object an empty string and frees memory as appropriate.
Definition string.h:230
_StorageType::const_iterator const_iterator
short typedefinition for cString iterators
Definition string.h:46
_myType & Set(const tChar *pString, tSize nLength=InvalidPos)
Assigns a new value to a cStringA object.
Definition string.h:269
static _myType FromType(tUInt32 ui32Value, const _myType &strFormat=Empty)
This function creates a new cString object from a numeric value.
Definition string.h:2103
tBool StartsWith(const _myType &strStartsWith, const tBool bNoCase=tFalse) const
This function checks if the string starts with a given prefix.
Definition string.h:1137
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:1501
tVoid NumTrim()
This function removes whitespace and redundant zero characters from a cStringA object.
Definition string.h:1676
tBool IsFloat() const
Check if string content represents a floating point value.
Definition string.h:1980
_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:796
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:890
tBool IsEmpty() const
This function checks if the string object is empty.
Definition string.h:447
tVoid HexToType(tInt64 &i64Value) const
This function converts a hexadecimal string representation to an integer value.
Definition string.h:2381
tVoid SetAt(tSize nIdx, tChar c)
The SetAt member function sets a single character at a specified position.
Definition string.h:404
string_base & operator=(const tChar &strValue)
The cString assignment (=) operator assigns a new value to the existing cString object.
Definition string.h:145
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:1725
const_reverse_iterator crend() const
Reverse iterator to end.
Definition string.h:220
string_base & operator=(const string_base< T2 > &strValue)
Constructor that initalizes an existing cString object with the spezified string value.
Definition string.h:123
tBool IsNumeric() const
Check if string content represents a numeric value.
Definition string.h:1994
string_base(const tChar *strValue)
Constructor that initalizes an existing cString object with the spezified string value.
Definition string.h:151
iterator end()
Iterator to end.
Definition string.h:190
tSize SetBuffer(tSize szSize)
Sets or resizes the internal string buffer.
Definition string.h:334
reverse_iterator rbegin()
Reverse iterator to beginning.
Definition string.h:195
string_base(_myType &&strValue)
Constructor that initalizes an existing cString object with the spezified string value.
Definition string.h:102
_myType & Unescape()
Escape control characters.
Definition string.h:1878
_myType & Insert(const _myType &strToInsertString, tSize nPos, tSize nLength=InvalidPos)
This function inserts a string into the cStringA object.
Definition string.h:640
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:943
tBool operator==(const tChar *pString) const
Checks if a string equals the cStringA object.
Definition string.h:1246
string_base & operator=(const tChar *strValue)
The cString assignment (=) operator assigns a new value to the existing cString object.
Definition string.h:166
iterator begin()
Iterator to beginning.
Definition string.h:185
_myType & Escape()
Escape control characters.
Definition string.h:1793
string_base(const tChar &strValue)
Constructor that initalizes an existing cString object with the spezified string value.
Definition string.h:140
tBool operator>=(const tChar *pString) const
Checks if a string is lexicographically smaller than or equal to the cStringA object.
Definition string.h:1303
string_base(const tChar *strValue, tSize szLength)
Constructor that initalizes an existing cString object with the spezified string value.
Definition string.h:161
tVoid ToType(tFloat32 &f32Value) const
This function converts the string to a floating-point value.
Definition string.h:2282
tBool operator>=(const _myType &strString) const
Checks if a string is lexicographically smaller than or equal to the cStringA object.
Definition string.h:1372
const _myType & operator+=(const _myType &strString)
The += concatenation operator joins characters to the end of this string.
Definition string.h:1234
tUInt64 AsUInt64() const
This function converts the string to an integer value.
Definition string.h:2170
tVoid SplitToken(string_list_base< _myType > &lstList, const _myType &strTokenList) const
Split string using a token list.
Definition string.h:1575
tFloat64 AsFloat64() const
This function converts the string to a floating-point value.
Definition string.h:2218
tBool operator<=(const _myType &strString) const
Checks if a string is lexicographically greater than or equal to the cStringA object.
Definition string.h:1360
_myType Left(tSize nLength) const
Extracts the first (that is, leftmost) nLength characters from the cStringA object and returns a copy...
Definition string.h:1454
tVoid ToType(tUInt64 &ui64Value) const
This function converts the string to an integer value.
Definition string.h:2188
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:1257
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:914
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:837
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 util or adtf_util.
Definition d_ptr.h:11
bool operator>=(const simple_pointer_iterator< T > &r1, const simple_pointer_iterator< T > &r2)
Define greater or equal to operator between iterators.
bool operator>(const simple_pointer_iterator< T > &r1, const simple_pointer_iterator< T > &r2)
Define greater than operator between iterators.
string_base_no_case_compare_func< cStackString, cStackString > cStringNoCaseCompareFunc
Compare functor for the cStackString.
Definition string.h:2795
bool operator<(const simple_pointer_iterator< T > &r1, const simple_pointer_iterator< T > &r2)
Define lesser than operator between iterators.
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:2784
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:2777
tBool operator!=(const cMultiArrayIndex &o_A, const cMultiArrayIndex &o_B)
Comparison operator.
tBool operator==(const cMultiArrayIndex &o_A, const cMultiArrayIndex &o_B)
Comparison operator.
bool operator<=(const simple_pointer_iterator< T > &r1, const simple_pointer_iterator< T > &r2)
Define lesser or equal to operator between iterators.
string_base_compare_func< cStackString, cStackString > cStringCompareFunc
Compare functor for the cStackString.
Definition string.h:2790
simple_pointer_iterator< T >::difference_type operator+(const simple_pointer_iterator< T > &r1, const simple_pointer_iterator< T > &r2)
Define arithmetic + operation between iterators.
Compare function for stl container e.g.
Definition string.h:2475
tBool operator()(const string_base< sT > &str1, const string_base< sT2 > &str2) const
String compare function.
Definition string.h:2482
Compare function for stl container e.g.
Definition string.h:2495
tBool operator()(const string_base< sT > &str1, const string_base< sT2 > &str2) const
String compare function.
Definition string.h:2502