PLCnext API Documentation 23.6.0.37
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 Tokens = std::vector<SelfType>;
42 using Bytes = std::vector<byte>;
43
44public: // policy typedefs
47 using size_type = typename BaseString::size_type;
48 using difference_type = typename BaseString::difference_type;
49 using reference = typename BaseString::reference;
50 using const_reference = typename BaseString::const_reference;
51 using pointer = typename AllocatorTraits::pointer;
52 using const_pointer = typename AllocatorTraits::const_pointer;
53 using iterator = typename BaseString::iterator;
54 using const_iterator = typename BaseString::const_iterator;
55 using reverse_iterator = typename BaseString::reverse_iterator;
56 using const_reverse_iterator = typename BaseString::const_reverse_iterator;
57
58private: // usings
60
61public: // construction/destruction
63 BasicString() = default;
64
67 BasicString(const SelfType& arg) = default;
68
72 BasicString(const SelfType& arg, const Allocator& alloc)
73 : baseString(arg.baseString, alloc)
74 {
75 }
76
79 explicit BasicString(const Allocator& alloc)
80 : baseString(alloc)
81 {
82 }
83
88 BasicString(const SelfType& arg, size_type offset, size_type count = NPos)
89 : baseString(arg.baseString, offset, count)
90 {
91 }
92
98 BasicString(const SelfType& arg, size_type offset, size_type count, const Allocator& alloc)
99 : baseString(arg.baseString, offset, count, alloc)
100 {
101 }
102
106 BasicString(const CharType* pChars, size_type count)
107 : baseString(pChars, count)
108 {
109 }
110
115 BasicString(const CharType* pChars, size_type count, const Allocator& alloc)
116 : baseString(pChars, count, alloc)
117 {
118 }
119
122 BasicString(const CharType* pChars)
123 : baseString(pChars)
124 {
125 }
126
130 BasicString(const CharType* pChars, const Allocator& alloc)
131 : baseString(pChars, alloc)
132 {
133 }
134
139 : baseString(count, c)
140 {
141 }
142
147 BasicString(size_type count, CharType c, const Allocator& alloc)
148 : baseString(count, c, alloc)
149 {
150 }
151
154 BasicString(SelfType&& arg) noexcept = default;
155
159 BasicString(SelfType&& arg, const Allocator& alloc)
160 : baseString(std::move(arg.baseString), alloc)
161 {
162 }
163
167 BasicString(std::initializer_list<CharType> arg, const Allocator& alloc = Allocator())
168 : baseString(arg, alloc)
169 {
170 }
171
176 BasicString(iterator first, iterator last, const Allocator& alloc = Allocator())
177 : baseString(first, last, alloc)
178 {
179 }
180
186 : baseString(first, last, alloc)
187 {
188 }
189
193 explicit BasicString(const Bytes& bytes, const Allocator& alloc = Allocator())
194 : baseString(reinterpret_cast<const char*>(bytes.data()), reinterpret_cast<const char*>(bytes.data() + bytes.size()), alloc)
195 {
196 }
197
201 : baseString(arg)
202 {
203 }
204
208 : baseString(std::move(arg))
209 {
210 }
211
213 ~BasicString() = default;
214
215public: // static fields
220 static const size_type NPos = size_type(-1);
224 static const SelfType Empty;
228 static const SelfType NewLine;
229
230public: // assignment operator
234 SelfType& operator=(SelfType&& right) noexcept = default;
235
239 SelfType& operator=(std::initializer_list<CharType> right)
240 {
241 this->baseString = right;
242 return (*this);
243 }
244
248 SelfType& operator=(const SelfType& right) = default;
249
254 {
255 this->baseString = right;
256 return (*this);
257 }
258
263 {
264 this->baseString = c;
265 return (*this);
266 }
267
268public: // append operator
272 SelfType& operator+=(std::initializer_list<CharType> right)
273 {
274 this->baseString += right;
275 return (*this);
276 }
277
282 {
283 this->baseString += right.baseString;
284 return (*this);
285 }
286
291 {
292 this->baseString += right;
293 return (*this);
294 }
295
300 {
301 this->baseString += c;
302 return (*this);
303 }
304
305public: // assign operations
306
311 {
312 this->baseString = std::move(arg.baseString);
313 return *this;
314 }
315
319 SelfType& Assign(std::initializer_list<CharType> arg)
320 {
321 this->baseString.assign(arg);
322 return *this;
323 }
324
329 {
330 this->baseString.assign(arg.baseString);
331 return *this;
332 }
333
338 SelfType& Assign(const SelfType& arg, size_type offset, size_type count = NPos)
339 {
340 this->baseString.assign(arg.baseString, offset, count);
341 return *this;
342 }
343
348 {
349 this->baseString.assign(arg);
350 return *this;
351 }
352
357 {
358 this->baseString.assign(std::move(arg));
359 return *this;
360 }
361
365 SelfType& Assign(const CharType* pChars, size_type count)
366 {
367 this->baseString.assign(pChars, count);
368 return *this;
369 }
370
373 SelfType& Assign(const CharType* pChars)
374 {
375 this->baseString.assign(pChars);
376 return *this;
377 }
378
383 {
384 this->baseString.assign(count, c);
385 return *this;
386 }
387
392 {
393 this->baseString.assign(first, last);
394 return *this;
395 }
396
401 {
402 this->baseString.assign(first, last);
403 return *this;
404 }
405
410 {
411 this->baseString.assign(first, last);
412 return *this;
413 }
414
415public: // append operations
416
420 SelfType& Append(std::initializer_list<CharType> arg)
421 {
422 this->baseString.append(arg);
423 return *this;
424 }
425
430 {
431 this->baseString.append(arg.baseString);
432 return *this;
433 }
434
439 SelfType& Append(const SelfType& arg, size_type offset, size_type count = NPos)
440 {
441 this->baseString.append(arg.baseString, offset, count);
442 return *this;
443 }
444
448 SelfType& Append(const CharType* pChars, size_type count)
449 {
450 this->baseString.append(pChars, count);
451 return *this;
452 }
453
456 SelfType& Append(const CharType* pChars)
457 {
458 this->baseString.append(pChars);
459 return *this;
460 }
461
466 {
467 this->baseString.append(count, c);
468 return *this;
469 }
470
475 {
476 this->baseString.append(first, last);
477 return *this;
478 }
479
484 {
485 this->baseString.append(first, last);
486 return *this;
487 }
488
493 {
494 this->baseString.append(first, last);
495 return *this;
496 }
497
498public: // insert operations
499
504 iterator Insert(const_iterator where, std::initializer_list<CharType> arg)
505 {
506 return this->baseString.insert(where, arg);
507 }
508
513 SelfType& Insert(size_type offset, const SelfType& arg)
514 {
515 this->baseString.insert(offset, arg.baseString);
516 return *this;
517 }
518
525 SelfType& Insert(size_type offset, const SelfType& arg, size_type argOffset, size_type count = NPos)
526 {
527 this->baseString.insert(offset, arg.baseString, argOffset, count);
528 return *this;
529 }
530
536 SelfType& Insert(size_type offset, const CharType* pChars, size_type count)
537 {
538 this->baseString.insert(offset, pChars, count);
539 return *this;
540 }
541
546 SelfType& Insert(size_type offset, const CharType* pChars)
547 {
548 this->baseString.insert(offset, pChars);
549 return *this;
550 }
551
558 {
559 this->baseString.insert(offset, count, c);
560 return *this;
561 }
562
568 {
569 return this->baseString.insert(where, c);
570 }
571
578 {
579 return this->baseString.insert(where, count, c);
580 }
581
588 {
589 return this->baseString.insert(where, first, last);
590 }
591
598 {
599 return this->baseString.insert(where, first, last);
600 }
601
608 {
609 return this->baseString.insert(where, first, last);
610 }
611
612public: // erase operations
613
618 {
619 this->baseString.erase(offset);
620 return (*this);
621 }
622
628 {
629 this->baseString.erase(offset, count);
630 return (*this);
631 }
632
637 {
638 return this->baseString.erase(where);
639 }
640
646 {
647 return this->baseString.erase(first, last);
648 }
649
650public: // replace operation
651
657 SelfType& Replace(const_iterator first, const_iterator last, std::initializer_list<CharType> chars)
658 {
659 this->baseString.replace(first, last, chars);
660 return *this;
661 }
662
668 SelfType& Replace(size_type offset, size_type length, const SelfType& arg)
669 {
670 this->baseString.replace(offset, length, arg.baseString);
671 return (*this);
672 }
673
681 SelfType& Replace(size_type offset, size_type length, const SelfType& arg, size_type offsetArg, size_type count = NPos)
682 {
683 this->baseString.replace(offset, length, arg.baseString, offsetArg, count);
684 return (*this);
685 }
686
693 SelfType& Replace(size_type offset, size_type length, const CharType* pChars, size_type count)
694 {
695 this->baseString.replace(offset, length, pChars, offset, count);
696 return (*this);
697 }
698
704 SelfType& Replace(size_type offset, size_type length, const CharType* pChars)
705 {
706 this->baseString.replace(offset, length, pChars);
707 return (*this);
708 }
709
717 {
718 this->baseString.replace(offset, length, count, c);
719 return (*this);
720 }
721
728 {
729 this->baseString.replace(first, last, arg.baseString);
730 return (*this);
731 }
732
740 {
741 this->baseString.replace(first, last, pChars, count);
742 return (*this);
743 }
744
751 {
752 this->baseString.replace(first, last, pChars);
753 return (*this);
754 }
755
763 {
764 this->baseString.replace(first, last, count, c);
765 return (*this);
766 }
767
775 {
776 this->baseString.replace(first, last, first2, last2);
777 return (*this);
778 }
779
787 {
788 this->baseString.replace(first, last, first2, last2);
789 return (*this);
790 }
791
799 {
800 this->baseString.replace(first, last, first2, last2);
801 return (*this);
802 }
803
811 {
812 this->baseString.replace(first, last, first2, last2);
813 return (*this);
814 }
815
816public: // replace_all operations
817
823 SelfType& ReplaceAll(const SelfType& pattern, const SelfType& replacement)
824 {
825 boost::replace_all(this->baseString, pattern.baseString, replacement.baseString);
826 return (*this);
827 }
828
829public: // support of range based for loops
830
835 {
836 return this->baseString.begin();
837 }
838
843 {
844 return this->baseString.begin();
845 }
846
851 {
852 return this->baseString.end();
853 }
854
859 {
860 return this->baseString.end();
861 }
862
863public: // container operations
864
868 {
869 return this->baseString.begin();
870 }
871
875 {
876 return this->baseString.begin();
877 }
878
882 {
883 return this->baseString.end();
884 }
885
889 {
890 return this->baseString.end();
891 }
892
896 {
897 return this->baseString.rbegin();
898 }
899
903 {
904 return this->baseString.rbegin();
905 }
906
910 {
911 return this->baseString.rend();
912 }
913
917 {
918 return this->baseString.rend();
919 }
920
924 {
925 return this->baseString.cbegin();
926 }
927
931 {
932 return this->baseString.cend();
933 }
934
938 {
939 return this->baseString.crbegin();
940 }
941
945 {
946 return this->baseString.crend();
947 }
948
951 {
952 this->baseString.shrink_to_fit();
953 }
954
958 {
959 this->baseString.push_back(c);
960 }
961
964 void PopBack()
965 {
966 if(!this->IsEmpty())
967 {
968 this->baseString.pop_back();
969 }
970 }
971
976 {
977 return this->baseString.front();
978 }
979
984 {
985 return this->baseString.front();
986 }
987
992 {
993 return this->baseString.back();
994 }
995
1000 {
1001 return this->baseString.back();
1002 }
1003
1009 {
1010 return this->baseString.at(offset);
1011 }
1012
1018 {
1019 return this->baseString.at(offset);
1020 }
1021
1027 {
1028 return this->baseString[offset];
1029 }
1030
1036 {
1037 return this->baseString[offset];
1038 }
1039
1040public: // Size/Length operations
1041
1050 {
1051 return this->baseString.length();
1052 }
1053
1062 {
1063 return this->baseString.size();
1064 }
1065
1068 {
1069 return this->baseString.max_size();
1070 }
1071
1080 {
1081 return this->baseString.capacity();
1082 }
1083
1086 bool IsEmpty() const
1087 {
1088 return this->baseString.empty();
1089 }
1090
1097 void Resize(size_type newSize)
1098 {
1099 this->baseString.resize(newSize);
1100 }
1101
1109 void Resize(size_type newSize, CharType c)
1110 {
1111 this->baseString.resize(newSize, c);
1112 }
1113
1121 void Reserve(size_type newCapacity = 0)
1122 {
1123 this->baseString.reserve(newCapacity);
1124 }
1125
1127 void Clear()
1128 {
1129 this->baseString.clear();
1130 }
1131
1132public: // Find operations
1133
1138 size_type Find(const SelfType& pattern, size_type offset = 0) const
1139 {
1140 return this->baseString.find(pattern.baseString, offset);
1141 }
1142
1148 size_type Find(const CharType* pChars, size_type offset, size_type count) const
1149 {
1150 return this->baseString.find(pChars, offset, count);
1151 }
1152
1157 size_type Find(const CharType* pChars, size_type offset = 0) const
1158 {
1159 return this->baseString.find(pChars, offset);
1160 }
1161
1166 size_type Find(CharType c, size_type offset = 0) const
1167 {
1168 return this->baseString.find(c, offset);
1169 }
1170
1175 size_type ReverseFind(const SelfType& pattern, size_type offset = NPos) const
1176 {
1177 return this->baseString.rfind(pattern.baseString, offset);
1178 }
1179
1185 size_type ReverseFind(const CharType* pChars, size_type offset, size_type count) const
1186 {
1187 return this->baseString.rfind(pChars, offset, count);
1188 }
1189
1194 size_type ReverseFind(const CharType* pChars, size_type offset = NPos) const
1195 {
1196 return this->baseString.rfind(pChars, offset);
1197 }
1198
1204 {
1205 return this->baseString.rfind(c, offset);
1206 }
1207
1212 size_type FindFirstOf(const SelfType& chars, size_type offset = 0) const
1213 {
1214 return this->baseString.find_first_of(chars.baseString, offset);
1215 }
1216
1222 size_type FindFirstOf(const CharType* pChars, size_type offset, size_type count) const
1223 {
1224 return this->baseString.find_first_of(pChars, offset, count);
1225 }
1226
1231 size_type FindFirstOf(const CharType* pChars, size_type offset = 0) const
1232 {
1233 return this->baseString.find_first_of(pChars, offset);
1234 }
1235
1242 {
1243 return this->baseString.find_first_of(c, offset);
1244 }
1245
1250 size_type FindLastOf(const SelfType& chars, size_type pos = NPos) const
1251 {
1252 return this->baseString.find_last_of(chars.baseString, pos);
1253 }
1254
1260 size_type FindLastOf(const CharType* pChars, size_type pos, size_type count) const
1261 {
1262 return this->baseString.find_last_of(pChars, pos, count);
1263 }
1264
1269 size_type FindLastOf(const CharType* pChars, size_type pos = NPos) const
1270 {
1271 return this->baseString.find_last_of(pChars, pos);
1272 }
1273
1280 {
1281 return this->baseString.find_last_of(c, pos);
1282 }
1283
1288 size_type FindFirstNotOf(const SelfType& chars, size_type offset = 0) const
1289 {
1290 return this->baseString.find_first_not_of(chars.baseString, offset);
1291 }
1292
1298 size_type FindFirstNotOf(const CharType* pChars, size_type offset, size_type count) const
1299 {
1300 return this->baseString.find_first_not_of(pChars, offset, count);
1301 }
1302
1307 size_type FindFirstNotOf(const CharType *pChars, size_type offset = 0) const
1308 {
1309 return this->baseString.find_first_not_of(pChars, offset);
1310 }
1311
1318 {
1319 return this->baseString.find_first_not_of(c, offset);
1320 }
1321
1326 size_type FindLastNotOf(const SelfType& chars, size_type pos = NPos) const
1327 {
1328 return this->baseString.find_last_not_of(chars.baseString, pos);
1329 }
1330
1336 size_type FindLastNotOf(const CharType *pChars, size_type pos, size_type count) const
1337 {
1338 return this->baseString.find_last_not_of(pChars, pos, count);
1339 }
1340
1345 size_type FindLastNotOf(const CharType *pChars, size_type pos = NPos) const
1346 {
1347 return this->baseString.find_last_not_of(pChars, pos);
1348 }
1349
1356 {
1357 return this->baseString.find_last_not_of(c, pos);
1358 }
1359
1360public: // Compare operations
1361
1369 int Compare(const SelfType& other) const
1370 {
1371 return this->baseString.compare(other.baseString);
1372 }
1373
1383 int Compare(size_type offset, size_type count, const SelfType& other) const
1384 {
1385 return this->baseString.compare(offset, count, other.baseString);
1386 }
1387
1399 int Compare(size_type offset, size_type count, const SelfType& other, size_type offsetOther, size_type countOther = NPos) const
1400 {
1401 return this->baseString.compare(offset, count, other.baseString, offsetOther, countOther);
1402 }
1403
1411 int Compare(const CharType *pOther) const
1412 {
1413 return this->baseString.compare(pOther);
1414 }
1415
1425 int Compare(size_type offset, size_type count, const CharType *pOther) const
1426 {
1427 return this->baseString.compare(offset, count, pOther);
1428 }
1429
1440 int Compare(size_type offset, size_type count, const CharType *pOther, size_type countOther) const
1441 {
1442 return this->baseString.compare(offset, count, pOther, countOther);
1443 }
1444
1445public: // misc operations (none std)
1446
1450 bool StartWith(const CharType *pChars)const
1451 {
1452 return this->Find(pChars) == 0;
1453 }
1454
1458 bool StartWith(const SelfType& pattern)const
1459 {
1460 return this->Find(pattern) == 0;
1461 }
1462
1466 bool EndWith(const CharType* pChars)const
1467 {
1468 return this->EndWith(SelfType(pChars));
1469 }
1470
1474 bool EndWith(const SelfType& pattern)const
1475 {
1476 size_t thisLength = this->baseString.length();
1477 size_t patternLength = pattern.baseString.length();
1478
1479 if (thisLength < patternLength)
1480 {
1481 return false;
1482 }
1483 // else
1484 return (this->baseString.compare(thisLength - patternLength, patternLength, pattern.baseString) == 0);
1485 }
1486
1487public: // Format operations
1492 template<typename... Args>
1493 static SelfType Format(const SelfType& format, const Args& ... args)
1494 {
1495 return Format(format.CStr(), args...);
1496 }
1497
1502 template<typename... Args>
1503 static SelfType Format(const char* format, const Args& ... args)
1504 {
1505 return BasicFormatterType::FormatCommon(&BasicStringFormatExceptionHandler::Invoke, format, args...);
1506 }
1507
1508public: // Misc operations
1512 {
1513 return this->baseString;
1514 }
1515
1518 const CharType* CStr() const
1519 {
1520 return this->baseString.c_str();
1521 }
1522
1525 operator const CharType*() const
1526 {
1527 return this->baseString.data();
1528 }
1529
1532 operator const BaseString& () const
1533 {
1534 return this->baseString;
1535 }
1536
1541 SelfType Substr(size_type offset = 0, size_type count = NPos) const
1542 {
1543 return SelfType(this->baseString.substr(offset, count));
1544 }
1545
1549 {
1550 return this->baseString.get_allocator();
1551 }
1552
1555 void Swap(SelfType& other)
1556 {
1557 this->baseString.swap(other.baseString);
1558 }
1559
1563 {
1564 return Bytes(reinterpret_cast<const byte*>(this->CStr()), reinterpret_cast<const byte*>(this->CStr() + this->Size()));
1565 }
1566
1570 {
1571 auto left = std::find_if(this->baseString.begin(), this->baseString.end(), [](char c)
1572 {
1573 return !std::isspace<char>(c, std::locale::classic());
1574 });
1575 return SelfType(left, this->baseString.end());
1576 }
1577
1581 {
1582 auto right = std::find_if(this->baseString.rbegin(), this->baseString.rend(), [](char c)
1583 {
1584 return !std::isspace<char>(c, std::locale::classic());
1585 });
1586 return SelfType(this->baseString.begin(), right.base());
1587 }
1588
1592 {
1593 auto left = std::find_if(this->baseString.begin(), this->baseString.end(), [](char c)
1594 {
1595 return !std::isspace<char>(c, std::locale::classic());
1596 });
1597
1598 // check if string only consists of whitespaces
1599 if (left == this->baseString.end())
1600 {
1601 return Empty;
1602 }
1603
1604 auto right = std::find_if(this->baseString.rbegin(), this->baseString.rend(), [](char c)
1605 {
1606 return !std::isspace<char>(c, std::locale::classic());
1607 });
1608 return SelfType(left, right.base());
1609 }
1610
1616 Tokens Split(char delimiter, bool trimTokens = true, bool removeEmptyTokens = true)const
1617 {
1618 char delimiters[] = { delimiter };
1619 return this->Split(delimiters, 1, trimTokens, removeEmptyTokens);
1620 }
1621
1628 Tokens Split(const char delimiters[], size_t delimitersCount, bool trimTokens = true, bool removeEmptyTokens = true)const
1629 {
1630 Tokens tokens;
1631
1632 size_t last = 0;
1633 size_t length = this->Length();
1634
1635 for (size_t first = 0; first < length; first = last + 1)
1636 {
1637 size_t position = this->FindFirstOf(delimiters, first, delimitersCount);
1638 last = (position != NPos) ? position : this->Length();
1639
1640 SelfType token = this->Substr(first, last - first);
1641 if (trimTokens)
1642 {
1643 token = token.Trim();
1644 }
1645 if (!removeEmptyTokens || !token.IsEmpty())
1646 {
1647 tokens.push_back(token);
1648 }
1649 }
1650
1651 if (!removeEmptyTokens && (this->FindLastOf(delimiters, NPos, delimitersCount) == (length - 1)))
1652 {
1653 tokens.push_back(Empty);
1654 }
1655
1656 return tokens;
1657 }
1658
1664 Tokens SplitByWord(const SelfType& delimiter, bool trimTokens = true, bool removeEmptyTokens = true)const
1665 {
1666 Tokens tokens;
1667
1668 size_t last = 0;
1669 size_t length = this->Length();
1670 size_t delimiterLength = delimiter.Length();
1671
1672 for (size_t first = 0; first < length; first = last + delimiterLength)
1673 {
1674 size_t position = this->Find(delimiter, first);
1675 last = (position != NPos) ? position : length;
1676
1677 SelfType token = this->Substr(first, last - first);
1678 if (trimTokens)
1679 {
1680 token = token.Trim();
1681 }
1682 if (!token.IsEmpty() || !removeEmptyTokens)
1683 {
1684 tokens.push_back(token);
1685 }
1686 }
1687
1688 if (!removeEmptyTokens && this->EndWith(delimiter))
1689 {
1690 tokens.push_back(Empty);
1691 }
1692
1693 return tokens;
1694 }
1695
1696 // warning 4996 occurs, to avoid use _SCL_SECURE_NO_WARNINGS
1697 //size_type Copy(CharType* pChars, size_type count, size_type offset = 0) const
1698 //{
1699 // return this->baseString.copy(pChars, count, offset);
1700 //}
1701
1702private: // fields
1703 BaseString baseString;
1704};
1705
1707// initializing of static fields
1708template <class CharType, class Alloc>
1709const BasicString<CharType, Alloc> BasicString<CharType, Alloc>::Empty;
1710
1711template <class CharType, class Alloc>
1712const BasicString<CharType, Alloc> BasicString<CharType, Alloc>::NewLine((CharType)'\n', (CharType)'\r');
1713
1715// inline global operators and functions of class BasicString<CharType, Alloc>
1716
1720template<class CharType, class Alloc>
1722{
1723 left.Swap(right);
1724}
1725
1730template<class CharType, class Alloc>
1731inline std::ostream& operator<<(std::ostream& os, const BasicString<CharType, Alloc>& right)
1732{
1733 os << right.GetBaseString();
1734 return os;
1735}
1736
1741template<class CharType, class Alloc>
1742inline std::istream& operator>>(std::istream& is, BasicString<CharType, Alloc>& right)
1743{
1744 std::basic_string<CharType, std::char_traits<CharType>, Alloc> baseString;
1745 is >> baseString;
1746 right.Assign(baseString);
1747 return is;
1748}
1749
1754template<class CharType, class Alloc>
1756 const BasicString<CharType, Alloc>& left,
1757 const BasicString<CharType, Alloc>& right)
1758{
1759 return left.GetBaseString() + right.GetBaseString();
1760}
1761
1766template<class CharType, class Alloc>
1768 const CharType* left,
1769 const BasicString<CharType, Alloc>& right)
1770{
1771 return left + right.GetBaseString();
1772}
1773
1778template<class CharType, class Alloc>
1780 const CharType left,
1781 const BasicString<CharType, Alloc>& right)
1782{
1783 return left + right.GetBaseString();
1784}
1785
1790template<class CharType, class Alloc>
1792 const BasicString<CharType, Alloc>& left,
1793 const CharType* right)
1794{
1795 return left.GetBaseString() + right;
1796}
1797
1802template<class CharType, class Alloc>
1804 const BasicString<CharType, Alloc>& left,
1805 const CharType right)
1806{
1807 return left.GetBaseString() + right;
1808}
1809
1814template<class CharType, class Alloc>
1816 const BasicString<CharType, Alloc>& left,
1818{
1819 return left.GetBaseString() + right.GetBaseString();
1820}
1821
1826template<class CharType, class Alloc>
1829 const BasicString<CharType, Alloc>& right)
1830{
1831 return (std::move(left.Append(right)));
1832}
1833
1838template<class CharType, class Alloc>
1842{
1843 return left.GetBaseString() + right.GetBaseString();
1844}
1845
1850template<class CharType, class Alloc>
1852 const CharType* left,
1854{
1855 return left + right.GetBaseString();
1856}
1857
1862template<class CharType, class Alloc>
1864 const CharType left,
1866{
1867 return left + right.GetBaseString();
1868}
1869
1874template<class CharType, class Alloc>
1877 const CharType* right)
1878{
1879 return left.GetBaseString() + right;
1880}
1881
1886template<class CharType, class Alloc>
1889 const CharType right)
1890{
1891 return left.GetBaseString() + right;
1892}
1893
1898template<class CharType, class Alloc>
1899inline bool operator==(
1900 const BasicString<CharType, Alloc>& left,
1901 const BasicString<CharType, Alloc>& right)
1902{
1903 return left.GetBaseString() == right.GetBaseString();
1904}
1905
1910template<class CharType, class Alloc>
1911inline bool operator==(
1912 const CharType* left,
1913 const BasicString<CharType, Alloc>& right)
1914{
1915 return left == right.GetBaseString();
1916}
1917
1922template<class CharType, class Alloc>
1923inline bool operator==(
1924 const BasicString<CharType, Alloc>& left,
1925 const CharType* right)
1926{
1927 return left.GetBaseString() == right;
1928}
1929
1934template<class CharType, class Alloc>
1935inline bool operator!=(
1936 const BasicString<CharType, Alloc>& left,
1937 const BasicString<CharType, Alloc>& right)
1938{
1939 return (!(left == right));
1940}
1941
1946template<class CharType, class Alloc>
1947inline bool operator!=(
1948 const CharType *left,
1949 const BasicString<CharType, Alloc>& right)
1950{
1951 return (!(left == right));
1952}
1953
1958template<class CharType, class Alloc>
1959inline bool operator!=(
1960 const BasicString<CharType, Alloc>& left,
1961 const CharType* right)
1962{
1963 return (!(left == right));
1964}
1965
1970template<class CharType, class Alloc>
1971inline bool operator<(
1972 const BasicString<CharType, Alloc>& left,
1973 const BasicString<CharType, Alloc>& right)
1974{
1975 return left.GetBaseString() < right.GetBaseString();
1976}
1977
1982template<class CharType, class Alloc>
1983inline bool operator<(
1984 const CharType* left,
1985 const BasicString<CharType, Alloc>& right)
1986{
1987 return left < right.GetBaseString();
1988}
1989
1994template<class CharType, class Alloc>
1995inline bool operator<(
1996 const BasicString<CharType, Alloc>& left,
1997 const CharType* right)
1998{
1999 return left.GetBaseString() < right;
2000}
2001
2006template<class CharType, class Alloc>
2007inline bool operator>(
2008 const BasicString<CharType, Alloc>& left,
2009 const BasicString<CharType, Alloc>& right)
2010{
2011 return (right < left);
2012}
2013
2018template<class CharType, class Alloc>
2019inline bool operator>(
2020 const CharType* left,
2021 const BasicString<CharType, Alloc>& right)
2022{
2023 return (right < left);
2024}
2025
2030template<class CharType, class Alloc>
2031inline bool operator>(
2032 const BasicString<CharType, Alloc>& left,
2033 const CharType* right)
2034{
2035 return (right < left);
2036}
2037
2042template<class CharType, class Alloc>
2043inline bool operator<=(
2044 const BasicString<CharType, Alloc>& left,
2045 const BasicString<CharType, Alloc>& right)
2046{
2047 return (!(right < left));
2048}
2049
2054template<class CharType, class Alloc>
2055inline bool operator<=(
2056 const CharType* left,
2057 const BasicString<CharType, Alloc>& right)
2058{
2059 return (!(right < left));
2060}
2061
2066template<class CharType, class Alloc>
2067inline bool operator<=(
2068 const BasicString<CharType, Alloc>& left,
2069 const CharType* right)
2070{
2071 return (!(right < left));
2072}
2073
2078template<class CharType, class Alloc>
2079inline bool operator>=(
2080 const BasicString<CharType, Alloc>& left,
2081 const BasicString<CharType, Alloc>& right)
2082{
2083 return (!(left < right));
2084}
2085
2090template<class CharType, class Alloc>
2091inline bool operator>=(
2092 const CharType* left,
2093 const BasicString<CharType, Alloc>& right)
2094{
2095 return (!(left < right));
2096}
2097
2102template<class CharType, class Alloc>
2103inline bool operator>=(
2104 const BasicString<CharType, Alloc>& left,
2105 const CharType* right)
2106{
2107 return (!(left < right));
2108}
2109
2110} // end of namesapce Arp
2111
2113// standard template specializations of class BasicString<C,Alloc>
2114namespace std
2115{
2116
2120template<class C, class Alloc>
2121struct hash<Arp::BasicString<C, Alloc>>
2122{
2123private:
2124 typedef typename Arp::BasicString<C, Alloc>::BaseString BaseString;
2125
2126public:
2130 typedef size_t result_type;
2131
2132public:
2137 {
2138 return std::hash<BaseString>()(key.GetBaseString());
2139 }
2140};
2141
2143
2144} // 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:1260
SelfType & Assign(const CharType *pChars, size_type count)
This operation copies the as argument passed C-string partially.
Definition: BasicString.hxx:365
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:239
typename AllocatorTraits::pointer pointer
The pointer type of this type.
Definition: BasicString.hxx:51
const_reverse_iterator ConstReverseBegin() const
Returns the begin iterator of this const string for reverse iterating.
Definition: BasicString.hxx:937
typename BaseString::const_iterator const_iterator
The const iterator type of this type.
Definition: BasicString.hxx:54
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:1288
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:1493
SelfType & Insert(size_type offset, const SelfType &arg)
This operation inserts the the argument at the given position.
Definition: BasicString.hxx:513
typename AllocatorTraits::const_pointer const_pointer
The const pointer type of this type.
Definition: BasicString.hxx:52
typename BaseString::size_type size_type
The size type of this type.
Definition: BasicString.hxx:47
size_type FindFirstOf(const CharType *pChars, size_type offset=0) const
Finds the first occurence of any character in pChars .
Definition: BasicString.hxx:1231
BasicString(const CharType *pChars, const Allocator &alloc)
This constructor copies the as argument passed C-string.
Definition: BasicString.hxx:130
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:1569
SelfType & operator+=(const CharType *right)
This assignment operator appends the the right-hand-side operand to this string.
Definition: BasicString.hxx:290
const_reference At(size_type offset) const
Returns a const reference to the character at position offset .
Definition: BasicString.hxx:1017
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:536
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:1616
bool IsEmpty() const
Determines if this string is empty.
Definition: BasicString.hxx:1086
size_type ReverseFind(CharType c, size_type offset=NPos) const
Finds the last char which equal to c .
Definition: BasicString.hxx:1203
iterator Erase(const_iterator where)
This operation erases a char from a string.
Definition: BasicString.hxx:636
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:176
BasicString(const BaseString &arg)
This copy constructor copies the as argument passed std::string to this string.
Definition: BasicString.hxx:200
const_reverse_iterator ConstReverseEnd() const
Returns the end iterator of this const string for reverse iterating.
Definition: BasicString.hxx:944
iterator Insert(const_iterator where, const_iterator first, const_iterator last)
Inserts a range of chars [first;last) at position where .
Definition: BasicString.hxx:597
SelfType & Assign(size_type count, CharType c)
Fills this string with count consecutive copies of character c .
Definition: BasicString.hxx:382
SelfType & Assign(const SelfType &arg, size_type offset, size_type count=NPos)
This operation copies the as argument passed string partially.
Definition: BasicString.hxx:338
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:668
SelfType & operator=(CharType c)
This assignment operator copies the right-hand-side operand to this string.
Definition: BasicString.hxx:262
SelfType & Replace(size_type offset, size_type length, size_type count, CharType c)
Replaces a range of chars by a character.
Definition: BasicString.hxx:716
const_iterator ConstBegin() const
Returns the begin iterator of this const string.
Definition: BasicString.hxx:923
size_type Find(CharType c, size_type offset=0) const
Finds the first char which equal to c .
Definition: BasicString.hxx:1166
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:1755
SelfType & Replace(const_iterator first, const_iterator last, const CharType *pChars)
Replaces a range of chars [first;last).
Definition: BasicString.hxx:750
typename BaseString::const_reverse_iterator const_reverse_iterator
The const reverse iterator type of this type.
Definition: BasicString.hxx:56
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:504
size_type FindLastOf(const SelfType &chars, size_type pos=NPos) const
Finds the last occurence of any character in chars .
Definition: BasicString.hxx:1250
bool EndWith(const CharType *pChars) const
Determines if this string ends with the pChars C-string.
Definition: BasicString.hxx:1466
Allocator GetAllocator() const
Gets the allocator of this string.
Definition: BasicString.hxx:1548
SelfType & Replace(size_type offset, size_type length, const CharType *pChars)
Replaces a range of chars.
Definition: BasicString.hxx:704
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:420
void Reserve(size_type newCapacity=0)
Reserves memory upto the specified newCapacity .
Definition: BasicString.hxx:1121
SelfType Substr(size_type offset=0, size_type count=NPos) const
Gets a substring of this string.
Definition: BasicString.hxx:1541
typename BaseString::difference_type difference_type
The difference type of this type.
Definition: BasicString.hxx:48
SelfType & Erase(size_type offset=0)
This operation erases chars from this string.
Definition: BasicString.hxx:617
SelfType & Erase(size_type offset, size_type count)
This operation erases chars from this string.
Definition: BasicString.hxx:627
SelfType & Append(iterator first, iterator last)
Appends the sequence of characters in the range [first,last), in the same order.
Definition: BasicString.hxx:474
reference operator[](size_type offset)
Returns a reference to the character at position offset .
Definition: BasicString.hxx:1026
SelfType & Replace(const_iterator first, const_iterator last, std::initializer_list< CharType > chars)
Replaces a range of chars [first;last).
Definition: BasicString.hxx:657
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:1503
SelfType & Replace(const_iterator first, const_iterator last, const_iterator first2, const_iterator last2)
Replaces a range of chars [first;last).
Definition: BasicString.hxx:786
int Compare(const SelfType &other) const
Compares this string to the other string lexicographical.
Definition: BasicString.hxx:1369
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:1721
const_iterator Begin() const
Returns the begin iterator of this string.
Definition: BasicString.hxx:874
bool operator<=(const BasicString< CharType, Alloc > &left, const BasicString< CharType, Alloc > &right)
Compares the left string to the right string.
Definition: BasicString.hxx:2043
const_reverse_iterator ReverseBegin() const
Returns the begin iterator of this string for reverse iterating.
Definition: BasicString.hxx:902
bool operator>(const BasicString< CharType, Alloc > &left, const BasicString< CharType, Alloc > &right)
Compares the left string to the right string.
Definition: BasicString.hxx:2007
void PushBack(CharType c)
Appends the character c to this string.
Definition: BasicString.hxx:957
BasicString(BaseString &&arg)
This move constructor moves the as argument passed std::string to this string.
Definition: BasicString.hxx:207
void Clear()
Clears the content of this string, but does not modify the capacity.
Definition: BasicString.hxx:1127
SelfType & Assign(const CharType *pChars)
This operation copies the as argument passed C-string.
Definition: BasicString.hxx:373
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:1307
size_type MaxSize() const
Returns the number maximum size any string might have.
Definition: BasicString.hxx:1067
SelfType Trim() const
Removes left and rigth appended white-spaces from this string
Definition: BasicString.hxx:1591
int Compare(const CharType *pOther) const
Compares this string to the pOther string lexicographical.
Definition: BasicString.hxx:1411
void Swap(SelfType &other)
Swaps the content of this string with the content of the other string.
Definition: BasicString.hxx:1555
SelfType & Assign(const SelfType &arg)
This operation copies the the argument to this string.
Definition: BasicString.hxx:328
iterator Insert(const_iterator where, iterator first, iterator last)
Inserts a range of chars [first;last) at position where .
Definition: BasicString.hxx:587
SelfType & Replace(const_iterator first, const_iterator last, size_type count, CharType c)
Replaces a range of chars [first;last).
Definition: BasicString.hxx:762
iterator begin()
Returns the begin iterator of this string.
Definition: BasicString.hxx:834
BasicString(const SelfType &arg, size_type offset, size_type count=NPos)
This constructor copies the as argument passed string partially.
Definition: BasicString.hxx:88
SelfType & Append(const SelfType &arg, size_type offset, size_type count=NPos)
This operation appends the as argument passed string partially.
Definition: BasicString.hxx:439
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:867
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:220
reverse_iterator ReverseEnd()
Returns the end iterator of this string for reverse iterating.
Definition: BasicString.hxx:909
const_iterator end() const
Returns the end iterator of this string.
Definition: BasicString.hxx:858
SelfType & Assign(const BaseString &arg)
This operation copies the argument to this string.
Definition: BasicString.hxx:347
size_type Find(const SelfType &pattern, size_type offset=0) const
Finds the first substring which equal to pattern .
Definition: BasicString.hxx:1138
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:1336
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:1326
BasicString(const CharType *pChars, size_type count)
This constructor copies the as argument passed C-string.
Definition: BasicString.hxx:106
bool operator<(const BasicString< CharType, Alloc > &left, const BasicString< CharType, Alloc > &right)
Compares the left string to the right string.
Definition: BasicString.hxx:1971
size_type ReverseFind(const CharType *pChars, size_type offset=NPos) const
Finds the last substring which equal to pChars .
Definition: BasicString.hxx:1194
typename BaseString::reference reference
The reference type of this type.
Definition: BasicString.hxx:49
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:1222
SelfType & operator+=(CharType c)
This assignment operator appends the the right-hand-side operand to this string.
Definition: BasicString.hxx:299
reverse_iterator ReverseBegin()
Returns the begin iterator of this string for reverse iterating.
Definition: BasicString.hxx:895
SelfType & Append(const CharType *pChars)
This operation appends the as argument passed C-string.
Definition: BasicString.hxx:456
std::ostream & operator<<(std::ostream &os, const BasicString< CharType, Alloc > &right)
Streams the right string to the outstream os .
Definition: BasicString.hxx:1731
SelfType & Replace(size_type offset, size_type length, const CharType *pChars, size_type count)
Replaces a range of chars.
Definition: BasicString.hxx:693
SelfType & Replace(const_iterator first, const_iterator last, const CharType *pChars, size_type count)
Replaces a range of chars [first;last).
Definition: BasicString.hxx:739
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:483
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:409
int Compare(size_type offset, size_type count, const CharType *pOther) const
Compares this string to the pOther string lexicographical.
Definition: BasicString.hxx:1425
SelfType & Insert(size_type offset, size_type count, CharType c)
Inserts count consecutive copies of character c at position offset .
Definition: BasicString.hxx:557
iterator Insert(const_iterator where, CharType c)
Inserts character c at position where .
Definition: BasicString.hxx:567
reference Front()
Returns a reference to the first character in the string.
Definition: BasicString.hxx:975
BasicString(const CharType *pChars, size_type count, const Allocator &alloc)
This constructor copies the as argument passed C-string.
Definition: BasicString.hxx:115
void Resize(size_type newSize, CharType c)
Resizes this string to the specified new size.
Definition: BasicString.hxx:1109
const_reference Back() const
Returns a const reference to the last character in the string.
Definition: BasicString.hxx:999
bool operator>=(const BasicString< CharType, Alloc > &left, const BasicString< CharType, Alloc > &right)
Compares the left string to the right string.
Definition: BasicString.hxx:2079
SelfType & Append(size_type count, CharType c)
Appends to this string count consecutive copies of character c .
Definition: BasicString.hxx:465
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:1628
BasicString(std::initializer_list< CharType > arg, const Allocator &alloc=Allocator())
Copies each of the characters in initList , in the same order.
Definition: BasicString.hxx:167
typename BaseString::iterator iterator
The iterator type of this type.
Definition: BasicString.hxx:53
size_type Find(const CharType *pChars, size_type offset=0) const
Finds the first substring which equal to pChars .
Definition: BasicString.hxx:1157
SelfType & Replace(const_iterator first, const_iterator last, const_pointer first2, const_pointer last2)
Replaces a range of chars [first;last).
Definition: BasicString.hxx:798
reference At(size_type offset)
Returns a const reference to the character at position offset .
Definition: BasicString.hxx:1008
void PopBack()
Removes the character at the end of this string.
Definition: BasicString.hxx:964
BasicString(const CharType *pChars)
This constructor copies the as argument passed C-string.
Definition: BasicString.hxx:122
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:1317
const_reference operator[](size_type offset) const
Returns a const reference to the character at position offset .
Definition: BasicString.hxx:1035
std::vector< SelfType > Tokens
Used by Split() operation.
Definition: BasicString.hxx:41
iterator Insert(const_iterator where, const_pointer first, const_pointer last)
Inserts a range of chars [first;last) at position where .
Definition: BasicString.hxx:607
BasicString(const Allocator &alloc)
This constructor creates an empty string instance.
Definition: BasicString.hxx:79
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:774
SelfType & Append(const SelfType &arg)
This operation appends the the argument to this string.
Definition: BasicString.hxx:429
bool StartWith(const SelfType &pattern) const
Determines if this string starts with the pattern string.
Definition: BasicString.hxx:1458
size_type FindLastOf(const CharType *pChars, size_type pos=NPos) const
Finds the last occurence of any character in pChars .
Definition: BasicString.hxx:1269
size_type Length() const
Returns the number of char elements in this string.
Definition: BasicString.hxx:1049
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:1345
std::istream & operator>>(std::istream &is, BasicString< CharType, Alloc > &right)
Streams the instream is into the right string.
Definition: BasicString.hxx:1742
int Compare(size_type offset, size_type count, const SelfType &other) const
Compares this string to the other string lexicographical.
Definition: BasicString.hxx:1383
typename BaseString::const_reference const_reference
The const reference type of this type.
Definition: BasicString.hxx:50
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:1935
bool EndWith(const SelfType &pattern) const
Determines if this string starts with the pattern string.
Definition: BasicString.hxx:1474
const CharType * CStr() const
Gets the character data of this string.
Definition: BasicString.hxx:1518
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:1298
const_reference Front() const
Returns a const reference to the first character in the string.
Definition: BasicString.hxx:983
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:823
size_type ReverseFind(const CharType *pChars, size_type offset, size_type count) const
Finds the last substring which equal to pChars .
Definition: BasicString.hxx:1185
iterator Erase(const_iterator first, const_iterator last)
Erases a range of chars [first;last).
Definition: BasicString.hxx:645
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:185
SelfType & Replace(const_iterator first, const_iterator last, pointer first2, pointer last2)
Replaces a range of chars [first;last).
Definition: BasicString.hxx:810
Bytes ToBytes() const
Copies this string to a byte array.
Definition: BasicString.hxx:1562
SelfType & Assign(iterator first, iterator last)
Copies the sequence of characters in the range [first,last), in the same order.
Definition: BasicString.hxx:391
iterator End()
Returns the end iterator of this string.
Definition: BasicString.hxx:881
SelfType & Assign(BaseString &&arg)
This operation moves the argument to this string.
Definition: BasicString.hxx:356
const_iterator ConstEnd() const
Returns the end iterator of this const string.
Definition: BasicString.hxx:930
BasicString(const Bytes &bytes, const Allocator &alloc=Allocator())
Copies the as arguments passed bytes to this string.
Definition: BasicString.hxx:193
const BaseString & GetBaseString() const
Gets the basic std string.
Definition: BasicString.hxx:1511
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:98
SelfType & Replace(const_iterator first, const_iterator last, const SelfType &arg)
Replaces a range of chars [first;last).
Definition: BasicString.hxx:727
const_reverse_iterator ReverseEnd() const
Returns the end iterator of this string for reverse iterating.
Definition: BasicString.hxx:916
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:1664
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:319
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:492
size_type FindLastOf(CharType c, size_type pos=NPos) const
Finds the last occurence of character c .
Definition: BasicString.hxx:1279
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:681
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:525
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:1399
SelfType & operator+=(const SelfType &right)
This assignment operator appends the the right-hand-side operand to this string.
Definition: BasicString.hxx:281
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:400
BasicString(size_type count, CharType c)
Fills the string with count consecutive copies of character c .
Definition: BasicString.hxx:138
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:1355
SelfType TrimRight() const
Removes right appended white-spaces from this string
Definition: BasicString.hxx:1580
~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:228
void ShrinkToFit()
Might reduce the capacity of this string to its size.
Definition: BasicString.hxx:950
iterator end()
Returns the end iterator of this string.
Definition: BasicString.hxx:850
bool StartWith(const CharType *pChars) const
Determines if this string starts with the pChars C-string.
Definition: BasicString.hxx:1450
size_type Find(const CharType *pChars, size_type offset, size_type count) const
Finds the first substring which equal to pChars .
Definition: BasicString.hxx:1148
static const SelfType Empty
An emtpy static string instance.
Definition: BasicString.hxx:224
SelfType & Append(const CharType *pChars, size_type count)
This operation appends the as argument passed C-string partially.
Definition: BasicString.hxx:448
size_type Capacity() const
Rceturns the capacity of this string.
Definition: BasicString.hxx:1079
size_type ReverseFind(const SelfType &pattern, size_type offset=NPos) const
Finds the last substring which equal to pattern .
Definition: BasicString.hxx:1175
reference Back()
Returns a reference to the last character in the string.
Definition: BasicString.hxx:991
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:1440
size_type Size() const
Returns the number of char elements in this string.
Definition: BasicString.hxx:1061
CharType value_type
The char type of this type.
Definition: BasicString.hxx:46
size_type FindFirstOf(CharType c, size_type offset=0) const
Finds the first occurence of character c .
Definition: BasicString.hxx:1241
Allocator allocator_type
The allocator type of this type.
Definition: BasicString.hxx:45
typename BaseString::reverse_iterator reverse_iterator
The reverse iterator type of this type.
Definition: BasicString.hxx:55
SelfType & Assign(SelfType &&arg)
This operation moves the as argument passed string to this string.
Definition: BasicString.hxx:310
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:1899
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:1097
const_iterator End() const
Returns the end iterator of this string.
Definition: BasicString.hxx:888
SelfType & Insert(size_type offset, const CharType *pChars)
This operation inserts the as argument passed string.
Definition: BasicString.hxx:546
BasicString(const SelfType &arg, const Allocator &alloc)
This constructor copies the as argument passed string deeply.
Definition: BasicString.hxx:72
BasicString(size_type count, CharType c, const Allocator &alloc)
Fills the string with count consecutive copies of character c .
Definition: BasicString.hxx:147
BasicString(SelfType &&arg, const Allocator &alloc)
This move constructor moves the as argument passed string to this string.
Definition: BasicString.hxx:159
const_iterator begin() const
Returns the begin iterator of this string.
Definition: BasicString.hxx:842
std::vector< byte > Bytes
Conversion from and to byte array.
Definition: BasicString.hxx:42
size_type FindFirstOf(const SelfType &chars, size_type offset=0) const
Finds the first occurence of any character in chars .
Definition: BasicString.hxx:1212
SelfType & operator=(const CharType *right)
This assignment operator copies the right-hand-side operand to this string.
Definition: BasicString.hxx:253
iterator Insert(const_iterator where, size_type count, CharType c)
Inserts character c at position where .
Definition: BasicString.hxx:577
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:272
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:2136
size_t result_type
The result type of this functor class (stl policy type)
Definition: BasicString.hxx:2130
Arp::BasicString< C, Alloc > argument_type
The argument type of this functor class (stl policy type)
Definition: BasicString.hxx:2128