Embedded Template Library 1.0
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 //***************************************************************************
54 {
55 public:
56
57 string_view_exception(string_type reason_, string_type file_name_, numeric_type line_number_)
58 : exception(reason_, file_name_, line_number_)
59 {
60 }
61 };
62
63 //***************************************************************************
66 //***************************************************************************
68 {
69 public:
70
71 string_view_bounds(string_type file_name_, numeric_type line_number_)
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
85 string_view_uninitialised(string_type file_name_, numeric_type line_number_)
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 (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 //*************************************************************************
303 ETL_CONSTEXPR14 void assign(const_pointer begin_, const_pointer end_)
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 //*************************************************************************
435 ETL_CONSTEXPR14 bool starts_with(etl::basic_string_view<T, TTraits> view) const
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 //*************************************************************************
457 ETL_CONSTEXPR14 bool ends_with(etl::basic_string_view<T, TTraits> view) const
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 //*************************************************************************
480 ETL_CONSTEXPR14 size_type find(etl::basic_string_view<T, TTraits> view, size_type position = 0) const
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 //*************************************************************************
559 ETL_CONSTEXPR14 size_type find_first_of(etl::basic_string_view<T, TTraits> view, size_type position = 0) const
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 {
584 return find_first_of(etl::basic_string_view<T, TTraits>(&c, 1), position);
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 //*************************************************************************
600 ETL_CONSTEXPR14 size_type find_last_of(etl::basic_string_view<T, TTraits> view, size_type position = npos) const
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 {
632 return find_last_of(etl::basic_string_view<T, TTraits>(&c, 1), position);
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 //*************************************************************************
648 ETL_CONSTEXPR14 size_type find_first_not_of(etl::basic_string_view<T, TTraits> view, size_type position = 0) const
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 }
666 }
667
668 if (!found)
669 {
670 return i;
671 }
672 }
673 }
674
675 return npos;
676 }
677
678 ETL_CONSTEXPR14 size_type find_first_not_of(T c, size_type position = 0) const
679 {
681 }
682
683 ETL_CONSTEXPR14 size_type find_first_not_of(const T* text, size_type position, size_type count) const
684 {
685 return find_first_not_of(etl::basic_string_view<T, TTraits>(text, count), position);
686 }
687
688 ETL_CONSTEXPR14 size_type find_first_not_of(const T* text, size_type position = 0) const
689 {
691 }
692
693 //*************************************************************************
695 //*************************************************************************
696 ETL_CONSTEXPR14 size_type find_last_not_of(etl::basic_string_view<T, TTraits> view, size_type position = npos) const
697 {
698 if (empty())
699 {
700 return npos;
701 }
702
703 position = etl::min(position, size() - 1);
704
705 const_reverse_iterator it = rbegin() + size() - position - 1;
706
707 while (it != rend())
708 {
709 bool found = false;
710
711 const size_t viewlength = view.size();
712
713 for (size_t j = 0UL; j < viewlength; ++j)
714 {
715 if (mbegin[position] == view[j])
716 {
717 found = true;
718 }
719 }
720
721 if (!found)
722 {
723 return position;
724 }
725
726 ++it;
727 --position;
728 }
729
730 return npos;
731 }
732
733 ETL_CONSTEXPR14 size_type find_last_not_of(T c, size_type position = npos) const
734 {
736 }
737
738 ETL_CONSTEXPR14 size_type find_last_not_of(const T* text, size_type position, size_type count) const
739 {
740 return find_last_not_of(etl::basic_string_view<T, TTraits>(text, count), position);
741 }
742
743 ETL_CONSTEXPR14 size_type find_last_not_of(const T* text, size_type position = npos) const
744 {
746 }
747
748 //*************************************************************************
750 //*************************************************************************
752 {
753 return (lhs.size() == rhs.size()) &&
754 etl::equal(lhs.begin(), lhs.end(), rhs.begin());
755 }
756
757 //*************************************************************************
759 //*************************************************************************
761 {
762 return !(lhs == rhs);
763 }
764
765 //*************************************************************************
767 //*************************************************************************
769 {
770 return etl::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
771 }
772
773 //*************************************************************************
775 //*************************************************************************
777 {
778 return rhs < lhs;
779 }
780
781 //*************************************************************************
783 //*************************************************************************
785 {
786 return !(lhs > rhs);
787 }
788
789 //*************************************************************************
791 //*************************************************************************
793 {
794 return !(lhs < rhs);
795 }
796
797 private:
798
799 const_pointer mbegin;
800 const_pointer mend;
801 };
802
803 typedef etl::basic_string_view<char> string_view;
804 typedef etl::basic_string_view<wchar_t> wstring_view;
805 typedef etl::basic_string_view<char16_t> u16string_view;
806 typedef etl::basic_string_view<char32_t> u32string_view;
807
808 //*************************************************************************
810 //*************************************************************************
811 template<size_t Array_Size>
812 ETL_CONSTEXPR14 string_view make_string_view(const char(&text)[Array_Size])
813 {
814 size_t length = etl::char_traits<char>::length(text, Array_Size - 1U);
815
816 return string_view(text, length);
817 }
818
819 //***********************************
820 template<size_t Array_Size>
821 ETL_CONSTEXPR14 wstring_view make_string_view(const wchar_t(&text)[Array_Size])
822 {
823 size_t length = etl::char_traits<wchar_t>::length(text, Array_Size - 1U);
824
825 return wstring_view(text, length);
826 }
827
828 //***********************************
829 template<size_t Array_Size>
830 ETL_CONSTEXPR14 u16string_view make_string_view(const char16_t(&text)[Array_Size])
831 {
832 size_t length = etl::char_traits<char16_t>::length(text, Array_Size - 1U);
833
834 return u16string_view(text, length);
835 }
836
837 //***********************************
838 template<size_t Array_Size>
839 ETL_CONSTEXPR14 u32string_view make_string_view(const char32_t(&text)[Array_Size])
840 {
841 size_t length = etl::char_traits<char32_t>::length(text, Array_Size - 1U);
842
843 return u32string_view(text, length);
844 }
845
846 //*************************************************************************
848 //*************************************************************************
849#if ETL_USING_8BIT_TYPES
850 template <>
851 struct hash<etl::string_view>
852 {
853 size_t operator()(const etl::string_view& text) const
854 {
855 return etl::private_hash::generic_hash<size_t>(reinterpret_cast<const uint8_t*>(text.data()),
856 reinterpret_cast<const uint8_t*>(text.data() + text.size()));
857 }
858 };
859
860 template <>
861 struct hash<etl::wstring_view>
862 {
863 size_t operator()(const etl::wstring_view& text) const
864 {
865 return etl::private_hash::generic_hash<size_t>(reinterpret_cast<const uint8_t*>(text.data()),
866 reinterpret_cast<const uint8_t*>(text.data() + text.size()));
867 }
868 };
869
870 template <>
871 struct hash<etl::u16string_view>
872 {
873 size_t operator()(const etl::u16string_view& text) const
874 {
875 return etl::private_hash::generic_hash<size_t>(reinterpret_cast<const uint8_t*>(text.data()),
876 reinterpret_cast<const uint8_t*>(text.data() + text.size()));
877 }
878 };
879
880 template <>
881 struct hash<etl::u32string_view>
882 {
883 size_t operator()(const etl::u32string_view& text) const
884 {
885 return etl::private_hash::generic_hash<size_t>(reinterpret_cast<const uint8_t*>(text.data()),
886 reinterpret_cast<const uint8_t*>(text.data() + text.size()));
887 }
888 };
889#endif
890}
891
892//*************************************************************************
894//*************************************************************************
895template <typename T, typename TTraits >
897{
898 lhs.swap(rhs);
899}
900
901template <typename T>
903{
904 lhs.swap(rhs);
905}
906
907#include "private/minmax_pop.h"
908
909#endif
910
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_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
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:784
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
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:792
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_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:760
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:768
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:696
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:776
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:751
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 size_t size() const
Returns the size of the array.
Definition: string_view.h:269
Definition: basic_string.h:326
The base class for basic_string_view exceptions.
Definition: string_view.h:54
#define ETL_ASSERT(b, e)
Definition: error_handler.h:316
ETL_CONSTEXPR exception(string_type reason_, string_type, numeric_type line_)
Constructor.
Definition: exception.h:69
Definition: exception.h:47
Definition: integral_limits.h:468
Definition: string_view.h:68
Definition: string_view.h:82
bitset_ext
Definition: absolute.h:38
ETL_CONSTEXPR14 string_view make_string_view(const char(&text)[Array_Size])
make_string_view.
Definition: string_view.h:812
void swap(etl::basic_string_view< T, TTraits > &lhs, etl::basic_string_view< T, TTraits > &rhs)
Swaps the values.
Definition: string_view.h:896
Character traits for any character type.
Definition: char_traits.h:102