PLCnext API Documentation  20.6.0.30321
BasicString.hxx
1 //
3 // Copyright PHOENIX CONTACT Electronics GmbH
4 //
6 #pragma once
7 #include <string>
8 #include <algorithm>
9 #include <memory>
10 #include <iostream>
11 #include <initializer_list>
12 #include "boost/algorithm/string/replace.hpp"
13 #include "Arp/System/Core/BasicFormatter.hxx"
14 #include "Arp/System/Core/Impl/BasicStringFormatExceptionHandler.hpp"
15 
16 #ifndef ARP_INSIDE_ARP_H
17  #error Never include 'BasicString.hxx' directly, just include 'Arp.h'
18 #endif
19 
20 namespace Arp
21 {
22 
24 
25 template<class C, class Alloc = std::allocator<C>>
26 class BasicString
27 {
28 public: // typedefs
29  typedef Alloc Allocator;
30  typedef C CharType;
31  typedef BasicString<CharType, Allocator> SelfType;
32  typedef std::basic_string<CharType, std::char_traits<CharType>, Allocator> BaseString;
33 
34 public: // policy typedefs
35  typedef Allocator allocator_type;
36  typedef CharType value_type;
37  typedef typename BaseString::size_type size_type;
38  typedef typename BaseString::difference_type difference_type;
39  typedef typename BaseString::reference reference;
40  typedef typename BaseString::const_reference const_reference;
41  typedef typename Allocator::pointer pointer;
42  typedef typename Allocator::const_pointer const_pointer;
43  typedef typename BaseString::iterator iterator;
44  typedef typename BaseString::const_iterator const_iterator;
45  typedef typename BaseString::reverse_iterator reverse_iterator;
46  typedef typename BaseString::const_reverse_iterator const_reverse_iterator;
47 
48 private: // usings
49  using BasicFormatterType = BasicFormatter<CharType, Allocator>;
50 
51 public: // construction/destruction
52  BasicString()
53  : baseString()
54  {
55  }
56 
57  BasicString(const SelfType& arg)
58  : baseString(arg.baseString)
59  {
60  }
61 
62  BasicString(const SelfType& arg, const Allocator& alloc)
63  : baseString(arg.baseString, alloc)
64  {
65  }
66 
67  explicit BasicString(const Allocator& alloc)
68  : baseString(alloc)
69  {
70  }
71 
72  BasicString(const SelfType& arg, size_type offset, size_type count = NPos)
73  : baseString(arg.baseString, offset, count)
74  {
75  }
76 
77  BasicString(const SelfType& arg, size_type offset, size_type count, const Allocator& alloc)
78  : baseString(arg.baseString, offset, count, alloc)
79  {
80  }
81 
82  BasicString(const CharType* pChars, size_type count)
83  : baseString(pChars, count)
84  {
85  }
86 
87  BasicString(const CharType* pChars, size_type count, const Allocator& alloc)
88  : baseString(pChars, count, alloc)
89  {
90  }
91 
92  BasicString(const CharType* pChars)
93  : baseString(pChars)
94  {
95  }
96 
97  BasicString(const CharType* pChars, const Allocator& alloc)
98  : baseString(pChars, alloc)
99  {
100  }
101 
102  BasicString(size_type count, CharType c)
103  : baseString(count, c)
104  {
105  }
106 
107  BasicString(size_type count, CharType c, const Allocator& alloc)
108  : baseString(count, c, alloc)
109  {
110  }
111 
112  BasicString(SelfType&& arg)
113  : baseString(arg.baseString)
114  {
115  }
116 
117  BasicString(SelfType&& arg, const Allocator& alloc)
118  : baseString(arg.baseString, alloc)
119  {
120  }
121 
122  BasicString(std::initializer_list<CharType> initList, const Allocator& alloc = Allocator())
123  : baseString(initList, alloc)
124  {
125  }
126 
127  BasicString(iterator first, iterator last, const Allocator& alloc = Allocator())
128  : baseString(first, last, alloc)
129  {
130  }
131 
132  BasicString(const_iterator first, const_iterator last, const Allocator& alloc = Allocator())
133  : baseString(first, last, alloc)
134  {
135  }
136 
137  BasicString(const BaseString& arg)
138  : baseString(arg)
139  {
140  }
141 
142  BasicString(BaseString&& arg)
143  : baseString(arg)
144  {
145  }
146 
147  ~BasicString()
148  {
149  }
150 
151 public: // static fields
152  static const size_type NPos = size_type(-1);
153  static const SelfType Empty;
154  static const SelfType NewLine;
155 
156 public: // assignment operator
157  SelfType& operator=(SelfType&& right)
158  {
159  this->baseString = right.baseString;
160  return (*this);
161  }
162 
163  SelfType& operator=(std::initializer_list<CharType> right)
164  {
165  this->baseString = right;
166  return (*this);
167  }
168 
169  SelfType& operator=(const SelfType& right)
170  {
171  this->baseString = right.baseString;
172  return (*this);
173  }
174 
175  SelfType& operator=(const CharType* pRight)
176  {
177  this->baseString = pRight;
178  return (*this);
179  }
180 
181  SelfType& operator=(CharType c)
182  {
183  this->baseString = c;
184  return (*this);
185  }
186 
187 public: // append operator
188  SelfType& operator+=(std::initializer_list<CharType> right)
189  {
190  this->baseString += right;
191  return (*this);
192  }
193 
194  SelfType& operator+=(const SelfType& right)
195  {
196  this->baseString += right.baseString;
197  return (*this);
198  }
199 
200  SelfType& operator+=(const CharType* pRight)
201  {
202  this->baseString += pRight;
203  return (*this);
204  }
205 
206  SelfType& operator+=(CharType c)
207  {
208  this->baseString += c;
209  return (*this);
210  }
211 
212 public: // assign operations
213 
214  SelfType& Assign(SelfType&& right)
215  {
216  this->baseString.assign(right.baseString);
217  return *this;
218  }
219 
220  SelfType& Assign(std::initializer_list<CharType> initList)
221  {
222  this->baseString.assign(initList);
223  return *this;
224  }
225 
226  SelfType& Assign(const SelfType& right)
227  {
228  this->baseString.assign(right.baseString);
229  return *this;
230  }
231 
232  SelfType& Assign(const SelfType& right, size_type offset, size_type count = NPos)
233  {
234  this->baseString.assign(right.baseString, offset, count);
235  return *this;
236  }
237 
238  SelfType& Assign(const BaseString& right)
239  {
240  this->baseString.assign(right);
241  return *this;
242  }
243 
244  SelfType& Assign(BaseString&& right)
245  {
246  this->baseString.assign(right);
247  return *this;
248  }
249 
250  SelfType& Assign(const CharType* pChars, size_type count)
251  {
252  this->baseString.assign(pChars, count);
253  return *this;
254  }
255 
256  SelfType& Assign(const CharType* pChars)
257  {
258  this->baseString.assign(pChars);
259  return *this;
260  }
261 
262  SelfType& Assign(size_type count, CharType c)
263  {
264  this->baseString.assign(count, c);
265  return *this;
266  }
267 
268  SelfType& Assign(iterator first, iterator last)
269  {
270  this->baseString.assign(first, last);
271  return *this;
272  }
273 
274  SelfType& Assign(const_iterator first, const_iterator last)
275  {
276  this->baseString.assign(first, last);
277  return *this;
278  }
279 
280  SelfType& Assign(const_pointer first, const_pointer last)
281  {
282  this->baseString.assign(first, last);
283  return *this;
284  }
285 
286 public: // append operations
287 
288  SelfType& Append(std::initializer_list<CharType> initList)
289  {
290  this->baseString.append(initList);
291  return *this;
292  }
293 
294  SelfType& Append(const SelfType& right)
295  {
296  this->baseString.append(right.baseString);
297  return *this;
298  }
299 
300  SelfType& Append(const SelfType& right, size_type offset, size_type count = NPos)
301  {
302  this->baseString.append(right.baseString, offset, count);
303  return *this;
304  }
305 
306  SelfType& Append(const CharType* pChars, size_type count)
307  {
308  this->baseString.append(pChars, count);
309  return *this;
310  }
311 
312  SelfType& Append(const CharType* pChars)
313  {
314  this->baseString.append(pChars);
315  return *this;
316  }
317 
318  SelfType& Append(size_type count, CharType c)
319  {
320  this->baseString.append(count, c);
321  return *this;
322  }
323 
324  SelfType& Append(iterator first, iterator last)
325  {
326  this->baseString.append(first, last);
327  return *this;
328  }
329 
330  SelfType& Append(const_iterator first, const_iterator last)
331  {
332  this->baseString.append(first, last);
333  return *this;
334  }
335 
336  SelfType& Append(const_pointer first, const_pointer last)
337  {
338  this->baseString.append(first, last);
339  return *this;
340  }
341 
342 public: // insert operations
343 
344  iterator Insert(const_iterator where, std::initializer_list<CharType> initList)
345  {
346  return this->baseString.insert(where, initList);
347  }
348 
349  SelfType& Insert(size_type offset, const SelfType& right)
350  {
351  this->baseString.insert(offset, right.baseString);
352  return *this;
353  }
354 
355  SelfType& Insert(size_type offset, const SelfType& right, size_type rightOffset, size_type count = NPos)
356  {
357  this->baseString.insert(offset, right.baseString, rightOffset, count);
358  return *this;
359  }
360 
361  SelfType& Insert(size_type offset, const CharType* pChars, size_type count)
362  {
363  this->baseString.insert(offset, pChars, count);
364  return *this;
365  }
366 
367  SelfType& Insert(size_type offset, const CharType* pChars)
368  {
369  this->baseString.insert(offset, pChars);
370  return *this;
371  }
372 
373  SelfType& Insert(size_type offset, size_type count, CharType c)
374  {
375  this->baseString.insert(offset, count, c);
376  return *this;
377  }
378 
379  iterator Insert(const_iterator where)
380  {
381  return this->baseString.insert(where);
382  }
383 
384  iterator Insert(const_iterator where, CharType c)
385  {
386  return this->baseString.insert(where, c);
387  }
388 
389  iterator Insert(const_iterator where, size_type count, CharType c)
390  {
391  return this->baseString.insert(where, count, c);
392  }
393 
394  iterator Insert(const_iterator where, iterator first, iterator last)
395  {
396  return this->baseString.insert(where, first, last);
397  }
398 
399  iterator Insert(const_iterator where, const_iterator first, const_iterator last)
400  {
401  return this->baseString.insert(where, first, last);
402  }
403 
404  iterator Insert(const_iterator where, const_pointer first, const_pointer last)
405  {
406  return this->baseString.insert(where, first, last);
407  }
408 
409 public: // erase operations
410 
411  SelfType& Erase(size_type offset = 0)
412  {
413  this->baseString.erase(offset);
414  return (*this);
415  }
416 
417  SelfType& Erase(size_type offset, size_type count)
418  {
419  this->baseString.erase(offset, count);
420  return (*this);
421  }
422 
423  iterator Erase(const_iterator where)
424  {
425  return this->baseString.erase(where);
426  }
427 
428  iterator Erase(const_iterator first, const_iterator last)
429  {
430  return this->baseString.erase(first, last);
431  }
432 
433 public: // replace operation
434 
435  SelfType& Replace(const_iterator first, const_iterator last, std::initializer_list<CharType> initList)
436  {
437  this->baseString.replace(first, last, initList);
438  return *this;
439  }
440 
441  SelfType& Replace(size_type offset, size_type length, const SelfType& right)
442  {
443  this->baseString.replace(offset, length, right.baseString);
444  return (*this);
445  }
446 
447  SelfType& Replace(size_type offset, size_type length, const SelfType& right, size_type offsetRight, size_type count = NPos)
448  {
449  this->baseString.replace(offset, length, right.baseString, offsetRight, count);
450  return (*this);
451  }
452 
453  SelfType& Replace(size_type offset, size_type length, const CharType* pChars, size_type count)
454  {
455  this->baseString.replace(offset, length, pChars, offset, count);
456  return (*this);
457  }
458 
459  SelfType& Replace(size_type offset, size_type length, const CharType* pChars)
460  {
461  this->baseString.replace(offset, length, pChars);
462  return (*this);
463  }
464 
465  SelfType& Replace(size_type offset, size_type length, size_type count, CharType c)
466  {
467  this->baseString.replace(offset, length, count, c);
468  return (*this);
469  }
470 
471  SelfType& Replace(const_iterator first, const_iterator last, const SelfType& right)
472  {
473  this->baseString.replace(first, last, right.baseString);
474  return (*this);
475  }
476 
477  SelfType& Replace(const_iterator first, const_iterator last, const CharType* pChars, size_type count)
478  {
479  this->baseString.replace(first, last, pChars, count);
480  return (*this);
481  }
482 
483  SelfType& Replace(const_iterator first, const_iterator last, const CharType* pChars)
484  {
485  this->baseString.replace(first, last, pChars);
486  return (*this);
487  }
488 
489  SelfType& Replace(const_iterator first, const_iterator last, size_type count, CharType c)
490  {
491  this->baseString.replace(first, last, count, c);
492  return (*this);
493  }
494 
495  SelfType& Replace(const_iterator first, const_iterator last, iterator first2, iterator last2)
496  {
497  this->baseString.replace(first, last, first2, last2);
498  return (*this);
499  }
500 
501  SelfType& Replace(const_iterator first, const_iterator last, const_iterator first2, const_iterator last2)
502  {
503  this->baseString.replace(first, last, first2, last2);
504  return (*this);
505  }
506 
507  SelfType& Replace(const_iterator first, const_iterator last, const_pointer first2, const_pointer last2)
508  {
509  this->baseString.replace(first, last, first2, last2);
510  return (*this);
511  }
512 
513  SelfType& Replace(const_iterator first, const_iterator last, pointer first2, pointer last2)
514  {
515  this->baseString.replace(first, last, first2, last2);
516  return (*this);
517  }
518 
519 public: // replace_all operations
520 
521  SelfType& ReplaceAll(const SelfType& search, const SelfType& replacement)
522  {
523  boost::replace_all(this->baseString, search.baseString, replacement.baseString);
524  return (*this);
525  }
526 
527 public: // support of range base for loops
528 
529  iterator begin()
530  {
531  return this->baseString.begin();
532  }
533 
534  const_iterator begin() const
535  {
536  return this->baseString.begin();
537  }
538 
539  iterator end()
540  {
541  return this->baseString.end();
542  }
543 
544  const_iterator end() const
545  {
546  return this->baseString.end();
547  }
548 
549 
550 public: // container operations
551 
552  iterator Begin()
553  {
554  return this->baseString.begin();
555  }
556 
557  const_iterator Begin() const
558  {
559  return this->baseString.begin();
560  }
561 
562  iterator End()
563  {
564  return this->baseString.end();
565  }
566 
567  const_iterator End() const
568  {
569  return this->baseString.end();
570  }
571 
572  reverse_iterator ReverseBegin()
573  {
574  return this->baseString.rbegin();
575  }
576 
577  const_reverse_iterator ReverseBegin() const
578  {
579  return this->baseString.rbegin();
580  }
581 
582  reverse_iterator ReverseEnd()
583  {
584  return this->baseString.rend();
585  }
586 
587  const_reverse_iterator ReverseEnd() const
588  {
589  return this->baseString.rend();
590  }
591 
592  const_iterator ConstBegin() const
593  {
594  return this->baseString.cbegin();
595  }
596 
597  const_iterator ConstEnd() const
598  {
599  return this->baseString.cend();
600  }
601 
602  const_reverse_iterator ConstReverseBegin() const
603  {
604  return this->baseString.crbegin();
605  }
606 
607  const_reverse_iterator ConstReverseEnd() const
608  {
609  return this->baseString.crend();
610  }
611 
612  void ShrinkToFit()
613  {
614  this->baseString.shrink_to_fit();
615  }
616 
617  void PushBack(CharType c)
618  {
619  this->baseString.push_back(c);
620  }
621 
622  void PopBack()
623  {
624  this->baseString.pop_back();
625  }
626 
627  reference Front()
628  {
629  return this->baseString.front();
630  }
631 
632  const_reference Front() const
633  {
634  return this->baseString.front();
635  }
636 
637  reference Back()
638  {
639  return this->baseString.back();
640  }
641 
642  const_reference Back() const
643  {
644  return this->baseString.back();
645  }
646 
647  const_reference At(size_type offset) const
648  {
649  return this->baseString.at(offset);
650  }
651 
652  reference operator[](size_type offset)
653  {
654  return this->baseString[offset];
655  }
656 
657  const_reference operator[](size_type offset) const
658  {
659  return this->baseString[offset];
660  }
661 
662 public: // Size/Length operations
663 
664  size_type Length() const
665  {
666  return this->baseString.length();
667  }
668 
669  size_type Size() const
670  {
671  return this->baseString.size();
672  }
673 
674  size_type MaxSize() const
675  {
676  return this->baseString.max_size();
677  }
678 
679  size_type Capacity() const
680  {
681  return this->baseString.capacity();
682  }
683 
684  bool IsEmpty() const
685  {
686  return this->baseString.empty();
687  }
688 
689  void Resize(size_type newSize)
690  {
691  this->baseString.resize(newSize);
692  }
693 
694  void Resize(size_type newSize, CharType c)
695  {
696  this->baseString.resize(newSize, c);
697  }
698 
699  void Reserve(size_type newCapacity = 0)
700  {
701  this->baseString.reserve(newCapacity);
702  }
703 
704  void Clear()
705  {
706  this->baseString.clear();
707  }
708 
709 public: // Find operations
710 
711  size_type Find(const SelfType& right, size_type offset = 0) const
712  {
713  return this->baseString.find(right.baseString, offset);
714  }
715 
716  size_type Find(const CharType* pChars, size_type offset, size_type count) const
717  {
718  return this->baseString.find(pChars, offset, count);
719  }
720 
721  size_type Find(const CharType* pChars, size_type offset = 0) const
722  {
723  return this->baseString.find(pChars, offset);
724  }
725 
726  size_type Find(CharType c, size_type offset = 0) const
727  {
728  return this->baseString.find(c, offset);
729  }
730 
731  size_type ReverseFind(const SelfType& right, size_type offset = NPos) const
732  {
733  return this->baseString.rfind(right.baseString, offset);
734  }
735 
736  size_type ReverseFind(const CharType* pChars, size_type offset, size_type count) const
737  {
738  return this->baseString.rfind(pChars, offset, count);
739  }
740 
741  size_type ReverseFind(const CharType* pChars, size_type offset = NPos) const
742  {
743  return this->baseString.rfind(pChars, offset);
744  }
745 
746  size_type ReverseFind(CharType c, size_type offset = NPos) const
747  {
748  return this->baseString.rfind(c, offset);
749  }
750 
751  size_type FindFirstOf(const SelfType& right, size_type offset = 0) const
752  {
753  return this->baseString.find_first_of(right.baseString, offset);
754  }
755 
756  size_type FindFirstOf(const CharType* pChars, size_type offset, size_type count) const
757  {
758  return this->baseString.find_first_of(pChars, offset, count);
759  }
760 
761  size_type FindFirstOf(const CharType* pChars, size_type offset = 0) const
762  {
763  return this->baseString.find_first_of(pChars, offset);
764  }
765 
766  size_type FindFirstOf(CharType c, size_type offset = 0) const
767  {
768  return this->baseString.find_first_of(c, offset);
769  }
770 
771  size_type FindLastOf(const SelfType& right, size_type offset = NPos) const
772  {
773  return this->baseString.find_last_of(right.baseString, offset);
774  }
775 
776  size_type FindLastOf(const CharType* pChars, size_type offset, size_type count) const
777  {
778  return this->baseString.find_last_of(pChars, offset, count);
779  }
780 
781  size_type FindLastOf(const CharType* pChars, size_type offset = NPos) const
782  {
783  return this->baseString.find_last_of(pChars, offset);
784  }
785 
786  size_type FindLastOf(CharType c, size_type offset = NPos) const
787  {
788  return this->baseString.find_last_of(c, offset);
789  }
790 
791  size_type FindFirstNotOf(const SelfType& right, size_type offset = 0) const
792  {
793  return this->baseString.find_first_not_of(right.baseString, offset);
794  }
795 
796  size_type FindFirstNotOf(const CharType* pChars, size_type offset, size_type count) const
797  {
798  return this->baseString.find_first_not_of(pChars, offset, count);
799  }
800 
801  size_type FindFirstNotOf(const CharType *pChars, size_type offset = 0) const
802  {
803  return this->baseString.find_first_not_of(pChars, offset);
804  }
805 
806  size_type FindFirstNotOf(CharType c, size_type offset = 0) const
807  {
808  return this->baseString.find_first_not_of(c, offset);
809  }
810 
811  size_type FindLastNotOf(const SelfType& right, size_type offset = NPos) const
812  {
813  return this->baseString.find_last_not_of(right.baseString, offset);
814  }
815 
816  size_type FindLastNotOf(const CharType *pChars, size_type offset, size_type count) const
817  {
818  return this->baseString.find_last_not_of(pChars, offset, count);
819  }
820 
821  size_type FindLastNotOf(const CharType *pChars, size_type offset = NPos) const
822  {
823  return this->baseString.find_last_not_of(pChars, offset);
824  }
825 
826  size_type FindLastNotOf(CharType c, size_type offset = NPos) const
827  {
828  return this->baseString.find_last_not_of(c, offset);
829  }
830 
831 public: // Compare operations
832 
833  int Compare(const SelfType& right) const
834  {
835  return this->baseString.compare(right.baseString);
836  }
837 
838  int Compare(size_type offset, size_type count, const SelfType& right) const
839  {
840  return this->baseString.compare(offset, count, right.baseString);
841  }
842 
843  int Compare(size_type offset, size_type count, const SelfType& right, size_type offsetRight, size_type countRight = NPos) const
844  {
845  return this->baseString.compare(offset, count, right.baseString, offsetRight, countRight);
846  }
847 
848  int Compare(const CharType *pChars) const
849  {
850  return this->baseString.compare(pChars);
851  }
852 
853  int Compare(size_type offset, size_type count, const CharType *pChars) const
854  {
855  return this->baseString.compare(offset, count, pChars);
856  }
857 
858  int Compare(size_type offset, size_type count, const CharType *pChars, size_type countChars) const
859  {
860  return this->baseString.compare(offset, count, pChars, countChars);
861  }
862 
863 public: // misc operations
864  bool StartWith(const CharType *pChars)const
865  {
866  return this->Find(pChars) == 0;
867  }
868 
869  bool StartWith(const SelfType& pattern)const
870  {
871  return this->Find(pattern) == 0;
872  }
873 
874 public: // Format operations
875 
876  template<typename... Args>
877  static SelfType Format(const SelfType& format, const Args& ... args)
878  {
879  return Format(format.CStr(), args...);
880  }
881 
882  template<typename... Args>
883  static SelfType Format(const char* format, const Args& ... args)
884  {
885  return BasicFormatterType::FormatCommon(&BasicStringFormatExceptionHandler::Invoke, format, args...);
886  }
887 
888 public: // Misc operations
889  const BaseString& GetBaseString()const
890  {
891  return this->baseString;
892  }
893 
894  const CharType* CStr() const
895  {
896  return this->baseString.c_str();
897  }
898 
899  operator const CharType*() const
900  {
901  return this->baseString.data();
902  }
903 
904  operator const BaseString& () const
905  {
906  return this->baseString;
907  }
908 
909  SelfType Substr(size_type offset = 0, size_type count = NPos) const
910  {
911  return SelfType(this->baseString.substr(offset, count));
912  }
913 
914  Allocator GetAllocator() const
915  {
916  return this->baseString.get_allocator();
917  }
918 
919  void Swap(SelfType& right)
920  {
921  this->baseString.swap(right.baseString);
922  }
923 
924  // warning 4996 occurs, to avoid use _SCL_SECURE_NO_WARNINGS
925  //size_type Copy(CharType* pChars, size_type count, size_type offset = 0) const
926  //{
927  // return this->baseString.copy(pChars, count, offset);
928  //}
929 
930 private: // fields
931  BaseString baseString;
932 };
933 
935 // initializing of static fields
936 template <class CharType, class Alloc>
937 const BasicString<CharType, Alloc> BasicString<CharType, Alloc>::Empty;
938 
939 template <class CharType, class Alloc>
940 const BasicString<CharType, Alloc> BasicString<CharType, Alloc>::NewLine((CharType)'\n', (CharType)'\r');
941 
943 // inline global operators and functions of class BasicString<CharType, Alloc>
944 template<class CharType, class Alloc>
945 inline void swap(BasicString<CharType, Alloc>& left, BasicString<CharType, Alloc>& right)
946 {
947  left.swap(right);
948 }
949 
950 template<class CharType, class Alloc>
951 inline std::ostream& operator<<(std::ostream& os, const BasicString<CharType, Alloc>& right)
952 {
953  os << right.GetBaseString();
954  return os;
955 }
956 
957 template<class CharType, class Alloc>
958 inline std::istream& operator>>(std::istream& is, BasicString<CharType, Alloc>& right)
959 {
960  std::basic_string<CharType, std::char_traits<CharType>, Alloc> baseString;
961  is >> baseString;
962  right.Assign(baseString);
963  return is;
964 }
965 
966 template<class CharType, class Alloc>
967 inline BasicString<CharType, Alloc> operator+(
968  const BasicString<CharType, Alloc>& left,
969  const BasicString<CharType, Alloc>& right)
970 {
971  return left.GetBaseString() + right.GetBaseString();
972 }
973 
974 template<class CharType, class Alloc>
975 inline BasicString<CharType, Alloc> operator+(
976  const CharType* left,
977  const BasicString<CharType, Alloc>& right)
978 {
979  return left + right.GetBaseString();
980 }
981 
982 template<class CharType, class Alloc>
983 inline BasicString<CharType, Alloc> operator+(
984  const CharType left,
985  const BasicString<CharType, Alloc>& right)
986 {
987  return left + right.GetBaseString();
988 }
989 
990 template<class CharType, class Alloc>
991 inline BasicString<CharType, Alloc> operator+(
992  const BasicString<CharType, Alloc>& left,
993  const CharType* right)
994 {
995  return left.GetBaseString() + right;
996 }
997 
998 template<class CharType, class Alloc>
999 inline BasicString<CharType, Alloc> operator+(
1000  const BasicString<CharType, Alloc>& left,
1001  const CharType right)
1002 {
1003  return left.GetBaseString() + right;
1004 }
1005 
1006 template<class CharType, class Alloc>
1007 inline BasicString<CharType, Alloc> operator+(
1008  const BasicString<CharType, Alloc>& left,
1009  BasicString<CharType, Alloc>&& right)
1010 {
1011  return left.GetBaseString() + right.GetBaseString();
1012 }
1013 
1014 template<class CharType, class Alloc>
1015 inline BasicString<CharType, Alloc> operator+(
1016  BasicString<CharType, Alloc>&& left,
1017  const BasicString<CharType, Alloc>& right)
1018 {
1019  return (std::move(left.Append(right)));
1020 }
1021 
1022 template<class CharType, class Alloc>
1023 inline BasicString<CharType, Alloc> operator+(
1024  BasicString<CharType, Alloc>&& left,
1025  BasicString<CharType, Alloc>&& right)
1026 {
1027  return left.GetBaseString() + right.GetBaseString();
1028 }
1029 
1030 template<class CharType, class Alloc>
1031 inline BasicString<CharType, Alloc> operator+(
1032  const CharType* left,
1033  BasicString<CharType, Alloc>&& right)
1034 {
1035  return left + right.GetBaseString();
1036 }
1037 
1038 template<class CharType, class Alloc>
1039 inline BasicString<CharType, Alloc> operator+(
1040  const CharType left,
1041  BasicString<CharType, Alloc>&& right)
1042 {
1043  return left + right.GetBaseString();
1044 }
1045 
1046 template<class CharType, class Alloc>
1047 inline BasicString<CharType, Alloc> operator+(
1048  BasicString<CharType, Alloc>&& left,
1049  const CharType* right)
1050 {
1051  return left.GetBaseString() + right;
1052 }
1053 
1054 template<class CharType, class Alloc>
1055 inline BasicString<CharType, Alloc> operator+(
1056  BasicString<CharType, Alloc>&& left,
1057  const CharType right)
1058 {
1059  return left.GetBaseString() + right;
1060 }
1061 
1062 template<class CharType, class Alloc>
1063 inline bool operator==(
1064  const BasicString<CharType, Alloc>& left,
1065  const BasicString<CharType, Alloc>& right)
1066 {
1067  return left.GetBaseString() == right.GetBaseString();
1068 }
1069 
1070 template<class CharType, class Alloc>
1071 inline bool operator==(
1072  const CharType* left,
1073  const BasicString<CharType, Alloc>& right)
1074 {
1075  return left == right.GetBaseString();
1076 }
1077 
1078 template<class CharType, class Alloc>
1079 inline bool operator==(
1080  const BasicString<CharType, Alloc>& left,
1081  const CharType* right)
1082 {
1083  return left.GetBaseString() == right;
1084 }
1085 
1086 template<class CharType, class Alloc>
1087 inline bool operator!=(
1088  const BasicString<CharType, Alloc>& left,
1089  const BasicString<CharType, Alloc>& right)
1090 {
1091  return (!(left == right));
1092 }
1093 
1094 template<class CharType, class Alloc>
1095 inline bool operator!=(
1096  const CharType *left,
1097  const BasicString<CharType, Alloc>& right)
1098 {
1099  return (!(left == right));
1100 }
1101 
1102 template<class CharType, class Alloc>
1103 inline bool operator!=(
1104  const BasicString<CharType, Alloc>& left,
1105  const CharType* right)
1106 {
1107  return (!(left == right));
1108 }
1109 
1110 template<class CharType, class Alloc>
1111 inline bool operator<(
1112  const BasicString<CharType, Alloc>& left,
1113  const BasicString<CharType, Alloc>& right)
1114 {
1115  return left.GetBaseString() < right.GetBaseString();
1116 }
1117 
1118 template<class CharType, class Alloc>
1119 inline bool operator<(
1120  const CharType* left,
1121  const BasicString<CharType, Alloc>& right)
1122 {
1123  return left < right.GetBaseString();
1124 }
1125 
1126 template<class CharType, class Alloc>
1127 inline bool operator<(
1128  const BasicString<CharType, Alloc>& left,
1129  const CharType* right)
1130 {
1131  return left.GetBaseString() == right;
1132 }
1133 
1134 template<class CharType, class Alloc>
1135 inline bool operator>(
1136  const BasicString<CharType, Alloc>& left,
1137  const BasicString<CharType, Alloc>& right)
1138 {
1139  return (right < left);
1140 }
1141 
1142 template<class CharType, class Alloc>
1143 inline bool operator>(
1144  const CharType* left,
1145  const BasicString<CharType, Alloc>& right)
1146 {
1147  return (right < left);
1148 }
1149 
1150 template<class CharType, class Alloc>
1151 inline bool operator>(
1152  const BasicString<CharType, Alloc>& left,
1153  const CharType* right)
1154 {
1155  return (right < left);
1156 }
1157 
1158 template<class CharType, class Alloc>
1159 inline bool operator<=(
1160  const BasicString<CharType, Alloc>& left,
1161  const BasicString<CharType, Alloc>& right)
1162 {
1163  return (!(right < left));
1164 }
1165 
1166 template<class CharType, class Alloc>
1167 inline bool operator<=(
1168  const CharType* left,
1169  const BasicString<CharType, Alloc>& right)
1170 {
1171  return (!(right < left));
1172 }
1173 
1174 template<class CharType, class Alloc>
1175 inline bool operator<=(
1176  const BasicString<CharType, Alloc>& left,
1177  const CharType* right)
1178 {
1179  return (!(right < left));
1180 }
1181 
1182 template<class CharType, class Alloc>
1183 inline bool operator>=(
1184  const BasicString<CharType, Alloc>& left,
1185  const BasicString<CharType, Alloc>& right)
1186 {
1187  return (!(left < right));
1188 }
1189 
1190 template<class CharType, class Alloc>
1191 inline bool operator>=(
1192  const CharType* left,
1193  const BasicString<CharType, Alloc>& right)
1194 {
1195  return (!(left < right));
1196 }
1197 
1198 template<class CharType, class Alloc>
1199 inline bool operator>=(
1200  const BasicString<CharType, Alloc>& left,
1201  const CharType* right)
1202 {
1203  return (!(left < right));
1204 }
1205 
1206 } // end of namesapce Arp
1207 
1209 // standard template specializations of class BasicString<C,Alloc>
1210 namespace std
1211 {
1212 
1213 // hash functor for BasicString
1214 template<class CharType, class Alloc>
1215 struct hash<Arp::BasicString<CharType, Alloc>>
1216 {
1217 private:
1218  typedef typename Arp::BasicString<CharType, Alloc>::BaseString BaseString;
1219 
1220 public:
1222  typedef size_t result_type;
1223 
1224 public:
1225  result_type operator()(const argument_type& key) const
1226  {
1227  return std::hash<BaseString>()(key.GetBaseString());
1228  }
1229 };
1230 }
Namespace of the C++ standard library
Definition: BasicFormatter.hxx:18
Definition: BasicStringFormatExceptionHandler.hpp:15
static StringType FormatCommon(ExceptionHandler exceptionHandler, const StringType &format, const Args &... args)
Uses common CLR syntax (.Net) for the placeholders in the format string like &#39;{0}&#39;.
Definition: BasicFormatter.hxx:47
Root namespace for the PLCnext API