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#include <stdint.h>
47
48namespace etl
49{
50 //***************************************************************************
52 //***************************************************************************
62
63 //***************************************************************************
66 //***************************************************************************
68 {
69 public:
70
72 : string_view_exception(ETL_ERROR_TEXT("basic_string_view:bounds", ETL_STRING_VIEW_FILE_ID"A"), file_name_, line_number_)
73 {
74 }
75 };
76
77 //***************************************************************************
80 //***************************************************************************
82 {
83 public:
84
86 : string_view_exception(ETL_ERROR_TEXT("basic_string_view:uninitialised", ETL_STRING_VIEW_FILE_ID"B"), file_name_, line_number_)
87 {
88 }
89 };
90
91 //***************************************************************************
93 //***************************************************************************
94 template <typename T, typename TTraits = etl::char_traits<T> >
96 {
97 public:
98
99 typedef T value_type;
100 typedef TTraits traits_type;
101 typedef size_t size_type;
102 typedef const T& const_reference;
103 typedef const T* const_pointer;
104 typedef const T* const_iterator;
105 typedef ETL_OR_STD::reverse_iterator<const_iterator> const_reverse_iterator;
106
107 enum
108 {
110 };
111
112 //*************************************************************************
114 //*************************************************************************
115 ETL_CONSTEXPR basic_string_view() ETL_NOEXCEPT
116 : mbegin(ETL_NULLPTR)
117 , mend(ETL_NULLPTR)
118 {
119 }
120
121 //*************************************************************************
123 //*************************************************************************
124 ETL_CONSTEXPR basic_string_view(const etl::ibasic_string<T>& str)
125 : mbegin(str.begin())
126 , mend(str.end())
127 {
128 }
129
130 //*************************************************************************
132 //*************************************************************************
133 ETL_CONSTEXPR14 ETL_EXPLICIT_STRING_FROM_CHAR basic_string_view(const T* begin_)
134 : mbegin(begin_)
135 , mend(begin_ + TTraits::length(begin_))
136 {
137 }
138
139 //*************************************************************************
141 //*************************************************************************
142 ETL_CONSTEXPR basic_string_view(const T* begin_, const T* end_)
143 : mbegin(begin_)
144 , mend(end_)
145 {
146 }
147
148 //*************************************************************************
150 //*************************************************************************
151 ETL_CONSTEXPR basic_string_view(const T* begin_, size_t size_)
152 : mbegin(begin_)
153 , mend(begin_ + size_)
154 {
155 }
156
157 //*************************************************************************
159 //*************************************************************************
160 ETL_CONSTEXPR basic_string_view(const basic_string_view& other) ETL_NOEXCEPT
161 : mbegin(other.mbegin)
162 , mend(other.mend)
163 {
164 }
165
166 //*************************************************************************
168 //*************************************************************************
169 ETL_CONSTEXPR const_reference front() const
170 {
171 return *mbegin;
172 }
173
174 //*************************************************************************
176 //*************************************************************************
177 ETL_CONSTEXPR const_reference back() const
178 {
179 return *(mend - 1);
180 }
181
182 //*************************************************************************
184 //*************************************************************************
185 ETL_CONSTEXPR const_pointer data() const
186 {
187 return mbegin;
188 }
189
190 //*************************************************************************
192 //*************************************************************************
193 ETL_CONSTEXPR const_iterator begin() const
194 {
195 return mbegin;
196 }
197
198 //*************************************************************************
200 //*************************************************************************
201 ETL_CONSTEXPR const_iterator cbegin() const
202 {
203 return mbegin;
204 }
205
206 //*************************************************************************
208 //*************************************************************************
209 ETL_CONSTEXPR const_iterator end() const
210 {
211 return mend;
212 }
213
214 //*************************************************************************
215 // Returns a const iterator to the end of the array.
216 //*************************************************************************
217 ETL_CONSTEXPR const_iterator cend() const
218 {
219 return mend;
220 }
221
222 //*************************************************************************
224 //*************************************************************************
225 ETL_CONSTEXPR const_reverse_iterator rbegin() const
226 {
227 return const_reverse_iterator(mend);
228 }
229
230 //*************************************************************************
232 //*************************************************************************
233 ETL_CONSTEXPR const_reverse_iterator crbegin() const
234 {
235 return const_reverse_iterator(mend);
236 }
237
238 //*************************************************************************
240 //*************************************************************************
241 ETL_CONSTEXPR const_reverse_iterator rend() const
242 {
243 return const_reverse_iterator(mbegin);
244 }
245
246 //*************************************************************************
248 //*************************************************************************
249 ETL_CONSTEXPR const_reverse_iterator crend() const
250 {
251 return const_reverse_iterator(mbegin);
252 }
253
254 //*************************************************************************
255 // Capacity
256 //*************************************************************************
257
258 //*************************************************************************
260 //*************************************************************************
261 ETL_CONSTEXPR bool empty() const
262 {
263 return (mbegin == mend);
264 }
265
266 //*************************************************************************
268 //*************************************************************************
269 ETL_CONSTEXPR size_t size() const
270 {
271 return static_cast<size_t>(mend - mbegin);
272 }
273
274 //*************************************************************************
276 //*************************************************************************
277 ETL_CONSTEXPR size_t length() const
278 {
279 return size();
280 }
281
282 //*************************************************************************
284 //*************************************************************************
285 ETL_CONSTEXPR size_t max_size() const
286 {
287 return size();
288 }
289
290 //*************************************************************************
292 //*************************************************************************
294 {
295 mbegin = other.mbegin;
296 mend = other.mend;
297 return *this;
298 }
299
300 //*************************************************************************
302 //*************************************************************************
304 {
305 mbegin = begin_;
306 mend = end_;
307 }
308
309 //*************************************************************************
311 //*************************************************************************
312 ETL_CONSTEXPR14 void assign(const_pointer begin_, size_t size_)
313 {
314 mbegin = begin_;
315 mend = begin_ + size_;
316 }
317
318 //*************************************************************************
320 //*************************************************************************
321 ETL_CONSTEXPR const_reference operator[](size_t i) const
322 {
323 return mbegin[i];
324 }
325
326 //*************************************************************************
328 //*************************************************************************
329 const_reference at(size_t i) const
330 {
331 ETL_ASSERT((mbegin != ETL_NULLPTR && mend != ETL_NULLPTR), ETL_ERROR(string_view_uninitialised));
332 ETL_ASSERT(i < size(), ETL_ERROR(string_view_bounds));
333 return mbegin[i];
334 }
335
336 //*************************************************************************
338 //*************************************************************************
339 ETL_CONSTEXPR14 void swap(basic_string_view& other) ETL_NOEXCEPT
340 {
341 using ETL_OR_STD::swap; // Allow ADL
342
343 swap(mbegin, other.mbegin);
344 swap(mend, other.mend);
345 }
346
347 //*************************************************************************
349 //*************************************************************************
350 ETL_CONSTEXPR14 size_type copy(T* destination, size_type count, size_type position = 0) const
351 {
352 size_t n = 0UL;
353
354 if (position < size())
355 {
356 n = etl::min(count, size() - position);
357
358 etl::copy(mbegin + position, mbegin + position + n, destination);
359 }
360
361 return n;
362 }
363
364 //*************************************************************************
366 //*************************************************************************
367 ETL_CONSTEXPR14 basic_string_view substr(size_type position = 0, size_type count = npos) const
368 {
370
371 if (position < size())
372 {
373 size_t n = etl::min(count, size() - position);
374
375 view = basic_string_view(mbegin + position, mbegin + position + n);
376 }
377
378 return view;
379 }
380
381 //*************************************************************************
383 //*************************************************************************
384 ETL_CONSTEXPR14 void remove_prefix(size_type n)
385 {
386 mbegin += n;
387 }
388
389 //*************************************************************************
391 //*************************************************************************
392 ETL_CONSTEXPR14 void remove_suffix(size_type n)
393 {
394 mend -= n;
395 }
396
397 //*************************************************************************
399 //*************************************************************************
400 ETL_CONSTEXPR14 int compare(basic_string_view<T, TTraits> view) const
401 {
402 return (*this == view) ? 0 : ((*this > view) ? 1 : -1);
403 }
404
405 ETL_CONSTEXPR14 int compare(size_type position, size_type count, basic_string_view view) const
406 {
407 return substr(position, count).compare(view);
408 }
409
410 ETL_CONSTEXPR14 int compare(size_type position1, size_type count1,
412 size_type position2, size_type count2) const
413 {
414 return substr(position1, count1).compare(view.substr(position2, count2));
415 }
416
417 ETL_CONSTEXPR14 int compare(const T* text) const
418 {
420 }
421
422 ETL_CONSTEXPR14 int compare(size_type position, size_type count, const T* text) const
423 {
424 return substr(position, count).compare(etl::basic_string_view<T, TTraits>(text));
425 }
426
427 ETL_CONSTEXPR14 int compare(size_type position, size_type count1, const T* text, size_type count2) const
428 {
429 return substr(position, count1).compare(etl::basic_string_view<T, TTraits>(text, count2));
430 }
431
432 //*************************************************************************
434 //*************************************************************************
436 {
437 return (size() >= view.size()) &&
438 (compare(0, view.size(), view) == 0);
439 }
440
441 ETL_CONSTEXPR14 bool starts_with(T c) const
442 {
443 return !empty() && (front() == c);
444 }
445
446 ETL_CONSTEXPR14 bool starts_with(const T* text) const
447 {
448 size_t lengthtext = TTraits::length(text);
449
450 return (size() >= lengthtext) &&
451 (compare(0, lengthtext, text) == 0);
452 }
453
454 //*************************************************************************
456 //*************************************************************************
458 {
459 return (size() >= view.size()) &&
460 (compare(size() - view.size(), npos, view) == 0);
461 }
462
463 ETL_CONSTEXPR14 bool ends_with(T c) const
464 {
465 return !empty() && (back() == c);
466 }
467
468 ETL_CONSTEXPR14 bool ends_with(const T* text) const
469 {
470 size_t lengthtext = TTraits::length(text);
471 size_t lengthview = size();
472
473 return (lengthview >= lengthtext) &&
474 (compare(lengthview - lengthtext, lengthtext, text) == 0);
475 }
476
477 //*************************************************************************
479 //*************************************************************************
481 {
482 if ((size() < view.size()))
483 {
484 return npos;
485 }
486
487 const_iterator iposition = etl::search(begin() + position, end(), view.begin(), view.end());
488
489 if (iposition == end())
490 {
491 return npos;
492 }
493 else
494 {
495 return etl::distance(begin(), iposition);
496 }
497 }
498
499 ETL_CONSTEXPR14 size_type find(T c, size_type position = 0) const
500 {
501 return find(etl::basic_string_view<T, TTraits>(&c, 1), position);
502 }
503
504 ETL_CONSTEXPR14 size_type find(const T* text, size_type position, size_type count) const
505 {
506 return find(etl::basic_string_view<T, TTraits>(text, count), position);
507 }
508
509 ETL_CONSTEXPR14 size_type find(const T* text, size_type position = 0) const
510 {
511 return find(etl::basic_string_view<T, TTraits>(text), position);
512 }
513
514 //*************************************************************************
516 //*************************************************************************
517 ETL_CONSTEXPR14 size_type rfind(etl::basic_string_view<T, TTraits> view, size_type position = npos) const
518 {
519 if ((size() < view.size()))
520 {
521 return npos;
522 }
523
524 position = etl::min(position, size());
525
526 const_iterator iposition = etl::find_end(begin(),
527 begin() + position,
528 view.begin(),
529 view.end());
530
531 if (iposition == end())
532 {
533 return npos;
534 }
535 else
536 {
537 return etl::distance(begin(), iposition);
538 }
539 }
540
541 ETL_CONSTEXPR14 size_type rfind(T c, size_type position = npos) const
542 {
543 return rfind(etl::basic_string_view<T, TTraits>(&c, 1), position);
544 }
545
546 ETL_CONSTEXPR14 size_type rfind(const T* text, size_type position, size_type count) const
547 {
548 return rfind(etl::basic_string_view<T, TTraits>(text, count), position);
549 }
550
551 ETL_CONSTEXPR14 size_type rfind(const T* text, size_type position = npos) const
552 {
553 return rfind(etl::basic_string_view<T, TTraits>(text), position);
554 }
555
556 //*************************************************************************
558 //*************************************************************************
560 {
561 const size_t lengthtext = size();
562
563 if (position < lengthtext)
564 {
565 for (size_t i = position; i < lengthtext; ++i)
566 {
567 const size_t lengthview = view.size();
568
569 for (size_t j = 0UL; j < lengthview; ++j)
570 {
571 if (mbegin[i] == view[j])
572 {
573 return i;
574 }
575 }
576 }
577 }
578
579 return npos;
580 }
581
582 ETL_CONSTEXPR14 size_type find_first_of(T c, size_type position = 0) const
583 {
585 }
586
587 ETL_CONSTEXPR14 size_type find_first_of(const T* text, size_type position, size_type count) const
588 {
589 return find_first_of(etl::basic_string_view<T, TTraits>(text, count), position);
590 }
591
592 ETL_CONSTEXPR14 size_type find_first_of(const T* text, size_type position = 0) const
593 {
595 }
596
597 //*************************************************************************
599 //*************************************************************************
601 {
602 if (empty())
603 {
604 return npos;
605 }
606
607 position = etl::min(position, size() - 1);
608
609 const_reverse_iterator it = rbegin() + size() - position - 1;
610
611 while (it != rend())
612 {
613 const size_t viewlength = view.size();
614
615 for (size_t j = 0UL; j < viewlength; ++j)
616 {
617 if (mbegin[position] == view[j])
618 {
619 return position;
620 }
621 }
622
623 ++it;
624 --position;
625 }
626
627 return npos;
628 }
629
630 ETL_CONSTEXPR14 size_type find_last_of(T c, size_type position = npos) const
631 {
633 }
634
635 ETL_CONSTEXPR14 size_type find_last_of(const T* text, size_type position, size_type count) const
636 {
637 return find_last_of(etl::basic_string_view<T, TTraits>(text, count), position);
638 }
639
640 ETL_CONSTEXPR14 size_type find_last_of(const T* text, size_type position = npos) const
641 {
642 return find_last_of(etl::basic_string_view<T, TTraits>(text), position);
643 }
644
645 //*************************************************************************
647 //*************************************************************************
649 {
650 const size_t lengthtext = size();
651
652 if (position < lengthtext)
653 {
654 for (size_t i = position; i < lengthtext; ++i)
655 {
656 bool found = false;
657
658 const size_t viewlength = view.size();
659
660 for (size_t j = 0UL; j < viewlength; ++j)
661 {
662 if (mbegin[i] == view[j])
663 {
664 found = true;
665 break;
666 }
667 }
668
669 if (!found)
670 {
671 return i;
672 }
673 }
674 }
675
676 return npos;
677 }
678
679 ETL_CONSTEXPR14 size_type find_first_not_of(T c, size_type position = 0) const
680 {
682 }
683
684 ETL_CONSTEXPR14 size_type find_first_not_of(const T* text, size_type position, size_type count) const
685 {
686 return find_first_not_of(etl::basic_string_view<T, TTraits>(text, count), position);
687 }
688
689 ETL_CONSTEXPR14 size_type find_first_not_of(const T* text, size_type position = 0) const
690 {
692 }
693
694 //*************************************************************************
696 //*************************************************************************
698 {
699 if (empty())
700 {
701 return npos;
702 }
703
704 position = etl::min(position, size() - 1);
705
706 const_reverse_iterator it = rbegin() + size() - position - 1;
707
708 while (it != rend())
709 {
710 bool found = false;
711
712 const size_t viewlength = view.size();
713
714 for (size_t j = 0UL; j < viewlength; ++j)
715 {
716 if (mbegin[position] == view[j])
717 {
718 found = true;
719 break;
720 }
721 }
722
723 if (!found)
724 {
725 return position;
726 }
727
728 ++it;
729 --position;
730 }
731
732 return npos;
733 }
734
735 ETL_CONSTEXPR14 size_type find_last_not_of(T c, size_type position = npos) const
736 {
738 }
739
740 ETL_CONSTEXPR14 size_type find_last_not_of(const T* text, size_type position, size_type count) const
741 {
742 return find_last_not_of(etl::basic_string_view<T, TTraits>(text, count), position);
743 }
744
745 ETL_CONSTEXPR14 size_type find_last_not_of(const T* text, size_type position = npos) const
746 {
748 }
749
750 //*************************************************************************
752 //*************************************************************************
754 {
755 return (lhs.size() == rhs.size()) &&
756 etl::equal(lhs.begin(), lhs.end(), rhs.begin());
757 }
758
759 //*************************************************************************
761 //*************************************************************************
763 {
764 return !(lhs == rhs);
765 }
766
767 //*************************************************************************
769 //*************************************************************************
771 {
772 return etl::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
773 }
774
775 //*************************************************************************
777 //*************************************************************************
779 {
780 return rhs < lhs;
781 }
782
783 //*************************************************************************
785 //*************************************************************************
787 {
788 return !(lhs > rhs);
789 }
790
791 //*************************************************************************
793 //*************************************************************************
795 {
796 return !(lhs < rhs);
797 }
798
799 private:
800
801 const_pointer mbegin;
802 const_pointer mend;
803 };
804
805 typedef etl::basic_string_view<char> string_view;
806 typedef etl::basic_string_view<wchar_t> wstring_view;
807 typedef etl::basic_string_view<char8_t> u8string_view;
808 typedef etl::basic_string_view<char16_t> u16string_view;
809 typedef etl::basic_string_view<char32_t> u32string_view;
810
811 //*************************************************************************
813 //*************************************************************************
814 template<size_t Array_Size>
815 ETL_CONSTEXPR14 string_view make_string_view(const char(&text)[Array_Size])
816 {
817 size_t length = etl::char_traits<char>::length(text, Array_Size - 1U);
818
819 return string_view(text, length);
820 }
821
822 //***********************************
823 template<size_t Array_Size>
824 ETL_CONSTEXPR14 wstring_view make_string_view(const wchar_t(&text)[Array_Size])
825 {
826 size_t length = etl::char_traits<wchar_t>::length(text, Array_Size - 1U);
827
828 return wstring_view(text, length);
829 }
830
831 //***********************************
832 template<size_t Array_Size>
833 ETL_CONSTEXPR14 u8string_view make_string_view(const char8_t(&text)[Array_Size])
834 {
835 size_t length = etl::char_traits<char8_t>::length(text, Array_Size - 1U);
836
837 return u8string_view(text, length);
838 }
839
840 //***********************************
841 template<size_t Array_Size>
842 ETL_CONSTEXPR14 u16string_view make_string_view(const char16_t(&text)[Array_Size])
843 {
844 size_t length = etl::char_traits<char16_t>::length(text, Array_Size - 1U);
845
846 return u16string_view(text, length);
847 }
848
849 //***********************************
850 template<size_t Array_Size>
851 ETL_CONSTEXPR14 u32string_view make_string_view(const char32_t(&text)[Array_Size])
852 {
853 size_t length = etl::char_traits<char32_t>::length(text, Array_Size - 1U);
854
855 return u32string_view(text, length);
856 }
857
858 //*************************************************************************
860 //*************************************************************************
861#if ETL_USING_8BIT_TYPES
862 template <>
863 struct hash<etl::string_view>
864 {
865 size_t operator()(const etl::string_view& text) const
866 {
867 return etl::private_hash::generic_hash<size_t>(reinterpret_cast<const uint8_t*>(text.data()),
868 reinterpret_cast<const uint8_t*>(text.data() + text.size()));
869 }
870 };
871
872 template <>
873 struct hash<etl::wstring_view>
874 {
875 size_t operator()(const etl::wstring_view& text) const
876 {
877 return etl::private_hash::generic_hash<size_t>(reinterpret_cast<const uint8_t*>(text.data()),
878 reinterpret_cast<const uint8_t*>(text.data() + text.size()));
879 }
880 };
881
882 template <>
883 struct hash<etl::u16string_view>
884 {
885 size_t operator()(const etl::u16string_view& text) const
886 {
887 return etl::private_hash::generic_hash<size_t>(reinterpret_cast<const uint8_t*>(text.data()),
888 reinterpret_cast<const uint8_t*>(text.data() + text.size()));
889 }
890 };
891
892 template <>
893 struct hash<etl::u32string_view>
894 {
895 size_t operator()(const etl::u32string_view& text) const
896 {
897 return etl::private_hash::generic_hash<size_t>(reinterpret_cast<const uint8_t*>(text.data()),
898 reinterpret_cast<const uint8_t*>(text.data() + text.size()));
899 }
900 };
901#endif
902}
903
904//*************************************************************************
906//*************************************************************************
907template <typename T, typename TTraits >
909{
910 lhs.swap(rhs);
911}
912
913template <typename T>
915{
916 lhs.swap(rhs);
917}
918
919#include "private/minmax_pop.h"
920
921#endif
922
String view.
Definition string_view.h:96
ETL_CONSTEXPR14 int compare(basic_string_view< T, TTraits > view) const
Compares two views.
Definition string_view.h:400
ETL_CONSTEXPR14 void assign(const_pointer begin_, size_t size_)
Assign from iterator and size.
Definition string_view.h:312
ETL_CONSTEXPR basic_string_view() ETL_NOEXCEPT
Default constructor.
Definition string_view.h:115
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:457
ETL_CONSTEXPR14 size_type copy(T *destination, size_type count, size_type position=0) const
Copies characters.
Definition string_view.h:350
ETL_CONSTEXPR basic_string_view(const basic_string_view &other) ETL_NOEXCEPT
Copy constructor.
Definition string_view.h:160
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:786
ETL_CONSTEXPR const_reverse_iterator rend() const
Returns a const reverse iterator to the end of the array.
Definition string_view.h:241
ETL_CONSTEXPR const_reverse_iterator crbegin() const
Returns a const reverse iterator to the reverse beginning of the array.
Definition string_view.h:233
ETL_CONSTEXPR const_reverse_iterator crend() const
Returns a const reverse iterator to the end of the array.
Definition string_view.h:249
ETL_CONSTEXPR size_t max_size() const
Returns the maximum possible size of the array.
Definition string_view.h:285
ETL_CONSTEXPR14 void remove_suffix(size_type n)
Shrinks the view by moving its end backward.
Definition string_view.h:392
ETL_CONSTEXPR basic_string_view(const etl::ibasic_string< T > &str)
Construct from string.
Definition string_view.h:124
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:794
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:435
ETL_CONSTEXPR basic_string_view(const T *begin_, const T *end_)
Construct from pointer range.
Definition string_view.h:142
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:600
ETL_CONSTEXPR const_iterator begin() const
Returns a const iterator to the beginning of the array.
Definition string_view.h:193
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:762
ETL_CONSTEXPR14 ETL_EXPLICIT_STRING_FROM_CHAR basic_string_view(const T *begin_)
Construct from T*.
Definition string_view.h:133
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:293
ETL_CONSTEXPR14 void remove_prefix(size_type n)
Shrinks the view by moving its start forward.
Definition string_view.h:384
ETL_CONSTEXPR14 void assign(const_pointer begin_, const_pointer end_)
Assign from iterators.
Definition string_view.h:303
ETL_CONSTEXPR14 void swap(basic_string_view &other) ETL_NOEXCEPT
Swaps with another basic_string_view.
Definition string_view.h:339
ETL_CONSTEXPR const_pointer data() const
Returns a const pointer to the first element of the internal storage.
Definition string_view.h:185
ETL_CONSTEXPR size_t length() const
Returns the size of the array.
Definition string_view.h:277
ETL_CONSTEXPR const_reverse_iterator rbegin() const
Returns a const reverse iterator to the reverse beginning of the array.
Definition string_view.h:225
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:770
ETL_CONSTEXPR const_reference back() const
Returns a const reference to the last element.
Definition string_view.h:177
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:697
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:559
const_reference at(size_t i) const
Returns a const reference to the indexed value.
Definition string_view.h:329
ETL_CONSTEXPR bool empty() const
Returns true if the array size is zero.
Definition string_view.h:261
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:480
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:517
ETL_CONSTEXPR const_iterator cbegin() const
Returns a const iterator to the beginning of the array.
Definition string_view.h:201
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:778
ETL_CONSTEXPR14 basic_string_view substr(size_type position=0, size_type count=npos) const
Returns a substring.
Definition string_view.h:367
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:753
ETL_CONSTEXPR const_reference front() const
Returns a const reference to the first element.
Definition string_view.h:169
ETL_CONSTEXPR const_reference operator[](size_t i) const
Returns a const reference to the indexed value.
Definition string_view.h:321
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:648
ETL_CONSTEXPR const_iterator end() const
Returns a const iterator to the end of the array.
Definition string_view.h:209
ETL_CONSTEXPR basic_string_view(const T *begin_, size_t size_)
Construct from pointer/size.
Definition string_view.h:151
ETL_CONSTEXPR size_t size() const
Returns the size of the array.
Definition string_view.h:269
The base class for basic_string_view exceptions.
Definition string_view.h:54
#define ETL_ASSERT(b, e)
Definition error_handler.h:316
Definition exception.h:47
Definition integral_limits.h:516
Definition string_view.h:68
Definition string_view.h:82
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:815
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