Embedded Template Library 1.0
Loading...
Searching...
No Matches
string_view.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) 2017 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_STRING_VIEW_INCLUDED
32#define ETL_STRING_VIEW_INCLUDED
33
34#include "platform.h"
35#include "memory.h"
36#include "iterator.h"
37#include "error_handler.h"
38#include "exception.h"
39#include "char_traits.h"
40#include "integral_limits.h"
41#include "hash.h"
42#include "basic_string.h"
43#include "algorithm.h"
44#include "private/minmax_push.h"
45
46#if ETL_USING_STL && ETL_USING_CPP17
47 #include <string_view>
48#endif
49
50#include <stdint.h>
51
52namespace etl
53{
54 //***************************************************************************
56 //***************************************************************************
66
67 //***************************************************************************
70 //***************************************************************************
72 {
73 public:
74
76 : string_view_exception(ETL_ERROR_TEXT("basic_string_view:bounds", ETL_STRING_VIEW_FILE_ID"A"), file_name_, line_number_)
77 {
78 }
79 };
80
81 //***************************************************************************
84 //***************************************************************************
86 {
87 public:
88
90 : string_view_exception(ETL_ERROR_TEXT("basic_string_view:uninitialised", ETL_STRING_VIEW_FILE_ID"B"), file_name_, line_number_)
91 {
92 }
93 };
94
95 //***************************************************************************
97 //***************************************************************************
98 template <typename T, typename TTraits = etl::char_traits<T> >
100 {
101 public:
102
103 typedef T value_type;
104 typedef TTraits traits_type;
105 typedef size_t size_type;
106 typedef const T& const_reference;
107 typedef const T* const_pointer;
108 typedef const T* const_iterator;
109 typedef ETL_OR_STD::reverse_iterator<const_iterator> const_reverse_iterator;
110
111 enum
112 {
114 };
115
116 //*************************************************************************
118 //*************************************************************************
119 ETL_CONSTEXPR basic_string_view() ETL_NOEXCEPT
120 : mbegin(ETL_NULLPTR)
121 , mend(ETL_NULLPTR)
122 {
123 }
124
125 //*************************************************************************
127 //*************************************************************************
128 ETL_CONSTEXPR basic_string_view(const etl::ibasic_string<T>& str)
129 : mbegin(str.begin())
130 , mend(str.end())
131 {
132 }
133
134 //*************************************************************************
136 //*************************************************************************
137 ETL_CONSTEXPR14 ETL_EXPLICIT_STRING_FROM_CHAR basic_string_view(const T* begin_)
138 : mbegin(begin_)
139 , mend(begin_ + TTraits::length(begin_))
140 {
141 }
142
143 //*************************************************************************
145 //*************************************************************************
146 ETL_CONSTEXPR basic_string_view(const T* begin_, const T* end_)
147 : mbegin(begin_)
148 , mend(end_)
149 {
150 }
151
152 //*************************************************************************
154 //*************************************************************************
155 ETL_CONSTEXPR basic_string_view(const T* begin_, size_t size_)
156 : mbegin(begin_)
157 , mend(begin_ + size_)
158 {
159 }
160
161 //*************************************************************************
163 //*************************************************************************
164 ETL_CONSTEXPR basic_string_view(const basic_string_view& other) ETL_NOEXCEPT
165 : mbegin(other.mbegin)
166 , mend(other.mend)
167 {
168 }
169
170 //*************************************************************************
172 //*************************************************************************
173 ETL_CONSTEXPR const_reference front() const
174 {
175 return *mbegin;
176 }
177
178 //*************************************************************************
180 //*************************************************************************
181 ETL_CONSTEXPR const_reference back() const
182 {
183 return *(mend - 1);
184 }
185
186 //*************************************************************************
188 //*************************************************************************
189 ETL_CONSTEXPR const_pointer data() const
190 {
191 return mbegin;
192 }
193
194 //*************************************************************************
196 //*************************************************************************
197 ETL_CONSTEXPR const_iterator begin() const
198 {
199 return mbegin;
200 }
201
202 //*************************************************************************
204 //*************************************************************************
205 ETL_CONSTEXPR const_iterator cbegin() const
206 {
207 return mbegin;
208 }
209
210 //*************************************************************************
212 //*************************************************************************
213 ETL_CONSTEXPR const_iterator end() const
214 {
215 return mend;
216 }
217
218 //*************************************************************************
219 // Returns a const iterator to the end of the array.
220 //*************************************************************************
221 ETL_CONSTEXPR const_iterator cend() const
222 {
223 return mend;
224 }
225
226 //*************************************************************************
228 //*************************************************************************
229 ETL_CONSTEXPR const_reverse_iterator rbegin() const
230 {
231 return const_reverse_iterator(mend);
232 }
233
234 //*************************************************************************
236 //*************************************************************************
237 ETL_CONSTEXPR const_reverse_iterator crbegin() const
238 {
239 return const_reverse_iterator(mend);
240 }
241
242 //*************************************************************************
244 //*************************************************************************
245 ETL_CONSTEXPR const_reverse_iterator rend() const
246 {
247 return const_reverse_iterator(mbegin);
248 }
249
250 //*************************************************************************
252 //*************************************************************************
253 ETL_CONSTEXPR const_reverse_iterator crend() const
254 {
255 return const_reverse_iterator(mbegin);
256 }
257
258 //*************************************************************************
259 // Capacity
260 //*************************************************************************
261
262 //*************************************************************************
264 //*************************************************************************
265 ETL_CONSTEXPR bool empty() const
266 {
267 return (mbegin == mend);
268 }
269
270 //*************************************************************************
272 //*************************************************************************
273 ETL_CONSTEXPR size_t size() const
274 {
275 return static_cast<size_t>(mend - mbegin);
276 }
277
278 //*************************************************************************
280 //*************************************************************************
281 ETL_CONSTEXPR size_t length() const
282 {
283 return size();
284 }
285
286 //*************************************************************************
288 //*************************************************************************
289 ETL_CONSTEXPR size_t max_size() const
290 {
291 return size();
292 }
293
294 //*************************************************************************
296 //*************************************************************************
298 {
299 mbegin = other.mbegin;
300 mend = other.mend;
301 return *this;
302 }
303
304 //*************************************************************************
306 //*************************************************************************
308 {
309 mbegin = begin_;
310 mend = end_;
311 }
312
313 //*************************************************************************
315 //*************************************************************************
316 ETL_CONSTEXPR14 void assign(const_pointer begin_, size_t size_)
317 {
318 mbegin = begin_;
319 mend = begin_ + size_;
320 }
321
322 //*************************************************************************
324 //*************************************************************************
325 ETL_CONSTEXPR const_reference operator[](size_t i) const
326 {
327 return mbegin[i];
328 }
329
330 //*************************************************************************
332 //*************************************************************************
333 const_reference at(size_t i) const
334 {
335 ETL_ASSERT((mbegin != ETL_NULLPTR && mend != ETL_NULLPTR), ETL_ERROR(string_view_uninitialised));
336 ETL_ASSERT(i < size(), ETL_ERROR(string_view_bounds));
337 return mbegin[i];
338 }
339
340 //*************************************************************************
342 //*************************************************************************
343 ETL_CONSTEXPR14 void swap(basic_string_view& other) ETL_NOEXCEPT
344 {
345 using ETL_OR_STD::swap; // Allow ADL
346
347 swap(mbegin, other.mbegin);
348 swap(mend, other.mend);
349 }
350
351 //*************************************************************************
353 //*************************************************************************
354 ETL_CONSTEXPR14 size_type copy(T* destination, size_type count, size_type position = 0) const
355 {
356 size_t n = 0UL;
357
358 if (position < size())
359 {
360 n = etl::min(count, size() - position);
361
362 etl::copy(mbegin + position, mbegin + position + n, destination);
363 }
364
365 return n;
366 }
367
368 //*************************************************************************
370 //*************************************************************************
371 ETL_CONSTEXPR14 basic_string_view substr(size_type position = 0, size_type count = npos) const
372 {
374
375 if (position < size())
376 {
377 size_t n = etl::min(count, size() - position);
378
379 view = basic_string_view(mbegin + position, mbegin + position + n);
380 }
381
382 return view;
383 }
384
385 //*************************************************************************
387 //*************************************************************************
388 ETL_CONSTEXPR14 void remove_prefix(size_type n)
389 {
390 mbegin += n;
391 }
392
393 //*************************************************************************
395 //*************************************************************************
396 ETL_CONSTEXPR14 void remove_suffix(size_type n)
397 {
398 mend -= n;
399 }
400
401 //*************************************************************************
403 //*************************************************************************
404 ETL_CONSTEXPR14 int compare(basic_string_view<T, TTraits> view) const
405 {
406 return (*this == view) ? 0 : ((*this > view) ? 1 : -1);
407 }
408
409 ETL_CONSTEXPR14 int compare(size_type position, size_type count, basic_string_view view) const
410 {
411 return substr(position, count).compare(view);
412 }
413
414 ETL_CONSTEXPR14 int compare(size_type position1, size_type count1,
416 size_type position2, size_type count2) const
417 {
418 return substr(position1, count1).compare(view.substr(position2, count2));
419 }
420
421 ETL_CONSTEXPR14 int compare(const T* text) const
422 {
423 const T* view_itr = mbegin;
424 const T* text_itr = text;
425
426 while (view_itr != mend && *text_itr != T(0))
427 {
428 if (*view_itr < *text_itr)
429 {
430 return -1;
431 }
432 else if (*view_itr > *text_itr)
433 {
434 return 1;
435 }
436 ++view_itr;
437 ++text_itr;
438 }
439
440 if ((view_itr == mend) && (*text_itr == T(0)))
441 {
442 return 0;
443 }
444 else if (view_itr == mend)
445 {
446 return -1;
447 }
448 else
449 {
450 return 1;
451 }
452 }
453
454 ETL_CONSTEXPR14 int compare(size_type position, size_type count, const T* text) const
455 {
456 return substr(position, count).compare(text);
457 }
458
459 ETL_CONSTEXPR14 int compare(size_type position, size_type count1, const T* text, size_type count2) const
460 {
461 return substr(position, count1).compare(etl::basic_string_view<T, TTraits>(text, count2));
462 }
463
464 //*************************************************************************
466 //*************************************************************************
468 {
469 return (size() >= view.size()) &&
470 (compare(0, view.size(), view) == 0);
471 }
472
473 ETL_CONSTEXPR14 bool starts_with(T c) const
474 {
475 return !empty() && (front() == c);
476 }
477
478 ETL_CONSTEXPR14 bool starts_with(const T* text) const
479 {
480 size_t lengthtext = TTraits::length(text);
481
482 return (size() >= lengthtext) &&
483 (compare(0, lengthtext, text) == 0);
484 }
485
486 //*************************************************************************
488 //*************************************************************************
490 {
491 return (size() >= view.size()) &&
492 (compare(size() - view.size(), npos, view) == 0);
493 }
494
495 ETL_CONSTEXPR14 bool ends_with(T c) const
496 {
497 return !empty() && (back() == c);
498 }
499
500 ETL_CONSTEXPR14 bool ends_with(const T* text) const
501 {
502 size_t lengthtext = TTraits::length(text);
503 size_t lengthview = size();
504
505 return (lengthview >= lengthtext) &&
506 (compare(lengthview - lengthtext, lengthtext, text) == 0);
507 }
508
509 //*************************************************************************
511 //*************************************************************************
513 {
514 if ((size() < view.size()))
515 {
516 return npos;
517 }
518
519 const_iterator iposition = etl::search(begin() + position, end(), view.begin(), view.end());
520
521 if (iposition == end())
522 {
523 return npos;
524 }
525 else
526 {
527 return etl::distance(begin(), iposition);
528 }
529 }
530
531 ETL_CONSTEXPR14 size_type find(T c, size_type position = 0) const
532 {
533 return find(etl::basic_string_view<T, TTraits>(&c, 1), position);
534 }
535
536 ETL_CONSTEXPR14 size_type find(const T* text, size_type position, size_type count) const
537 {
538 return find(etl::basic_string_view<T, TTraits>(text, count), position);
539 }
540
541 ETL_CONSTEXPR14 size_type find(const T* text, size_type position = 0) const
542 {
543 return find(etl::basic_string_view<T, TTraits>(text), position);
544 }
545
546 //*************************************************************************
548 //*************************************************************************
549 ETL_CONSTEXPR14 size_type rfind(etl::basic_string_view<T, TTraits> view, size_type position = npos) const
550 {
551 if ((size() < view.size()))
552 {
553 return npos;
554 }
555
556 position = etl::min(position, size());
557
558 const_iterator iposition = etl::find_end(begin(),
559 begin() + position,
560 view.begin(),
561 view.end());
562
563 if (iposition == end())
564 {
565 return npos;
566 }
567 else
568 {
569 return etl::distance(begin(), iposition);
570 }
571 }
572
573 ETL_CONSTEXPR14 size_type rfind(T c, size_type position = npos) const
574 {
575 return rfind(etl::basic_string_view<T, TTraits>(&c, 1), position);
576 }
577
578 ETL_CONSTEXPR14 size_type rfind(const T* text, size_type position, size_type count) const
579 {
580 return rfind(etl::basic_string_view<T, TTraits>(text, count), position);
581 }
582
583 ETL_CONSTEXPR14 size_type rfind(const T* text, size_type position = npos) const
584 {
585 return rfind(etl::basic_string_view<T, TTraits>(text), position);
586 }
587
588 //*************************************************************************
590 //*************************************************************************
592 {
593 const size_t lengthtext = size();
594
595 if (position < lengthtext)
596 {
597 for (size_t i = position; i < lengthtext; ++i)
598 {
599 const size_t lengthview = view.size();
600
601 for (size_t j = 0UL; j < lengthview; ++j)
602 {
603 if (mbegin[i] == view[j])
604 {
605 return i;
606 }
607 }
608 }
609 }
610
611 return npos;
612 }
613
614 ETL_CONSTEXPR14 size_type find_first_of(T c, size_type position = 0) const
615 {
617 }
618
619 ETL_CONSTEXPR14 size_type find_first_of(const T* text, size_type position, size_type count) const
620 {
621 return find_first_of(etl::basic_string_view<T, TTraits>(text, count), position);
622 }
623
624 ETL_CONSTEXPR14 size_type find_first_of(const T* text, size_type position = 0) const
625 {
627 }
628
629 //*************************************************************************
631 //*************************************************************************
633 {
634 if (empty())
635 {
636 return npos;
637 }
638
639 position = etl::min(position, size() - 1);
640
641 const_reverse_iterator it = rbegin() + size() - position - 1;
642
643 while (it != rend())
644 {
645 const size_t viewlength = view.size();
646
647 for (size_t j = 0UL; j < viewlength; ++j)
648 {
649 if (mbegin[position] == view[j])
650 {
651 return position;
652 }
653 }
654
655 ++it;
656 --position;
657 }
658
659 return npos;
660 }
661
662 ETL_CONSTEXPR14 size_type find_last_of(T c, size_type position = npos) const
663 {
665 }
666
667 ETL_CONSTEXPR14 size_type find_last_of(const T* text, size_type position, size_type count) const
668 {
669 return find_last_of(etl::basic_string_view<T, TTraits>(text, count), position);
670 }
671
672 ETL_CONSTEXPR14 size_type find_last_of(const T* text, size_type position = npos) const
673 {
674 return find_last_of(etl::basic_string_view<T, TTraits>(text), position);
675 }
676
677 //*************************************************************************
679 //*************************************************************************
681 {
682 const size_t lengthtext = size();
683
684 if (position < lengthtext)
685 {
686 for (size_t i = position; i < lengthtext; ++i)
687 {
688 bool found = false;
689
690 const size_t viewlength = view.size();
691
692 for (size_t j = 0UL; j < viewlength; ++j)
693 {
694 if (mbegin[i] == view[j])
695 {
696 found = true;
697 break;
698 }
699 }
700
701 if (!found)
702 {
703 return i;
704 }
705 }
706 }
707
708 return npos;
709 }
710
711 ETL_CONSTEXPR14 size_type find_first_not_of(T c, size_type position = 0) const
712 {
714 }
715
716 ETL_CONSTEXPR14 size_type find_first_not_of(const T* text, size_type position, size_type count) const
717 {
718 return find_first_not_of(etl::basic_string_view<T, TTraits>(text, count), position);
719 }
720
721 ETL_CONSTEXPR14 size_type find_first_not_of(const T* text, size_type position = 0) const
722 {
724 }
725
726 //*************************************************************************
728 //*************************************************************************
730 {
731 if (empty())
732 {
733 return npos;
734 }
735
736 position = etl::min(position, size() - 1);
737
738 const_reverse_iterator it = rbegin() + size() - position - 1;
739
740 while (it != rend())
741 {
742 bool found = false;
743
744 const size_t viewlength = view.size();
745
746 for (size_t j = 0UL; j < viewlength; ++j)
747 {
748 if (mbegin[position] == view[j])
749 {
750 found = true;
751 break;
752 }
753 }
754
755 if (!found)
756 {
757 return position;
758 }
759
760 ++it;
761 --position;
762 }
763
764 return npos;
765 }
766
767 ETL_CONSTEXPR14 size_type find_last_not_of(T c, size_type position = npos) const
768 {
770 }
771
772 ETL_CONSTEXPR14 size_type find_last_not_of(const T* text, size_type position, size_type count) const
773 {
774 return find_last_not_of(etl::basic_string_view<T, TTraits>(text, count), position);
775 }
776
777 ETL_CONSTEXPR14 size_type find_last_not_of(const T* text, size_type position = npos) const
778 {
780 }
781
782 //*********************************************************************
784 //*********************************************************************
786 {
787 return find(view) != npos;
788 }
789
790 //*********************************************************************
792 //*********************************************************************
794 {
795 return find(s) != npos;
796 }
797
798 //*********************************************************************
800 //*********************************************************************
801 bool contains(value_type c) const
802 {
803 return find(c) != npos;
804 }
805
806 //*************************************************************************
808 //*************************************************************************
810 {
811 return (lhs.size() == rhs.size()) &&
812 etl::equal(lhs.begin(), lhs.end(), rhs.begin());
813 }
814
815 //*************************************************************************
817 //*************************************************************************
819 {
820 return !(lhs == rhs);
821 }
822
823 //*************************************************************************
825 //*************************************************************************
827 {
828 return etl::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
829 }
830
831 //*************************************************************************
833 //*************************************************************************
835 {
836 return rhs < lhs;
837 }
838
839 //*************************************************************************
841 //*************************************************************************
843 {
844 return !(lhs > rhs);
845 }
846
847 //*************************************************************************
849 //*************************************************************************
851 {
852 return !(lhs < rhs);
853 }
854
855 private:
856
857 const_pointer mbegin;
858 const_pointer mend;
859 };
860
861 typedef etl::basic_string_view<char> string_view;
862 typedef etl::basic_string_view<wchar_t> wstring_view;
863 typedef etl::basic_string_view<char8_t> u8string_view;
864 typedef etl::basic_string_view<char16_t> u16string_view;
865 typedef etl::basic_string_view<char32_t> u32string_view;
866
867 //*************************************************************************
869 //*************************************************************************
870 template<size_t Array_Size>
871 ETL_CONSTEXPR14 string_view make_string_view(const char(&text)[Array_Size])
872 {
873 size_t length = etl::char_traits<char>::length(text, Array_Size - 1U);
874
875 return string_view(text, length);
876 }
877
878 //***********************************
879 template<size_t Array_Size>
880 ETL_CONSTEXPR14 wstring_view make_string_view(const wchar_t(&text)[Array_Size])
881 {
882 size_t length = etl::char_traits<wchar_t>::length(text, Array_Size - 1U);
883
884 return wstring_view(text, length);
885 }
886
887 //***********************************
888 template<size_t Array_Size>
889 ETL_CONSTEXPR14 u8string_view make_string_view(const char8_t(&text)[Array_Size])
890 {
891 size_t length = etl::char_traits<char8_t>::length(text, Array_Size - 1U);
892
893 return u8string_view(text, length);
894 }
895
896 //***********************************
897 template<size_t Array_Size>
898 ETL_CONSTEXPR14 u16string_view make_string_view(const char16_t(&text)[Array_Size])
899 {
900 size_t length = etl::char_traits<char16_t>::length(text, Array_Size - 1U);
901
902 return u16string_view(text, length);
903 }
904
905 //***********************************
906 template<size_t Array_Size>
907 ETL_CONSTEXPR14 u32string_view make_string_view(const char32_t(&text)[Array_Size])
908 {
909 size_t length = etl::char_traits<char32_t>::length(text, Array_Size - 1U);
910
911 return u32string_view(text, length);
912 }
913
914 //*************************************************************************
916 //*************************************************************************
917#if ETL_USING_8BIT_TYPES
918 template <>
919 struct hash<etl::string_view>
920 {
921 size_t operator()(const etl::string_view& text) const
922 {
923 return etl::private_hash::generic_hash<size_t>(reinterpret_cast<const uint8_t*>(text.data()),
924 reinterpret_cast<const uint8_t*>(text.data() + text.size()));
925 }
926 };
927
928 template <>
929 struct hash<etl::wstring_view>
930 {
931 size_t operator()(const etl::wstring_view& text) const
932 {
933 return etl::private_hash::generic_hash<size_t>(reinterpret_cast<const uint8_t*>(text.data()),
934 reinterpret_cast<const uint8_t*>(text.data() + text.size()));
935 }
936 };
937
938 template <>
939 struct hash<etl::u16string_view>
940 {
941 size_t operator()(const etl::u16string_view& text) const
942 {
943 return etl::private_hash::generic_hash<size_t>(reinterpret_cast<const uint8_t*>(text.data()),
944 reinterpret_cast<const uint8_t*>(text.data() + text.size()));
945 }
946 };
947
948 template <>
949 struct hash<etl::u32string_view>
950 {
951 size_t operator()(const etl::u32string_view& text) const
952 {
953 return etl::private_hash::generic_hash<size_t>(reinterpret_cast<const uint8_t*>(text.data()),
954 reinterpret_cast<const uint8_t*>(text.data() + text.size()));
955 }
956 };
957#endif
958}
959
960//*************************************************************************
962//*************************************************************************
963template <typename T, typename TTraits >
965{
966 lhs.swap(rhs);
967}
968
969template <typename T>
971{
972 lhs.swap(rhs);
973}
974
975#include "private/minmax_pop.h"
976
977#endif
978
String view.
Definition string_view.h:100
ETL_CONSTEXPR14 int compare(basic_string_view< T, TTraits > view) const
Compares two views.
Definition string_view.h:404
ETL_CONSTEXPR14 void assign(const_pointer begin_, size_t size_)
Assign from iterator and size.
Definition string_view.h:316
ETL_CONSTEXPR basic_string_view() ETL_NOEXCEPT
Default constructor.
Definition string_view.h:119
ETL_CONSTEXPR14 bool ends_with(etl::basic_string_view< T, TTraits > view) const
Checks if the string view ends with the given suffix.
Definition string_view.h:489
ETL_CONSTEXPR14 size_type copy(T *destination, size_type count, size_type position=0) const
Copies characters.
Definition string_view.h:354
ETL_CONSTEXPR basic_string_view(const basic_string_view &other) ETL_NOEXCEPT
Copy constructor.
Definition string_view.h:164
friend ETL_CONSTEXPR14 bool operator<=(const etl::basic_string_view< T, TTraits > &lhs, const etl::basic_string_view< T, TTraits > &rhs)
Less-than-equal for string_view.
Definition string_view.h:842
ETL_CONSTEXPR const_reverse_iterator rend() const
Returns a const reverse iterator to the end of the array.
Definition string_view.h:245
ETL_CONSTEXPR const_reverse_iterator crbegin() const
Returns a const reverse iterator to the reverse beginning of the array.
Definition string_view.h:237
ETL_CONSTEXPR const_reverse_iterator crend() const
Returns a const reverse iterator to the end of the array.
Definition string_view.h:253
ETL_CONSTEXPR size_t max_size() const
Returns the maximum possible size of the array.
Definition string_view.h:289
ETL_CONSTEXPR14 void remove_suffix(size_type n)
Shrinks the view by moving its end backward.
Definition string_view.h:396
ETL_CONSTEXPR basic_string_view(const etl::ibasic_string< T > &str)
Construct from string.
Definition string_view.h:128
friend ETL_CONSTEXPR14 bool operator>=(const etl::basic_string_view< T, TTraits > &lhs, const etl::basic_string_view< T, TTraits > &rhs)
Greater-than-equal for string_view.
Definition string_view.h:850
ETL_CONSTEXPR14 bool starts_with(etl::basic_string_view< T, TTraits > view) const
Checks if the string view starts with the given prefix.
Definition string_view.h:467
ETL_CONSTEXPR basic_string_view(const T *begin_, const T *end_)
Construct from pointer range.
Definition string_view.h:146
bool contains(value_type c) const
Checks that character is within this string.
Definition string_view.h:801
ETL_CONSTEXPR14 size_type find_last_of(etl::basic_string_view< T, TTraits > view, size_type position=npos) const
Find last occurrence of characters.
Definition string_view.h:632
ETL_CONSTEXPR const_iterator begin() const
Returns a const iterator to the beginning of the array.
Definition string_view.h:197
friend ETL_CONSTEXPR14 bool operator!=(const etl::basic_string_view< T, TTraits > &lhs, const etl::basic_string_view< T, TTraits > &rhs)
Inequality for string_view.
Definition string_view.h:818
ETL_CONSTEXPR14 ETL_EXPLICIT_STRING_FROM_CHAR basic_string_view(const T *begin_)
Construct from T*.
Definition string_view.h:137
ETL_CONSTEXPR14 etl::basic_string_view< T, TTraits > & operator=(const etl::basic_string_view< T, TTraits > &other)
Assign from a view.
Definition string_view.h:297
ETL_CONSTEXPR14 void remove_prefix(size_type n)
Shrinks the view by moving its start forward.
Definition string_view.h:388
ETL_CONSTEXPR14 void assign(const_pointer begin_, const_pointer end_)
Assign from iterators.
Definition string_view.h:307
ETL_CONSTEXPR14 void swap(basic_string_view &other) ETL_NOEXCEPT
Swaps with another basic_string_view.
Definition string_view.h:343
ETL_CONSTEXPR const_pointer data() const
Returns a const pointer to the first element of the internal storage.
Definition string_view.h:189
ETL_CONSTEXPR size_t length() const
Returns the size of the array.
Definition string_view.h:281
ETL_CONSTEXPR const_reverse_iterator rbegin() const
Returns a const reverse iterator to the reverse beginning of the array.
Definition string_view.h:229
bool contains(const etl::basic_string_view< T, TTraits > &view) const
Checks that the view is within this string.
Definition string_view.h:785
friend ETL_CONSTEXPR14 bool operator<(const etl::basic_string_view< T, TTraits > &lhs, const etl::basic_string_view< T, TTraits > &rhs)
Less-than for string_view.
Definition string_view.h:826
bool contains(const_pointer s) const
Checks that text is within this string.
Definition string_view.h:793
ETL_CONSTEXPR const_reference back() const
Returns a const reference to the last element.
Definition string_view.h:181
ETL_CONSTEXPR14 size_type find_last_not_of(etl::basic_string_view< T, TTraits > view, size_type position=npos) const
Find last absence of characters.
Definition string_view.h:729
ETL_CONSTEXPR14 size_type find_first_of(etl::basic_string_view< T, TTraits > view, size_type position=0) const
Find first occurrence of characters.
Definition string_view.h:591
const_reference at(size_t i) const
Returns a const reference to the indexed value.
Definition string_view.h:333
ETL_CONSTEXPR bool empty() const
Returns true if the array size is zero.
Definition string_view.h:265
ETL_CONSTEXPR14 size_type find(etl::basic_string_view< T, TTraits > view, size_type position=0) const
Find characters in the view.
Definition string_view.h:512
ETL_CONSTEXPR14 size_type rfind(etl::basic_string_view< T, TTraits > view, size_type position=npos) const
Find the last occurrence of a substring.
Definition string_view.h:549
ETL_CONSTEXPR const_iterator cbegin() const
Returns a const iterator to the beginning of the array.
Definition string_view.h:205
friend ETL_CONSTEXPR14 bool operator>(const etl::basic_string_view< T, TTraits > &lhs, const etl::basic_string_view< T, TTraits > &rhs)
Greater-than for string_view.
Definition string_view.h:834
ETL_CONSTEXPR14 basic_string_view substr(size_type position=0, size_type count=npos) const
Returns a substring.
Definition string_view.h:371
friend ETL_CONSTEXPR14 bool operator==(const etl::basic_string_view< T, TTraits > &lhs, const etl::basic_string_view< T, TTraits > &rhs)
Equality for string_view.
Definition string_view.h:809
ETL_CONSTEXPR const_reference front() const
Returns a const reference to the first element.
Definition string_view.h:173
ETL_CONSTEXPR const_reference operator[](size_t i) const
Returns a const reference to the indexed value.
Definition string_view.h:325
ETL_CONSTEXPR14 size_type find_first_not_of(etl::basic_string_view< T, TTraits > view, size_type position=0) const
Find first absence of characters.
Definition string_view.h:680
ETL_CONSTEXPR const_iterator end() const
Returns a const iterator to the end of the array.
Definition string_view.h:213
ETL_CONSTEXPR basic_string_view(const T *begin_, size_t size_)
Construct from pointer/size.
Definition string_view.h:155
ETL_CONSTEXPR size_t size() const
Returns the size of the array.
Definition string_view.h:273
The base class for basic_string_view exceptions.
Definition string_view.h:58
#define ETL_ASSERT(b, e)
Definition error_handler.h:356
Definition exception.h:47
Definition integral_limits.h:516
Definition string_view.h:72
Definition string_view.h:86
bitset_ext
Definition absolute.h:38
void swap(etl::array< T, SIZE > &lhs, etl::array< T, SIZE > &rhs)
Template deduction guides.
Definition array.h:630
ETL_CONSTEXPR14 string_view make_string_view(const char(&text)[Array_Size])
make_string_view.
Definition string_view.h:871
Character traits for any character type.
Definition char_traits.h:120
Definition compare.h:51
pair holds two objects of arbitrary type
Definition utility.h:164