Embedded Template Library  1.0
string_view.h
Go to the documentation of this file.
1 
3 /******************************************************************************
4 The MIT License(MIT)
5 
6 Embedded Template Library.
7 https://github.com/ETLCPP/etl
8 https://www.etlcpp.com
9 
10 Copyright(c) 2017 jwellbelove
11 
12 Permission is hereby granted, free of charge, to any person obtaining a copy
13 of this software and associated documentation files(the "Software"), to deal
14 in the Software without restriction, including without limitation the rights
15 to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
16 copies of the Software, and to permit persons to whom the Software is
17 furnished to do so, subject to the following conditions :
18 
19 The above copyright notice and this permission notice shall be included in all
20 copies or substantial portions of the Software.
21 
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
25 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28 SOFTWARE.
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 
45 #include "stdint.h"
46 
50 
51 #undef ETL_FILE
52 #define ETL_FILE "42"
53 
54 #include "private/minmax_push.h"
55 
56 namespace etl
57 {
58  //***************************************************************************
60  //***************************************************************************
62  {
63  public:
64 
65  string_view_exception(string_type reason_, string_type file_name_, numeric_type line_number_)
66  : exception(reason_, file_name_, line_number_)
67  {
68  }
69  };
70 
71  //***************************************************************************
74  //***************************************************************************
76  {
77  public:
78 
79  string_view_bounds(string_type file_name_, numeric_type line_number_)
80  : string_view_exception(ETL_ERROR_TEXT("basic_string_view:bounds", ETL_FILE"A"), file_name_, line_number_)
81  {
82  }
83  };
84 
85  //***************************************************************************
88  //***************************************************************************
90  {
91  public:
92 
93  string_view_uninitialised(string_type file_name_, numeric_type line_number_)
94  : string_view_exception(ETL_ERROR_TEXT("basic_string_view:uninitialised", ETL_FILE"B"), file_name_, line_number_)
95  {
96  }
97  };
98 
99  //***************************************************************************
101  //***************************************************************************
102  template <typename T, typename TTraits = etl::char_traits<T> >
104  {
105  public:
106 
107  typedef T value_type;
108  typedef TTraits traits_type;
109  typedef size_t size_type;
110  typedef const T& const_reference;
111  typedef const T* const_pointer;
112  typedef const T* const_iterator;
113  typedef ETL_OR_STD::reverse_iterator<const_iterator> const_reverse_iterator;
114 
115  enum
116  {
118  };
119 
120  //*************************************************************************
122  //*************************************************************************
123  ETL_CONSTEXPR17 basic_string_view()
124  : mbegin(ETL_NULLPTR)
125  , mend(ETL_NULLPTR)
126  {
127  }
128 
129  //*************************************************************************
131  //*************************************************************************
132  ETL_CONSTEXPR17 basic_string_view(const etl::ibasic_string<T>& str)
133  : mbegin(str.begin())
134  , mend(str.end())
135  {
136  }
137 
138  //*************************************************************************
140  //*************************************************************************
141  ETL_EXPLICIT_STRING_FROM_CHAR ETL_CONSTEXPR17 basic_string_view(const T* begin_)
142  : mbegin(begin_)
143  , mend(begin_ + TTraits::length(begin_))
144  {
145  }
146 
147  //*************************************************************************
149  //*************************************************************************
150  ETL_CONSTEXPR17 basic_string_view(const T* begin_, const T* end_)
151  : mbegin(begin_)
152  , mend(end_)
153  {
154  }
155 
156  //*************************************************************************
158  //*************************************************************************
159  ETL_CONSTEXPR17 basic_string_view(const T* begin_, size_t size_)
160  : mbegin(begin_)
161  , mend(begin_ + size_)
162  {
163  }
164 
165  //*************************************************************************
167  //*************************************************************************
168  ETL_CONSTEXPR17 basic_string_view(const basic_string_view& other)
169  : mbegin(other.mbegin)
170  , mend(other.mend)
171  {
172  }
173 
174  //*************************************************************************
176  //*************************************************************************
177  const_reference front() const
178  {
179  return *mbegin;
180  }
181 
182  //*************************************************************************
184  //*************************************************************************
185  const_reference back() const
186  {
187  return *(mend - 1);
188  }
189 
190  //*************************************************************************
192  //*************************************************************************
193  const_pointer data() const
194  {
195  return mbegin;
196  }
197 
198  //*************************************************************************
200  //*************************************************************************
201  const_iterator begin() const
202  {
203  return mbegin;
204  }
205 
206  //*************************************************************************
208  //*************************************************************************
209  const_iterator cbegin() const
210  {
211  return mbegin;
212  }
213 
214  //*************************************************************************
216  //*************************************************************************
217  const_iterator end() const
218  {
219  return mend;
220  }
221 
222  //*************************************************************************
223  // Returns a const iterator to the end of the array.
224  //*************************************************************************
225  const_iterator cend() const
226  {
227  return mend;
228  }
229 
230  //*************************************************************************
232  //*************************************************************************
233  const_reverse_iterator rbegin() const
234  {
235  return const_reverse_iterator(mend);
236  }
237 
238  //*************************************************************************
240  //*************************************************************************
241  const_reverse_iterator crbegin() const
242  {
243  return const_reverse_iterator(mend);
244  }
245 
246  //*************************************************************************
248  //*************************************************************************
249  const_reverse_iterator rend() const
250  {
251  return const_reverse_iterator(mbegin);
252  }
253 
254  //*************************************************************************
256  //*************************************************************************
257  const_reverse_iterator crend() const
258  {
259  return const_reverse_iterator(mbegin);
260  }
261 
262  //*************************************************************************
263  // Capacity
264  //*************************************************************************
265 
266  //*************************************************************************
268  //*************************************************************************
269  bool empty() const
270  {
271  return (mbegin == mend);
272  }
273 
274  //*************************************************************************
276  //*************************************************************************
277  size_t size() const
278  {
279  return (mend - mbegin);
280  }
281 
282  //*************************************************************************
284  //*************************************************************************
285  size_t length() const
286  {
287  return size();
288  }
289 
290  //*************************************************************************
292  //*************************************************************************
293  size_t max_size() const
294  {
295  return size();
296  }
297 
298  //*************************************************************************
300  //*************************************************************************
302  {
303  mbegin = other.mbegin;
304  mend = other.mend;
305  return *this;
306  }
307 
308  //*************************************************************************
310  //*************************************************************************
311  template <typename TIterator>
312  void assign(TIterator begin_, TIterator end_)
313  {
314  mbegin = etl::addressof(*begin_);
315  mend = etl::addressof(*begin_) + etl::distance(begin_, end_);
316  }
317 
318  //*************************************************************************
320  //*************************************************************************
321  template <typename TIterator>
322  void assign(TIterator begin_, size_t size_)
323  {
324  mbegin = etl::addressof(*begin_);
325  mend = etl::addressof(*begin_) + size_;
326  }
327 
328  //*************************************************************************
330  //*************************************************************************
331  const_reference operator[](size_t i) const
332  {
333  return mbegin[i];
334  }
335 
336  //*************************************************************************
338  //*************************************************************************
339  const_reference at(size_t i) const
340  {
341  ETL_ASSERT((mbegin != ETL_NULLPTR && mend != ETL_NULLPTR), ETL_ERROR(string_view_uninitialised));
342  ETL_ASSERT(i < size(), ETL_ERROR(string_view_bounds));
343  return mbegin[i];
344  }
345 
346  //*************************************************************************
348  //*************************************************************************
349  void swap(basic_string_view& other)
350  {
351  using ETL_OR_STD::swap; // Allow ADL
352 
353  swap(mbegin, other.mbegin);
354  swap(mend, other.mend);
355  }
356 
357  //*************************************************************************
359  //*************************************************************************
360  size_type copy(T* destination, size_type count, size_type position = 0) const
361  {
362  size_t n = 0;
363 
364  if (position < size())
365  {
366  n = etl::min(count, size() - position);
367 
368  etl::copy(mbegin + position, mbegin + position + n, destination);
369  }
370 
371  return n;
372  }
373 
374  //*************************************************************************
376  //*************************************************************************
377  basic_string_view substr(size_type position = 0, size_type count = npos) const
378  {
379  basic_string_view view;
380 
381  if (position < size())
382  {
383  size_t n = etl::min(count, size() - position);
384 
385  view = basic_string_view(mbegin + position, mbegin + position + n);
386  }
387 
388  return view;
389  }
390 
391  //*************************************************************************
393  //*************************************************************************
394  void remove_prefix(size_type n)
395  {
396  mbegin += n;
397  }
398 
399  //*************************************************************************
401  //*************************************************************************
402  void remove_suffix(size_type n)
403  {
404  mend -= n;
405  }
406 
407  //*************************************************************************
409  //*************************************************************************
411  {
412  return (*this == view) ? 0 : ((*this > view) ? 1 : -1);
413  }
414 
415  int compare(size_type position, size_type count, basic_string_view view) const
416  {
417  return substr(position, count).compare(view);
418  }
419 
420  int compare(size_type position1, size_type count1,
421  basic_string_view view,
422  size_type position2, size_type count2) const
423  {
424  return substr(position1, count1).compare(view.substr(position2, count2));
425  }
426 
427  int compare(const T* text) const
428  {
430  }
431 
432  int compare(size_type position, size_type count, const T* text) const
433  {
434  return substr(position, count).compare(etl::basic_string_view<T, TTraits>(text));
435  }
436 
437  int compare(size_type position, size_type count1, const T* text, size_type count2) const
438  {
439  return substr(position, count1).compare(etl::basic_string_view<T, TTraits>(text, count2));
440  }
441 
442  //*************************************************************************
444  //*************************************************************************
446  {
447  return (size() >= view.size()) &&
448  (compare(0, view.size(), view) == 0);
449  }
450 
451  bool starts_with(T c) const
452  {
453  return !empty() && (front() == c);
454  }
455 
456  bool starts_with(const T* text) const
457  {
458  size_t lengthtext = TTraits::length(text);
459 
460  return (size() >= lengthtext) &&
461  (compare(0, lengthtext, text) == 0);
462  }
463 
464  //*************************************************************************
466  //*************************************************************************
468  {
469  return (size() >= view.size()) &&
470  (compare(size() - view.size(), npos, view) == 0);
471  }
472 
473  bool ends_with(T c) const
474  {
475  return !empty() && (back() == c);
476  }
477 
478  bool ends_with(const T* text) const
479  {
480  size_t lengthtext = TTraits::length(text);
481  size_t lengthview = size();
482 
483  return (lengthview >= lengthtext) &&
484  (compare(lengthview - lengthtext, lengthtext, text) == 0);
485  }
486 
487  //*************************************************************************
489  //*************************************************************************
490  size_type find(etl::basic_string_view<T, TTraits> view, size_type position = 0) const
491  {
492  if ((size() < view.size()))
493  {
494  return npos;
495  }
496 
497  const_iterator iposition = etl::search(begin() + position, end(), view.begin(), view.end());
498 
499  if (iposition == end())
500  {
501  return npos;
502  }
503  else
504  {
505  return etl::distance(begin(), iposition);
506  }
507  }
508 
509  size_type find(T c, size_type position = 0) const
510  {
511  return find(etl::basic_string_view<T, TTraits>(&c, 1), position);
512  }
513 
514  size_type find(const T* text, size_type position, size_type count) const
515  {
516  return find(etl::basic_string_view<T, TTraits>(text, count), position);
517  }
518 
519  size_type find(const T* text, size_type position = 0) const
520  {
521  return find(etl::basic_string_view<T, TTraits>(text), position);
522  }
523 
524  //*************************************************************************
526  //*************************************************************************
527  size_type rfind(etl::basic_string_view<T, TTraits> view, size_type position = npos) const
528  {
529  if ((size() < view.size()))
530  {
531  return npos;
532  }
533 
534  position = etl::min(position, size());
535 
536  const_iterator iposition = etl::find_end(begin(),
537  begin() + position,
538  view.begin(),
539  view.end());
540 
541  if (iposition == end())
542  {
543  return npos;
544  }
545  else
546  {
547  return etl::distance(begin(), iposition);
548  }
549  }
550 
551  size_type rfind(T c, size_type position = npos) const
552  {
553  return rfind(etl::basic_string_view<T, TTraits>(&c, 1), position);
554  }
555 
556  size_type rfind(const T* text, size_type position, size_type count) const
557  {
558  return rfind(etl::basic_string_view<T, TTraits>(text, count), position);
559  }
560 
561  size_type rfind(const T* text, size_type position = npos) const
562  {
563  return rfind(etl::basic_string_view<T, TTraits>(text), position);
564  }
565 
566  //*************************************************************************
568  //*************************************************************************
569  size_type find_first_of(etl::basic_string_view<T, TTraits> view, size_type position = 0) const
570  {
571  const size_t lengthtext = size();
572 
573  if (position < lengthtext)
574  {
575  for (size_t i = position; i < lengthtext; ++i)
576  {
577  const size_t lengthview = view.size();
578 
579  for (size_t j = 0; j < lengthview; ++j)
580  {
581  if (mbegin[i] == view[j])
582  {
583  return i;
584  }
585  }
586  }
587  }
588 
589  return npos;
590  }
591 
592  size_type find_first_of(T c, size_type position = 0) const
593  {
594  return find_first_of(etl::basic_string_view<T, TTraits>(&c, 1), position);
595  }
596 
597  size_type find_first_of(const T* text, size_type position, size_type count) const
598  {
599  return find_first_of(etl::basic_string_view<T, TTraits>(text, count), position);
600  }
601 
602  size_type find_first_of(const T* text, size_type position = 0) const
603  {
604  return find_first_of(etl::basic_string_view<T, TTraits>(text), position);
605  }
606 
607  //*************************************************************************
609  //*************************************************************************
610  size_type find_last_of(etl::basic_string_view<T, TTraits> view, size_type position = npos) const
611  {
612  if (empty())
613  {
614  return npos;
615  }
616 
617  position = etl::min(position, size() - 1);
618 
619  const_reverse_iterator it = rbegin() + size() - position - 1;
620 
621  while (it != rend())
622  {
623  const size_t viewlength = view.size();
624 
625  for (size_t j = 0; j < viewlength; ++j)
626  {
627  if (mbegin[position] == view[j])
628  {
629  return position;
630  }
631  }
632 
633  ++it;
634  --position;
635  }
636 
637  return npos;
638  }
639 
640  size_type find_last_of(T c, size_type position = npos) const
641  {
642  return find_last_of(etl::basic_string_view<T, TTraits>(&c, 1), position);
643  }
644 
645  size_type find_last_of(const T* text, size_type position, size_type count) const
646  {
647  return find_last_of(etl::basic_string_view<T, TTraits>(text, count), position);
648  }
649 
650  size_type find_last_of(const T* text, size_type position = npos) const
651  {
652  return find_last_of(etl::basic_string_view<T, TTraits>(text), position);
653  }
654 
655  //*************************************************************************
657  //*************************************************************************
658  size_type find_first_not_of(etl::basic_string_view<T, TTraits> view, size_type position = 0) const
659  {
660  const size_t lengthtext = size();
661 
662  if (position < lengthtext)
663  {
664  for (size_t i = position; i < lengthtext; ++i)
665  {
666  bool found = false;
667 
668  const size_t viewlength = view.size();
669 
670  for (size_t j = 0; j < viewlength; ++j)
671  {
672  if (mbegin[i] == view[j])
673  {
674  found = true;
675  }
676  }
677 
678  if (!found)
679  {
680  return i;
681  }
682  }
683  }
684 
685  return npos;
686  }
687 
688  size_type find_first_not_of(T c, size_type position = 0) const
689  {
690  return find_first_not_of(etl::basic_string_view<T, TTraits>(&c, 1), position);
691  }
692 
693  size_type find_first_not_of(const T* text, size_type position, size_type count) const
694  {
695  return find_first_not_of(etl::basic_string_view<T, TTraits>(text, count), position);
696  }
697 
698  size_type find_first_not_of(const T* text, size_type position = 0) const
699  {
701  }
702 
703  //*************************************************************************
705  //*************************************************************************
706  size_type find_last_not_of(etl::basic_string_view<T, TTraits> view, size_type position = npos) const
707  {
708  if (empty())
709  {
710  return npos;
711  }
712 
713  position = etl::min(position, size() - 1);
714 
715  const_reverse_iterator it = rbegin() + size() - position - 1;
716 
717  while (it != rend())
718  {
719  bool found = false;
720 
721  const size_t viewlength = view.size();
722 
723  for (size_t j = 0; j < viewlength; ++j)
724  {
725  if (mbegin[position] == view[j])
726  {
727  found = true;
728  }
729  }
730 
731  if (!found)
732  {
733  return position;
734  }
735 
736  ++it;
737  --position;
738  }
739 
740  return npos;
741  }
742 
743  size_type find_last_not_of(T c, size_type position = npos) const
744  {
745  return find_last_not_of(etl::basic_string_view<T, TTraits>(&c, 1), position);
746  }
747 
748  size_type find_last_not_of(const T* text, size_type position, size_type count) const
749  {
750  return find_last_not_of(etl::basic_string_view<T, TTraits>(text, count), position);
751  }
752 
753  size_type find_last_not_of(const T* text, size_type position = npos) const
754  {
756  }
757 
758  //*************************************************************************
760  //*************************************************************************
762  {
763  return (lhs.size() == rhs.size()) &&
764  etl::equal(lhs.begin(), lhs.end(), rhs.begin());
765  }
766 
767  //*************************************************************************
769  //*************************************************************************
771  {
772  return !(lhs == rhs);
773  }
774 
775  //*************************************************************************
777  //*************************************************************************
779  {
780  return etl::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
781  }
782 
783  //*************************************************************************
785  //*************************************************************************
787  {
788  return rhs < lhs;
789  }
790 
791  //*************************************************************************
793  //*************************************************************************
795  {
796  return !(lhs > rhs);
797  }
798 
799  //*************************************************************************
801  //*************************************************************************
803  {
804  return !(lhs < rhs);
805  }
806 
807  private:
808 
809  const T* mbegin;
810  const T* mend;
811  };
812 
813  typedef etl::basic_string_view<char> string_view;
814  typedef etl::basic_string_view<wchar_t> wstring_view;
815  typedef etl::basic_string_view<char16_t> u16string_view;
816  typedef etl::basic_string_view<char32_t> u32string_view;
817 
818  //*************************************************************************
820  //*************************************************************************
821  template<size_t ARRAY_SIZE>
822  string_view make_string_view(const char(&text)[ARRAY_SIZE])
823  {
824  return string_view(text, ARRAY_SIZE - 1U);
825  }
826 
827  template<size_t ARRAY_SIZE>
828  wstring_view make_string_view(const wchar_t(&text)[ARRAY_SIZE])
829  {
830  return wstring_view(text, ARRAY_SIZE - 1U);
831  }
832 
833  template<size_t ARRAY_SIZE>
834  u16string_view make_string_view(const char16_t(&text)[ARRAY_SIZE])
835  {
836  return u16string_view(text, ARRAY_SIZE - 1U);
837  }
838 
839  template<size_t ARRAY_SIZE>
840  u32string_view make_string_view(const char32_t(&text)[ARRAY_SIZE])
841  {
842  return u32string_view(text, ARRAY_SIZE - 1U);
843  }
844 
845  //*************************************************************************
847  //*************************************************************************
848 #if ETL_8BIT_SUPPORT
849  template <>
850  struct hash<etl::string_view>
851  {
852  size_t operator()(const etl::string_view& text) const
853  {
854  return etl::private_hash::generic_hash<size_t>(reinterpret_cast<const uint8_t*>(&text[0]),
855  reinterpret_cast<const uint8_t*>(&text[text.size()]));
856  }
857  };
858 
859  template <>
860  struct hash<etl::wstring_view>
861  {
862  size_t operator()(const etl::wstring_view& text) const
863  {
864  return etl::private_hash::generic_hash<size_t>(reinterpret_cast<const uint8_t*>(&text[0]),
865  reinterpret_cast<const uint8_t*>(&text[text.size()]));
866  }
867  };
868 
869  template <>
870  struct hash<etl::u16string_view>
871  {
872  size_t operator()(const etl::u16string_view& text) const
873  {
874  return etl::private_hash::generic_hash<size_t>(reinterpret_cast<const uint8_t*>(&text[0]),
875  reinterpret_cast<const uint8_t*>(&text[text.size()]));
876  }
877  };
878 
879  template <>
880  struct hash<etl::u32string_view>
881  {
882  size_t operator()(const etl::u32string_view& text) const
883  {
884  return etl::private_hash::generic_hash<size_t>(reinterpret_cast<const uint8_t*>(&text[0]),
885  reinterpret_cast<const uint8_t*>(&text[text.size()]));
886  }
887  };
888 #endif
889 }
890 
891 //*************************************************************************
893 //*************************************************************************
894 template <typename T, typename TTraits >
896 {
897  lhs.swap(rhs);
898 }
899 
900 template <typename T>
902 {
903  lhs.swap(rhs);
904 }
905 
906 #include "private/minmax_pop.h"
907 
908 #undef ETL_FILE
909 
910 #endif
911 
String view.
Definition: string_view.h:104
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:467
etl::basic_string_view< T, TTraits > & operator=(const etl::basic_string_view< T, TTraits > &other)
Assign from a view.
Definition: string_view.h:301
const_iterator cbegin() const
Returns a const iterator to the beginning of the array.
Definition: string_view.h:209
int compare(basic_string_view< T, TTraits > view) const
Compares two views.
Definition: string_view.h:410
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:445
const_reference operator[](size_t i) const
Returns a const reference to the indexed value.
Definition: string_view.h:331
const_iterator begin() const
Returns a const iterator to the beginning of the array.
Definition: string_view.h:201
size_type find(etl::basic_string_view< T, TTraits > view, size_type position=0) const
Find characters in the view.
Definition: string_view.h:490
const_reference back() const
Returns a const reference to the last element.
Definition: string_view.h:185
size_t length() const
Returns the size of the array.
Definition: string_view.h:285
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:527
friend bool operator>(const etl::basic_string_view< T, TTraits > &lhs, const etl::basic_string_view< T, TTraits > &rhs)
Greater-than for array views.
Definition: string_view.h:786
void swap(basic_string_view &other)
Swaps with another basic_string_view.
Definition: string_view.h:349
void assign(TIterator begin_, size_t size_)
Assign from iterator and size.
Definition: string_view.h:322
ETL_CONSTEXPR17 basic_string_view()
Default constructor.
Definition: string_view.h:123
size_t max_size() const
Returns the maximum possible size of the array.
Definition: string_view.h:293
void assign(TIterator begin_, TIterator end_)
Assign from iterators.
Definition: string_view.h:312
const_reverse_iterator crend() const
Returns a const reverse iterator to the end of the array.
Definition: string_view.h:257
basic_string_view substr(size_type position=0, size_type count=npos) const
Returns a substring.
Definition: string_view.h:377
friend bool operator<=(const etl::basic_string_view< T, TTraits > &lhs, const etl::basic_string_view< T, TTraits > &rhs)
Less-than-equal for array views.
Definition: string_view.h:794
const_pointer data() const
Returns a const pointer to the first element of the internal storage.
Definition: string_view.h:193
size_type copy(T *destination, size_type count, size_type position=0) const
Copies characters.
Definition: string_view.h:360
const_reverse_iterator crbegin() const
Returns a const reverse iterator to the reverse beginning of the array.
Definition: string_view.h:241
void remove_prefix(size_type n)
Shrinks the view by moving its start forward.
Definition: string_view.h:394
const_reference at(size_t i) const
Returns a const reference to the indexed value.
Definition: string_view.h:339
const_reference front() const
Returns a const reference to the first element.
Definition: string_view.h:177
bool empty() const
Returns true if the array size is zero.
Definition: string_view.h:269
const_reverse_iterator rbegin() const
Returns a const reverse iterator to the reverse beginning of the array.
Definition: string_view.h:233
friend bool operator<(const etl::basic_string_view< T, TTraits > &lhs, const etl::basic_string_view< T, TTraits > &rhs)
Less-than for array views.
Definition: string_view.h:778
const_reverse_iterator rend() const
Returns a const reverse iterator to the end of the array.
Definition: string_view.h:249
const_iterator end() const
Returns a const iterator to the end of the array.
Definition: string_view.h:217
friend bool operator!=(const etl::basic_string_view< T, TTraits > &lhs, const etl::basic_string_view< T, TTraits > &rhs)
Inequality for array views.
Definition: string_view.h:770
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:610
friend bool operator>=(const etl::basic_string_view< T, TTraits > &lhs, const etl::basic_string_view< T, TTraits > &rhs)
Greater-than-equal for array views.
Definition: string_view.h:802
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:569
friend bool operator==(const etl::basic_string_view< T, TTraits > &lhs, const etl::basic_string_view< T, TTraits > &rhs)
Equality for array views.
Definition: string_view.h:761
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:706
void remove_suffix(size_type n)
Shrinks the view by moving its end backward.
Definition: string_view.h:402
size_t size() const
Returns the size of the array.
Definition: string_view.h:277
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:658
Definition: basic_string.h:321
The base class for basic_string_view exceptions.
Definition: string_view.h:62
#define ETL_ASSERT(b, e)
Definition: error_handler.h:290
exception(string_type reason_, string_type file_, numeric_type line_)
Constructor.
Definition: exception.h:67
Definition: exception.h:47
Definition: integral_limits.h:54
T * addressof(T &t)
Definition: memory.h:61
Definition: string_view.h:76
Definition: string_view.h:90
Definition: absolute.h:37
string_view make_string_view(const char(&text)[ARRAY_SIZE])
make_string_view.
Definition: string_view.h:822
void swap(etl::basic_string_view< T, TTraits > &lhs, etl::basic_string_view< T, TTraits > &rhs)
Swaps the values.
Definition: string_view.h:895
Character traits for any character type.
Definition: char_traits.h:97