PLCnext API Documentation 24.0.0.71
BasicString.hxx
1
2//
3// Copyright PHOENIX CONTACT Electronics GmbH
4//
6#pragma once
8#include <string>
9#include <vector>
10#include <algorithm>
11#include <memory>
12#include <iostream>
13#include <initializer_list>
14#include "boost/algorithm/string/replace.hpp"
15#include "Arp/System/Core/BasicFormatter.hxx"
16#include "Arp/System/Core/Impl/BasicStringFormatExceptionHandler.hpp"
17
18#ifndef ARP_INSIDE_ARP_H
19 #error Never include 'BasicString.hxx' directly, just include 'Arp.h'
20#endif
21
22namespace Arp
23{
24
26
29
32template<class C, class Alloc = std::allocator<C>>
34{
35public: // usings
36 using Allocator = Alloc;
37 using AllocatorTraits = std::allocator_traits<Alloc>;
38 using CharType = C;
40 using BaseString = std::basic_string<CharType, std::char_traits<CharType>, Allocator>;
41 using StdString = std::basic_string<CharType, std::char_traits<CharType>, Allocator>;
42 using Tokens = std::vector<SelfType>;
43 using Bytes = std::vector<byte>;
44
45public: // policy typedefs
48 using size_type = typename BaseString::size_type;
49 using difference_type = typename BaseString::difference_type;
50 using reference = typename BaseString::reference;
51 using const_reference = typename BaseString::const_reference;
52 using pointer = typename AllocatorTraits::pointer;
53 using const_pointer = typename AllocatorTraits::const_pointer;
54 using iterator = typename BaseString::iterator;
55 using const_iterator = typename BaseString::const_iterator;
56 using reverse_iterator = typename BaseString::reverse_iterator;
57 using const_reverse_iterator = typename BaseString::const_reverse_iterator;
58
59private: // usings
61
62public: // construction/destruction
64 BasicString() = default;
65
68 BasicString(const SelfType& arg) = default;
69
73 BasicString(const SelfType& arg, const Allocator& alloc)
74 : baseString(arg.baseString, alloc)
75 {
76 }
77
80 explicit BasicString(const Allocator& alloc)
81 : baseString(alloc)
82 {
83 }
84
89 BasicString(const SelfType& arg, size_type offset, size_type count = NPos)
90 : baseString(arg.baseString, offset, count)
91 {
92 }
93
99 BasicString(const SelfType& arg, size_type offset, size_type count, const Allocator& alloc)
100 : baseString(arg.baseString, offset, count, alloc)
101 {
102 }
103
107 BasicString(const CharType* pChars, size_type count)
108 : baseString(pChars, count)
109 {
110 }
111
116 BasicString(const CharType* pChars, size_type count, const Allocator& alloc)
117 : baseString(pChars, count, alloc)
118 {
119 }
120
123 BasicString(const CharType* pChars)
124 : baseString(pChars)
125 {
126 }
127
131 BasicString(const CharType* pChars, const Allocator& alloc)
132 : baseString(pChars, alloc)
133 {
134 }
135
140 : baseString(count, c)
141 {
142 }
143
148 BasicString(size_type count, CharType c, const Allocator& alloc)
149 : baseString(count, c, alloc)
150 {
151 }
152
155 BasicString(SelfType&& arg) noexcept = default;
156
160 BasicString(SelfType&& arg, const Allocator& alloc)
161 : baseString(std::move(arg.baseString), alloc)
162 {
163 }
164
168 BasicString(std::initializer_list<CharType> arg, const Allocator& alloc = Allocator())
169 : baseString(arg, alloc)
170 {
171 }
172
177 BasicString(iterator first, iterator last, const Allocator& alloc = Allocator())
178 : baseString(first, last, alloc)
179 {
180 }
181
187 : baseString(first, last, alloc)
188 {
189 }
190
194 explicit BasicString(const Bytes& bytes, const Allocator& alloc = Allocator())
195 : baseString(reinterpret_cast<const char*>(bytes.data()), reinterpret_cast<const char*>(bytes.data() + bytes.size()), alloc)
196 {
197 }
198
202 : baseString(arg)
203 {
204 }
205
209 : baseString(std::move(arg))
210 {
211 }
212
214 ~BasicString() = default;
215
216public: // static fields
221 static const size_type NPos = size_type(-1);
225 static const SelfType Empty;
229 static const SelfType NewLine;
230
231public: // assignment operator
235 SelfType& operator=(SelfType&& right) noexcept = default;
236
240 SelfType& operator=(std::initializer_list<CharType> right)
241 {
242 this->baseString = right;
243 return (*this);
244 }
245
249 SelfType& operator=(const SelfType& right) = default;
250
255 {
256 this->baseString = right;
257 return (*this);
258 }
259
264 {
265 this->baseString = c;
266 return (*this);
267 }
268
269public: // append operator
273 SelfType& operator+=(std::initializer_list<CharType> right)
274 {
275 this->baseString += right;
276 return (*this);
277 }
278
283 {
284 this->baseString += right.baseString;
285 return (*this);
286 }
287
292 {
293 this->baseString += right;
294 return (*this);
295 }
296
301 {
302 this->baseString += c;
303 return (*this);
304 }
305
306public: // assign operations
307
312 {
313 this->baseString = std::move(arg.baseString);
314 return *this;
315 }
316
320 SelfType& Assign(std::initializer_list<CharType> arg)
321 {
322 this->baseString.assign(arg);
323 return *this;
324 }
325
330 {
331 this->baseString.assign(arg.baseString);
332 return *this;
333 }
334
339 SelfType& Assign(const SelfType& arg, size_type offset, size_type count = NPos)
340 {
341 this->baseString.assign(arg.baseString, offset, count);
342 return *this;
343 }
344
349 {
350 this->baseString.assign(arg);
351 return *this;
352 }
353
358 {
359 this->baseString.assign(std::move(arg));
360 return *this;
361 }
362
366 SelfType& Assign(const CharType* pChars, size_type count)
367 {
368 this->baseString.assign(pChars, count);
369 return *this;
370 }
371
374 SelfType& Assign(const CharType* pChars)
375 {
376 this->baseString.assign(pChars);
377 return *this;
378 }
379
384 {
385 this->baseString.assign(count, c);
386 return *this;
387 }
388
393 {
394 this->baseString.assign(first, last);
395 return *this;
396 }
397
402 {
403 this->baseString.assign(first, last);
404 return *this;
405 }
406
411 {
412 this->baseString.assign(first, last);
413 return *this;
414 }
415
416public: // append operations
417
421 SelfType& Append(std::initializer_list<CharType> arg)
422 {
423 this->baseString.append(arg);
424 return *this;
425 }
426
431 {
432 this->baseString.append(arg.baseString);
433 return *this;
434 }
435
440 SelfType& Append(const SelfType& arg, size_type offset, size_type count = NPos)
441 {
442 this->baseString.append(arg.baseString, offset, count);
443 return *this;
444 }
445
449 SelfType& Append(const CharType* pChars, size_type count)
450 {
451 this->baseString.append(pChars, count);
452 return *this;
453 }
454
457 SelfType& Append(const CharType* pChars)
458 {
459 this->baseString.append(pChars);
460 return *this;
461 }
462
467 {
468 this->baseString.append(count, c);
469 return *this;
470 }
471
476 {
477 this->baseString.append(first, last);
478 return *this;
479 }
480
485 {
486 this->baseString.append(first, last);
487 return *this;
488 }
489
494 {
495 this->baseString.append(first, last);
496 return *this;
497 }
498
499public: // insert operations
500
505 iterator Insert(const_iterator where, std::initializer_list<CharType> arg)
506 {
507 return this->baseString.insert(where, arg);
508 }
509
514 SelfType& Insert(size_type offset, const SelfType& arg)
515 {
516 this->baseString.insert(offset, arg.baseString);
517 return *this;
518 }
519
526 SelfType& Insert(size_type offset, const SelfType& arg, size_type argOffset, size_type count = NPos)
527 {
528 this->baseString.insert(offset, arg.baseString, argOffset, count);
529 return *this;
530 }
531
537 SelfType& Insert(size_type offset, const CharType* pChars, size_type count)
538 {
539 this->baseString.insert(offset, pChars, count);
540 return *this;
541 }
542
547 SelfType& Insert(size_type offset, const CharType* pChars)
548 {
549 this->baseString.insert(offset, pChars);
550 return *this;
551 }
552
559 {
560 this->baseString.insert(offset, count, c);
561 return *this;
562 }
563
569 {
570 return this->baseString.insert(where, c);
571 }
572
579 {
580 return this->baseString.insert(where, count, c);
581 }
582
589 {
590 return this->baseString.insert(where, first, last);
591 }
592
599 {
600 return this->baseString.insert(where, first, last);
601 }
602
609 {
610 return this->baseString.insert(where, first, last);
611 }
612
613public: // erase operations
614
619 {
620 this->baseString.erase(offset);
621 return (*this);
622 }
623
629 {
630 this->baseString.erase(offset, count);
631 return (*this);
632 }
633
638 {
639 return this->baseString.erase(where);
640 }
641
647 {
648 return this->baseString.erase(first, last);
649 }
650
651public: // replace operation
652
658 SelfType& Replace(const_iterator first, const_iterator last, std::initializer_list<CharType> chars)
659 {
660 this->baseString.replace(first, last, chars);
661 return *this;
662 }
663
669 SelfType& Replace(size_type offset, size_type length, const SelfType& arg)
670 {
671 this->baseString.replace(offset, length, arg.baseString);
672 return (*this);
673 }
674
682 SelfType& Replace(size_type offset, size_type length, const SelfType& arg, size_type offsetArg, size_type count = NPos)
683 {
684 this->baseString.replace(offset, length, arg.baseString, offsetArg, count);
685 return (*this);
686 }
687
694 SelfType& Replace(size_type offset, size_type length, const CharType* pChars, size_type count)
695 {
696 this->baseString.replace(offset, length, pChars, offset, count);
697 return (*this);
698 }
699
705 SelfType& Replace(size_type offset, size_type length, const CharType* pChars)
706 {
707 this->baseString.replace(offset, length, pChars);
708 return (*this);
709 }
710
718 {
719 this->baseString.replace(offset, length, count, c);
720 return (*this);
721 }
722
729 {
730 this->baseString.replace(first, last, arg.baseString);
731 return (*this);
732 }
733
741 {
742 this->baseString.replace(first, last, pChars, count);
743 return (*this);
744 }
745
752 {
753 this->baseString.replace(first, last, pChars);
754 return (*this);
755 }
756
764 {
765 this->baseString.replace(first, last, count, c);
766 return (*this);
767 }
768
776 {
777 this->baseString.replace(first, last, first2, last2);
778 return (*this);
779 }
780
788 {
789 this->baseString.replace(first, last, first2, last2);
790 return (*this);
791 }
792
800 {
801 this->baseString.replace(first, last, first2, last2);
802 return (*this);
803 }
804
812 {
813 this->baseString.replace(first, last, first2, last2);
814 return (*this);
815 }
816
817public: // replace_all operations
818
824 SelfType& ReplaceAll(const SelfType& pattern, const SelfType& replacement)
825 {
826 boost::replace_all(this->baseString, pattern.baseString, replacement.baseString);
827 return (*this);
828 }
829
830public: // support of range based for loops
831
836 {
837 return this->baseString.begin();
838 }
839
844 {
845 return this->baseString.begin();
846 }
847
852 {
853 return this->baseString.end();
854 }
855
860 {
861 return this->baseString.end();
862 }
863
864public: // container operations
865
869 {
870 return this->baseString.begin();
871 }
872
876 {
877 return this->baseString.begin();
878 }
879
883 {
884 return this->baseString.end();
885 }
886
890 {
891 return this->baseString.end();
892 }
893
897 {
898 return this->baseString.rbegin();
899 }
900
904 {
905 return this->baseString.rbegin();
906 }
907
911 {
912 return this->baseString.rend();
913 }
914
918 {
919 return this->baseString.rend();
920 }
921
925 {
926 return this->baseString.cbegin();
927 }
928
932 {
933 return this->baseString.cend();
934 }
935
939 {
940 return this->baseString.crbegin();
941 }
942
946 {
947 return this->baseString.crend();
948 }
949
952 {
953 this->baseString.shrink_to_fit();
954 }
955
959 {
960 this->baseString.push_back(c);
961 }
962
965 void PopBack()
966 {
967 if(!this->IsEmpty())
968 {
969 this->baseString.pop_back();
970 }
971 }
972
977 {
978 return this->baseString.front();
979 }
980
985 {
986 return this->baseString.front();
987 }
988
993 {
994 return this->baseString.back();
995 }
996
1001 {
1002 return this->baseString.back();
1003 }
1004
1010 {
1011 return this->baseString.at(offset);
1012 }
1013
1019 {
1020 return this->baseString.at(offset);
1021 }
1022
1028 {
1029 return this->baseString[offset];
1030 }
1031
1037 {
1038 return this->baseString[offset];
1039 }
1040
1041public: // Size/Length operations
1042
1051 {
1052 return this->baseString.length();
1053 }
1054
1063 {
1064 return this->baseString.size();
1065 }
1066
1069 {
1070 return this->baseString.max_size();
1071 }
1072
1081 {
1082 return this->baseString.capacity();
1083 }
1084
1087 bool IsEmpty() const
1088 {
1089 return this->baseString.empty();
1090 }
1091
1098 void Resize(size_type newSize)
1099 {
1100 this->baseString.resize(newSize);
1101 }
1102
1110 void Resize(size_type newSize, CharType c)
1111 {
1112 this->baseString.resize(newSize, c);
1113 }
1114
1122 void Reserve(size_type newCapacity = 0)
1123 {
1124 this->baseString.reserve(newCapacity);
1125 }
1126
1128 void Clear()
1129 {
1130 this->baseString.clear();
1131 }
1132
1133public: // Find operations
1134
1139 size_type Find(const SelfType& pattern, size_type offset = 0) const
1140 {
1141 return this->baseString.find(pattern.baseString, offset);
1142 }
1143
1149 size_type Find(const CharType* pChars, size_type offset, size_type count) const
1150 {
1151 return this->baseString.find(pChars, offset, count);
1152 }
1153
1158 size_type Find(const CharType* pChars, size_type offset = 0) const
1159 {
1160 return this->baseString.find(pChars, offset);
1161 }
1162
1167 size_type Find(CharType c, size_type offset = 0) const
1168 {
1169 return this->baseString.find(c, offset);
1170 }
1171
1176 size_type ReverseFind(const SelfType& pattern, size_type offset = NPos) const
1177 {
1178 return this->baseString.rfind(pattern.baseString, offset);
1179 }
1180
1186 size_type ReverseFind(const CharType* pChars, size_type offset, size_type count) const
1187 {
1188 return this->baseString.rfind(pChars, offset, count);
1189 }
1190
1195 size_type ReverseFind(const CharType* pChars, size_type offset = NPos) const
1196 {
1197 return this->baseString.rfind(pChars, offset);
1198 }
1199
1205 {
1206 return this->baseString.rfind(c, offset);
1207 }
1208
1213 size_type FindFirstOf(const SelfType& chars, size_type offset = 0) const
1214 {
1215 return this->baseString.find_first_of(chars.baseString, offset);
1216 }
1217
1223 size_type FindFirstOf(const CharType* pChars, size_type offset, size_type count) const
1224 {
1225 return this->baseString.find_first_of(pChars, offset, count);
1226 }
1227
1232 size_type FindFirstOf(const CharType* pChars, size_type offset = 0) const
1233 {
1234 return this->baseString.find_first_of(pChars, offset);
1235 }
1236
1243 {
1244 return this->baseString.find_first_of(c, offset);
1245 }
1246
1251 size_type FindLastOf(const SelfType& chars, size_type pos = NPos) const
1252 {
1253 return this->baseString.find_last_of(chars.baseString, pos);
1254 }
1255
1261 size_type FindLastOf(const CharType* pChars, size_type pos, size_type count) const
1262 {
1263 return this->baseString.find_last_of(pChars, pos, count);
1264 }
1265
1270 size_type FindLastOf(const CharType* pChars, size_type pos = NPos) const
1271 {
1272 return this->baseString.find_last_of(pChars, pos);
1273 }
1274
1281 {
1282 return this->baseString.find_last_of(c, pos);
1283 }
1284
1289 size_type FindFirstNotOf(const SelfType& chars, size_type offset = 0) const
1290 {
1291 return this->baseString.find_first_not_of(chars.baseString, offset);
1292 }
1293
1299 size_type FindFirstNotOf(const CharType* pChars, size_type offset, size_type count) const
1300 {
1301 return this->baseString.find_first_not_of(pChars, offset, count);
1302 }
1303
1308 size_type FindFirstNotOf(const CharType *pChars, size_type offset = 0) const
1309 {
1310 return this->baseString.find_first_not_of(pChars, offset);
1311 }
1312
1319 {
1320 return this->baseString.find_first_not_of(c, offset);
1321 }
1322
1327 size_type FindLastNotOf(const SelfType& chars, size_type pos = NPos) const
1328 {
1329 return this->baseString.find_last_not_of(chars.baseString, pos);
1330 }
1331
1337 size_type FindLastNotOf(const CharType *pChars, size_type pos, size_type count) const
1338 {
1339 return this->baseString.find_last_not_of(pChars, pos, count);
1340 }
1341
1346 size_type FindLastNotOf(const CharType *pChars, size_type pos = NPos) const
1347 {
1348 return this->baseString.find_last_not_of(pChars, pos);
1349 }
1350
1357 {
1358 return this->baseString.find_last_not_of(c, pos);
1359 }
1360
1361public: // Compare operations
1362
1370 int Compare(const SelfType& other) const
1371 {
1372 return this->baseString.compare(other.baseString);
1373 }
1374
1384 int Compare(size_type offset, size_type count, const SelfType& other) const
1385 {
1386 return this->baseString.compare(offset, count, other.baseString);
1387 }
1388
1400 int Compare(size_type offset, size_type count, const SelfType& other, size_type offsetOther, size_type countOther = NPos) const
1401 {
1402 return this->baseString.compare(offset, count, other.baseString, offsetOther, countOther);
1403 }
1404
1412 int Compare(const CharType *pOther) const
1413 {
1414 return this->baseString.compare(pOther);
1415 }
1416
1426 int Compare(size_type offset, size_type count, const CharType *pOther) const
1427 {
1428 return this->baseString.compare(offset, count, pOther);
1429 }
1430
1441 int Compare(size_type offset, size_type count, const CharType *pOther, size_type countOther) const
1442 {
1443 return this->baseString.compare(offset, count, pOther, countOther);
1444 }
1445
1446public: // misc operations (none std)
1447
1451 bool StartWith(const CharType *pChars)const
1452 {
1453 return this->Find(pChars) == 0;
1454 }
1455
1459 bool StartWith(const SelfType& pattern)const
1460 {
1461 return this->Find(pattern) == 0;
1462 }
1463
1467 bool EndWith(const CharType* pChars)const
1468 {
1469 return this->EndWith(SelfType(pChars));
1470 }
1471
1475 bool EndWith(const SelfType& pattern)const
1476 {
1477 size_t thisLength = this->baseString.length();
1478 size_t patternLength = pattern.baseString.length();
1479
1480 if (thisLength < patternLength)
1481 {
1482 return false;
1483 }
1484 // else
1485 return (this->baseString.compare(thisLength - patternLength, patternLength, pattern.baseString) == 0);
1486 }
1487
1488public: // Format operations
1493 template<typename... Args>
1494 static SelfType Format(const SelfType& format, const Args& ... args)
1495 {
1496 return Format(format.CStr(), args...);
1497 }
1498
1503 template<typename... Args>
1504 static SelfType Format(const char* format, const Args& ... args)
1505 {
1506 return BasicFormatterType::FormatCommon(&BasicStringFormatExceptionHandler::Invoke, format, args...);
1507 }
1508
1509public: // Misc operations
1512 ARP_DEPRECATED("Use GetStdString() instead.")
1514 {
1515 return this->baseString;
1516 }
1517
1521 {
1522 return this->baseString;
1523 }
1524
1527 const CharType* CStr() const
1528 {
1529 return this->baseString.c_str();
1530 }
1531
1534 operator const CharType*() const
1535 {
1536 return this->baseString.data();
1537 }
1538
1541 operator const BaseString& () const
1542 {
1543 return this->baseString;
1544 }
1545
1550 SelfType Substr(size_type offset = 0, size_type count = NPos) const
1551 {
1552 return SelfType(this->baseString.substr(offset, count));
1553 }
1554
1558 {
1559 return this->baseString.get_allocator();
1560 }
1561
1564 void Swap(SelfType& other)
1565 {
1566 this->baseString.swap(other.baseString);
1567 }
1568
1572 {
1573 return Bytes(reinterpret_cast<const byte*>(this->CStr()), reinterpret_cast<const byte*>(this->CStr() + this->Size()));
1574 }
1575
1579 {
1580 auto left = std::find_if(this->baseString.begin(), this->baseString.end(), [](char c)
1581 {
1582 return !std::isspace<char>(c, std::locale::classic());
1583 });
1584 return SelfType(left, this->baseString.end());
1585 }
1586
1590 {
1591 auto right = std::find_if(this->baseString.rbegin(), this->baseString.rend(), [](char c)
1592 {
1593 return !std::isspace<char>(c, std::locale::classic());
1594 });
1595 return SelfType(this->baseString.begin(), right.base());
1596 }
1597
1601 {
1602 auto left = std::find_if(this->baseString.begin(), this->baseString.end(), [](char c)
1603 {
1604 return !std::isspace<char>(c, std::locale::classic());
1605 });
1606
1607 // check if string only consists of whitespaces
1608 if (left == this->baseString.end())
1609 {
1610 return Empty;
1611 }
1612
1613 auto right = std::find_if(this->baseString.rbegin(), this->baseString.rend(), [](char c)
1614 {
1615 return !std::isspace<char>(c, std::locale::classic());
1616 });
1617 return SelfType(left, right.base());
1618 }
1619
1625 Tokens Split(char delimiter, bool trimTokens = true, bool removeEmptyTokens = true)const
1626 {
1627 char delimiters[] = { delimiter };
1628 return this->Split(delimiters, 1, trimTokens, removeEmptyTokens);
1629 }
1630
1637 Tokens Split(const char delimiters[], size_t delimitersCount, bool trimTokens = true, bool removeEmptyTokens = true)const
1638 {
1639 Tokens tokens;
1640
1641 size_t last = 0;
1642 size_t length = this->Length();
1643
1644 for (size_t first = 0; first < length; first = last + 1)
1645 {
1646 size_t position = this->FindFirstOf(delimiters, first, delimitersCount);
1647 last = (position != NPos) ? position : this->Length();
1648
1649 SelfType token = this->Substr(first, last - first);
1650 if (trimTokens)
1651 {
1652 token = token.Trim();
1653 }
1654 if (!removeEmptyTokens || !token.IsEmpty())
1655 {
1656 tokens.push_back(token);
1657 }
1658 }
1659
1660 if (!removeEmptyTokens && (this->FindLastOf(delimiters, NPos, delimitersCount) == (length - 1)))
1661 {
1662 tokens.push_back(Empty);
1663 }
1664
1665 return tokens;
1666 }
1667
1673 Tokens SplitByWord(const SelfType& delimiter, bool trimTokens = true, bool removeEmptyTokens = true)const
1674 {
1675 Tokens tokens;
1676
1677 size_t last = 0;
1678 size_t length = this->Length();
1679 size_t delimiterLength = delimiter.Length();
1680
1681 for (size_t first = 0; first < length; first = last + delimiterLength)
1682 {
1683 size_t position = this->Find(delimiter, first);
1684 last = (position != NPos) ? position : length;
1685
1686 SelfType token = this->Substr(first, last - first);
1687 if (trimTokens)
1688 {
1689 token = token.Trim();
1690 }
1691 if (!token.IsEmpty() || !removeEmptyTokens)
1692 {
1693 tokens.push_back(token);
1694 }
1695 }
1696
1697 if (!removeEmptyTokens && this->EndWith(delimiter))
1698 {
1699 tokens.push_back(Empty);
1700 }
1701
1702 return tokens;
1703 }
1704
1705 // warning 4996 occurs, to avoid use _SCL_SECURE_NO_WARNINGS
1706 //size_type Copy(CharType* pChars, size_type count, size_type offset = 0) const
1707 //{
1708 // return this->baseString.copy(pChars, count, offset);
1709 //}
1710
1711private: // fields
1712 BaseString baseString;
1713};
1714
1716// initializing of static fields
1717template <class CharType, class Alloc>
1718const BasicString<CharType, Alloc> BasicString<CharType, Alloc>::Empty;
1719
1720template <class CharType, class Alloc>
1721const BasicString<CharType, Alloc> BasicString<CharType, Alloc>::NewLine((CharType)'\n', (CharType)'\r');
1722
1724// inline global operators and functions of class BasicString<CharType, Alloc>
1725
1729template<class CharType, class Alloc>
1731{
1732 left.Swap(right);
1733}
1734
1739template<class CharType, class Alloc>
1740inline std::ostream& operator<<(std::ostream& os, const BasicString<CharType, Alloc>& right)
1741{
1742 os << right.GetStdString();
1743 return os;
1744}
1745
1750template<class CharType, class Alloc>
1751inline std::istream& operator>>(std::istream& is, BasicString<CharType, Alloc>& right)
1752{
1753 std::basic_string<CharType, std::char_traits<CharType>, Alloc> baseString;
1754 is >> baseString;
1755 right.Assign(baseString);
1756 return is;
1757}
1758
1763template<class CharType, class Alloc>
1765 const BasicString<CharType, Alloc>& left,
1766 const BasicString<CharType, Alloc>& right)
1767{
1768 return left.GetStdString() + right.GetStdString();
1769}
1770
1775template<class CharType, class Alloc>
1777 const CharType* left,
1778 const BasicString<CharType, Alloc>& right)
1779{
1780 return left + right.GetStdString();
1781}
1782
1787template<class CharType, class Alloc>
1789 const CharType left,
1790 const BasicString<CharType, Alloc>& right)
1791{
1792 return left + right.GetStdString();
1793}
1794
1799template<class CharType, class Alloc>
1801 const BasicString<CharType, Alloc>& left,
1802 const CharType* right)
1803{
1804 return left.GetStdString() + right;
1805}
1806
1811template<class CharType, class Alloc>
1813 const BasicString<CharType, Alloc>& left,
1814 const CharType right)
1815{
1816 return left.GetStdString() + right;
1817}
1818
1823template<class CharType, class Alloc>
1825 const BasicString<CharType, Alloc>& left,
1827{
1828 return left.GetStdString() + right.GetStdString();
1829}
1830
1835template<class CharType, class Alloc>
1838 const BasicString<CharType, Alloc>& right)
1839{
1840 return (std::move(left.Append(right)));
1841}
1842
1847template<class CharType, class Alloc>
1851{
1852 return left.GetStdString() + right.GetStdString();
1853}
1854
1859template<class CharType, class Alloc>
1861 const CharType* left,
1863{
1864 return left + right.GetStdString();
1865}
1866
1871template<class CharType, class Alloc>
1873 const CharType left,
1875{
1876 return left + right.GetStdString();
1877}
1878
1883template<class CharType, class Alloc>
1886 const CharType* right)
1887{
1888 return left.GetStdString() + right;
1889}
1890
1895template<class CharType, class Alloc>
1898 const CharType right)
1899{
1900 return left.GetStdString() + right;
1901}
1902
1907template<class CharType, class Alloc>
1908inline bool operator==(
1909 const BasicString<CharType, Alloc>& left,
1910 const BasicString<CharType, Alloc>& right)
1911{
1912 return left.GetStdString() == right.GetStdString();
1913}
1914
1919template<class CharType, class Alloc>
1920inline bool operator==(
1921 const CharType* left,
1922 const BasicString<CharType, Alloc>& right)
1923{
1924 return left == right.GetStdString();
1925}
1926
1931template<class CharType, class Alloc>
1932inline bool operator==(
1933 const BasicString<CharType, Alloc>& left,
1934 const CharType* right)
1935{
1936 return left.GetStdString() == right;
1937}
1938
1943template<class CharType, class Alloc>
1944inline bool operator!=(
1945 const BasicString<CharType, Alloc>& left,
1946 const BasicString<CharType, Alloc>& right)
1947{
1948 return (!(left == right));
1949}
1950
1955template<class CharType, class Alloc>
1956inline bool operator!=(
1957 const CharType *left,
1958 const BasicString<CharType, Alloc>& right)
1959{
1960 return (!(left == right));
1961}
1962
1967template<class CharType, class Alloc>
1968inline bool operator!=(
1969 const BasicString<CharType, Alloc>& left,
1970 const CharType* right)
1971{
1972 return (!(left == right));
1973}
1974
1979template<class CharType, class Alloc>
1980inline bool operator<(
1981 const BasicString<CharType, Alloc>& left,
1982 const BasicString<CharType, Alloc>& right)
1983{
1984 return left.GetStdString() < right.GetStdString();
1985}
1986
1991template<class CharType, class Alloc>
1992inline bool operator<(
1993 const CharType* left,
1994 const BasicString<CharType, Alloc>& right)
1995{
1996 return left < right.GetStdString();
1997}
1998
2003template<class CharType, class Alloc>
2004inline bool operator<(
2005 const BasicString<CharType, Alloc>& left,
2006 const CharType* right)
2007{
2008 return left.GetStdString() < right;
2009}
2010
2015template<class CharType, class Alloc>
2016inline bool operator>(
2017 const BasicString<CharType, Alloc>& left,
2018 const BasicString<CharType, Alloc>& right)
2019{
2020 return (right < left);
2021}
2022
2027template<class CharType, class Alloc>
2028inline bool operator>(
2029 const CharType* left,
2030 const BasicString<CharType, Alloc>& right)
2031{
2032 return (right < left);
2033}
2034
2039template<class CharType, class Alloc>
2040inline bool operator>(
2041 const BasicString<CharType, Alloc>& left,
2042 const CharType* right)
2043{
2044 return (right < left);
2045}
2046
2051template<class CharType, class Alloc>
2052inline bool operator<=(
2053 const BasicString<CharType, Alloc>& left,
2054 const BasicString<CharType, Alloc>& right)
2055{
2056 return (!(right < left));
2057}
2058
2063template<class CharType, class Alloc>
2064inline bool operator<=(
2065 const CharType* left,
2066 const BasicString<CharType, Alloc>& right)
2067{
2068 return (!(right < left));
2069}
2070
2075template<class CharType, class Alloc>
2076inline bool operator<=(
2077 const BasicString<CharType, Alloc>& left,
2078 const CharType* right)
2079{
2080 return (!(right < left));
2081}
2082
2087template<class CharType, class Alloc>
2088inline bool operator>=(
2089 const BasicString<CharType, Alloc>& left,
2090 const BasicString<CharType, Alloc>& right)
2091{
2092 return (!(left < right));
2093}
2094
2099template<class CharType, class Alloc>
2100inline bool operator>=(
2101 const CharType* left,
2102 const BasicString<CharType, Alloc>& right)
2103{
2104 return (!(left < right));
2105}
2106
2111template<class CharType, class Alloc>
2112inline bool operator>=(
2113 const BasicString<CharType, Alloc>& left,
2114 const CharType* right)
2115{
2116 return (!(left < right));
2117}
2118
2119} // end of namesapce Arp
2120
2122// standard template specializations of class BasicString<C,Alloc>
2123namespace std
2124{
2125
2129template<class C, class Alloc>
2130struct hash<Arp::BasicString<C, Alloc>>
2131{
2132private:
2133 typedef typename Arp::BasicString<C, Alloc>::BaseString BaseString;
2134
2135public:
2139 typedef size_t result_type;
2140
2141public:
2146 {
2147 return std::hash<BaseString>()(key.GetStdString());
2148 }
2149};
2150
2152
2153} // end of namespace std
This class encapsulates formatting operations which are based on the open source library libfmt forme...
Definition: BasicFormatter.hxx:28
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:56
Definition: BasicString.hxx:34
size_type FindLastOf(const CharType *pChars, size_type pos, size_type count) const
Finds the last occurence of any character in pChars .
Definition: BasicString.hxx:1261
SelfType & Assign(const CharType *pChars, size_type count)
This operation copies the as argument passed C-string partially.
Definition: BasicString.hxx:366
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:240
typename AllocatorTraits::pointer pointer
The pointer type of this type.
Definition: BasicString.hxx:52
const_reverse_iterator ConstReverseBegin() const
Returns the begin iterator of this const string for reverse iterating.
Definition: BasicString.hxx:938
typename BaseString::const_iterator const_iterator
The const iterator type of this type.
Definition: BasicString.hxx:55
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:1289
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:1494
SelfType & Insert(size_type offset, const SelfType &arg)
This operation inserts the the argument at the given position.
Definition: BasicString.hxx:514
typename AllocatorTraits::const_pointer const_pointer
The const pointer type of this type.
Definition: BasicString.hxx:53
typename BaseString::size_type size_type
The size type of this type.
Definition: BasicString.hxx:48
size_type FindFirstOf(const CharType *pChars, size_type offset=0) const
Finds the first occurence of any character in pChars .
Definition: BasicString.hxx:1232
BasicString(const CharType *pChars, const Allocator &alloc)
This constructor copies the as argument passed C-string.
Definition: BasicString.hxx:131
BasicString< CharType, Allocator > SelfType
The self type.
Definition: BasicString.hxx:39
SelfType TrimLeft() const
Removes left appended white-spaces from this string
Definition: BasicString.hxx:1578
SelfType & operator+=(const CharType *right)
This assignment operator appends the the right-hand-side operand to this string.
Definition: BasicString.hxx:291
const_reference At(size_type offset) const
Returns a const reference to the character at position offset .
Definition: BasicString.hxx:1018
C CharType
The character type.
Definition: BasicString.hxx:38
SelfType & Insert(size_type offset, const CharType *pChars, size_type count)
This operation inserts the as argument passed string partially.
Definition: BasicString.hxx:537
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:1625
bool IsEmpty() const
Determines if this string is empty.
Definition: BasicString.hxx:1087
size_type ReverseFind(CharType c, size_type offset=NPos) const
Finds the last char which equal to c .
Definition: BasicString.hxx:1204
iterator Erase(const_iterator where)
This operation erases a char from a string.
Definition: BasicString.hxx:637
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:177
BasicString(const BaseString &arg)
This copy constructor copies the as argument passed std::string to this string.
Definition: BasicString.hxx:201
const_reverse_iterator ConstReverseEnd() const
Returns the end iterator of this const string for reverse iterating.
Definition: BasicString.hxx:945
iterator Insert(const_iterator where, const_iterator first, const_iterator last)
Inserts a range of chars [first;last) at position where .
Definition: BasicString.hxx:598
SelfType & Assign(size_type count, CharType c)
Fills this string with count consecutive copies of character c .
Definition: BasicString.hxx:383
SelfType & Assign(const SelfType &arg, size_type offset, size_type count=NPos)
This operation copies the as argument passed string partially.
Definition: BasicString.hxx:339
SelfType & operator=(SelfType &&right) noexcept=default
This move assignment operator moves the right-hand-side operand to this string.
SelfType & Replace(size_type offset, size_type length, const SelfType &arg)
Replaces a range of chars.
Definition: BasicString.hxx:669
SelfType & operator=(CharType c)
This assignment operator copies the right-hand-side operand to this string.
Definition: BasicString.hxx:263
SelfType & Replace(size_type offset, size_type length, size_type count, CharType c)
Replaces a range of chars by a character.
Definition: BasicString.hxx:717
const_iterator ConstBegin() const
Returns the begin iterator of this const string.
Definition: BasicString.hxx:924
size_type Find(CharType c, size_type offset=0) const
Finds the first char which equal to c .
Definition: BasicString.hxx:1167
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:1764
SelfType & Replace(const_iterator first, const_iterator last, const CharType *pChars)
Replaces a range of chars [first;last).
Definition: BasicString.hxx:751
typename BaseString::const_reverse_iterator const_reverse_iterator
The const reverse iterator type of this type.
Definition: BasicString.hxx:57
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:505
size_type FindLastOf(const SelfType &chars, size_type pos=NPos) const
Finds the last occurence of any character in chars .
Definition: BasicString.hxx:1251
bool EndWith(const CharType *pChars) const
Determines if this string ends with the pChars C-string.
Definition: BasicString.hxx:1467
Allocator GetAllocator() const
Gets the allocator of this string.
Definition: BasicString.hxx:1557
SelfType & Replace(size_type offset, size_type length, const CharType *pChars)
Replaces a range of chars.
Definition: BasicString.hxx:705
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:421
void Reserve(size_type newCapacity=0)
Reserves memory upto the specified newCapacity .
Definition: BasicString.hxx:1122
SelfType Substr(size_type offset=0, size_type count=NPos) const
Gets a substring of this string.
Definition: BasicString.hxx:1550
typename BaseString::difference_type difference_type
The difference type of this type.
Definition: BasicString.hxx:49
SelfType & Erase(size_type offset=0)
This operation erases chars from this string.
Definition: BasicString.hxx:618
SelfType & Erase(size_type offset, size_type count)
This operation erases chars from this string.
Definition: BasicString.hxx:628
SelfType & Append(iterator first, iterator last)
Appends the sequence of characters in the range [first,last), in the same order.
Definition: BasicString.hxx:475
reference operator[](size_type offset)
Returns a reference to the character at position offset .
Definition: BasicString.hxx:1027
SelfType & Replace(const_iterator first, const_iterator last, std::initializer_list< CharType > chars)
Replaces a range of chars [first;last).
Definition: BasicString.hxx:658
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:1504
SelfType & Replace(const_iterator first, const_iterator last, const_iterator first2, const_iterator last2)
Replaces a range of chars [first;last).
Definition: BasicString.hxx:787
int Compare(const SelfType &other) const
Compares this string to the other string lexicographical.
Definition: BasicString.hxx:1370
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:1730
const_iterator Begin() const
Returns the begin iterator of this string.
Definition: BasicString.hxx:875
bool operator<=(const BasicString< CharType, Alloc > &left, const BasicString< CharType, Alloc > &right)
Compares the left string to the right string.
Definition: BasicString.hxx:2052
const_reverse_iterator ReverseBegin() const
Returns the begin iterator of this string for reverse iterating.
Definition: BasicString.hxx:903
bool operator>(const BasicString< CharType, Alloc > &left, const BasicString< CharType, Alloc > &right)
Compares the left string to the right string.
Definition: BasicString.hxx:2016
void PushBack(CharType c)
Appends the character c to this string.
Definition: BasicString.hxx:958
BasicString(BaseString &&arg)
This move constructor moves the as argument passed std::string to this string.
Definition: BasicString.hxx:208
void Clear()
Clears the content of this string, but does not modify the capacity.
Definition: BasicString.hxx:1128
SelfType & Assign(const CharType *pChars)
This operation copies the as argument passed C-string.
Definition: BasicString.hxx:374
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:1308
size_type MaxSize() const
Returns the number maximum size any string might have.
Definition: BasicString.hxx:1068
SelfType Trim() const
Removes left and rigth appended white-spaces from this string
Definition: BasicString.hxx:1600
int Compare(const CharType *pOther) const
Compares this string to the pOther string lexicographical.
Definition: BasicString.hxx:1412
void Swap(SelfType &other)
Swaps the content of this string with the content of the other string.
Definition: BasicString.hxx:1564
SelfType & Assign(const SelfType &arg)
This operation copies the the argument to this string.
Definition: BasicString.hxx:329
iterator Insert(const_iterator where, iterator first, iterator last)
Inserts a range of chars [first;last) at position where .
Definition: BasicString.hxx:588
SelfType & Replace(const_iterator first, const_iterator last, size_type count, CharType c)
Replaces a range of chars [first;last).
Definition: BasicString.hxx:763
iterator begin()
Returns the begin iterator of this string.
Definition: BasicString.hxx:835
BasicString(const SelfType &arg, size_type offset, size_type count=NPos)
This constructor copies the as argument passed string partially.
Definition: BasicString.hxx:89
SelfType & Append(const SelfType &arg, size_type offset, size_type count=NPos)
This operation appends the as argument passed string partially.
Definition: BasicString.hxx:440
SelfType & operator=(const SelfType &right)=default
This assignment operator copies the the right-hand-side operand to this string.
iterator Begin()
Returns the begin iterator of this string.
Definition: BasicString.hxx:868
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:221
reverse_iterator ReverseEnd()
Returns the end iterator of this string for reverse iterating.
Definition: BasicString.hxx:910
const_iterator end() const
Returns the end iterator of this string.
Definition: BasicString.hxx:859
SelfType & Assign(const BaseString &arg)
This operation copies the argument to this string.
Definition: BasicString.hxx:348
size_type Find(const SelfType &pattern, size_type offset=0) const
Finds the first substring which equal to pattern .
Definition: BasicString.hxx:1139
size_type FindLastNotOf(const CharType *pChars, size_type pos, size_type count) const
Finds the last occurence of any character which is not in pChars .
Definition: BasicString.hxx:1337
size_type FindLastNotOf(const SelfType &chars, size_type pos=NPos) const
Finds the last occurence of any character which is not in chars .
Definition: BasicString.hxx:1327
BasicString(const CharType *pChars, size_type count)
This constructor copies the as argument passed C-string.
Definition: BasicString.hxx:107
bool operator<(const BasicString< CharType, Alloc > &left, const BasicString< CharType, Alloc > &right)
Compares the left string to the right string.
Definition: BasicString.hxx:1980
size_type ReverseFind(const CharType *pChars, size_type offset=NPos) const
Finds the last substring which equal to pChars .
Definition: BasicString.hxx:1195
typename BaseString::reference reference
The reference type of this type.
Definition: BasicString.hxx:50
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:1223
SelfType & operator+=(CharType c)
This assignment operator appends the the right-hand-side operand to this string.
Definition: BasicString.hxx:300
reverse_iterator ReverseBegin()
Returns the begin iterator of this string for reverse iterating.
Definition: BasicString.hxx:896
SelfType & Append(const CharType *pChars)
This operation appends the as argument passed C-string.
Definition: BasicString.hxx:457
std::ostream & operator<<(std::ostream &os, const BasicString< CharType, Alloc > &right)
Streams the right string to the outstream os .
Definition: BasicString.hxx:1740
SelfType & Replace(size_type offset, size_type length, const CharType *pChars, size_type count)
Replaces a range of chars.
Definition: BasicString.hxx:694
SelfType & Replace(const_iterator first, const_iterator last, const CharType *pChars, size_type count)
Replaces a range of chars [first;last).
Definition: BasicString.hxx:740
BasicString(const SelfType &arg)=default
The copy constructor copies the as argument passed string deeply.
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:484
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:410
int Compare(size_type offset, size_type count, const CharType *pOther) const
Compares this string to the pOther string lexicographical.
Definition: BasicString.hxx:1426
SelfType & Insert(size_type offset, size_type count, CharType c)
Inserts count consecutive copies of character c at position offset .
Definition: BasicString.hxx:558
iterator Insert(const_iterator where, CharType c)
Inserts character c at position where .
Definition: BasicString.hxx:568
reference Front()
Returns a reference to the first character in the string.
Definition: BasicString.hxx:976
BasicString(const CharType *pChars, size_type count, const Allocator &alloc)
This constructor copies the as argument passed C-string.
Definition: BasicString.hxx:116
void Resize(size_type newSize, CharType c)
Resizes this string to the specified new size.
Definition: BasicString.hxx:1110
const_reference Back() const
Returns a const reference to the last character in the string.
Definition: BasicString.hxx:1000
bool operator>=(const BasicString< CharType, Alloc > &left, const BasicString< CharType, Alloc > &right)
Compares the left string to the right string.
Definition: BasicString.hxx:2088
SelfType & Append(size_type count, CharType c)
Appends to this string count consecutive copies of character c .
Definition: BasicString.hxx:466
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:1637
BasicString(std::initializer_list< CharType > arg, const Allocator &alloc=Allocator())
Copies each of the characters in initList , in the same order.
Definition: BasicString.hxx:168
typename BaseString::iterator iterator
The iterator type of this type.
Definition: BasicString.hxx:54
size_type Find(const CharType *pChars, size_type offset=0) const
Finds the first substring which equal to pChars .
Definition: BasicString.hxx:1158
SelfType & Replace(const_iterator first, const_iterator last, const_pointer first2, const_pointer last2)
Replaces a range of chars [first;last).
Definition: BasicString.hxx:799
reference At(size_type offset)
Returns a const reference to the character at position offset .
Definition: BasicString.hxx:1009
void PopBack()
Removes the character at the end of this string.
Definition: BasicString.hxx:965
BasicString(const CharType *pChars)
This constructor copies the as argument passed C-string.
Definition: BasicString.hxx:123
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:1318
const_reference operator[](size_type offset) const
Returns a const reference to the character at position offset .
Definition: BasicString.hxx:1036
const StdString & GetStdString() const
Gets the basic std string.
Definition: BasicString.hxx:1520
std::vector< SelfType > Tokens
Used by Split() operation.
Definition: BasicString.hxx:42
iterator Insert(const_iterator where, const_pointer first, const_pointer last)
Inserts a range of chars [first;last) at position where .
Definition: BasicString.hxx:608
BasicString(const Allocator &alloc)
This constructor creates an empty string instance.
Definition: BasicString.hxx:80
BasicString(SelfType &&arg) noexcept=default
This move constructor moves the as argument passed string to this string.
SelfType & Replace(const_iterator first, const_iterator last, iterator first2, iterator last2)
Replaces a range of chars [first;last).
Definition: BasicString.hxx:775
SelfType & Append(const SelfType &arg)
This operation appends the the argument to this string.
Definition: BasicString.hxx:430
bool StartWith(const SelfType &pattern) const
Determines if this string starts with the pattern string.
Definition: BasicString.hxx:1459
size_type FindLastOf(const CharType *pChars, size_type pos=NPos) const
Finds the last occurence of any character in pChars .
Definition: BasicString.hxx:1270
size_type Length() const
Returns the number of char elements in this string.
Definition: BasicString.hxx:1050
size_type FindLastNotOf(const CharType *pChars, size_type pos=NPos) const
Finds the last occurence of any character which is not in pChars .
Definition: BasicString.hxx:1346
std::istream & operator>>(std::istream &is, BasicString< CharType, Alloc > &right)
Streams the instream is into the right string.
Definition: BasicString.hxx:1751
int Compare(size_type offset, size_type count, const SelfType &other) const
Compares this string to the other string lexicographical.
Definition: BasicString.hxx:1384
typename BaseString::const_reference const_reference
The const reference type of this type.
Definition: BasicString.hxx:51
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:1944
bool EndWith(const SelfType &pattern) const
Determines if this string starts with the pattern string.
Definition: BasicString.hxx:1475
const CharType * CStr() const
Gets the character data of this string.
Definition: BasicString.hxx:1527
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:1299
const_reference Front() const
Returns a const reference to the first character in the string.
Definition: BasicString.hxx:984
Alloc Allocator
The characters allocator type.
Definition: BasicString.hxx:36
SelfType & ReplaceAll(const SelfType &pattern, const SelfType &replacement)
Replaces a given pattern by a replacement string.
Definition: BasicString.hxx:824
size_type ReverseFind(const CharType *pChars, size_type offset, size_type count) const
Finds the last substring which equal to pChars .
Definition: BasicString.hxx:1186
iterator Erase(const_iterator first, const_iterator last)
Erases a range of chars [first;last).
Definition: BasicString.hxx:646
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:186
SelfType & Replace(const_iterator first, const_iterator last, pointer first2, pointer last2)
Replaces a range of chars [first;last).
Definition: BasicString.hxx:811
Bytes ToBytes() const
Copies this string to a byte array.
Definition: BasicString.hxx:1571
SelfType & Assign(iterator first, iterator last)
Copies the sequence of characters in the range [first,last), in the same order.
Definition: BasicString.hxx:392
iterator End()
Returns the end iterator of this string.
Definition: BasicString.hxx:882
SelfType & Assign(BaseString &&arg)
This operation moves the argument to this string.
Definition: BasicString.hxx:357
const_iterator ConstEnd() const
Returns the end iterator of this const string.
Definition: BasicString.hxx:931
BasicString(const Bytes &bytes, const Allocator &alloc=Allocator())
Copies the as arguments passed bytes to this string.
Definition: BasicString.hxx:194
const BaseString & GetBaseString() const
Gets the basic std string.
Definition: BasicString.hxx:1513
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:99
SelfType & Replace(const_iterator first, const_iterator last, const SelfType &arg)
Replaces a range of chars [first;last).
Definition: BasicString.hxx:728
const_reverse_iterator ReverseEnd() const
Returns the end iterator of this string for reverse iterating.
Definition: BasicString.hxx:917
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:1673
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:320
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:493
size_type FindLastOf(CharType c, size_type pos=NPos) const
Finds the last occurence of character c .
Definition: BasicString.hxx:1280
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:682
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:526
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:1400
SelfType & operator+=(const SelfType &right)
This assignment operator appends the the right-hand-side operand to this string.
Definition: BasicString.hxx:282
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:401
BasicString(size_type count, CharType c)
Fills the string with count consecutive copies of character c .
Definition: BasicString.hxx:139
BasicString()=default
The default constructor constructs an empty string instance.
size_type FindLastNotOf(CharType c, size_type pos=NPos) const
Finds the last occurence of any character which is not equal to c .
Definition: BasicString.hxx:1356
SelfType TrimRight() const
Removes right appended white-spaces from this string
Definition: BasicString.hxx:1589
~BasicString()=default
The destructor deallocates all memory of this instance.
static const SelfType NewLine
This static string instance represents the (platform specific) new line string.
Definition: BasicString.hxx:229
std::basic_string< CharType, std::char_traits< CharType >, Allocator > StdString
The type of the basic std string.
Definition: BasicString.hxx:41
void ShrinkToFit()
Might reduce the capacity of this string to its size.
Definition: BasicString.hxx:951
iterator end()
Returns the end iterator of this string.
Definition: BasicString.hxx:851
bool StartWith(const CharType *pChars) const
Determines if this string starts with the pChars C-string.
Definition: BasicString.hxx:1451
size_type Find(const CharType *pChars, size_type offset, size_type count) const
Finds the first substring which equal to pChars .
Definition: BasicString.hxx:1149
static const SelfType Empty
An emtpy static string instance.
Definition: BasicString.hxx:225
SelfType & Append(const CharType *pChars, size_type count)
This operation appends the as argument passed C-string partially.
Definition: BasicString.hxx:449
size_type Capacity() const
Rceturns the capacity of this string.
Definition: BasicString.hxx:1080
size_type ReverseFind(const SelfType &pattern, size_type offset=NPos) const
Finds the last substring which equal to pattern .
Definition: BasicString.hxx:1176
reference Back()
Returns a reference to the last character in the string.
Definition: BasicString.hxx:992
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:1441
size_type Size() const
Returns the number of char elements in this string.
Definition: BasicString.hxx:1062
CharType value_type
The char type of this type.
Definition: BasicString.hxx:47
size_type FindFirstOf(CharType c, size_type offset=0) const
Finds the first occurence of character c .
Definition: BasicString.hxx:1242
Allocator allocator_type
The allocator type of this type.
Definition: BasicString.hxx:46
typename BaseString::reverse_iterator reverse_iterator
The reverse iterator type of this type.
Definition: BasicString.hxx:56
SelfType & Assign(SelfType &&arg)
This operation moves the as argument passed string to this string.
Definition: BasicString.hxx:311
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:1908
std::basic_string< CharType, std::char_traits< CharType >, Allocator > BaseString
The type of the basic std string.
Definition: BasicString.hxx:40
void Resize(size_type newSize)
Resizes this string to the specified new size.
Definition: BasicString.hxx:1098
const_iterator End() const
Returns the end iterator of this string.
Definition: BasicString.hxx:889
SelfType & Insert(size_type offset, const CharType *pChars)
This operation inserts the as argument passed string.
Definition: BasicString.hxx:547
BasicString(const SelfType &arg, const Allocator &alloc)
This constructor copies the as argument passed string deeply.
Definition: BasicString.hxx:73
BasicString(size_type count, CharType c, const Allocator &alloc)
Fills the string with count consecutive copies of character c .
Definition: BasicString.hxx:148
BasicString(SelfType &&arg, const Allocator &alloc)
This move constructor moves the as argument passed string to this string.
Definition: BasicString.hxx:160
const_iterator begin() const
Returns the begin iterator of this string.
Definition: BasicString.hxx:843
std::vector< byte > Bytes
Conversion from and to byte array.
Definition: BasicString.hxx:43
size_type FindFirstOf(const SelfType &chars, size_type offset=0) const
Finds the first occurence of any character in chars .
Definition: BasicString.hxx:1213
SelfType & operator=(const CharType *right)
This assignment operator copies the right-hand-side operand to this string.
Definition: BasicString.hxx:254
iterator Insert(const_iterator where, size_type count, CharType c)
Inserts character c at position where .
Definition: BasicString.hxx:578
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:273
Root namespace for the PLCnext API
class ARP_DEPRECATED("Use Arp::Enum<T> instead.") EnumStrings
Deprecated! The class implements an adapter for enums to define the string literals of the enum entri...
Definition: EnumStrings.hxx:38
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:2145
size_t result_type
The result type of this functor class (stl policy type)
Definition: BasicString.hxx:2139
Arp::BasicString< C, Alloc > argument_type
The argument type of this functor class (stl policy type)
Definition: BasicString.hxx:2137