Embedded Template Library 1.0
Loading...
Searching...
No Matches
basic_string.h
Go to the documentation of this file.
1
2
3/******************************************************************************
4The MIT License(MIT)
5
6Embedded Template Library.
7https://github.com/ETLCPP/etl
8https://www.etlcpp.com
9
10Copyright(c) 2016 John Wellbelove
11
12Permission is hereby granted, free of charge, to any person obtaining a copy
13of this software and associated documentation files(the "Software"), to deal
14in the Software without restriction, including without limitation the rights
15to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
16copies of the Software, and to permit persons to whom the Software is
17furnished to do so, subject to the following conditions :
18
19The above copyright notice and this permission notice shall be included in all
20copies or substantial portions of the Software.
21
22THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
25AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28SOFTWARE.
29******************************************************************************/
30
31#ifndef ETL_BASIC_STRING_INCLUDED
32#define ETL_BASIC_STRING_INCLUDED
33
34#include "platform.h"
35#include "algorithm.h"
36#include "iterator.h"
37#include "functional.h"
38#include "char_traits.h"
39#include "alignment.h"
40#include "array.h"
41#include "algorithm.h"
42#include "type_traits.h"
43#include "error_handler.h"
44#include "integral_limits.h"
45#include "exception.h"
46#include "memory.h"
47#include "exception.h"
48#include "binary.h"
49#include "flags.h"
50
51#include <stddef.h>
52#include <stdint.h>
53#include <string.h>
54
55#if ETL_USING_STL && ETL_USING_CPP17
56 #include <string_view>
57#endif
58
59#include "private/minmax_push.h"
60
61//*****************************************************************************
65//*****************************************************************************
66
67// Forward declaration of string_view
68namespace etl
69{
70 template <typename T, typename TTraits>
71 class basic_string_view;
72}
73
74namespace etl
75{
76 //***************************************************************************
79 //***************************************************************************
89
90 //***************************************************************************
93 //***************************************************************************
95 {
96 public:
97
99 : string_exception(ETL_ERROR_TEXT("string:empty", ETL_BASIC_STRING_FILE_ID"A"), file_name_, line_number_)
100 {
101 }
102 };
103
104 //***************************************************************************
107 //***************************************************************************
109 {
110 public:
111
113 : string_exception(ETL_ERROR_TEXT("string:bounds", ETL_BASIC_STRING_FILE_ID"B"), file_name_, line_number_)
114 {
115 }
116 };
117
118 //***************************************************************************
121 //***************************************************************************
123 {
124 public:
125
127 : string_exception(ETL_ERROR_TEXT("string:iterator", ETL_BASIC_STRING_FILE_ID"C"), file_name_, line_number_)
128 {
129 }
130 };
131
132 //***************************************************************************
135 //***************************************************************************
137 {
138 public:
139
141 : string_exception(ETL_ERROR_TEXT("string:truncation", ETL_BASIC_STRING_FILE_ID"D"), file_name_, line_number_)
142 {
143 }
144 };
145
146 //***************************************************************************
149 //***************************************************************************
150 namespace private_basic_string
151 {
152 //*************************************************************************
153 template <typename T = void>
155 {
156 public:
157
158 typedef size_t size_type;
159
160 static ETL_CONSTANT uint_least8_t IS_TRUNCATED = etl::bit<0>::value;
161 static ETL_CONSTANT uint_least8_t CLEAR_AFTER_USE = etl::bit<1>::value;
162
163 static ETL_CONSTANT size_type npos = etl::integral_limits<size_type>::max;
164 };
165
166 template <typename T>
168
169 template <typename T>
171
172 template <typename T>
174 }
175
176 //***************************************************************************
178 {
179 public:
180
181 typedef size_t size_type;
182
183 //*************************************************************************
186 //*************************************************************************
187 size_type size() const
188 {
189 return current_size;
190 }
191
192 //*************************************************************************
195 //*************************************************************************
196 size_type length() const
197 {
198 return current_size;
199 }
200
201 //*************************************************************************
204 //*************************************************************************
205 bool empty() const
206 {
207 return (current_size == 0);
208 }
209
210 //*************************************************************************
213 //*************************************************************************
214 bool full() const
215 {
216 return current_size == CAPACITY;
217 }
218
219 //*************************************************************************
222 //*************************************************************************
223 size_type capacity() const
224 {
225 return CAPACITY;
226 }
227
228 //*************************************************************************
231 //*************************************************************************
232 size_type max_size() const
233 {
234 return CAPACITY;
235 }
236
237 //*************************************************************************
240 //*************************************************************************
241 size_type available() const
242 {
243 return max_size() - size();
244 }
245
246#if ETL_HAS_STRING_TRUNCATION_CHECKS
247 //*************************************************************************
251 //*************************************************************************
252 ETL_DEPRECATED
253 bool truncated() const
254 {
255 return flags.test<IS_TRUNCATED>();
256 }
257
258 //*************************************************************************
261 //*************************************************************************
262 bool is_truncated() const
263 {
264 return flags.test<IS_TRUNCATED>();
265 }
266
267 //*************************************************************************
269 //*************************************************************************
271 {
272 flags.set<IS_TRUNCATED, false>();
273 }
274#endif
275
276#if ETL_HAS_STRING_CLEAR_AFTER_USE
277 //*************************************************************************
279 //*************************************************************************
281 {
282 flags.set<CLEAR_AFTER_USE>();
283 }
284
285 //*************************************************************************
287 //*************************************************************************
288 bool is_secure() const
289 {
290 return flags.test<CLEAR_AFTER_USE>();
291 }
292#endif
293
294 protected:
295
296 //*************************************************************************
298 //*************************************************************************
300 : current_size(0)
302 {
303 }
304
305#if ETL_HAS_STRING_TRUNCATION_CHECKS
306 //*************************************************************************
308 //*************************************************************************
309 void set_truncated(bool status)
310 {
311 flags.set<IS_TRUNCATED>(status);
312 }
313#endif
314
315 //*************************************************************************
317 //*************************************************************************
319 {
320 }
321
322 size_type current_size;
323 const size_type CAPACITY;
324
325#if ETL_HAS_STRING_TRUNCATION_CHECKS || ETL_HAS_STRING_CLEAR_AFTER_USE
327#endif
328 };
329
330 //***************************************************************************
334 //***************************************************************************
335 template <typename T>
337 {
338 public:
339
341
342 typedef T value_type;
343 typedef T& reference;
344 typedef const T& const_reference;
345 typedef T* pointer;
346 typedef const T* const_pointer;
347 typedef T* iterator;
348 typedef const T* const_iterator;
349 typedef ETL_OR_STD::reverse_iterator<iterator> reverse_iterator;
350 typedef ETL_OR_STD::reverse_iterator<const_iterator> const_reverse_iterator;
351
352 typedef typename etl::iterator_traits<iterator>::difference_type difference_type;
353
354 //*********************************************************************
357 //*********************************************************************
359 {
360 return &p_buffer[0];
361 }
362
363 //*********************************************************************
366 //*********************************************************************
368 {
369 return &p_buffer[0];
370 }
371
372 //*********************************************************************
375 //*********************************************************************
377 {
378 return &p_buffer[current_size];
379 }
380
381 //*********************************************************************
384 //*********************************************************************
386 {
387 return &p_buffer[current_size];
388 }
389
390 //*********************************************************************
393 //*********************************************************************
395 {
396 return &p_buffer[0];
397 }
398
399 //*********************************************************************
402 //*********************************************************************
404 {
405 return &p_buffer[current_size];
406 }
407
408 //*********************************************************************
411 //*********************************************************************
412 reverse_iterator rbegin()
413 {
414 return reverse_iterator(end());
415 }
416
417 //*********************************************************************
420 //*********************************************************************
421 const_reverse_iterator rbegin() const
422 {
423 return const_reverse_iterator(end());
424 }
425
426 //*********************************************************************
429 //*********************************************************************
430 reverse_iterator rend()
431 {
432 return reverse_iterator(begin());
433 }
434
435 //*********************************************************************
438 //*********************************************************************
439 const_reverse_iterator rend() const
440 {
441 return const_reverse_iterator(begin());
442 }
443
444 //*********************************************************************
447 //*********************************************************************
448 const_reverse_iterator crbegin() const
449 {
450 return const_reverse_iterator(cend());
451 }
452
453 //*********************************************************************
456 //*********************************************************************
457 const_reverse_iterator crend() const
458 {
459 return const_reverse_iterator(cbegin());
460 }
461
462 //*********************************************************************
466 //*********************************************************************
468 {
469 resize(new_size, 0);
470 }
471
472 //*********************************************************************
476 //*********************************************************************
478 {
479 if (new_size > CAPACITY)
480 {
481#if ETL_HAS_STRING_TRUNCATION_CHECKS
482 set_truncated(true);
483
484#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
485 ETL_ASSERT_FAIL(ETL_ERROR(string_truncation));
486#endif
487#endif
488 }
489
490 new_size = etl::min(new_size, CAPACITY);
491
492 // Size up?
494 {
495 etl::fill(p_buffer + current_size, p_buffer + new_size, value);
496 }
497
499 p_buffer[new_size] = 0;
500 cleanup();
501 }
502
503 //*********************************************************************
505 //*********************************************************************
506 template <typename TOperation>
508 {
509 if (new_size > CAPACITY)
510 {
511 ETL_ASSERT_FAIL(ETL_ERROR(string_out_of_bounds));
512 }
513
514 current_size = operation(p_buffer, new_size);
515 p_buffer[current_size] = '\0';
516 cleanup();
517 }
518
519 //*********************************************************************
523 //*********************************************************************
525 {
526 new_size = etl::min(new_size, CAPACITY);
527
529 p_buffer[new_size] = 0;
530 }
531
532 //*********************************************************************
536 //*********************************************************************
537 void fill(T value)
538 {
539 etl::fill(begin(), end(), value);
540 }
541
542 //*********************************************************************
546 //*********************************************************************
548 {
549 return p_buffer[i];
550 }
551
552 //*********************************************************************
556 //*********************************************************************
558 {
559 return p_buffer[i];
560 }
561
562 //*********************************************************************
567 //*********************************************************************
569 {
570 ETL_ASSERT(i < size(), ETL_ERROR(string_out_of_bounds));
571 return p_buffer[i];
572 }
573
574 //*********************************************************************
579 //*********************************************************************
581 {
582 ETL_ASSERT(i < size(), ETL_ERROR(string_out_of_bounds));
583 return p_buffer[i];
584 }
585
586 //*********************************************************************
589 //*********************************************************************
591 {
592 return p_buffer[0];
593 }
594
595 //*********************************************************************
598 //*********************************************************************
600 {
601 return p_buffer[0];
602 }
603
604 //*********************************************************************
607 //*********************************************************************
609 {
610 return p_buffer[current_size - 1];
611 }
612
613 //*********************************************************************
616 //*********************************************************************
618 {
619 return p_buffer[current_size - 1];
620 }
621
622 //*********************************************************************
625 //*********************************************************************
627 {
628 return p_buffer;
629 }
630
631 //*********************************************************************
634 //*********************************************************************
635 ETL_CONSTEXPR const_pointer data() const
636 {
637 return p_buffer;
638 }
639
640 //*********************************************************************
643 //*********************************************************************
645 {
646 return p_buffer + current_size;
647 }
648
649 //*********************************************************************
652 //*********************************************************************
653 const_pointer data_end() const
654 {
655 return p_buffer + current_size;
656 }
657
658 //*********************************************************************
662 //*********************************************************************
664 {
665 if (&other != this)
666 {
667 assign_impl(other.begin(), other.end(), other.is_truncated(), other.is_secure());
668 }
669 }
670
671 //*********************************************************************
677 //*********************************************************************
679 {
680 if (&other != this)
681 {
682 if (sublength == npos)
683 {
684 sublength = other.size() - subposition;
685 }
686
687 ETL_ASSERT(subposition <= other.size(), ETL_ERROR(string_out_of_bounds));
688
689 assign_impl(other.begin() + subposition, other.begin() + subposition + sublength, other.is_truncated(), other.is_secure());
690 }
691 }
692
693 //*********************************************************************
699 //*********************************************************************
700 template <typename TIterator>
701 void assign(TIterator first, TIterator last)
702 {
703 assign_impl(first, last, false, false);
704 }
705
706 //*********************************************************************
710 //*********************************************************************
711 void assign(const_pointer text)
712 {
713 assign_impl(text, text + etl::strlen(text), false, false);
714 }
715
716 //*********************************************************************
721 //*********************************************************************
722 void assign(const_pointer text, size_type length_)
723 {
724 assign_impl(text, text + length_, false, false);
725 }
726
727 //*********************************************************************
729 //*********************************************************************
730 template <typename TOtherTraits>
732 {
733 assign_impl(view.begin(), view.end(), false, false);
734 }
735
736 //*********************************************************************
741 //*********************************************************************
742 void assign(size_type n, T value)
743 {
744 initialise();
745
746#if ETL_HAS_STRING_TRUNCATION_CHECKS
748
749#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
750 ETL_ASSERT(flags.test<IS_TRUNCATED>() == false, ETL_ERROR(string_truncation));
751#endif
752#endif
753
754 n = etl::min(n, CAPACITY);
755
756 etl::fill_n(begin(), n, value);
757 current_size = n;
758 p_buffer[current_size] = 0;
759 }
760
761 //*************************************************************************
763 //*************************************************************************
764 void clear()
765 {
766 initialise();
767 }
768
769 //*********************************************************************
773 //*********************************************************************
774 void push_back(T value)
775 {
776 if (current_size != CAPACITY)
777 {
778 p_buffer[current_size++] = value;
779 p_buffer[current_size] = 0;
780 }
781 else
782 {
783#if ETL_HAS_STRING_TRUNCATION_CHECKS
784 set_truncated(true);
785
786#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
787 ETL_ASSERT_FAIL(ETL_ERROR(string_truncation));
788#endif
789#endif
790 }
791 }
792
793 //*************************************************************************
796 //*************************************************************************
797 void pop_back()
798 {
799 if (current_size != 0)
800 {
801 p_buffer[--current_size] = 0;
802 }
803 }
804
805 //*********************************************************************
808 //*********************************************************************
810 {
811 insert(end(), str.begin(), str.end());
812
813#if ETL_HAS_STRING_TRUNCATION_CHECKS
814 if (str.is_truncated())
815 {
816 set_truncated(true);
817
818#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
819 ETL_ASSERT_FAIL(ETL_ERROR(string_truncation));
820#endif
821 }
822#endif
823
824 return *this;
825 }
826
827 //*********************************************************************
832 //*********************************************************************
834 {
835 ETL_ASSERT(subposition <= str.size(), ETL_ERROR(string_out_of_bounds));
836
838
839 return *this;
840 }
841
842 //*********************************************************************
845 //*********************************************************************
846 ibasic_string& append(const T* str)
847 {
848 insert(size(), str);
849 return *this;
850 }
851
852 //*********************************************************************
856 //*********************************************************************
858 {
859 insert(size(), str, n);
860 return *this;
861 }
862
863 //*********************************************************************
867 //*********************************************************************
869 {
870 insert(size(), n, c);
871 return *this;
872 }
873
874 //*********************************************************************
878 //*********************************************************************
879 template <class TIterator>
881 {
882 insert(end(), first, last);
883 return *this;
884 }
885
886 //*********************************************************************
889 //*********************************************************************
890 template <typename TOtherTraits>
892 {
893 insert(end(), view.begin(), view.end());
894 return *this;
895 }
896
897 //*********************************************************************
901 //*********************************************************************
903 {
904 // Quick hack, as iterators are pointers.
906
908 {
909 // Not full yet.
910 if (position != end())
911 {
912 // Insert in the middle.
913 ++current_size;
914 etl::copy_backward(insert_position, end() - 1, end());
915 *insert_position = value;
916 }
917 else
918 {
919 // Insert at the end.
920 *insert_position = value;
921 ++current_size;
922 }
923 }
924 else
925 {
926 // Already full.
927 if (position != end())
928 {
929 // Insert in the middle.
930 etl::copy_backward(insert_position, end() - 1, end());
931 *insert_position = value;
932 }
933
934#if ETL_HAS_STRING_TRUNCATION_CHECKS
935 set_truncated(true);
936
937#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
938 ETL_ASSERT_FAIL(ETL_ERROR(string_truncation));
939#endif
940#endif
941 }
942
943 p_buffer[current_size] = 0;
944
945 return insert_position;
946 }
947
948 //*********************************************************************
953 //*********************************************************************
955 {
956 iterator position_ = to_iterator(position);
957
958 if (n == 0)
959 {
960 return position_;
961 }
962
963 // Quick hack, as iterators are pointers.
965 const size_type start = etl::distance(cbegin(), position);
966
967 // No effect.
968 if (start >= CAPACITY)
969 {
970#if ETL_HAS_STRING_TRUNCATION_CHECKS
971 set_truncated(true);
972
973#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
974 ETL_ASSERT_FAIL(ETL_ERROR(string_truncation));
975#endif
976#endif
977 return to_iterator(position);;
978 }
979
980 // Fills the string to the end?
981 if ((start + n) >= CAPACITY)
982 {
983 if ((current_size + n) > CAPACITY)
984 {
985#if ETL_HAS_STRING_TRUNCATION_CHECKS
986 set_truncated(true);
987
988#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
989 ETL_ASSERT_FAIL(ETL_ERROR(string_truncation));
990#endif
991#endif
992 }
993
995 etl::fill(insert_position, end(), value);
996 }
997 else
998 {
999 // Lets do some shifting.
1000 const size_type shift_amount = n;
1001 const size_type to_position = start + shift_amount;
1005
1006 // Will the string truncate?
1007 if ((start + shift_amount + remaining_characters) > CAPACITY)
1008 {
1010
1011#if ETL_HAS_STRING_TRUNCATION_CHECKS
1012 set_truncated(true);
1013
1014#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
1015 ETL_ASSERT_FAIL(ETL_ERROR(string_truncation));
1016#endif
1017#endif
1018 }
1019 else
1020 {
1022 }
1023
1025 etl::fill(insert_position, insert_position + shift_amount, value);
1026 }
1027
1028 p_buffer[current_size] = 0;
1029
1030 return position_;
1031 }
1032
1033 //*********************************************************************
1039 //*********************************************************************
1040 template <typename TIterator>
1042 {
1043 iterator position_ = to_iterator(position);
1044
1045 if (first == last)
1046 {
1047 return position_;
1048 }
1049
1050 const size_type start = etl::distance(begin(), position_);
1051 const size_type n = etl::distance(first, last);
1052
1053 // No effect.
1054 if (start >= CAPACITY)
1055 {
1056#if ETL_HAS_STRING_TRUNCATION_CHECKS
1057 set_truncated(true);
1058
1059#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
1060 ETL_ASSERT_FAIL(ETL_ERROR(string_truncation));
1061#endif
1062#endif
1063 return position_;
1064 }
1065
1066 // Fills the string to the end?
1067 if ((start + n) >= CAPACITY)
1068 {
1069 if (((current_size + n) > CAPACITY))
1070 {
1071#if ETL_HAS_STRING_TRUNCATION_CHECKS
1072 set_truncated(true);
1073
1074#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
1075 ETL_ASSERT_FAIL(ETL_ERROR(string_truncation));
1076#endif
1077#endif
1078 }
1079
1081
1082 while (position_ != end())
1083 {
1084 *position_++ = *first++;
1085 }
1086 }
1087 else
1088 {
1089 // Lets do some shifting.
1090 const size_type shift_amount = n;
1091 const size_type to_position = start + shift_amount;
1095
1096 // Will the string truncate?
1097 if ((start + shift_amount + remaining_characters) > CAPACITY)
1098 {
1100
1101#if ETL_HAS_STRING_TRUNCATION_CHECKS
1102 set_truncated(true);
1103
1104#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
1105 ETL_ASSERT_FAIL(ETL_ERROR(string_truncation));
1106#endif
1107#endif
1108 }
1109 else
1110 {
1112 }
1113
1115
1116 while (first != last)
1117 {
1118 *position_++ = *first++;
1119 }
1120 }
1121
1122 p_buffer[current_size] = 0;
1123
1124 return position_;
1125 }
1126
1127 //*********************************************************************
1132 //*********************************************************************
1133 template <typename TOtherTraits>
1135 {
1136 return insert(position, view.begin(), view.end());
1137 }
1138
1139 //*********************************************************************
1143 //*********************************************************************
1145 {
1146 ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds));
1147
1148 insert(begin() + position, str.cbegin(), str.cend());
1149
1150#if ETL_HAS_STRING_TRUNCATION_CHECKS
1151 if (str.is_truncated())
1152 {
1153 set_truncated(true);
1154
1155#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
1156 ETL_ASSERT_FAIL(ETL_ERROR(string_truncation));
1157#endif
1158 }
1159#endif
1160
1161 return *this;
1162 }
1163
1164 //*********************************************************************
1168 //*********************************************************************
1169 template <typename TOtherTraits>
1171 {
1172 ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds));
1173
1174 insert(begin() + position, view.cbegin(), view.cend());
1175
1176 return *this;
1177 }
1178
1179 //*********************************************************************
1185 //*********************************************************************
1187 {
1188 ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds));
1189 ETL_ASSERT(subposition <= str.size(), ETL_ERROR(string_out_of_bounds));
1190
1191 if ((sublength == npos) || (subposition + sublength > str.size()))
1192 {
1193 sublength = str.size() - subposition;
1194 }
1195
1196 insert(begin() + position, str.cbegin() + subposition, str.cbegin() + subposition + sublength);
1197
1198#if ETL_HAS_STRING_TRUNCATION_CHECKS
1199 if (str.is_truncated())
1200 {
1201 set_truncated(true);
1202
1203#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
1204 ETL_ASSERT_FAIL(ETL_ERROR(string_truncation));
1205#endif
1206 }
1207#endif
1208
1209 return *this;
1210 }
1211
1212 //*********************************************************************
1218 //*********************************************************************
1219 template <typename TOtherTraits>
1221 {
1222 ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds));
1223 ETL_ASSERT(subposition <= view.size(), ETL_ERROR(string_out_of_bounds));
1224
1225 if ((sublength == npos) || (subposition + sublength > view.size()))
1226 {
1227 sublength = view.size() - subposition;
1228 }
1229
1230 insert(begin() + position, view.cbegin() + subposition, view.cbegin() + subposition + sublength);
1231
1232 return *this;
1233 }
1234
1235 //*********************************************************************
1239 //*********************************************************************
1240 etl::ibasic_string<T>& insert(size_type position, const_pointer s)
1241 {
1242 ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds));
1243
1244 insert(begin() + position, s, s + etl::strlen(s));
1245 return *this;
1246 }
1247
1248 //*********************************************************************
1253 //*********************************************************************
1255 {
1256 ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds));
1257
1258 insert(begin() + position, s, s + n);
1259 return *this;
1260 }
1261
1262 //*********************************************************************
1267 //*********************************************************************
1269 {
1270 ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds));
1271
1272 insert(begin() + position, n, c);
1273 return *this;
1274 }
1275
1276 //*********************************************************************
1281 //*********************************************************************
1283 {
1284 // Limit the length.
1285 length_ = etl::min(length_, size() - position);
1286
1287 erase(begin() + position, begin() + position + length_);
1288
1289 return *this;
1290 }
1291
1292 //*********************************************************************
1296 //*********************************************************************
1298 {
1299 etl::copy(i_element + 1, end(), i_element);
1300 p_buffer[--current_size] = 0;
1301
1302 return i_element;
1303 }
1304
1305 //*********************************************************************
1309 //*********************************************************************
1311 {
1313
1314 etl::copy(i_element_ + 1, end(), i_element_);
1315 p_buffer[--current_size] = 0;
1316
1317 return i_element_;
1318 }
1319
1320 //*********************************************************************
1327 //*********************************************************************
1329 {
1330 iterator first_ = to_iterator(first);
1331 iterator last_ = to_iterator(last);
1332
1333 if (first_ == last_)
1334 {
1335 return first_;
1336 }
1337
1338 etl::copy(last_, end(), first_);
1339 size_type n_delete = etl::distance(first_, last_);
1340
1342 p_buffer[current_size] = 0;
1343 cleanup();
1344
1345 return first_;
1346 }
1347
1348 //*********************************************************************
1350 //*********************************************************************
1351 const_pointer c_str() const
1352 {
1353 return p_buffer;
1354 }
1355
1356 //*********************************************************************
1361 //*********************************************************************
1363 {
1364 if (pos < size())
1365 {
1366 if (count != npos)
1367 {
1368 count = etl::min(count, size() - pos);
1369 }
1370 else
1371 {
1372 count = size() - pos;
1373 }
1374
1375 etl::copy_n(p_buffer + pos, count, dest);
1376
1377 return count;
1378 }
1379 else
1380 {
1381 return 0U;
1382 }
1383 }
1384
1385 //*********************************************************************
1389 //*********************************************************************
1391 {
1392 return find_impl(str.begin(), str.end(), str.size(), pos);
1393 }
1394
1395 //*********************************************************************
1399 //*********************************************************************
1400 template <typename TOtherTraits>
1402 {
1403 return find_impl(view.begin(), view.end(), view.size(), pos);
1404 }
1405
1406 //*********************************************************************
1410 //*********************************************************************
1411 size_type find(const_pointer s, size_type pos = 0) const
1412 {
1413 size_t sz = etl::strlen(s);
1414
1415 return find_impl(s, s + sz, sz, pos);
1416 }
1417
1418 //*********************************************************************
1423 //*********************************************************************
1424 size_type find(const_pointer s, size_type pos, size_type n) const
1425 {
1426 size_t sz = etl::strlen(s);
1427
1428 return find_impl(s, s + n, sz, pos);
1429 }
1430
1431 //*********************************************************************
1435 //*********************************************************************
1436 size_type find(T c, size_type position = 0) const
1437 {
1438 const_iterator i = etl::find(begin() + position, end(), c);
1439
1440 if (i != end())
1441 {
1442 return etl::distance(begin(), i);
1443 }
1444 else
1445 {
1446 return npos;
1447 }
1448 }
1449
1450 //*********************************************************************
1454 //*********************************************************************
1455 size_type rfind(const ibasic_string<T>& str, size_type position = npos) const
1456 {
1457 return rfind_impl(str.rbegin(), str.rend(), str.size(), position);
1458 }
1459
1460 //*********************************************************************
1464 //*********************************************************************
1465 template <typename TOtherTraits>
1467 {
1468 return rfind_impl(view.rbegin(), view.rend(), view.size(), pos);
1469 }
1470
1471 //*********************************************************************
1475 //*********************************************************************
1476 size_type rfind(const_pointer s, size_type position = npos) const
1477 {
1479
1480 const_reverse_iterator srbegin(s + len);
1481 const_reverse_iterator srend(s);
1482
1483 return rfind_impl(srbegin, srend, len, position);
1484 }
1485
1486 //*********************************************************************
1490 //*********************************************************************
1491 size_type rfind(const_pointer s, size_type position, size_type length_) const
1492 {
1493 const_reverse_iterator srbegin(s + length_);
1494 const_reverse_iterator srend(s);
1495
1496 return rfind_impl(srbegin, srend, length_, position);
1497 }
1498
1499 //*********************************************************************
1503 //*********************************************************************
1504 size_type rfind(T c, size_type position = npos) const
1505 {
1506 if (position >= size())
1507 {
1508 position = size();
1509 }
1510
1511 position = size() - position;
1512
1513 const_reverse_iterator i = etl::find(rbegin() + position, rend(), c);
1514
1515 if (i != rend())
1516 {
1517 return size() - etl::distance(rbegin(), i) - 1;
1518 }
1519 else
1520 {
1521 return npos;
1522 }
1523 }
1524
1525 //*********************************************************************
1527 //*********************************************************************
1528 bool contains(const etl::ibasic_string<T>& str) const
1529 {
1530 return find(str) != npos;
1531 }
1532
1533 //*********************************************************************
1535 //*********************************************************************
1536 template <typename TOtherTraits>
1538 {
1539 return find(view) != npos;
1540 }
1541
1542 //*********************************************************************
1544 //*********************************************************************
1545 bool contains(const_pointer s) const
1546 {
1547 return find(s) != npos;
1548 }
1549
1550 //*********************************************************************
1552 //*********************************************************************
1553 bool contains(value_type c) const
1554 {
1555 return find(c) != npos;
1556 }
1557
1558 //*********************************************************************
1560 //*********************************************************************
1561 bool starts_with(const etl::ibasic_string<T>& str) const
1562 {
1563 return compare(0, str.size(), str) == 0;
1564 }
1565
1566 //*********************************************************************
1568 //*********************************************************************
1569 template <typename TOtherTraits>
1571 {
1572 return compare(0, view.size(), view) == 0;
1573 }
1574
1575 //*********************************************************************
1577 //*********************************************************************
1578 bool starts_with(const_pointer s) const
1579 {
1580 size_t len = etl::strlen(s);
1581
1582 return compare(0, len, s, len) == 0;
1583 }
1584
1585 //*********************************************************************
1587 //*********************************************************************
1589 {
1590 return !empty() && (front() == c);
1591 }
1592
1593 //*********************************************************************
1595 //*********************************************************************
1596 bool ends_with(const etl::ibasic_string<T>& str) const
1597 {
1598 if (str.size() > size())
1599 {
1600 return false;
1601 }
1602
1603 return compare(size() - str.size(), str.size(), str) == 0;
1604 }
1605
1606 //*********************************************************************
1608 //*********************************************************************
1609 template <typename TOtherTraits>
1611 {
1612 if (view.size() > size())
1613 {
1614 return false;
1615 }
1616
1617 return compare(size() - view.size(), view.size(), view) == 0;
1618 }
1619
1620 //*********************************************************************
1622 //*********************************************************************
1623 bool ends_with(const_pointer s) const
1624 {
1625 size_t len = etl::strlen(s);
1626
1627 if (len > size())
1628 {
1629 return false;
1630 }
1631
1632 return compare(size() - len, len, s, len) == 0;
1633 }
1634
1635 //*********************************************************************
1637 //*********************************************************************
1639 {
1640 return !empty() && (back() == c);
1641 }
1642
1643 //*********************************************************************
1648 //*********************************************************************
1650 {
1651 ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds));
1652
1653 // Limit the length.
1654 length_ = etl::min(length_, size() - position);
1655
1656 // Erase the bit we want to replace.
1657 erase(position, length_);
1658
1659 // Insert the new stuff.
1660 insert(position, str);
1661
1662 return *this;
1663 }
1664
1665 //*********************************************************************
1670 //*********************************************************************
1671 template <typename TOtherTraits>
1673 {
1674 ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds));
1675
1676 // Limit the length.
1677 length_ = etl::min(length_, size() - position);
1678
1679 // Erase the bit we want to replace.
1680 erase(position, length_);
1681
1682 // Insert the new stuff.
1683 insert(position, view);
1684
1685 return *this;
1686 }
1687
1688 //*********************************************************************
1693 //*********************************************************************
1695 {
1696 // Quick hack, as iterators are pointers.
1697 iterator first_ = to_iterator(first);
1698 iterator last_ = to_iterator(last);
1699
1700 // Erase the bit we want to replace.
1701 erase(first_, last_);
1702
1703 // Insert the new stuff.
1704 insert(first_, str.begin(), str.end());
1705
1706#if ETL_HAS_STRING_TRUNCATION_CHECKS
1707 if (str.is_truncated())
1708 {
1709 set_truncated(true);
1710
1711#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
1712 ETL_ASSERT_FAIL(ETL_ERROR(string_truncation));
1713#endif
1714 }
1715#endif
1716
1717 return *this;
1718 }
1719
1720 //*********************************************************************
1725 //*********************************************************************
1726 template <typename TOtherTraits>
1728 {
1729 // Quick hack, as iterators are pointers.
1730 iterator first_ = to_iterator(first);
1731 iterator last_ = to_iterator(last);
1732
1733 // Erase the bit we want to replace.
1734 erase(first_, last_);
1735
1736 // Insert the new stuff.
1737 insert(first_, view.begin(), view.end());
1738
1739 return *this;
1740 }
1741
1742 //*********************************************************************
1744 //*********************************************************************
1746 {
1747 ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds));
1748 ETL_ASSERT(subposition <= str.size(), ETL_ERROR(string_out_of_bounds));
1749
1750 // Limit the lengths.
1751 length_ = etl::min(length_, size() - position);
1752 sublength = etl::min(sublength, str.size() - subposition);
1753
1754 // Erase the bit we want to replace.
1755 erase(position, length_);
1756
1757 // Insert the new stuff.
1758 insert(position, str, subposition, sublength);
1759
1760#if ETL_HAS_STRING_TRUNCATION_CHECKS
1761 if (str.is_truncated())
1762 {
1763 set_truncated(true);
1764
1765#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
1766 ETL_ASSERT_FAIL(ETL_ERROR(string_truncation));
1767#endif
1768 }
1769#endif
1770
1771 return *this;
1772 }
1773
1774 //*********************************************************************
1776 //*********************************************************************
1777 template <typename TOtherTraits>
1779 {
1780 ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds));
1781 ETL_ASSERT(subposition <= view.size(), ETL_ERROR(string_out_of_bounds));
1782
1783 // Limit the lengths.
1784 length_ = etl::min(length_, size() - position);
1785 sublength = etl::min(sublength, view.size() - subposition);
1786
1787 // Erase the bit we want to replace.
1788 erase(position, length_);
1789
1790 // Insert the new stuff.
1791 insert(position, view, subposition, sublength);
1792
1793 return *this;
1794 }
1795
1796 //*********************************************************************
1798 //*********************************************************************
1800 {
1801 ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds));
1802
1803 // Limit the length.
1804 length_ = etl::min(length_, size() - position);
1805
1806 // Erase the bit we want to replace.
1807 erase(position, length_);
1808
1809 // Insert the new stuff.
1810 insert(position, s, etl::strlen(s));
1811
1812 return *this;
1813 }
1814
1815 //*********************************************************************
1817 //*********************************************************************
1819 {
1820 // Quick hack, as iterators are pointers.
1821 iterator first_ = to_iterator(first);
1822 iterator last_ = to_iterator(last);
1823
1824 // Erase the bit we want to replace.
1825 erase(first_, last_);
1826
1827 // Insert the new stuff.
1828 insert(first_, s, s + etl::strlen(s));
1829
1830 return *this;
1831 }
1832
1833 //*********************************************************************
1835 //*********************************************************************
1837 {
1838 ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds));
1839
1840 // Limit the length.
1841 length_ = etl::min(length_, size() - position);
1842
1843 // Erase the bit we want to replace.
1844 erase(position, length_);
1845
1846 // Insert the new stuff.
1847 insert(position, s, n);
1848
1849 return *this;
1850 }
1851
1852 //*********************************************************************
1854 //*********************************************************************
1856 {
1857 // Quick hack, as iterators are pointers.
1858 iterator first_ = to_iterator(first);
1859 iterator last_ = to_iterator(last);
1860
1861 // Erase the bit we want to replace.
1862 erase(first_, last_);
1863
1864 // Insert the new stuff.
1865 insert(first_, s, s + n);
1866
1867 return *this;
1868 }
1869
1870 //*********************************************************************
1872 //*********************************************************************
1874 {
1875 ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds));
1876
1877 // Limit the length.
1878 length_ = etl::min(length_, size() - position);
1879
1880 // Erase the bit we want to replace.
1881 erase(position, length_);
1882
1883 // Insert the new stuff.
1884 insert(position, n, c);
1885
1886 return *this;
1887 }
1888
1889 //*********************************************************************
1891 //*********************************************************************
1893 {
1894 // Quick hack, as iterators are pointers.
1895 iterator first_ = to_iterator(first);
1896 iterator last_ = to_iterator(last);
1897
1898 // Erase the bit we want to replace.
1899 erase(first_, last_);
1900
1901 // Insert the new stuff.
1902 insert(first_, n, c);
1903
1904 return *this;
1905 }
1906
1907 //*********************************************************************
1909 //*********************************************************************
1910 template <typename TIterator>
1912 {
1913 // Quick hack, as iterators are pointers.
1914 iterator first_ = to_iterator(first);
1915 iterator last_ = to_iterator(last);
1916
1917 // Erase the bit we want to replace.
1918 erase(first_, last_);
1919
1920 // Insert the new stuff.
1922
1923 return *this;
1924 }
1925
1926 //*************************************************************************
1928 //*************************************************************************
1929 int compare(const ibasic_string& str) const
1930 {
1931 return compare(p_buffer,
1932 p_buffer + size(),
1933 str.p_buffer,
1934 str.p_buffer + str.size());
1935 }
1936
1937 //*************************************************************************
1939 //*************************************************************************
1940 template <typename TOtherTraits>
1942 {
1943 return compare(p_buffer,
1944 p_buffer + size(),
1945 view.data(),
1946 view.data() + view.size());
1947 }
1948
1949 //*************************************************************************
1951 //*************************************************************************
1952 int compare(size_type position, size_type length_, const ibasic_string& str) const
1953 {
1954 ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds));
1955
1956 // Limit the length.
1957 length_ = etl::min(length_, size() - position);
1958
1959 return compare(p_buffer + position,
1960 p_buffer + position + length_,
1961 str.p_buffer,
1962 str.p_buffer + str.size());
1963 }
1964
1965 //*************************************************************************
1967 //*************************************************************************
1968 template <typename TOtherTraits>
1970 {
1971 return compare(p_buffer + position,
1972 p_buffer + position + length_,
1973 view.data(),
1974 view.data() + view.size());
1975 }
1976
1977 //*************************************************************************
1979 //*************************************************************************
1981 {
1982 ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds));
1983 ETL_ASSERT(subposition <= str.size(), ETL_ERROR(string_out_of_bounds));
1984
1985 // Limit the lengths.
1986 length_ = etl::min(length_, size() - position);
1987 sublength = etl::min(sublength, str.size() - subposition);
1988
1989 return compare(p_buffer + position,
1990 p_buffer + position + length_,
1991 str.p_buffer + subposition,
1992 str.p_buffer + subposition + sublength);
1993 }
1994
1995 //*************************************************************************
1997 //*************************************************************************
1998 template <typename TOtherTraits>
2000 {
2001 ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds));
2002 ETL_ASSERT(subposition <= view.size(), ETL_ERROR(string_out_of_bounds));
2003
2004 // Limit the lengths.
2005 length_ = etl::min(length_, size() - position);
2006 sublength = etl::min(sublength, view.size() - subposition);
2007
2008 return compare(p_buffer + position,
2009 p_buffer + position + length_,
2010 view.data() + subposition,
2011 view.data() + subposition + sublength);
2012 }
2013
2014 //*************************************************************************
2016 //*************************************************************************
2017 int compare(const value_type* s) const
2018 {
2019 return compare(p_buffer,
2020 p_buffer + size(),
2021 s,
2022 s + etl::strlen(s));
2023 }
2024
2025 //*************************************************************************
2027 //*************************************************************************
2028 int compare(size_type position, size_type length_, const_pointer s) const
2029 {
2030 return compare(p_buffer + position,
2031 p_buffer + position + length_,
2032 s,
2033 s + etl::strlen(s));
2034 }
2035
2036 //*************************************************************************
2038 //*************************************************************************
2039 int compare(size_type position, size_type length_, const_pointer s, size_type n) const
2040 {
2041 return compare(p_buffer + position,
2042 p_buffer + position + length_,
2043 s,
2044 s + n);
2045 }
2046
2047 //*********************************************************************
2051 //*********************************************************************
2052 size_type find_first_of(const ibasic_string<T>& str, size_type position = 0) const
2053 {
2054 return find_first_of(str.c_str(), position, str.size());
2055 }
2056
2057 //*********************************************************************
2061 //*********************************************************************
2062 size_type find_first_of(const_pointer s, size_type position = 0) const
2063 {
2064 return find_first_of(s, position, etl::strlen(s));
2065 }
2066
2067 //*********************************************************************
2071 //*********************************************************************
2072 template <typename TOtherTraits>
2074 {
2075 return find_first_of(view.data(), position, view.size());
2076 }
2077
2078 //*********************************************************************
2083 //*********************************************************************
2084 size_type find_first_of(const_pointer s, size_type position, size_type n) const
2085 {
2086 if (position < size())
2087 {
2088 for (size_type i = position; i < size(); ++i)
2089 {
2090 for (size_type j = 0; j < n; ++j)
2091 {
2092 if (p_buffer[i] == s[j])
2093 {
2094 return i;
2095 }
2096 }
2097 }
2098 }
2099
2100 return npos;
2101 }
2102
2103 //*********************************************************************
2107 //*********************************************************************
2109 {
2110 if (position < size())
2111 {
2112 for (size_type i = position; i < size(); ++i)
2113 {
2114 if (p_buffer[i] == c)
2115 {
2116 return i;
2117 }
2118 }
2119 }
2120
2121 return npos;
2122 }
2123
2124 //*********************************************************************
2128 //*********************************************************************
2129 size_type find_last_of(const ibasic_string<T>& str, size_type position = npos) const
2130 {
2131 return find_last_of(str.c_str(), position, str.size());
2132 }
2133
2134 //*********************************************************************
2138 //*********************************************************************
2139 size_type find_last_of(const_pointer s, size_type position = npos) const
2140 {
2141 return find_last_of(s, position, etl::strlen(s));
2142 }
2143
2144 //*********************************************************************
2148 //*********************************************************************
2149 template <typename TOtherTraits>
2151 {
2152 return find_last_of(view.data(), position, view.size());
2153 }
2154
2155 //*********************************************************************
2160 //*********************************************************************
2161 size_type find_last_of(const_pointer s, size_type position, size_type n) const
2162 {
2163 if (empty())
2164 {
2165 return npos;
2166 }
2167
2168 position = etl::min(position, size() - 1);
2169
2170 const_reverse_iterator it = rbegin() + size() - position - 1;
2171
2172 while (it != rend())
2173 {
2174 for (size_type j = 0; j < n; ++j)
2175 {
2176 if (p_buffer[position] == s[j])
2177 {
2178 return position;
2179 }
2180 }
2181
2182 ++it;
2183 --position;
2184 }
2185
2186 return npos;
2187 }
2188
2189 //*********************************************************************
2193 //*********************************************************************
2195 {
2196 if (empty())
2197 {
2198 return npos;
2199 }
2200
2201 position = etl::min(position, size() - 1);
2202
2203 const_reverse_iterator it = rbegin() + size() - position - 1;
2204
2205 while (it != rend())
2206 {
2207 if (p_buffer[position] == c)
2208 {
2209 return position;
2210 }
2211
2212 ++it;
2213 --position;
2214 }
2215
2216 return npos;
2217 }
2218
2219 //*********************************************************************
2223 //*********************************************************************
2225 {
2226 return find_first_not_of(str.c_str(), position, str.size());
2227 }
2228
2229 //*********************************************************************
2233 //*********************************************************************
2234 size_type find_first_not_of(const_pointer s, size_type position = 0) const
2235 {
2236 return find_first_not_of(s, position, etl::strlen(s));
2237 }
2238
2239 //*********************************************************************
2243 //*********************************************************************
2244 template <typename TOtherTraits>
2246 {
2247 return find_first_not_of(view.data(), position, view.size());
2248 }
2249
2250 //*********************************************************************
2255 //*********************************************************************
2256 size_type find_first_not_of(const_pointer s, size_type position, size_type n) const
2257 {
2258 if (position < size())
2259 {
2260 for (size_type i = position; i < size(); ++i)
2261 {
2262 bool found = false;
2263
2264 for (size_type j = 0; j < n; ++j)
2265 {
2266 if (p_buffer[i] == s[j])
2267 {
2268 found = true;
2269 }
2270 }
2271
2272 if (!found)
2273 {
2274 return i;
2275 }
2276 }
2277 }
2278
2279 return npos;
2280 }
2281
2282 //*********************************************************************
2286 //*********************************************************************
2288 {
2289 if (position < size())
2290 {
2291 for (size_type i = position; i < size(); ++i)
2292 {
2293 if (*(p_buffer + i) != c)
2294 {
2295 return i;
2296 }
2297 }
2298 }
2299
2300 return npos;
2301 }
2302
2303 //*********************************************************************
2307 //*********************************************************************
2308 size_type find_last_not_of(const ibasic_string<T>& str, size_type position = npos) const
2309 {
2310 return find_last_not_of(str.c_str(), position, str.size());
2311 }
2312
2313 //*********************************************************************
2317 //*********************************************************************
2318 size_type find_last_not_of(const_pointer s, size_type position = npos) const
2319 {
2320 return find_last_not_of(s, position, etl::strlen(s));
2321 }
2322
2323 //*********************************************************************
2327 //*********************************************************************
2328 template <typename TOtherTraits>
2330 {
2331 return find_last_not_of(view.data(), position, view.size());
2332 }
2333
2334 //*********************************************************************
2339 //*********************************************************************
2340 size_type find_last_not_of(const_pointer s, size_type position, size_type n) const
2341 {
2342 if (empty())
2343 {
2344 return npos;
2345 }
2346
2347 position = etl::min(position, size() - 1);
2348
2349 const_reverse_iterator it = rbegin() + size() - position - 1;
2350
2351 while (it != rend())
2352 {
2353 bool found = false;
2354
2355 for (size_type j = 0; j < n; ++j)
2356 {
2357 if (p_buffer[position] == s[j])
2358 {
2359 found = true;
2360 }
2361 }
2362
2363 if (!found)
2364 {
2365 return position;
2366 }
2367
2368 ++it;
2369 --position;
2370 }
2371
2372 return npos;
2373 }
2374
2375 //*********************************************************************
2376 //
2377 //*********************************************************************
2378 size_type find_last_not_of(value_type c, size_type position = npos) const
2379 {
2380 if (empty())
2381 {
2382 return npos;
2383 }
2384
2385 position = etl::min(position, size() - 1);
2386
2387 const_reverse_iterator it = rbegin() + size() - position - 1;
2388
2389 while (it != rend())
2390 {
2391 if (p_buffer[position] != c)
2392 {
2393 return position;
2394 }
2395
2396 ++it;
2397 --position;
2398 }
2399
2400 return npos;
2401 }
2402
2403 //*************************************************************************
2405 //*************************************************************************
2407 {
2408 if (&rhs != this)
2409 {
2410 assign(rhs);
2411 }
2412
2413 return *this;
2414 }
2415
2416 //*************************************************************************
2418 //*************************************************************************
2420 {
2421 assign(rhs);
2422
2423 return *this;
2424 }
2425
2426 //*************************************************************************
2428 //*************************************************************************
2429 template <typename TOtherTraits>
2431 {
2432 assign(view);
2433
2434 return *this;
2435 }
2436
2437 //*************************************************************************
2439 //*************************************************************************
2441 {
2442 append(rhs);
2443
2444 return *this;
2445 }
2446
2447 //*************************************************************************
2449 //*************************************************************************
2450 template <typename TOtherTraits>
2452 {
2453 append(rhs);
2454
2455 return *this;
2456 }
2457
2458 //*************************************************************************
2460 //*************************************************************************
2462 {
2463 append(rhs);
2464
2465 return *this;
2466 }
2467
2468 //*************************************************************************
2470 //*************************************************************************
2472 {
2473 append(size_type(1), rhs);
2474
2475 return *this;
2476 }
2477
2478#if ETL_HAS_ISTRING_REPAIR
2479 //*************************************************************************
2481 //*************************************************************************
2482 virtual void repair() = 0;
2483#endif
2484
2485 //*********************************************************************
2487 //*********************************************************************
2489 {
2490#if ETL_HAS_STRING_TRUNCATION_CHECKS
2491 set_truncated(false);
2492#endif
2493 etl::fill(&p_buffer[current_size], &p_buffer[CAPACITY + 1U], T(0));
2494 }
2495
2496 //*********************************************************************
2500 //*********************************************************************
2502 {
2503#if ETL_HAS_STRING_TRUNCATION_CHECKS
2504 set_truncated(p_buffer[CAPACITY] != T(0));
2505#endif
2506
2507 p_buffer[CAPACITY] = T(0); // Ensure a terminating null.
2508 current_size = etl::strlen(p_buffer);
2509 }
2510
2511 protected:
2512
2513 //*********************************************************************
2515 //*********************************************************************
2518 p_buffer(p_buffer_)
2519 {
2520 }
2521
2522 //*********************************************************************
2524 //*********************************************************************
2526 {
2527 current_size = 0U;
2528 cleanup();
2529 p_buffer[0] = 0;
2530#if ETL_HAS_STRING_TRUNCATION_CHECKS
2531 set_truncated(false);
2532#endif
2533 }
2534
2535 //*************************************************************************
2537 //*************************************************************************
2539 {
2540 p_buffer = p_buffer_;
2541 }
2542
2543 private:
2544
2545 //*************************************************************************
2547 //*************************************************************************
2548 int compare(const_pointer first1, const_pointer last1, const_pointer first2, const_pointer last2) const
2549 {
2550 while ((first1 != last1) && (first2 != last2))
2551 {
2552 if (*first1 < *first2)
2553 {
2554 // Compared character is lower.
2555 return -1;
2556 }
2557 else if (*first1 > *first2)
2558 {
2559 // Compared character is higher.
2560 return 1;
2561 }
2562
2563 ++first1;
2564 ++first2;
2565 }
2566
2567 // We reached the end of one or both of the strings.
2568 if ((first1 == last1) && (first2 == last2))
2569 {
2570 // Same length.
2571 return 0;
2572 }
2573 else if (first1 == last1)
2574 {
2575 // Compared string is shorter.
2576 return -1;
2577 }
2578 else
2579 {
2580 // Compared string is longer.
2581 return 1;
2582 }
2583 }
2584
2585 //*************************************************************************
2587 //*************************************************************************
2588 void cleanup()
2589 {
2590#if ETL_HAS_STRING_CLEAR_AFTER_USE
2591 if (is_secure())
2592 {
2593 etl::memory_clear_range(&p_buffer[current_size], &p_buffer[CAPACITY]);
2594 }
2595#endif
2596 }
2597
2598 //*************************************************************************
2600 //*************************************************************************
2601 ibasic_string(const ibasic_string&);
2602
2603 //*************************************************************************
2605 //*************************************************************************
2606 T* p_buffer;
2607
2608 //*************************************************************************
2610 //*************************************************************************
2611#if defined(ETL_POLYMORPHIC_STRINGS) || defined(ETL_POLYMORPHIC_CONTAINERS) || defined(ETL_ISTRING_REPAIR_ENABLE)
2612 public:
2613 virtual
2614#else
2615 protected:
2616#endif
2618 {
2619#if ETL_HAS_STRING_CLEAR_AFTER_USE
2620 if (is_secure())
2621 {
2622 initialise();
2623 }
2624#endif
2625 }
2626
2627 protected:
2628
2629 //*************************************************************************
2631 //*************************************************************************
2633 {
2634 return const_cast<iterator>(itr);
2635 }
2636
2637 private:
2638
2639 //*********************************************************************
2641 //*********************************************************************
2642 template <typename TIterator>
2643 void assign_impl(TIterator first, TIterator last, bool truncated, bool secure)
2644 {
2645#if ETL_IS_DEBUG_BUILD
2646 difference_type d = etl::distance(first, last);
2647 ETL_ASSERT(d >= 0, ETL_ERROR(string_iterator));
2648#endif
2649
2650 initialise();
2651
2652 while ((first != last) && (current_size != CAPACITY))
2653 {
2654 p_buffer[current_size++] = *first++;
2655 }
2656
2657 p_buffer[current_size] = 0;
2658
2659#if ETL_HAS_STRING_TRUNCATION_CHECKS
2660 set_truncated((first != last) || truncated);
2661
2662#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
2663 ETL_ASSERT(flags.test<IS_TRUNCATED>() == false, ETL_ERROR(string_truncation));
2664#endif
2665#endif
2666
2667#if ETL_HAS_STRING_CLEAR_AFTER_USE
2668 if (secure)
2669 {
2670 set_secure();
2671 }
2672#endif
2673
2674 cleanup();
2675 }
2676
2677 //*************************************************************************
2679 //*************************************************************************
2680 template <typename TIterator>
2681 size_type find_impl(TIterator first, TIterator last, size_type sz, size_type pos = 0) const
2682 {
2683 if ((pos + sz) > size())
2684 {
2685 return npos;
2686 }
2687
2688 const_iterator iposition = etl::search(begin() + pos, end(), first, last);
2689
2690 if (iposition == end())
2691 {
2692 return npos;
2693 }
2694 else
2695 {
2696 return etl::distance(begin(), iposition);
2697 }
2698 }
2699
2700 //*************************************************************************
2702 //*************************************************************************
2703 template <typename TIterator>
2704 size_type rfind_impl(TIterator rfirst, TIterator rlast, size_type sz, size_type pos = 0) const
2705 {
2706 if (sz > size())
2707 {
2708 return npos;
2709 }
2710
2711 if (pos >= size())
2712 {
2713 pos = size();
2714 }
2715
2716 pos = size() - pos;
2717
2718 const_reverse_iterator iposition = etl::search(rbegin() + pos, rend(), rfirst, rlast);
2719
2720 if (iposition == rend())
2721 {
2722 return npos;
2723 }
2724 else
2725 {
2726 return size() - sz - etl::distance(rbegin(), iposition);
2727 }
2728 }
2729 };
2730
2731 //***************************************************************************
2737 //***************************************************************************
2738 template <typename T>
2740 {
2741 return (lhs.size() == rhs.size()) && etl::equal(lhs.begin(), lhs.end(), rhs.begin());
2742 }
2743
2744 //***************************************************************************
2750 //***************************************************************************
2751 template <typename T>
2753 {
2754 return (lhs.size() == etl::strlen(rhs)) && etl::equal(lhs.begin(), lhs.end(), rhs);
2755 }
2756
2757 //***************************************************************************
2763 //***************************************************************************
2764 template <typename T>
2766 {
2767 return (rhs.size() == etl::strlen(lhs)) && etl::equal(rhs.begin(), rhs.end(), lhs);
2768 }
2769
2770 //***************************************************************************
2776 //***************************************************************************
2777 template <typename T>
2779 {
2780 return !(lhs == rhs);
2781 }
2782
2783 //***************************************************************************
2789 //***************************************************************************
2790 template <typename T>
2792 {
2793 return !(lhs == rhs);
2794 }
2795
2796 //***************************************************************************
2802 //***************************************************************************
2803 template <typename T>
2805 {
2806 return !(lhs == rhs);
2807 }
2808
2809 //***************************************************************************
2815 //***************************************************************************
2816 template <typename T>
2818 {
2819 return etl::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
2820 }
2821
2822 //***************************************************************************
2828 //***************************************************************************
2829 template <typename T>
2831 {
2832 return etl::lexicographical_compare(lhs.begin(), lhs.end(), rhs, rhs + etl::strlen(rhs));
2833 }
2834
2835 //***************************************************************************
2841 //***************************************************************************
2842 template <typename T>
2844 {
2845 return etl::lexicographical_compare(lhs, lhs + etl::strlen(lhs), rhs.begin(), rhs.end());
2846 }
2847
2848
2849 //***************************************************************************
2855 //***************************************************************************
2856 template <typename T>
2858 {
2859 return (rhs < lhs);
2860 }
2861
2862 //***************************************************************************
2868 //***************************************************************************
2869 template <typename T>
2871 {
2872 return (rhs < lhs);
2873 }
2874
2875 //***************************************************************************
2881 //***************************************************************************
2882 template <typename T>
2884 {
2885 return (rhs < lhs);
2886 }
2887
2888
2889 //***************************************************************************
2895 //***************************************************************************
2896 template <typename T>
2898 {
2899 return !(lhs > rhs);
2900 }
2901
2902 //***************************************************************************
2908 //***************************************************************************
2909 template <typename T>
2911 {
2912 return !(lhs > rhs);
2913 }
2914
2915 //***************************************************************************
2921 //***************************************************************************
2922 template <typename T>
2924 {
2925 return !(lhs > rhs);
2926 }
2927
2928
2929 //***************************************************************************
2935 //***************************************************************************
2936 template <typename T>
2938 {
2939 return !(lhs < rhs);
2940 }
2941
2942 //***************************************************************************
2948 //***************************************************************************
2949 template <typename T>
2951 {
2952 return !(lhs < rhs);
2953 }
2954
2955 //***************************************************************************
2961 //***************************************************************************
2962 template <typename T>
2964 {
2965 return !(lhs < rhs);
2966 }
2967}
2968
2969#include "private/minmax_pop.h"
2970
2971#endif
Definition flags.h:53
ETL_CONSTEXPR14 flags< T, MASK > & set() ETL_NOEXCEPT
Set the bits.
Definition flags.h:102
ETL_CONSTEXPR bool test() const ETL_NOEXCEPT
Tests bits.
Definition flags.h:87
Definition basic_string.h:337
int compare(size_type position, size_type length_, const ibasic_string &str) const
Compare position / length with string.
Definition basic_string.h:1952
ibasic_string & append(TIterator first, TIterator last)
Definition basic_string.h:880
size_type find_last_of(const_pointer s, size_type position=npos) const
Definition basic_string.h:2139
size_type rfind(const_pointer s, size_type position=npos) const
Definition basic_string.h:1476
ibasic_string & replace(const_iterator first, const_iterator last, const etl::basic_string_view< T, TOtherTraits > &view)
Definition basic_string.h:1727
etl::ibasic_string< T > & insert(size_type position, const etl::ibasic_string< T > &str)
Definition basic_string.h:1144
ibasic_string & append(const T *str)
Definition basic_string.h:846
size_type find_last_not_of(const_pointer s, size_type position=npos) const
Definition basic_string.h:2318
size_type find(const_pointer s, size_type pos=0) const
Definition basic_string.h:1411
ibasic_string & operator=(const ibasic_string &rhs)
Assignment operator.
Definition basic_string.h:2406
ibasic_string & append(const ibasic_string &str, size_type subposition, size_type sublength=npos)
Definition basic_string.h:833
const_reverse_iterator rbegin() const
Definition basic_string.h:421
bool contains(const etl::ibasic_string< T > &str) const
Checks that the string is within this string.
Definition basic_string.h:1528
reference operator[](size_type i)
Definition basic_string.h:547
void assign(const etl::ibasic_string< T > &other, size_type subposition, size_type sublength)
Definition basic_string.h:678
etl::ibasic_string< T > & insert(size_type position, const etl::basic_string_view< T, TOtherTraits > &view, size_type subposition, size_type sublength)
Definition basic_string.h:1220
pointer data_end()
Definition basic_string.h:644
iterator erase(const_iterator first, const_iterator last)
Definition basic_string.h:1328
iterator insert(const_iterator position, TIterator first, TIterator last)
Definition basic_string.h:1041
bool contains(value_type c) const
Checks that character is within this string.
Definition basic_string.h:1553
size_type find_last_of(const ibasic_string< T > &str, size_type position=npos) const
Definition basic_string.h:2129
size_type find_first_of(value_type c, size_type position=0) const
Definition basic_string.h:2108
bool starts_with(const etl::ibasic_string< T > &str) const
Checks that the string is the start of this string.
Definition basic_string.h:1561
size_type find(T c, size_type position=0) const
Definition basic_string.h:1436
ibasic_string & replace(size_type position, size_type length_, const etl::basic_string_view< T, TOtherTraits > &view, size_type subposition, size_type sublength)
Replace characters from 'position' of 'length' with 'view' from 'subposition' of 'sublength'.
Definition basic_string.h:1778
bool ends_with(value_type c) const
Checks that the character is the end of this string.
Definition basic_string.h:1638
void pop_back()
Definition basic_string.h:797
size_type rfind(const ibasic_string< T > &str, size_type position=npos) const
Definition basic_string.h:1455
bool contains(const_pointer s) const
Checks that text is within this string.
Definition basic_string.h:1545
etl::ibasic_string< T > & insert(size_type position, const etl::basic_string_view< T, TOtherTraits > &view)
Definition basic_string.h:1170
void resize_and_overwrite(size_type new_size, TOperation operation)
Resizes the string and overwrites to data using the operation.
Definition basic_string.h:507
void initialize_free_space()
Clears the free space to string terminator value.
Definition basic_string.h:2488
ibasic_string & replace(size_type position, size_type length_, const_pointer s, size_type n)
Replace characters from 'position' of 'length' with 'n' characters from pointed to string.
Definition basic_string.h:1836
iterator to_iterator(const_iterator itr) const
Convert from const_iterator to iterator.
Definition basic_string.h:2632
ibasic_string & replace(size_type position, size_type length_, size_type n, value_type c)
Replace characters from 'position' of 'length' with 'n' copies of 'c'.
Definition basic_string.h:1873
ibasic_string & replace(const_iterator first, const_iterator last, const ibasic_string &str)
Definition basic_string.h:1694
size_type find_first_of(const ibasic_string< T > &str, size_type position=0) const
Definition basic_string.h:2052
size_type find_first_of(const etl::basic_string_view< T, TOtherTraits > &view, size_type position=0) const
Definition basic_string.h:2073
const_reference back() const
Definition basic_string.h:617
const_iterator begin() const
Definition basic_string.h:367
size_type find_last_of(const_pointer s, size_type position, size_type n) const
Definition basic_string.h:2161
bool ends_with(const etl::basic_string_view< T, TOtherTraits > &view) const
Checks that the view is the end of this string.
Definition basic_string.h:1610
reverse_iterator rbegin()
Definition basic_string.h:412
ibasic_string & replace(const_iterator first, const_iterator last, TIterator first_replace, TIterator last_replace)
Replace characters from 'first' of 'last' with characters from 'first_replace' to 'last_replace'.
Definition basic_string.h:1911
void resize(size_type new_size)
Definition basic_string.h:467
size_type find_last_not_of(const_pointer s, size_type position, size_type n) const
Definition basic_string.h:2340
ibasic_string & replace(size_type position, size_type length_, const etl::basic_string_view< T, TOtherTraits > &view)
Definition basic_string.h:1672
size_type find_first_not_of(const_pointer s, size_type position=0) const
Definition basic_string.h:2234
size_type rfind(T c, size_type position=npos) const
Definition basic_string.h:1504
etl::ibasic_string< T > & erase(size_type position, size_type length_=npos)
Definition basic_string.h:1282
int compare(const value_type *s) const
Compare with C string.
Definition basic_string.h:2017
int compare(size_type position, size_type length_, const_pointer s) const
Compare position / length with C string.
Definition basic_string.h:2028
iterator insert(const_iterator position, size_type n, T value)
Definition basic_string.h:954
ibasic_string & append(const etl::basic_string_view< T, TOtherTraits > &view)
Definition basic_string.h:891
const_reference at(size_type i) const
Definition basic_string.h:580
void assign(const etl::basic_string_view< T, TOtherTraits > &view)
Assigns values to the string from a view.
Definition basic_string.h:731
void clear()
Clears the string.
Definition basic_string.h:764
int compare(size_type position, size_type length_, const ibasic_string &str, size_type subposition, size_type sublength) const
Compare position / length with string / subposition / sublength.
Definition basic_string.h:1980
reverse_iterator rend()
Definition basic_string.h:430
size_type find_last_of(const etl::basic_string_view< T, TOtherTraits > &view, size_type position=npos) const
Definition basic_string.h:2150
iterator erase(iterator i_element)
Definition basic_string.h:1297
const_reverse_iterator crend() const
Definition basic_string.h:457
bool contains(const etl::basic_string_view< T, TOtherTraits > &view) const
Checks that the view is within this string.
Definition basic_string.h:1537
reference at(size_type i)
Definition basic_string.h:568
size_type rfind(const etl::basic_string_view< T, TOtherTraits > &view, size_type pos=0) const
Definition basic_string.h:1466
bool starts_with(value_type c) const
Checks that the character is the start of this string.
Definition basic_string.h:1588
int compare(const etl::basic_string_view< T, TOtherTraits > &view) const
Compare with etl::basic_string_view.
Definition basic_string.h:1941
~ibasic_string()
Destructor.
Definition basic_string.h:2617
ibasic_string & replace(const_iterator first, const_iterator last, const_pointer s)
Replace characters from 'first' 'last' with pointed to string.
Definition basic_string.h:1818
size_type find(const_pointer s, size_type pos, size_type n) const
Definition basic_string.h:1424
size_type find_first_of(const_pointer s, size_type position=0) const
Definition basic_string.h:2062
ibasic_string & replace(size_type position, size_type length_, const ibasic_string &str, size_type subposition, size_type sublength)
Replace characters from 'position' of 'length' with 'str' from 'subposition' of 'sublength'.
Definition basic_string.h:1745
iterator begin()
Definition basic_string.h:358
iterator end()
Definition basic_string.h:376
ibasic_string & replace(const_iterator first, const_iterator last, size_type n, value_type c)
Replace characters from 'first' of 'last' with 'n' copies of 'c'.
Definition basic_string.h:1892
ibasic_string & replace(const_iterator first, const_iterator last, const_pointer s, size_type n)
Replace characters from 'first' to 'last' with 'n' characters from pointed to string.
Definition basic_string.h:1855
void assign(TIterator first, TIterator last)
Definition basic_string.h:701
etl::ibasic_string< T > & insert(size_type position, const etl::ibasic_string< T > &str, size_type subposition, size_type sublength)
Definition basic_string.h:1186
size_type find(const ibasic_string< T > &str, size_type pos=0) const
Definition basic_string.h:1390
void push_back(T value)
Definition basic_string.h:774
size_type find_first_not_of(const_pointer s, size_type position, size_type n) const
Definition basic_string.h:2256
void assign(size_type n, T value)
Definition basic_string.h:742
const_reverse_iterator crbegin() const
Definition basic_string.h:448
iterator insert(const_iterator position, T value)
Definition basic_string.h:902
etl::ibasic_string< T > & insert(size_type position, const_pointer s, size_type n)
Definition basic_string.h:1254
ibasic_string & replace(size_type position, size_type length_, const ibasic_string &str)
Definition basic_string.h:1649
ibasic_string(T *p_buffer_, size_type MAX_SIZE_)
Constructor.
Definition basic_string.h:2516
bool ends_with(const_pointer s) const
Checks that the string is the end of this string.
Definition basic_string.h:1623
etl::ibasic_string< T > & insert(size_type position, size_type n, value_type c)
Definition basic_string.h:1268
const_reverse_iterator rend() const
Definition basic_string.h:439
size_type find_last_not_of(const ibasic_string< T > &str, size_type position=npos) const
Definition basic_string.h:2308
size_type find(const etl::basic_string_view< T, TOtherTraits > &view, size_type pos=0) const
Definition basic_string.h:1401
const_pointer data_end() const
Definition basic_string.h:653
void assign(const etl::ibasic_string< T > &other)
Definition basic_string.h:663
const_iterator cend() const
Definition basic_string.h:403
const_pointer c_str() const
Return a pointer to a C string.
Definition basic_string.h:1351
void resize(size_type new_size, T value)
Definition basic_string.h:477
ETL_CONSTEXPR const_pointer data() const
Definition basic_string.h:635
const_reference front() const
Definition basic_string.h:599
pointer data()
Definition basic_string.h:626
size_type find_first_not_of(value_type c, size_type position=0) const
Definition basic_string.h:2287
ibasic_string & append(size_type n, T c)
Definition basic_string.h:868
void assign(const_pointer text, size_type length_)
Definition basic_string.h:722
size_type find_first_not_of(const ibasic_string< T > &str, size_type position=0) const
Definition basic_string.h:2224
size_type find_last_of(value_type c, size_type position=npos) const
Definition basic_string.h:2194
size_type copy(pointer dest, size_type count, size_type pos=0) const
Definition basic_string.h:1362
ibasic_string & append(const ibasic_string &str)
Definition basic_string.h:809
size_type find_last_not_of(const etl::basic_string_view< T, TOtherTraits > &view, size_type position=npos) const
Definition basic_string.h:2329
ibasic_string & replace(size_type position, size_type length_, const_pointer s)
Replace characters from 'position' of 'length' with pointed to string.
Definition basic_string.h:1799
reference front()
Definition basic_string.h:590
reference back()
Definition basic_string.h:608
bool starts_with(const_pointer s) const
Checks that the string is the start of this string.
Definition basic_string.h:1578
const_iterator cbegin() const
Definition basic_string.h:394
size_type find_first_not_of(const etl::basic_string_view< T, TOtherTraits > &view, size_type position=0) const
Definition basic_string.h:2245
int compare(size_type position, size_type length_, const etl::basic_string_view< T, TOtherTraits > &view, size_type subposition, size_type sublength) const
Compare position / length with etl::basic_string_view. / subposition / sublength.
Definition basic_string.h:1999
void initialise()
Initialise the string.
Definition basic_string.h:2525
bool starts_with(const etl::basic_string_view< T, TOtherTraits > &view) const
Checks that the view is the start of this string.
Definition basic_string.h:1570
ibasic_string & operator+=(const ibasic_string &rhs)
+= operator.
Definition basic_string.h:2440
void trim_to_terminator()
Definition basic_string.h:2501
void uninitialized_resize(size_type new_size)
Definition basic_string.h:524
ibasic_string & append(const T *str, size_type n)
Definition basic_string.h:857
int compare(size_type position, size_type length_, const_pointer s, size_type n) const
Compare position / length with C string / n.
Definition basic_string.h:2039
size_type rfind(const_pointer s, size_type position, size_type length_) const
Definition basic_string.h:1491
bool ends_with(const etl::ibasic_string< T > &str) const
Checks that the string is the end of this string.
Definition basic_string.h:1596
size_type find_first_of(const_pointer s, size_type position, size_type n) const
Definition basic_string.h:2084
int compare(const ibasic_string &str) const
Compare with string.
Definition basic_string.h:1929
const_iterator end() const
Definition basic_string.h:385
iterator erase(const_iterator i_element)
Definition basic_string.h:1310
int compare(size_type position, size_type length_, const etl::basic_string_view< T, TOtherTraits > &view) const
Compare position / length with etl::basic_string_view.
Definition basic_string.h:1969
void assign(const_pointer text)
Definition basic_string.h:711
etl::ibasic_string< T > & insert(size_type position, const_pointer s)
Definition basic_string.h:1240
void fill(T value)
Definition basic_string.h:537
void repair_buffer(T *p_buffer_)
Fix the internal pointers after a low level memory copy.
Definition basic_string.h:2538
iterator insert(const_iterator position, const etl::basic_string_view< T, TOtherTraits > &view)
Definition basic_string.h:1134
Definition basic_string.h:178
void set_secure()
Sets the 'secure' flag to the requested state.
Definition basic_string.h:280
bool is_secure() const
Gets the 'secure' state flag.
Definition basic_string.h:288
const size_type CAPACITY
The maximum number of elements in the string.
Definition basic_string.h:323
bool full() const
Definition basic_string.h:214
~string_base()
Destructor.
Definition basic_string.h:318
ETL_DEPRECATED bool truncated() const
Definition basic_string.h:253
void set_truncated(bool status)
Sets the 'truncated' flag.
Definition basic_string.h:309
size_type max_size() const
Definition basic_string.h:232
string_base(size_type max_size_)
Constructor.
Definition basic_string.h:299
void clear_truncated()
Clears the 'truncated' flag.
Definition basic_string.h:270
size_type length() const
Definition basic_string.h:196
size_type current_size
The current number of elements in the string.
Definition basic_string.h:322
size_type available() const
Definition basic_string.h:241
bool empty() const
Definition basic_string.h:205
size_type capacity() const
Definition basic_string.h:223
bool is_truncated() const
Definition basic_string.h:262
size_type size() const
Definition basic_string.h:187
Definition basic_string.h:95
Definition basic_string.h:81
Definition basic_string.h:123
Definition basic_string.h:109
Definition basic_string.h:137
Definition binary.h:353
#define ETL_ASSERT(b, e)
Definition error_handler.h:356
Definition exception.h:47
Definition integral_limits.h:516
bitset_ext
Definition absolute.h:38
bool operator>(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:693
bool operator>=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:705
bool operator!=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:654
ETL_CONSTEXPR14 size_t strlen(const T *t)
Alternative strlen for all character types.
Definition char_traits.h:285
bool operator==(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:642
bool operator<(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:666
bool operator<=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:681
Definition compare.h:51
pair holds two objects of arbitrary type
Definition utility.h:164