PLCnext API Documentation  22.9.0.33
BasicString.hxx
1 //
3 // Copyright PHOENIX CONTACT Electronics GmbH
4 //
6 #pragma once
7 #include <string>
8 #include <vector>
9 #include <algorithm>
10 #include <memory>
11 #include <iostream>
12 #include <initializer_list>
13 #include "boost/algorithm/string/replace.hpp"
14 #include "Arp/System/Core/BasicFormatter.hxx"
15 #include "Arp/System/Core/Impl/BasicStringFormatExceptionHandler.hpp"
16 
17 #ifndef ARP_INSIDE_ARP_H
18  #error Never include 'BasicString.hxx' directly, just include 'Arp.h'
19 #endif
20 
21 namespace Arp
22 {
23 
25 
28 
31 template<class C, class Alloc = std::allocator<C>>
33 {
34 public: // usings
35  using Allocator = Alloc;
36  using AllocatorTraits = std::allocator_traits<Alloc>;
37  using CharType = C;
39  using BaseString = std::basic_string<CharType, std::char_traits<CharType>, Allocator>;
40  using Tokens = std::vector<SelfType>;
41 
42 public: // policy typedefs
44  using value_type = CharType;
45  using size_type = typename BaseString::size_type;
46  using difference_type = typename BaseString::difference_type;
47  using reference = typename BaseString::reference;
48  using const_reference = typename BaseString::const_reference;
49  using pointer = typename AllocatorTraits::pointer;
50  using const_pointer = typename AllocatorTraits::const_pointer;
51  using iterator = typename BaseString::iterator;
52  using const_iterator = typename BaseString::const_iterator;
53  using reverse_iterator = typename BaseString::reverse_iterator;
54  using const_reverse_iterator = typename BaseString::const_reverse_iterator;
55 
56 private: // usings
58 
59 public: // construction/destruction
61  BasicString() = default;
62 
65  BasicString(const SelfType& arg) = default;
66 
70  BasicString(const SelfType& arg, const Allocator& alloc)
71  : baseString(arg.baseString, alloc)
72  {
73  }
74 
77  explicit BasicString(const Allocator& alloc)
78  : baseString(alloc)
79  {
80  }
81 
86  BasicString(const SelfType& arg, size_type offset, size_type count = NPos)
87  : baseString(arg.baseString, offset, count)
88  {
89  }
90 
96  BasicString(const SelfType& arg, size_type offset, size_type count, const Allocator& alloc)
97  : baseString(arg.baseString, offset, count, alloc)
98  {
99  }
100 
104  BasicString(const CharType* pChars, size_type count)
105  : baseString(pChars, count)
106  {
107  }
108 
113  BasicString(const CharType* pChars, size_type count, const Allocator& alloc)
114  : baseString(pChars, count, alloc)
115  {
116  }
117 
120  BasicString(const CharType* pChars)
121  : baseString(pChars)
122  {
123  }
124 
128  BasicString(const CharType* pChars, const Allocator& alloc)
129  : baseString(pChars, alloc)
130  {
131  }
132 
137  : baseString(count, c)
138  {
139  }
140 
145  BasicString(size_type count, CharType c, const Allocator& alloc)
146  : baseString(count, c, alloc)
147  {
148  }
149 
152  BasicString(SelfType&& arg) noexcept = default;
153 
157  BasicString(SelfType&& arg, const Allocator& alloc)
158  : baseString(std::move(arg.baseString), alloc)
159  {
160  }
161 
165  BasicString(std::initializer_list<CharType> arg, const Allocator& alloc = Allocator())
166  : baseString(arg, alloc)
167  {
168  }
169 
174  BasicString(iterator first, iterator last, const Allocator& alloc = Allocator())
175  : baseString(first, last, alloc)
176  {
177  }
178 
184  : baseString(first, last, alloc)
185  {
186  }
187 
191  : baseString(arg)
192  {
193  }
194 
198  : baseString(std::move(arg))
199  {
200  }
201 
203  ~BasicString() = default;
204 
205 public: // static fields
210  static const size_type NPos = size_type(-1);
214  static const SelfType Empty;
218  static const SelfType NewLine;
219 
220 public: // assignment operator
224  SelfType& operator=(SelfType&& right) noexcept = default;
225 
229  SelfType& operator=(std::initializer_list<CharType> right)
230  {
231  this->baseString = right;
232  return (*this);
233  }
234 
238  SelfType& operator=(const SelfType& right) = default;
239 
243  SelfType& operator=(const CharType* right)
244  {
245  this->baseString = right;
246  return (*this);
247  }
248 
253  {
254  this->baseString = c;
255  return (*this);
256  }
257 
258 public: // append operator
262  SelfType& operator+=(std::initializer_list<CharType> right)
263  {
264  this->baseString += right;
265  return (*this);
266  }
267 
271  SelfType& operator+=(const SelfType& right)
272  {
273  this->baseString += right.baseString;
274  return (*this);
275  }
276 
280  SelfType& operator+=(const CharType* right)
281  {
282  this->baseString += right;
283  return (*this);
284  }
285 
290  {
291  this->baseString += c;
292  return (*this);
293  }
294 
295 public: // assign operations
296 
301  {
302  this->baseString = std::move(arg.baseString);
303  return *this;
304  }
305 
309  SelfType& Assign(std::initializer_list<CharType> arg)
310  {
311  this->baseString.assign(arg);
312  return *this;
313  }
314 
318  SelfType& Assign(const SelfType& arg)
319  {
320  this->baseString.assign(arg.baseString);
321  return *this;
322  }
323 
328  SelfType& Assign(const SelfType& arg, size_type offset, size_type count = NPos)
329  {
330  this->baseString.assign(arg.baseString, offset, count);
331  return *this;
332  }
333 
338  {
339  this->baseString.assign(arg);
340  return *this;
341  }
342 
347  {
348  this->baseString.assign(std::move(arg));
349  return *this;
350  }
351 
355  SelfType& Assign(const CharType* pChars, size_type count)
356  {
357  this->baseString.assign(pChars, count);
358  return *this;
359  }
360 
363  SelfType& Assign(const CharType* pChars)
364  {
365  this->baseString.assign(pChars);
366  return *this;
367  }
368 
373  {
374  this->baseString.assign(count, c);
375  return *this;
376  }
377 
382  {
383  this->baseString.assign(first, last);
384  return *this;
385  }
386 
391  {
392  this->baseString.assign(first, last);
393  return *this;
394  }
395 
400  {
401  this->baseString.assign(first, last);
402  return *this;
403  }
404 
405 public: // append operations
406 
410  SelfType& Append(std::initializer_list<CharType> arg)
411  {
412  this->baseString.append(arg);
413  return *this;
414  }
415 
419  SelfType& Append(const SelfType& arg)
420  {
421  this->baseString.append(arg.baseString);
422  return *this;
423  }
424 
429  SelfType& Append(const SelfType& arg, size_type offset, size_type count = NPos)
430  {
431  this->baseString.append(arg.baseString, offset, count);
432  return *this;
433  }
434 
438  SelfType& Append(const CharType* pChars, size_type count)
439  {
440  this->baseString.append(pChars, count);
441  return *this;
442  }
443 
446  SelfType& Append(const CharType* pChars)
447  {
448  this->baseString.append(pChars);
449  return *this;
450  }
451 
456  {
457  this->baseString.append(count, c);
458  return *this;
459  }
460 
465  {
466  this->baseString.append(first, last);
467  return *this;
468  }
469 
474  {
475  this->baseString.append(first, last);
476  return *this;
477  }
478 
483  {
484  this->baseString.append(first, last);
485  return *this;
486  }
487 
488 public: // insert operations
489 
494  iterator Insert(const_iterator where, std::initializer_list<CharType> arg)
495  {
496  return this->baseString.insert(where, arg);
497  }
498 
503  SelfType& Insert(size_type offset, const SelfType& arg)
504  {
505  this->baseString.insert(offset, arg.baseString);
506  return *this;
507  }
508 
515  SelfType& Insert(size_type offset, const SelfType& arg, size_type argOffset, size_type count = NPos)
516  {
517  this->baseString.insert(offset, arg.baseString, argOffset, count);
518  return *this;
519  }
520 
526  SelfType& Insert(size_type offset, const CharType* pChars, size_type count)
527  {
528  this->baseString.insert(offset, pChars, count);
529  return *this;
530  }
531 
536  SelfType& Insert(size_type offset, const CharType* pChars)
537  {
538  this->baseString.insert(offset, pChars);
539  return *this;
540  }
541 
548  {
549  this->baseString.insert(offset, count, c);
550  return *this;
551  }
552 
558  {
559  return this->baseString.insert(where, c);
560  }
561 
568  {
569  return this->baseString.insert(where, count, c);
570  }
571 
578  {
579  return this->baseString.insert(where, first, last);
580  }
581 
588  {
589  return this->baseString.insert(where, first, last);
590  }
591 
598  {
599  return this->baseString.insert(where, first, last);
600  }
601 
602 public: // erase operations
603 
607  SelfType& Erase(size_type offset = 0)
608  {
609  this->baseString.erase(offset);
610  return (*this);
611  }
612 
618  {
619  this->baseString.erase(offset, count);
620  return (*this);
621  }
622 
627  {
628  return this->baseString.erase(where);
629  }
630 
636  {
637  return this->baseString.erase(first, last);
638  }
639 
640 public: // replace operation
641 
647  SelfType& Replace(const_iterator first, const_iterator last, std::initializer_list<CharType> chars)
648  {
649  this->baseString.replace(first, last, chars);
650  return *this;
651  }
652 
658  SelfType& Replace(size_type offset, size_type length, const SelfType& arg)
659  {
660  this->baseString.replace(offset, length, arg.baseString);
661  return (*this);
662  }
663 
671  SelfType& Replace(size_type offset, size_type length, const SelfType& arg, size_type offsetArg, size_type count = NPos)
672  {
673  this->baseString.replace(offset, length, arg.baseString, offsetArg, count);
674  return (*this);
675  }
676 
683  SelfType& Replace(size_type offset, size_type length, const CharType* pChars, size_type count)
684  {
685  this->baseString.replace(offset, length, pChars, offset, count);
686  return (*this);
687  }
688 
694  SelfType& Replace(size_type offset, size_type length, const CharType* pChars)
695  {
696  this->baseString.replace(offset, length, pChars);
697  return (*this);
698  }
699 
707  {
708  this->baseString.replace(offset, length, count, c);
709  return (*this);
710  }
711 
718  {
719  this->baseString.replace(first, last, arg.baseString);
720  return (*this);
721  }
722 
729  SelfType& Replace(const_iterator first, const_iterator last, const CharType* pChars, size_type count)
730  {
731  this->baseString.replace(first, last, pChars, count);
732  return (*this);
733  }
734 
741  {
742  this->baseString.replace(first, last, pChars);
743  return (*this);
744  }
745 
753  {
754  this->baseString.replace(first, last, count, c);
755  return (*this);
756  }
757 
765  {
766  this->baseString.replace(first, last, first2, last2);
767  return (*this);
768  }
769 
777  {
778  this->baseString.replace(first, last, first2, last2);
779  return (*this);
780  }
781 
789  {
790  this->baseString.replace(first, last, first2, last2);
791  return (*this);
792  }
793 
801  {
802  this->baseString.replace(first, last, first2, last2);
803  return (*this);
804  }
805 
806 public: // replace_all operations
807 
813  SelfType& ReplaceAll(const SelfType& pattern, const SelfType& replacement)
814  {
815  boost::replace_all(this->baseString, pattern.baseString, replacement.baseString);
816  return (*this);
817  }
818 
819 public: // support of range based for loops
820 
825  {
826  return this->baseString.begin();
827  }
828 
833  {
834  return this->baseString.begin();
835  }
836 
841  {
842  return this->baseString.end();
843  }
844 
849  {
850  return this->baseString.end();
851  }
852 
853 public: // container operations
854 
858  {
859  return this->baseString.begin();
860  }
861 
865  {
866  return this->baseString.begin();
867  }
868 
872  {
873  return this->baseString.end();
874  }
875 
879  {
880  return this->baseString.end();
881  }
882 
886  {
887  return this->baseString.rbegin();
888  }
889 
893  {
894  return this->baseString.rbegin();
895  }
896 
900  {
901  return this->baseString.rend();
902  }
903 
907  {
908  return this->baseString.rend();
909  }
910 
914  {
915  return this->baseString.cbegin();
916  }
917 
921  {
922  return this->baseString.cend();
923  }
924 
928  {
929  return this->baseString.crbegin();
930  }
931 
935  {
936  return this->baseString.crend();
937  }
938 
940  void ShrinkToFit()
941  {
942  this->baseString.shrink_to_fit();
943  }
944 
948  {
949  this->baseString.push_back(c);
950  }
951 
954  void PopBack()
955  {
956  if(!this->IsEmpty())
957  {
958  this->baseString.pop_back();
959  }
960  }
961 
966  {
967  return this->baseString.front();
968  }
969 
974  {
975  return this->baseString.front();
976  }
977 
982  {
983  return this->baseString.back();
984  }
985 
990  {
991  return this->baseString.back();
992  }
993 
999  {
1000  return this->baseString.at(offset);
1001  }
1002 
1008  {
1009  return this->baseString.at(offset);
1010  }
1011 
1017  {
1018  return this->baseString[offset];
1019  }
1020 
1026  {
1027  return this->baseString[offset];
1028  }
1029 
1030 public: // Size/Length operations
1031 
1040  {
1041  return this->baseString.length();
1042  }
1043 
1051  size_type Size() const
1052  {
1053  return this->baseString.size();
1054  }
1055 
1058  {
1059  return this->baseString.max_size();
1060  }
1061 
1070  {
1071  return this->baseString.capacity();
1072  }
1073 
1076  bool IsEmpty() const
1077  {
1078  return this->baseString.empty();
1079  }
1080 
1087  void Resize(size_type newSize)
1088  {
1089  this->baseString.resize(newSize);
1090  }
1091 
1099  void Resize(size_type newSize, CharType c)
1100  {
1101  this->baseString.resize(newSize, c);
1102  }
1103 
1111  void Reserve(size_type newCapacity = 0)
1112  {
1113  this->baseString.reserve(newCapacity);
1114  }
1115 
1117  void Clear()
1118  {
1119  this->baseString.clear();
1120  }
1121 
1122 public: // Find operations
1123 
1128  size_type Find(const SelfType& pattern, size_type offset = 0) const
1129  {
1130  return this->baseString.find(pattern.baseString, offset);
1131  }
1132 
1138  size_type Find(const CharType* pChars, size_type offset, size_type count) const
1139  {
1140  return this->baseString.find(pChars, offset, count);
1141  }
1142 
1147  size_type Find(const CharType* pChars, size_type offset = 0) const
1148  {
1149  return this->baseString.find(pChars, offset);
1150  }
1151 
1156  size_type Find(CharType c, size_type offset = 0) const
1157  {
1158  return this->baseString.find(c, offset);
1159  }
1160 
1165  size_type ReverseFind(const SelfType& pattern, size_type offset = NPos) const
1166  {
1167  return this->baseString.rfind(pattern.baseString, offset);
1168  }
1169 
1175  size_type ReverseFind(const CharType* pChars, size_type offset, size_type count) const
1176  {
1177  return this->baseString.rfind(pChars, offset, count);
1178  }
1179 
1184  size_type ReverseFind(const CharType* pChars, size_type offset = NPos) const
1185  {
1186  return this->baseString.rfind(pChars, offset);
1187  }
1188 
1194  {
1195  return this->baseString.rfind(c, offset);
1196  }
1197 
1202  size_type FindFirstOf(const SelfType& chars, size_type offset = 0) const
1203  {
1204  return this->baseString.find_first_of(chars.baseString, offset);
1205  }
1206 
1212  size_type FindFirstOf(const CharType* pChars, size_type offset, size_type count) const
1213  {
1214  return this->baseString.find_first_of(pChars, offset, count);
1215  }
1216 
1221  size_type FindFirstOf(const CharType* pChars, size_type offset = 0) const
1222  {
1223  return this->baseString.find_first_of(pChars, offset);
1224  }
1225 
1232  {
1233  return this->baseString.find_first_of(c, offset);
1234  }
1235 
1240  size_type FindLastOf(const SelfType& chars, size_type offset = NPos) const
1241  {
1242  return this->baseString.find_last_of(chars.baseString, offset);
1243  }
1244 
1250  size_type FindLastOf(const CharType* pChars, size_type offset, size_type count) const
1251  {
1252  return this->baseString.find_last_of(pChars, offset, count);
1253  }
1254 
1259  size_type FindLastOf(const CharType* pChars, size_type offset = NPos) const
1260  {
1261  return this->baseString.find_last_of(pChars, offset);
1262  }
1263 
1270  {
1271  return this->baseString.find_last_of(c, offset);
1272  }
1273 
1278  size_type FindFirstNotOf(const SelfType& chars, size_type offset = 0) const
1279  {
1280  return this->baseString.find_first_not_of(chars.baseString, offset);
1281  }
1282 
1288  size_type FindFirstNotOf(const CharType* pChars, size_type offset, size_type count) const
1289  {
1290  return this->baseString.find_first_not_of(pChars, offset, count);
1291  }
1292 
1297  size_type FindFirstNotOf(const CharType *pChars, size_type offset = 0) const
1298  {
1299  return this->baseString.find_first_not_of(pChars, offset);
1300  }
1301 
1308  {
1309  return this->baseString.find_first_not_of(c, offset);
1310  }
1311 
1316  size_type FindLastNotOf(const SelfType& chars, size_type offset = NPos) const
1317  {
1318  return this->baseString.find_last_not_of(chars.baseString, offset);
1319  }
1320 
1326  size_type FindLastNotOf(const CharType *pChars, size_type offset, size_type count) const
1327  {
1328  return this->baseString.find_last_not_of(pChars, offset, count);
1329  }
1330 
1335  size_type FindLastNotOf(const CharType *pChars, size_type offset = NPos) const
1336  {
1337  return this->baseString.find_last_not_of(pChars, offset);
1338  }
1339 
1346  {
1347  return this->baseString.find_last_not_of(c, offset);
1348  }
1349 
1350 public: // Compare operations
1351 
1359  int Compare(const SelfType& other) const
1360  {
1361  return this->baseString.compare(other.baseString);
1362  }
1363 
1373  int Compare(size_type offset, size_type count, const SelfType& other) const
1374  {
1375  return this->baseString.compare(offset, count, other.baseString);
1376  }
1377 
1389  int Compare(size_type offset, size_type count, const SelfType& other, size_type offsetOther, size_type countOther = NPos) const
1390  {
1391  return this->baseString.compare(offset, count, other.baseString, offsetOther, countOther);
1392  }
1393 
1401  int Compare(const CharType *pOther) const
1402  {
1403  return this->baseString.compare(pOther);
1404  }
1405 
1415  int Compare(size_type offset, size_type count, const CharType *pOther) const
1416  {
1417  return this->baseString.compare(offset, count, pOther);
1418  }
1419 
1430  int Compare(size_type offset, size_type count, const CharType *pOther, size_type countOther) const
1431  {
1432  return this->baseString.compare(offset, count, pOther, countOther);
1433  }
1434 
1435 public: // misc operations (none std)
1436 
1440  bool StartWith(const CharType *pChars)const
1441  {
1442  return this->Find(pChars) == 0;
1443  }
1444 
1448  bool StartWith(const SelfType& pattern)const
1449  {
1450  return this->Find(pattern) == 0;
1451  }
1452 
1456  bool EndWith(const CharType* pChars)const
1457  {
1458  return this->EndWith(SelfType(pChars));
1459  }
1460 
1464  bool EndWith(const SelfType& pattern)const
1465  {
1466  size_t thisLength = this->baseString.length();
1467  size_t patternLength = pattern.baseString.length();
1468 
1469  if (thisLength < patternLength)
1470  {
1471  return false;
1472  }
1473  // else
1474  return (this->baseString.compare(thisLength - patternLength, patternLength, pattern.baseString) == 0);
1475  }
1476 
1477 public: // Format operations
1482  template<typename... Args>
1483  static SelfType Format(const SelfType& format, const Args& ... args)
1484  {
1485  return Format(format.CStr(), args...);
1486  }
1487 
1492  template<typename... Args>
1493  static SelfType Format(const char* format, const Args& ... args)
1494  {
1495  return BasicFormatterType::FormatCommon(&BasicStringFormatExceptionHandler::Invoke, format, args...);
1496  }
1497 
1498 public: // Misc operations
1502  {
1503  return this->baseString;
1504  }
1505 
1508  const CharType* CStr() const
1509  {
1510  return this->baseString.c_str();
1511  }
1512 
1515  operator const CharType*() const
1516  {
1517  return this->baseString.data();
1518  }
1519 
1522  operator const BaseString& () const
1523  {
1524  return this->baseString;
1525  }
1526 
1531  SelfType Substr(size_type offset = 0, size_type count = NPos) const
1532  {
1533  return SelfType(this->baseString.substr(offset, count));
1534  }
1535 
1539  {
1540  return this->baseString.get_allocator();
1541  }
1542 
1545  void Swap(SelfType& other)
1546  {
1547  this->baseString.swap(other.baseString);
1548  }
1549 
1550  SelfType TrimLeft()const
1551  {
1552  auto left = std::find_if(this->baseString.begin(), this->baseString.end(), [](char c)
1553  {
1554  return !std::isspace<char>(c, std::locale::classic());
1555  });
1556  return SelfType(left, this->baseString.end());
1557  }
1558 
1559  SelfType TrimRight()const
1560  {
1561  auto right = std::find_if(this->baseString.rbegin(), this->baseString.rend(), [](char c)
1562  {
1563  return !std::isspace<char>(c, std::locale::classic());
1564  });
1565  return SelfType(this->baseString.begin(), right.base());
1566  }
1567 
1568  SelfType Trim()const
1569  {
1570  auto left = std::find_if(this->baseString.begin(), this->baseString.end(), [](char c)
1571  {
1572  return !std::isspace<char>(c, std::locale::classic());
1573  });
1574 
1575  // check if string only consists of whitespaces
1576  if (left == this->baseString.end())
1577  {
1578  return Empty;
1579  }
1580 
1581  auto right = std::find_if(this->baseString.rbegin(), this->baseString.rend(), [](char c)
1582  {
1583  return !std::isspace<char>(c, std::locale::classic());
1584  });
1585  return SelfType(left, right.base());
1586  }
1587 
1593  Tokens Split(char delimiter, bool trimTokens = true, bool removeEmptyTokens = true)const
1594  {
1595  char delimiters[] = { delimiter };
1596  return this->Split(delimiters, 1, trimTokens, removeEmptyTokens);
1597  }
1598 
1605  Tokens Split(const char delimiters[], size_t delimitersCount, bool trimTokens = true, bool removeEmptyTokens = true)const
1606  {
1607  Tokens tokens;
1608 
1609  size_t last = 0;
1610  size_t length = this->Length();
1611 
1612  for (size_t first = 0; first < length; first = last + 1)
1613  {
1614  size_t position = this->FindFirstOf(delimiters, first, delimitersCount);
1615  last = (position != NPos) ? position : this->Length();
1616 
1617  SelfType token = this->Substr(first, last - first);
1618  if (trimTokens)
1619  {
1620  token = token.Trim();
1621  }
1622  if (!removeEmptyTokens || !token.IsEmpty())
1623  {
1624  tokens.push_back(token);
1625  }
1626  }
1627 
1628  if (!removeEmptyTokens && (this->FindLastOf(delimiters, NPos, delimitersCount) == (length - 1)))
1629  {
1630  tokens.push_back(Empty);
1631  }
1632 
1633  return tokens;
1634  }
1635 
1641  Tokens SplitByWord(const SelfType& delimiter, bool trimTokens = true, bool removeEmptyTokens = true)const
1642  {
1643  Tokens tokens;
1644 
1645  size_t last = 0;
1646  size_t length = this->Length();
1647  size_t delimiterLength = delimiter.Length();
1648 
1649  for (size_t first = 0; first < length; first = last + delimiterLength)
1650  {
1651  size_t position = this->Find(delimiter, first);
1652  last = (position != NPos) ? position : length;
1653 
1654  SelfType token = this->Substr(first, last - first);
1655  if (trimTokens)
1656  {
1657  token = token.Trim();
1658  }
1659  if (!token.IsEmpty() || !removeEmptyTokens)
1660  {
1661  tokens.push_back(token);
1662  }
1663  }
1664 
1665  if (!removeEmptyTokens && this->EndWith(delimiter))
1666  {
1667  tokens.push_back(Empty);
1668  }
1669 
1670  return tokens;
1671  }
1672 
1673  // warning 4996 occurs, to avoid use _SCL_SECURE_NO_WARNINGS
1674  //size_type Copy(CharType* pChars, size_type count, size_type offset = 0) const
1675  //{
1676  // return this->baseString.copy(pChars, count, offset);
1677  //}
1678 
1679 private: // fields
1680  BaseString baseString;
1681 };
1682 
1684 // initializing of static fields
1685 template <class CharType, class Alloc>
1686 const BasicString<CharType, Alloc> BasicString<CharType, Alloc>::Empty;
1687 
1688 template <class CharType, class Alloc>
1689 const BasicString<CharType, Alloc> BasicString<CharType, Alloc>::NewLine((CharType)'\n', (CharType)'\r');
1690 
1692 // inline global operators and functions of class BasicString<CharType, Alloc>
1693 
1697 template<class CharType, class Alloc>
1699 {
1700  left.Swap(right);
1701 }
1702 
1707 template<class CharType, class Alloc>
1708 inline std::ostream& operator<<(std::ostream& os, const BasicString<CharType, Alloc>& right)
1709 {
1710  os << right.GetBaseString();
1711  return os;
1712 }
1713 
1718 template<class CharType, class Alloc>
1719 inline std::istream& operator>>(std::istream& is, BasicString<CharType, Alloc>& right)
1720 {
1721  std::basic_string<CharType, std::char_traits<CharType>, Alloc> baseString;
1722  is >> baseString;
1723  right.Assign(baseString);
1724  return is;
1725 }
1726 
1731 template<class CharType, class Alloc>
1733  const BasicString<CharType, Alloc>& left,
1734  const BasicString<CharType, Alloc>& right)
1735 {
1736  return left.GetBaseString() + right.GetBaseString();
1737 }
1738 
1743 template<class CharType, class Alloc>
1745  const CharType* left,
1746  const BasicString<CharType, Alloc>& right)
1747 {
1748  return left + right.GetBaseString();
1749 }
1750 
1755 template<class CharType, class Alloc>
1757  const CharType left,
1758  const BasicString<CharType, Alloc>& right)
1759 {
1760  return left + right.GetBaseString();
1761 }
1762 
1767 template<class CharType, class Alloc>
1769  const BasicString<CharType, Alloc>& left,
1770  const CharType* right)
1771 {
1772  return left.GetBaseString() + right;
1773 }
1774 
1779 template<class CharType, class Alloc>
1781  const BasicString<CharType, Alloc>& left,
1782  const CharType right)
1783 {
1784  return left.GetBaseString() + right;
1785 }
1786 
1791 template<class CharType, class Alloc>
1793  const BasicString<CharType, Alloc>& left,
1795 {
1796  return left.GetBaseString() + right.GetBaseString();
1797 }
1798 
1803 template<class CharType, class Alloc>
1806  const BasicString<CharType, Alloc>& right)
1807 {
1808  return (std::move(left.Append(right)));
1809 }
1810 
1815 template<class CharType, class Alloc>
1819 {
1820  return left.GetBaseString() + right.GetBaseString();
1821 }
1822 
1827 template<class CharType, class Alloc>
1829  const CharType* left,
1831 {
1832  return left + right.GetBaseString();
1833 }
1834 
1839 template<class CharType, class Alloc>
1841  const CharType left,
1843 {
1844  return left + right.GetBaseString();
1845 }
1846 
1851 template<class CharType, class Alloc>
1854  const CharType* right)
1855 {
1856  return left.GetBaseString() + right;
1857 }
1858 
1863 template<class CharType, class Alloc>
1866  const CharType right)
1867 {
1868  return left.GetBaseString() + right;
1869 }
1870 
1875 template<class CharType, class Alloc>
1876 inline bool operator==(
1877  const BasicString<CharType, Alloc>& left,
1878  const BasicString<CharType, Alloc>& right)
1879 {
1880  return left.GetBaseString() == right.GetBaseString();
1881 }
1882 
1887 template<class CharType, class Alloc>
1888 inline bool operator==(
1889  const CharType* left,
1890  const BasicString<CharType, Alloc>& right)
1891 {
1892  return left == right.GetBaseString();
1893 }
1894 
1899 template<class CharType, class Alloc>
1900 inline bool operator==(
1901  const BasicString<CharType, Alloc>& left,
1902  const CharType* right)
1903 {
1904  return left.GetBaseString() == right;
1905 }
1906 
1911 template<class CharType, class Alloc>
1912 inline bool operator!=(
1913  const BasicString<CharType, Alloc>& left,
1914  const BasicString<CharType, Alloc>& right)
1915 {
1916  return (!(left == right));
1917 }
1918 
1923 template<class CharType, class Alloc>
1924 inline bool operator!=(
1925  const CharType *left,
1926  const BasicString<CharType, Alloc>& right)
1927 {
1928  return (!(left == right));
1929 }
1930 
1935 template<class CharType, class Alloc>
1936 inline bool operator!=(
1937  const BasicString<CharType, Alloc>& left,
1938  const CharType* right)
1939 {
1940  return (!(left == right));
1941 }
1942 
1947 template<class CharType, class Alloc>
1948 inline bool operator<(
1949  const BasicString<CharType, Alloc>& left,
1950  const BasicString<CharType, Alloc>& right)
1951 {
1952  return left.GetBaseString() < right.GetBaseString();
1953 }
1954 
1959 template<class CharType, class Alloc>
1960 inline bool operator<(
1961  const CharType* left,
1962  const BasicString<CharType, Alloc>& right)
1963 {
1964  return left < right.GetBaseString();
1965 }
1966 
1971 template<class CharType, class Alloc>
1972 inline bool operator<(
1973  const BasicString<CharType, Alloc>& left,
1974  const CharType* right)
1975 {
1976  return left.GetBaseString() < right;
1977 }
1978 
1983 template<class CharType, class Alloc>
1984 inline bool operator>(
1985  const BasicString<CharType, Alloc>& left,
1986  const BasicString<CharType, Alloc>& right)
1987 {
1988  return (right < left);
1989 }
1990 
1995 template<class CharType, class Alloc>
1996 inline bool operator>(
1997  const CharType* left,
1998  const BasicString<CharType, Alloc>& right)
1999 {
2000  return (right < left);
2001 }
2002 
2007 template<class CharType, class Alloc>
2008 inline bool operator>(
2009  const BasicString<CharType, Alloc>& left,
2010  const CharType* right)
2011 {
2012  return (right < left);
2013 }
2014 
2019 template<class CharType, class Alloc>
2020 inline bool operator<=(
2021  const BasicString<CharType, Alloc>& left,
2022  const BasicString<CharType, Alloc>& right)
2023 {
2024  return (!(right < left));
2025 }
2026 
2031 template<class CharType, class Alloc>
2032 inline bool operator<=(
2033  const CharType* left,
2034  const BasicString<CharType, Alloc>& right)
2035 {
2036  return (!(right < left));
2037 }
2038 
2043 template<class CharType, class Alloc>
2044 inline bool operator<=(
2045  const BasicString<CharType, Alloc>& left,
2046  const CharType* right)
2047 {
2048  return (!(right < left));
2049 }
2050 
2055 template<class CharType, class Alloc>
2056 inline bool operator>=(
2057  const BasicString<CharType, Alloc>& left,
2058  const BasicString<CharType, Alloc>& right)
2059 {
2060  return (!(left < right));
2061 }
2062 
2067 template<class CharType, class Alloc>
2068 inline bool operator>=(
2069  const CharType* left,
2070  const BasicString<CharType, Alloc>& right)
2071 {
2072  return (!(left < right));
2073 }
2074 
2079 template<class CharType, class Alloc>
2080 inline bool operator>=(
2081  const BasicString<CharType, Alloc>& left,
2082  const CharType* right)
2083 {
2084  return (!(left < right));
2085 }
2086 
2087 } // end of namesapce Arp
2088 
2090 // standard template specializations of class BasicString<C,Alloc>
2091 namespace std
2092 {
2093 
2097 template<class C, class Alloc>
2098 struct hash<Arp::BasicString<C, Alloc>>
2099 {
2100 private:
2101  typedef typename Arp::BasicString<C, Alloc>::BaseString BaseString;
2102 
2103 public:
2107  typedef size_t result_type;
2108 
2109 public:
2114  {
2115  return std::hash<BaseString>()(key.GetBaseString());
2116  }
2117 };
2118 
2120 
2121 } // end of namespace std
This class encapsulates formatting operations which are based on the open source library libfmt forme...
Definition: BasicFormatter.hxx:27
static StringType FormatCommon(ExceptionHandler exceptionHandler, const StringType &format, const Args &... args)
Uses common CLR syntax (.Net) for the placeholders in the format string like '{0}'.
Definition: BasicFormatter.hxx:55
Definition: BasicString.hxx:33
SelfType & Insert(size_type offset, size_type count, CharType c)
Inserts count consecutive copies of character c at position offset .
Definition: BasicString.hxx:547
SelfType & Replace(size_type offset, size_type length, const CharType *pChars, size_type count)
Replaces a range of chars.
Definition: BasicString.hxx:683
SelfType & Insert(size_type offset, const CharType *pChars, size_type count)
This operation inserts the as argument passed string partially.
Definition: BasicString.hxx:526
typename AllocatorTraits::pointer pointer
The pointer type of this type.
Definition: BasicString.hxx:49
const_reverse_iterator ConstReverseBegin() const
Returns the begin iterator of this const string for reverse iterating.
Definition: BasicString.hxx:927
typename BaseString::const_iterator const_iterator
The const iterator type of this type.
Definition: BasicString.hxx:52
size_type FindLastNotOf(const CharType *pChars, size_type offset=NPos) const
Finds the last occurence of any character which is not in pChars .
Definition: BasicString.hxx:1335
SelfType & Assign(const CharType *pChars, size_type count)
This operation copies the as argument passed C-string partially.
Definition: BasicString.hxx:355
size_type FindFirstNotOf(const SelfType &chars, size_type offset=0) const
Finds the first occurence of any character which is not in chars .
Definition: BasicString.hxx:1278
static SelfType Format(const SelfType &format, const Args &... args)
Formats the format string using the .NET/Python syntax with the given variadic arguments.
Definition: BasicString.hxx:1483
typename AllocatorTraits::const_pointer const_pointer
The const pointer type of this type.
Definition: BasicString.hxx:50
typename BaseString::size_type size_type
The size type of this type.
Definition: BasicString.hxx:45
size_type FindFirstOf(const CharType *pChars, size_type offset=0) const
Finds the first occurence of any character in pChars .
Definition: BasicString.hxx:1221
std::ostream & operator<<(std::ostream &os, const BasicString< CharType, Alloc > &right)
Streams the right string to the outstream os .
Definition: BasicString.hxx:1708
BasicString(const CharType *pChars, const Allocator &alloc)
This constructor copies the as argument passed C-string.
Definition: BasicString.hxx:128
const CharType * CStr() const
Gets the character data of this string.
Definition: BasicString.hxx:1508
BasicString< CharType, Allocator > SelfType
The self type.
Definition: BasicString.hxx:38
SelfType & Replace(const_iterator first, const_iterator last, iterator first2, iterator last2)
Replaces a range of chars [first;last).
Definition: BasicString.hxx:764
SelfType & Replace(const_iterator first, const_iterator last, size_type count, CharType c)
Replaces a range of chars [first;last).
Definition: BasicString.hxx:752
BasicString< CharType, Alloc > operator+(const BasicString< CharType, Alloc > &left, const BasicString< CharType, Alloc > &right)
Concatenates the right string to the left string.
Definition: BasicString.hxx:1732
const_reference At(size_type offset) const
Returns a const reference to the character at position offset .
Definition: BasicString.hxx:1007
C CharType
The character type.
Definition: BasicString.hxx:37
Tokens Split(char delimiter, bool trimTokens=true, bool removeEmptyTokens=true) const
Splits this string into tokens using the specified delimiter characters (multiple).
Definition: BasicString.hxx:1593
bool IsEmpty() const
Determines if this string is empty.
Definition: BasicString.hxx:1076
size_type ReverseFind(CharType c, size_type offset=NPos) const
Finds the last char which equal to c .
Definition: BasicString.hxx:1193
iterator Erase(const_iterator where)
This operation erases chars from this string.
Definition: BasicString.hxx:626
BasicString(iterator first, iterator last, const Allocator &alloc=Allocator())
Copies the sequence of characters in the range [first,last), in the same order..
Definition: BasicString.hxx:174
SelfType & operator+=(const CharType *right)
This assignment operator appends the the right-hand-side operand to this string.
Definition: BasicString.hxx:280
SelfType & operator+=(const SelfType &right)
This assignment operator appends the the right-hand-side operand to this string.
Definition: BasicString.hxx:271
SelfType & Replace(const_iterator first, const_iterator last, std::initializer_list< CharType > chars)
Replaces a range of chars [first;last).
Definition: BasicString.hxx:647
SelfType & Assign(std::initializer_list< CharType > arg)
This operation copies each of the characters in the argument to this string, in the same order.
Definition: BasicString.hxx:309
BasicString(const BaseString &arg)
This copy constructor copies the as argument passed std::string to this string.
Definition: BasicString.hxx:190
const_reverse_iterator ConstReverseEnd() const
Returns the end iterator of this const string for reverse iterating.
Definition: BasicString.hxx:934
size_type FindLastOf(const SelfType &chars, size_type offset=NPos) const
Finds the last occurence of any character in chars .
Definition: BasicString.hxx:1240
iterator Insert(const_iterator where, const_iterator first, const_iterator last)
Inserts a range of chars [first;last) at position where .
Definition: BasicString.hxx:587
SelfType & Assign(SelfType &&arg)
This operation moves the as argument passed string to this string.
Definition: BasicString.hxx:300
const_iterator ConstBegin() const
Returns the begin iterator of this const string.
Definition: BasicString.hxx:913
SelfType & operator+=(CharType c)
This assignment operator appends the the right-hand-side operand to this string.
Definition: BasicString.hxx:289
size_type Find(CharType c, size_type offset=0) const
Finds the first char which equal to c .
Definition: BasicString.hxx:1156
typename BaseString::const_reverse_iterator const_reverse_iterator
The const reverse iterator type of this type.
Definition: BasicString.hxx:54
SelfType & operator=(std::initializer_list< CharType > right)
This assignment operator copies each of the characters in the right-hand-side operand to this string,...
Definition: BasicString.hxx:229
iterator Insert(const_iterator where, std::initializer_list< CharType > arg)
This operation inserts each of the characters in the argument to this string, in the same order.
Definition: BasicString.hxx:494
const BaseString & GetBaseString() const
Gets the basic std string.
Definition: BasicString.hxx:1501
SelfType & Append(size_type count, CharType c)
Appends to this string count consecutive copies of character c .
Definition: BasicString.hxx:455
SelfType & Replace(const_iterator first, const_iterator last, const CharType *pChars)
Replaces a range of chars [first;last).
Definition: BasicString.hxx:740
SelfType & Append(const SelfType &arg)
This operation appends the the argument to this string.
Definition: BasicString.hxx:419
bool EndWith(const CharType *pChars) const
Determines if this string ends with the pChars C-string.
Definition: BasicString.hxx:1456
Allocator GetAllocator() const
Gets the allocator of this string.
Definition: BasicString.hxx:1538
SelfType & operator=(const CharType *right)
This assignment operator copies the right-hand-side operand to this string.
Definition: BasicString.hxx:243
void Reserve(size_type newCapacity=0)
Reserves memory upto the specified newCapacity .
Definition: BasicString.hxx:1111
SelfType Substr(size_type offset=0, size_type count=NPos) const
Gets a substring of this string.
Definition: BasicString.hxx:1531
typename BaseString::difference_type difference_type
The difference type of this type.
Definition: BasicString.hxx:46
reference operator[](size_type offset)
Returns a reference to the character at position offset .
Definition: BasicString.hxx:1016
SelfType & Append(const SelfType &arg, size_type offset, size_type count=NPos)
This operation appends the as argument passed string partially.
Definition: BasicString.hxx:429
static SelfType Format(const char *format, const Args &... args)
Formats the format C-string using the .NET/Python syntax with the given variadic arguments.
Definition: BasicString.hxx:1493
SelfType & Erase(size_type offset, size_type count)
This operation erases chars from this string.
Definition: BasicString.hxx:617
int Compare(const SelfType &other) const
Compares this string to the other string lexicographical.
Definition: BasicString.hxx:1359
void swap(BasicString< CharType, Alloc > &left, BasicString< CharType, Alloc > &right) noexcept
Swaps the content of the left string with the content of the right string.
Definition: BasicString.hxx:1698
const_iterator Begin() const
Returns the begin iterator of this string.
Definition: BasicString.hxx:864
bool operator<=(const BasicString< CharType, Alloc > &left, const BasicString< CharType, Alloc > &right)
Compares the left string to the right string.
Definition: BasicString.hxx:2020
const_reverse_iterator ReverseBegin() const
Returns the begin iterator of this string for reverse iterating.
Definition: BasicString.hxx:892
bool operator>(const BasicString< CharType, Alloc > &left, const BasicString< CharType, Alloc > &right)
Compares the left string to the right string.
Definition: BasicString.hxx:1984
void PushBack(CharType c)
Appends the character c to this string.
Definition: BasicString.hxx:947
SelfType & Replace(const_iterator first, const_iterator last, const_iterator first2, const_iterator last2)
Replaces a range of chars [first;last).
Definition: BasicString.hxx:776
BasicString(BaseString &&arg)
This move constructor moves the as argument passed std::string to this string.
Definition: BasicString.hxx:197
void Clear()
Clears the content of this string, but does not modify the capacity.
Definition: BasicString.hxx:1117
size_type FindFirstNotOf(const CharType *pChars, size_type offset=0) const
Finds the first occurence of any character which is not in pChars .
Definition: BasicString.hxx:1297
size_type MaxSize() const
Returns the number maximum size any string might have.
Definition: BasicString.hxx:1057
int Compare(const CharType *pOther) const
Compares this string to the pOther string lexicographical.
Definition: BasicString.hxx:1401
void Swap(SelfType &other)
Swaps the content of this string with the content of the other string.
Definition: BasicString.hxx:1545
SelfType & Assign(BaseString &&arg)
This operation moves the argument to this string.
Definition: BasicString.hxx:346
iterator Insert(const_iterator where, iterator first, iterator last)
Inserts a range of chars [first;last) at position where .
Definition: BasicString.hxx:577
iterator begin()
Returns the begin iterator of this string.
Definition: BasicString.hxx:824
BasicString(const SelfType &arg, size_type offset, size_type count=NPos)
This constructor copies the as argument passed string partially.
Definition: BasicString.hxx:86
iterator Begin()
Returns the begin iterator of this string.
Definition: BasicString.hxx:857
SelfType & Replace(size_type offset, size_type length, const CharType *pChars)
Replaces a range of chars.
Definition: BasicString.hxx:694
static const size_type NPos
This position value is returned when find operations do not match, or is used as default value for an...
Definition: BasicString.hxx:210
reverse_iterator ReverseEnd()
Returns the end iterator of this string for reverse iterating.
Definition: BasicString.hxx:899
const_iterator end() const
Returns the end iterator of this string.
Definition: BasicString.hxx:848
SelfType & Append(const_pointer first, const_pointer last)
Appends the sequence of characters in the range [first,last), in the same order.
Definition: BasicString.hxx:482
size_type Find(const SelfType &pattern, size_type offset=0) const
Finds the first substring which equal to pattern .
Definition: BasicString.hxx:1128
BasicString(const CharType *pChars, size_type count)
This constructor copies the as argument passed C-string.
Definition: BasicString.hxx:104
bool operator<(const BasicString< CharType, Alloc > &left, const BasicString< CharType, Alloc > &right)
Compares the left string to the right string.
Definition: BasicString.hxx:1948
size_type ReverseFind(const CharType *pChars, size_type offset=NPos) const
Finds the last substring which equal to pChars .
Definition: BasicString.hxx:1184
typename BaseString::reference reference
The reference type of this type.
Definition: BasicString.hxx:47
size_type FindFirstOf(const CharType *pChars, size_type offset, size_type count) const
Finds the first occurence of any character in pChars .
Definition: BasicString.hxx:1212
SelfType & Insert(size_type offset, const CharType *pChars)
This operation inserts the as argument passed string.
Definition: BasicString.hxx:536
size_type FindLastOf(const CharType *pChars, size_type offset=NPos) const
Finds the last occurence of any character in pChars .
Definition: BasicString.hxx:1259
reverse_iterator ReverseBegin()
Returns the begin iterator of this string for reverse iterating.
Definition: BasicString.hxx:885
SelfType & operator+=(std::initializer_list< CharType > right)
This assignment operator appends each of the characters in the right-hand-side operand to this string...
Definition: BasicString.hxx:262
SelfType & operator=(SelfType &&right) noexcept=default
This move assignment operator moves the right-hand-side operand to this string.
BasicString(const SelfType &arg)=default
The copy constructor copies the as argument passed string deeply.
SelfType & Replace(const_iterator first, const_iterator last, const_pointer first2, const_pointer last2)
Replaces a range of chars [first;last).
Definition: BasicString.hxx:788
int Compare(size_type offset, size_type count, const CharType *pOther) const
Compares this string to the pOther string lexicographical.
Definition: BasicString.hxx:1415
iterator Insert(const_iterator where, CharType c)
Inserts character c at position where .
Definition: BasicString.hxx:557
reference Front()
Returns a reference to the first character in the string.
Definition: BasicString.hxx:965
BasicString(const CharType *pChars, size_type count, const Allocator &alloc)
This constructor copies the as argument passed C-string.
Definition: BasicString.hxx:113
size_type FindLastOf(CharType c, size_type offset=NPos) const
Finds the last occurence of character c .
Definition: BasicString.hxx:1269
SelfType & Erase(size_type offset=0)
This operation erases chars from this string.
Definition: BasicString.hxx:607
SelfType & Replace(size_type offset, size_type length, size_type count, CharType c)
Replaces a range of chars by a character.
Definition: BasicString.hxx:706
void Resize(size_type newSize, CharType c)
Resizes this string to the specified new size.
Definition: BasicString.hxx:1099
const_reference Back() const
Returns a const reference to the last character in the string.
Definition: BasicString.hxx:989
bool operator>=(const BasicString< CharType, Alloc > &left, const BasicString< CharType, Alloc > &right)
Compares the left string to the right string.
Definition: BasicString.hxx:2056
Tokens Split(const char delimiters[], size_t delimitersCount, bool trimTokens=true, bool removeEmptyTokens=true) const
Splits this string into tokens using the specified delimiter characters (multiple).
Definition: BasicString.hxx:1605
size_type FindLastNotOf(const SelfType &chars, size_type offset=NPos) const
Finds the last occurence of any character which is not in chars .
Definition: BasicString.hxx:1316
BasicString(std::initializer_list< CharType > arg, const Allocator &alloc=Allocator())
Copies each of the characters in initList , in the same order.
Definition: BasicString.hxx:165
typename BaseString::iterator iterator
The iterator type of this type.
Definition: BasicString.hxx:51
size_type Find(const CharType *pChars, size_type offset=0) const
Finds the first substring which equal to pChars .
Definition: BasicString.hxx:1147
reference At(size_type offset)
Returns a const reference to the character at position offset .
Definition: BasicString.hxx:998
void PopBack()
Removes the character at the end of this string.
Definition: BasicString.hxx:954
BasicString(const CharType *pChars)
This constructor copies the as argument passed C-string.
Definition: BasicString.hxx:120
size_type FindFirstNotOf(CharType c, size_type offset=0) const
Finds the first occurence of any character which is not equal to c .
Definition: BasicString.hxx:1307
SelfType & Append(const CharType *pChars)
This operation appends the as argument passed C-string.
Definition: BasicString.hxx:446
const_reference operator[](size_type offset) const
Returns a const reference to the character at position offset .
Definition: BasicString.hxx:1025
size_type FindLastNotOf(CharType c, size_type offset=NPos) const
Finds the last occurence of any character which is not equal to c .
Definition: BasicString.hxx:1345
std::vector< SelfType > Tokens
Used by Split() operation.
Definition: BasicString.hxx:40
iterator Insert(const_iterator where, const_pointer first, const_pointer last)
Inserts a range of chars [first;last) at position where .
Definition: BasicString.hxx:597
BasicString(const Allocator &alloc)
This constructor creates an empty string instance.
Definition: BasicString.hxx:77
BasicString(SelfType &&arg) noexcept=default
This move constructor moves the as argument passed string to this string.
bool StartWith(const SelfType &pattern) const
Determines if this string starts with the pattern string.
Definition: BasicString.hxx:1448
size_type Length() const
Returns the number of char elements in this string.
Definition: BasicString.hxx:1039
SelfType & Assign(iterator first, iterator last)
Copies the sequence of characters in the range [first,last), in the same order.
Definition: BasicString.hxx:381
int Compare(size_type offset, size_type count, const SelfType &other) const
Compares this string to the other string lexicographical.
Definition: BasicString.hxx:1373
SelfType & Append(std::initializer_list< CharType > arg)
This operation appends each of the characters in the argument to this string, in the same order.
Definition: BasicString.hxx:410
typename BaseString::const_reference const_reference
The const reference type of this type.
Definition: BasicString.hxx:48
bool operator!=(const BasicString< CharType, Alloc > &left, const BasicString< CharType, Alloc > &right)
Compares the left string to the right string on inequality.
Definition: BasicString.hxx:1912
SelfType & Insert(size_type offset, const SelfType &arg)
This operation inserts the the argument at the given position.
Definition: BasicString.hxx:503
bool EndWith(const SelfType &pattern) const
Determines if this string starts with the pattern string.
Definition: BasicString.hxx:1464
SelfType & Replace(size_type offset, size_type length, const SelfType &arg)
Replaces a range of chars.
Definition: BasicString.hxx:658
SelfType & operator=(CharType c)
This assignment operator copies the right-hand-side operand to this string.
Definition: BasicString.hxx:252
size_type FindFirstNotOf(const CharType *pChars, size_type offset, size_type count) const
Finds the first occurence of any character which is not in pChars .
Definition: BasicString.hxx:1288
const_reference Front() const
Returns a const reference to the first character in the string.
Definition: BasicString.hxx:973
SelfType & Append(const CharType *pChars, size_type count)
This operation appends the as argument passed C-string partially.
Definition: BasicString.hxx:438
Alloc Allocator
The characters allocator type.
Definition: BasicString.hxx:35
size_type ReverseFind(const CharType *pChars, size_type offset, size_type count) const
Finds the last substring which equal to pChars .
Definition: BasicString.hxx:1175
SelfType & Append(const_iterator first, const_iterator last)
Appends the sequence of characters in the range [first,last), in the same order.
Definition: BasicString.hxx:473
size_type FindLastNotOf(const CharType *pChars, size_type offset, size_type count) const
Finds the last occurence of any character which is not in pChars .
Definition: BasicString.hxx:1326
iterator Erase(const_iterator first, const_iterator last)
Erases a range of chars [first;last).
Definition: BasicString.hxx:635
BasicString(const_iterator first, const_iterator last, const Allocator &alloc=Allocator())
Copies the sequence of characters in the range [first,last), in the same order..
Definition: BasicString.hxx:183
std::istream & operator>>(std::istream &is, BasicString< CharType, Alloc > &right)
Streams the instream is into the right string.
Definition: BasicString.hxx:1719
iterator End()
Returns the end iterator of this string.
Definition: BasicString.hxx:871
const_iterator ConstEnd() const
Returns the end iterator of this const string.
Definition: BasicString.hxx:920
BasicString(const SelfType &arg, size_type offset, size_type count, const Allocator &alloc)
This constructor copies the as argument passed string partially.
Definition: BasicString.hxx:96
const_reverse_iterator ReverseEnd() const
Returns the end iterator of this string for reverse iterating.
Definition: BasicString.hxx:906
Tokens SplitByWord(const SelfType &delimiter, bool trimTokens=true, bool removeEmptyTokens=true) const
Splits this string into tokens using the specified (single) delimiter string.
Definition: BasicString.hxx:1641
SelfType & Assign(const BaseString &arg)
This operation copies the argument to this string.
Definition: BasicString.hxx:337
SelfType & Assign(const_iterator first, const_iterator last)
Copies the sequence of characters in the range [first,last), in the same order.
Definition: BasicString.hxx:390
int Compare(size_type offset, size_type count, const SelfType &other, size_type offsetOther, size_type countOther=NPos) const
Compares a substring of this string to a substring of the other string lexicographical.
Definition: BasicString.hxx:1389
size_type FindLastOf(const CharType *pChars, size_type offset, size_type count) const
Finds the last occurence of any character in pChars .
Definition: BasicString.hxx:1250
SelfType & Assign(const SelfType &arg, size_type offset, size_type count=NPos)
This operation copies the as argument passed string partially.
Definition: BasicString.hxx:328
BasicString(size_type count, CharType c)
Fills the string with count consecutive copies of character c .
Definition: BasicString.hxx:136
BasicString()=default
The default constructor constructs an empty string instance.
~BasicString()=default
The destructor deallocates all memory of this instance.
SelfType & operator=(const SelfType &right)=default
This assignment operator copies the the right-hand-side operand to this string.
static const SelfType NewLine
This static string instance represents the (platform specific) new line string.
Definition: BasicString.hxx:218
void ShrinkToFit()
Reduces the capacity of this string to its size.
Definition: BasicString.hxx:940
iterator end()
Returns the end iterator of this string.
Definition: BasicString.hxx:840
bool StartWith(const CharType *pChars) const
Determines if this string starts with the pChars C-string.
Definition: BasicString.hxx:1440
size_type Find(const CharType *pChars, size_type offset, size_type count) const
Finds the first substring which equal to pChars .
Definition: BasicString.hxx:1138
static const SelfType Empty
An emtpy static string instance.
Definition: BasicString.hxx:214
size_type Capacity() const
Rceturns the capacity of this string.
Definition: BasicString.hxx:1069
SelfType & Insert(size_type offset, const SelfType &arg, size_type argOffset, size_type count=NPos)
This operation inserts the as argument passed string partially.
Definition: BasicString.hxx:515
size_type ReverseFind(const SelfType &pattern, size_type offset=NPos) const
Finds the last substring which equal to pattern .
Definition: BasicString.hxx:1165
reference Back()
Returns a reference to the last character in the string.
Definition: BasicString.hxx:981
int Compare(size_type offset, size_type count, const CharType *pOther, size_type countOther) const
Compares a substring of this string to a substring of the pOther string lexicographical.
Definition: BasicString.hxx:1430
size_type Size() const
Returns the number of char elements in this string.
Definition: BasicString.hxx:1051
CharType value_type
The char type of this type.
Definition: BasicString.hxx:44
SelfType & Replace(const_iterator first, const_iterator last, const SelfType &arg)
Replaces a range of chars [first;last).
Definition: BasicString.hxx:717
size_type FindFirstOf(CharType c, size_type offset=0) const
Finds the first occurence of character c .
Definition: BasicString.hxx:1231
Allocator allocator_type
The allocator type of this type.
Definition: BasicString.hxx:43
SelfType & ReplaceAll(const SelfType &pattern, const SelfType &replacement)
Replaces a given pattern by a replacement string.
Definition: BasicString.hxx:813
typename BaseString::reverse_iterator reverse_iterator
The reverse iterator type of this type.
Definition: BasicString.hxx:53
bool operator==(const BasicString< CharType, Alloc > &left, const BasicString< CharType, Alloc > &right)
Compares the left string to the right string on equality.
Definition: BasicString.hxx:1876
SelfType & Replace(const_iterator first, const_iterator last, const CharType *pChars, size_type count)
Replaces a range of chars [first;last).
Definition: BasicString.hxx:729
std::basic_string< CharType, std::char_traits< CharType >, Allocator > BaseString
The type of the basic std string.
Definition: BasicString.hxx:39
SelfType & Assign(const CharType *pChars)
This operation copies the as argument passed C-string.
Definition: BasicString.hxx:363
void Resize(size_type newSize)
Resizes this string to the specified new size.
Definition: BasicString.hxx:1087
const_iterator End() const
Returns the end iterator of this string.
Definition: BasicString.hxx:878
SelfType & Assign(const SelfType &arg)
This operation copies the the argument to this string.
Definition: BasicString.hxx:318
BasicString(const SelfType &arg, const Allocator &alloc)
This constructor copies the as argument passed string deeply.
Definition: BasicString.hxx:70
SelfType & Replace(size_type offset, size_type length, const SelfType &arg, size_type offsetArg, size_type count=NPos)
Replaces a range of chars.
Definition: BasicString.hxx:671
SelfType & Append(iterator first, iterator last)
Appends the sequence of characters in the range [first,last), in the same order.
Definition: BasicString.hxx:464
BasicString(size_type count, CharType c, const Allocator &alloc)
Fills the string with count consecutive copies of character c .
Definition: BasicString.hxx:145
BasicString(SelfType &&arg, const Allocator &alloc)
This move constructor moves the as argument passed string to this string.
Definition: BasicString.hxx:157
const_iterator begin() const
Returns the begin iterator of this string.
Definition: BasicString.hxx:832
SelfType & Replace(const_iterator first, const_iterator last, pointer first2, pointer last2)
Replaces a range of chars [first;last).
Definition: BasicString.hxx:800
SelfType & Assign(size_type count, CharType c)
Fills this string with count consecutive copies of character c .
Definition: BasicString.hxx:372
SelfType & Assign(const_pointer first, const_pointer last)
Copies the sequence of characters in the range [first,last), in the same order.
Definition: BasicString.hxx:399
size_type FindFirstOf(const SelfType &chars, size_type offset=0) const
Finds the first occurence of any character in chars .
Definition: BasicString.hxx:1202
iterator Insert(const_iterator where, size_type count, CharType c)
Inserts character c at position where .
Definition: BasicString.hxx:567
Root namespace for the PLCnext API
Namespace of the C++ standard library
Definition: BasicStringFormatExceptionHandler.hpp:16
result_type operator()(const argument_type &key) const
This functor operator returns the hash value of the as argument passed string.
Definition: BasicString.hxx:2113
size_t result_type
The result type of this functor class (stl policy type)
Definition: BasicString.hxx:2107
Arp::BasicString< C, Alloc > argument_type
The argument type of this functor class (stl policy type)
Definition: BasicString.hxx:2105