aws-crt-cpp
C++ wrapper around the aws-c-* libraries. Provides Cross-Platform Transport Protocols and SSL/TLS implementations for C++.
StringView.h
Go to the documentation of this file.
1#pragma once
11#include <algorithm>
12#include <cassert>
13#include <iterator>
14#include <limits>
15#include <stddef.h>
16#include <type_traits>
17
18#if __cplusplus >= 201703L || (defined(_MSC_LANG) && _MSC_LANG >= 201703L)
19# include <string_view>
20#endif
21
22namespace Aws
23{
24 namespace Crt
25 {
26 template <typename CharT, typename Traits = std::char_traits<CharT>> class basic_string_view
27 {
28 public:
29 // types
30 using traits_type = Traits;
31 using value_type = CharT;
33 using const_pointer = const value_type *;
35 using const_reference = const value_type &;
36 using const_iterator = const value_type *;
38 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
40 using size_type = size_t;
41 using difference_type = ptrdiff_t;
42 static constexpr size_type npos = static_cast<size_type>(-1);
43
44 // constructors and assignment
45
46 constexpr basic_string_view() noexcept : m_size{0}, m_data{nullptr} {}
47
48 constexpr basic_string_view(const basic_string_view &) noexcept = default;
49
50 constexpr basic_string_view(const CharT *s) noexcept : m_size{traits_type::length(s)}, m_data{s} {}
51
52 constexpr basic_string_view(const CharT *s, size_type length) noexcept : m_size{length}, m_data{s} {}
53
54 basic_string_view &operator=(const basic_string_view &) noexcept = default;
55
56#if __cplusplus >= 201703L || (defined(_MSC_LANG) && _MSC_LANG >= 201703L)
57 constexpr basic_string_view(const std::basic_string_view<CharT, Traits> &other) noexcept
58 : m_size(other.size()), m_data(other.data())
59 {
60 }
61
62 basic_string_view &operator=(const std::basic_string_view<CharT, Traits> &other) noexcept
63 {
64 m_data = other->data();
65 m_size = other->size();
66 return *this;
67 }
68#endif
69 // iterators
70
71 constexpr const_iterator begin() const noexcept { return this->m_data; }
72
73 constexpr const_iterator end() const noexcept { return this->m_data + this->m_size; }
74
75 constexpr const_iterator cbegin() const noexcept { return this->m_data; }
76
77 constexpr const_iterator cend() const noexcept { return this->m_data + this->m_size; }
78
79 constexpr const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(this->end()); }
80
81 constexpr const_reverse_iterator rend() const noexcept { return const_reverse_iterator(this->begin()); }
82
83 constexpr const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(this->end()); }
84
85 constexpr const_reverse_iterator crend() const noexcept { return const_reverse_iterator(this->begin()); }
86
87 constexpr size_type size() const noexcept { return this->m_size; }
88
89 constexpr size_type length() const noexcept { return m_size; }
90
91 constexpr size_type max_size() const noexcept { return (std::numeric_limits<size_type>::max)(); }
92
93 constexpr bool empty() const noexcept { return this->m_size == 0; }
94
95 // element accessors
96
98 {
99 assert(pos < m_size);
100 return *(this->m_data + pos);
101 }
102
104 {
105 assert(pos < m_size);
106 return *(this->m_data + pos);
107 }
108
109 const_reference front() const noexcept
110 {
111 assert(m_size > 0);
112 return *this->m_data;
113 }
114
115 const_reference back() const noexcept
116 {
117 assert(m_size > 0);
118 return *(this->m_data + this->m_size - 1);
119 }
120
121 constexpr const_pointer data() const noexcept { return this->m_data; }
122
123 // modifiers
124 void remove_prefix(size_type n) noexcept
125 {
126 assert(this->m_size >= n);
127 this->m_data += n;
128 this->m_size -= n;
129 }
130
131 void remove_suffix(size_type n) noexcept { this->m_size -= n; }
132
133 void swap(basic_string_view &other) noexcept
134 {
135 auto tmp = *this;
136 *this = other;
137 other = tmp;
138 }
139
140 // string operations
141 size_type copy(CharT *s, size_type n, size_type pos = 0) const
142 {
143 assert(pos <= size());
144 const size_type copyLen = (std::min)(n, m_size - pos);
145 traits_type::copy(s, data() + pos, copyLen);
146 return copyLen;
147 }
148
149 basic_string_view substr(size_type pos = 0, size_type n = npos) const noexcept(false)
150 {
151 assert(pos <= size());
152 const size_type copyLen = (std::min)(n, m_size - pos);
153 return basic_string_view{m_data + pos, copyLen};
154 }
155
156 int compare(const basic_string_view &s) const noexcept
157 {
158 const size_type compareLen = (std::min)(this->m_size, s.m_size);
159 int ret = traits_type::compare(this->m_data, s.m_data, compareLen);
160 if (ret == 0)
161 {
162 ret = _s_compare(this->m_size, s.m_size);
163 }
164 return ret;
165 }
166
167 constexpr int compare(size_type pos1, size_type n1, const basic_string_view &s) const
168 {
169 return this->substr(pos1, n1).compare(s);
170 }
171
172 constexpr int compare(
173 size_type pos1,
174 size_type n1,
175 const basic_string_view &s,
176 size_type pos2,
177 size_type n2) const
178 {
179 return this->substr(pos1, n1).compare(s.substr(pos2, n2));
180 }
181
182 constexpr int compare(const CharT *s) const noexcept { return this->compare(basic_string_view{s}); }
183
184 constexpr int compare(size_type pos1, size_type n1, const CharT *s) const
185 {
186 return this->substr(pos1, n1).compare(basic_string_view{s});
187 }
188
189 constexpr int compare(size_type pos1, size_type n1, const CharT *s, size_type n2) const noexcept(false)
190 {
191 return this->substr(pos1, n1).compare(basic_string_view(s, n2));
192 }
193
194 constexpr bool starts_with(const basic_string_view &other) const noexcept
195 {
196 return this->substr(0, other.size()) == other;
197 }
198
199 constexpr bool starts_with(CharT c) const noexcept
200 {
201 return !this->empty() && traits_type::eq(this->front(), c);
202 }
203
204 constexpr bool starts_with(const CharT *s) const noexcept
205 {
206 return this->starts_with(basic_string_view(s));
207 }
208
209 constexpr bool ends_with(const basic_string_view &other) const noexcept
210 {
211 return this->m_size >= other.m_size && this->compare(this->m_size - other.m_size, npos, other) == 0;
212 }
213
214 constexpr bool ends_with(CharT c) const noexcept
215 {
216 return !this->empty() && traits_type::eq(this->back(), c);
217 }
218
219 constexpr bool ends_with(const CharT *s) const noexcept { return this->ends_with(basic_string_view(s)); }
220
221 // find utilities
222 constexpr size_type find(const basic_string_view &s, size_type pos = 0) const noexcept
223 {
224 return this->find(s.m_data, pos, s.m_size);
225 }
226
227 size_type find(CharT c, size_type pos = 0) const noexcept
228 {
229 if (pos >= m_size)
230 {
231 return npos;
232 }
233 const CharT *r = Traits::find(m_data + pos, m_size - pos, c);
234 if (r == nullptr)
235 {
236 return npos;
237 }
238 return static_cast<size_type>(r - m_data);
239 }
240
241 size_type find(const CharT *s, size_type pos, size_type n) const noexcept
242 {
243 if (n && !s)
244 {
245 return npos;
246 }
247
248 if (pos > m_size)
249 {
250 return npos;
251 }
252
253 if (n == 0)
254 {
255 return pos;
256 }
257
258 const CharT *r = _s_search_substr(m_data + pos, m_data + m_size, s, s + n);
259
260 if (r == m_data + m_size)
261 {
262 return npos;
263 }
264 return static_cast<size_type>(r - m_data);
265 }
266
267 constexpr size_type find(const CharT *s, size_type pos = 0) const noexcept
268 {
269 return this->find(s, pos, traits_type::length(s));
270 }
271
273 {
274 if (s.m_size && !s.m_data)
275 {
276 return npos;
277 }
278 return this->rfind(s.m_data, pos, s.m_size);
279 }
280
281 size_type rfind(CharT c, size_type pos = npos) const noexcept
282 {
283 if (m_size <= 0)
284 {
285 return npos;
286 }
287
288 if (pos < m_size)
289 {
290 ++pos;
291 }
292 else
293 {
294 pos = m_size;
295 }
296
297 for (const CharT *ptr = m_data + pos; ptr != m_data;)
298 {
299 if (Traits::eq(*--ptr, c))
300 {
301 return static_cast<size_type>(ptr - m_data);
302 }
303 }
304 return npos;
305 }
306
307 size_type rfind(const CharT *s, size_type pos, size_type n) const noexcept
308 {
309 if (n && !s)
310 {
311 return npos;
312 }
313
314 pos = (std::min)(pos, m_size);
315 if (n < m_size - pos)
316 {
317 pos += n;
318 }
319 else
320 {
321 pos = m_size;
322 }
323 const CharT *r = _s_find_end(m_data, m_data + pos, s, s + n);
324 if (n > 0 && r == m_data + pos)
325 {
326 return npos;
327 }
328 return static_cast<size_type>(r - m_data);
329 }
330
331 constexpr size_type rfind(const CharT *s, size_type pos = npos) const noexcept
332 {
333 return this->rfind(s, pos, traits_type::length(s));
334 }
335
336 constexpr size_type find_first_of(basic_string_view s, size_type pos = 0) const noexcept
337 {
338 return this->find_first_of(s.m_data, pos, s.m_size);
339 }
340
341 constexpr size_type find_first_of(CharT c, size_type pos = 0) const noexcept { return this->find(c, pos); }
342
343 size_type find_first_of(const CharT *s, size_type pos, size_type n) const noexcept
344 {
345 if (pos >= m_size || !n || !s)
346 {
347 return npos;
348 }
349
350 const CharT *r = _s_find_first_of_ce(m_data + pos, m_data + m_size, s, s + n);
351
352 if (r == m_data + m_size)
353 {
354 return npos;
355 }
356
357 return static_cast<size_type>(r - m_data);
358 }
359
360 constexpr size_type find_first_of(const CharT *s, size_type pos = 0) const noexcept
361 {
362 return this->find_first_of(s, pos, traits_type::length(s));
363 }
364
365 constexpr size_type find_last_of(basic_string_view s, size_type pos = npos) const noexcept
366 {
367 return this->find_last_of(s.m_data, pos, s.m_size);
368 }
369
370 constexpr size_type find_last_of(CharT c, size_type pos = npos) const noexcept
371 {
372 return this->rfind(c, pos);
373 }
374
375 size_type find_last_of(const CharT *s, size_type pos, size_type n) const noexcept
376 {
377 if (!n || s == nullptr)
378 {
379 return npos;
380 }
381
382 if (pos < m_size)
383 {
384 ++pos;
385 }
386 else
387 {
388 pos = m_size;
389 }
390
391 for (const CharT *ptr = m_data + pos; ptr != m_data;)
392 {
393 const CharT *r = Traits::find(s, n, *--ptr);
394 if (r)
395 {
396 return static_cast<size_type>(ptr - m_data);
397 }
398 }
399
400 return npos;
401 }
402
403 constexpr size_type find_last_of(const CharT *s, size_type pos = npos) const noexcept
404 {
405 return this->find_last_of(s, pos, traits_type::length(s));
406 }
407
409 {
410 if (s.m_size && !s.m_data)
411 {
412 return npos;
413 }
414 return this->find_first_not_of(s.m_data, pos, s.m_size);
415 }
416
417 size_type find_first_not_of(CharT c, size_type pos = 0) const noexcept
418 {
419 if (!m_data || pos >= m_size)
420 {
421 return npos;
422 }
423
424 const CharT *pend = m_data + m_size;
425 for (const CharT *ptr = m_data + pos; ptr != pend; ++ptr)
426 {
427 if (!Traits::eq(*ptr, c))
428 {
429 return static_cast<size_type>(ptr - m_data);
430 }
431 }
432
433 return npos;
434 }
435
436 size_type find_first_not_of(const CharT *s, size_type pos, size_type n) const noexcept
437 {
438 if (n && s == nullptr)
439 {
440 return npos;
441 }
442
443 if (m_data == nullptr || pos >= m_size)
444 {
445 return npos;
446 }
447
448 const CharT *pend = m_data + m_size;
449 for (const CharT *ptr = m_data + pos; ptr != pend; ++ptr)
450 {
451 if (Traits::find(s, n, *ptr) == 0)
452 {
453 return static_cast<size_type>(ptr - m_data);
454 }
455 }
456
457 return npos;
458 }
459
460 constexpr size_type find_first_not_of(const CharT *s, size_type pos = 0) const noexcept
461 {
462 return this->find_first_not_of(s, pos, traits_type::length(s));
463 }
464
466 {
467 if (s.m_size && !s.m_data)
468 {
469 return npos;
470 }
471 return this->find_last_not_of(s.m_data, pos, s.m_size);
472 }
473
474 size_type find_last_not_of(CharT c, size_type pos = npos) const noexcept
475 {
476 if (pos < m_size)
477 {
478 ++pos;
479 }
480 else
481 {
482 pos = m_size;
483 }
484
485 for (const CharT *ptr = m_data + pos; ptr != m_data;)
486 {
487 if (!Traits::eq(*--ptr, c))
488 {
489 return static_cast<size_type>(ptr - m_data);
490 }
491 }
492 return npos;
493 }
494
495 size_type find_last_not_of(const CharT *s, size_type pos, size_type n) const noexcept
496 {
497 if (n && !s)
498 {
499 return npos;
500 }
501
502 if (pos < m_size)
503 {
504 ++pos;
505 }
506 else
507 {
508 pos = m_size;
509 }
510
511 for (const CharT *ptr = m_data + pos; ptr != m_data;)
512 {
513 if (Traits::find(s, n, *--ptr) == 0)
514 {
515 return static_cast<size_type>(ptr - m_data);
516 }
517 }
518 return npos;
519 }
520
521 constexpr size_type find_last_not_of(const CharT *s, size_type pos = npos) const noexcept
522 {
523 return this->find_last_not_of(s, pos, traits_type::length(s));
524 }
525
526 private:
527 static int _s_compare(size_type n1, size_type n2) noexcept
528 {
529 const difference_type diff = n1 - n2;
530
531 if (diff > (std::numeric_limits<int>::max)())
532 {
533 return (std::numeric_limits<int>::max)();
534 }
535
536 if (diff < (std::numeric_limits<int>::min)())
537 {
538 return (std::numeric_limits<int>::min)();
539 }
540
541 return static_cast<int>(diff);
542 }
543
544 static const CharT *_s_search_substr(
545 const CharT *first1,
546 const CharT *last1,
547 const CharT *first2,
548 const CharT *last2)
549 {
550 const ptrdiff_t length2 = last2 - first2;
551 if (length2 == 0)
552 {
553 return first1;
554 }
555
556 ptrdiff_t length1 = last1 - first1;
557 if (length1 < length2)
558 {
559 return last1;
560 }
561
562 while (true)
563 {
564 length1 = last1 - first1;
565 if (length1 < length2)
566 {
567 return last1;
568 }
569
570 first1 = Traits::find(first1, length1 - length2 + 1, *first2);
571 if (first1 == 0)
572 {
573 return last1;
574 }
575
576 if (Traits::compare(first1, first2, length2) == 0)
577 {
578 return first1;
579 }
580
581 ++first1;
582 }
583 }
584
585 static const CharT *_s_find_end(
586 const CharT *first1,
587 const CharT *last1,
588 const CharT *first2,
589 const CharT *last2)
590 {
591 const CharT *r = last1;
592 if (first2 == last2)
593 {
594 return r;
595 }
596
597 while (true)
598 {
599 while (true)
600 {
601 if (first1 == last1)
602 {
603 return r;
604 }
605 if (Traits::eq(*first1, *first2))
606 {
607 break;
608 }
609 ++first1;
610 }
611
612 const CharT *m1 = first1;
613 const CharT *m2 = first2;
614 while (true)
615 {
616 if (++m2 == last2)
617 {
618 r = first1;
619 ++first1;
620 break;
621 }
622 if (++m1 == last1)
623 {
624 return r;
625 }
626 if (!Traits::eq(*m1, *m2))
627 {
628 ++first1;
629 break;
630 }
631 }
632 }
633 }
634
635 static const CharT *_s_find_first_of_ce(
636 const CharT *first1,
637 const CharT *last1,
638 const CharT *first2,
639 const CharT *last2)
640 {
641 for (; first1 != last1; ++first1)
642 {
643 for (const CharT *ptr = first2; ptr != last2; ++ptr)
644 {
645 if (Traits::eq(*first1, *ptr))
646 {
647 return first1;
648 }
649 }
650 }
651 return last1;
652 }
653
654 size_type m_size;
655 const CharT *m_data;
656 };
657
658 // operator ==
659 template <class CharT, class Traits>
662 const basic_string_view<CharT, Traits> &rhs) noexcept
663 {
664 return (lhs.size() != rhs.size()) ? false : lhs.compare(rhs) == 0;
665 }
666
667 template <class CharT, class Traits>
670 typename std::common_type<basic_string_view<CharT, Traits>>::type &rhs) noexcept
671 {
672 return (lhs.size() != rhs.size()) ? false : lhs.compare(rhs) == 0;
673 }
674
675 template <class CharT, class Traits>
677 typename std::common_type<basic_string_view<CharT, Traits>>::type &lhs,
678 const basic_string_view<CharT, Traits> &rhs) noexcept
679 {
680 return (lhs.size() != rhs.size()) ? false : lhs.compare(rhs) == 0;
681 }
682
683 // operator !=
684 template <class CharT, class Traits>
687 const basic_string_view<CharT, Traits> &rhs) noexcept
688 {
689 return (lhs.size() != rhs.size()) ? true : lhs.compare(rhs) != 0;
690 }
691
692 template <class CharT, class Traits>
695 typename std::common_type<basic_string_view<CharT, Traits>>::type &rhs) noexcept
696 {
697 return (lhs.size() != rhs.size()) ? true : lhs.compare(rhs) != 0;
698 }
699
700 template <class CharT, class Traits>
702 typename std::common_type<basic_string_view<CharT, Traits>>::type &lhs,
703 const basic_string_view<CharT, Traits> &rhs) noexcept
704 {
705 return (lhs.size() != rhs.size()) ? true : lhs.compare(rhs) != 0;
706 }
707
708 // operator <
709 template <class CharT, class Traits>
712 const basic_string_view<CharT, Traits> &rhs) noexcept
713 {
714 return lhs.compare(rhs) < 0;
715 }
716
717 template <class CharT, class Traits>
718 constexpr bool operator<(
720 typename std::common_type<basic_string_view<CharT, Traits>>::type &rhs) noexcept
721 {
722 return lhs.compare(rhs) < 0;
723 }
724
725 template <class CharT, class Traits>
726 constexpr bool operator<(
727 typename std::common_type<basic_string_view<CharT, Traits>>::type &lhs,
728 const basic_string_view<CharT, Traits> &rhs) noexcept
729 {
730 return lhs.compare(rhs) < 0;
731 }
732
733 // operator >
734 template <class CharT, class Traits>
735 constexpr bool operator>(
737 const basic_string_view<CharT, Traits> &rhs) noexcept
738 {
739 return lhs.compare(rhs) > 0;
740 }
741
742 template <class CharT, class Traits>
743 constexpr bool operator>(
745 typename std::common_type<basic_string_view<CharT, Traits>>::type &rhs) noexcept
746 {
747 return lhs.compare(rhs) > 0;
748 }
749
750 template <class CharT, class Traits>
751 constexpr bool operator>(
752 typename std::common_type<basic_string_view<CharT, Traits>>::type &lhs,
753 const basic_string_view<CharT, Traits> &rhs) noexcept
754 {
755 return lhs.compare(rhs) > 0;
756 }
757
758 // operator <=
759 template <class CharT, class Traits>
760 constexpr bool operator<=(
762 const basic_string_view<CharT, Traits> &rhs) noexcept
763 {
764 return lhs.compare(rhs) <= 0;
765 }
766
767 template <class CharT, class Traits>
768 constexpr bool operator<=(
770 typename std::common_type<basic_string_view<CharT, Traits>>::type &rhs) noexcept
771 {
772 return lhs.compare(rhs) <= 0;
773 }
774
775 template <class CharT, class Traits>
776 constexpr bool operator<=(
777 typename std::common_type<basic_string_view<CharT, Traits>>::type &lhs,
778 const basic_string_view<CharT, Traits> &rhs) noexcept
779 {
780 return lhs.compare(rhs) <= 0;
781 }
782
783 // operator >=
784 template <class CharT, class Traits>
785 constexpr bool operator>=(
787 const basic_string_view<CharT, Traits> &rhs) noexcept
788 {
789 return lhs.compare(rhs) >= 0;
790 }
791
792 template <class CharT, class Traits>
793 constexpr bool operator>=(
795 typename std::common_type<basic_string_view<CharT, Traits>>::type &rhs) noexcept
796 {
797 return lhs.compare(rhs) >= 0;
798 }
799
800 template <class CharT, class Traits>
801 constexpr bool operator>=(
802 typename std::common_type<basic_string_view<CharT, Traits>>::type &lhs,
803 const basic_string_view<CharT, Traits> &rhs) noexcept
804 {
805 return lhs.compare(rhs) >= 0;
806 }
807
812
813 inline namespace literals
814 {
815 inline namespace string_view_literals
816 {
817 inline basic_string_view<char> operator"" _sv(const char *s, size_t length) noexcept
818 {
820 }
821
822 inline basic_string_view<wchar_t> operator"" _sv(const wchar_t *s, size_t length) noexcept
823 {
825 }
826
827 inline basic_string_view<char16_t> operator"" _sv(const char16_t *s, size_t length) noexcept
828 {
830 }
831
832 inline basic_string_view<char32_t> operator"" _sv(const char32_t *s, size_t length) noexcept
833 {
835 }
836 } // namespace string_view_literals
837
838 } // namespace literals
839
841 } // namespace Crt
842} // namespace Aws
843
844// hash
845namespace std
846{
847 template <class CharT, class Traits> struct hash<Aws::Crt::basic_string_view<CharT, Traits>>
848 {
849 size_t operator()(const Aws::Crt::basic_string_view<CharT, Traits> &val) const noexcept;
850 };
851
852 template <class CharT, class Traits>
853 size_t hash<Aws::Crt::basic_string_view<CharT, Traits>>::operator()(
854 const Aws::Crt::basic_string_view<CharT, Traits> &val) const noexcept
855 {
856 auto str = std::basic_string<CharT, Traits>(val.data(), val.size());
857 return std::hash<std::basic_string<CharT, Traits>>()(str);
858 }
859} // namespace std
Definition: StringView.h:27
constexpr const_iterator begin() const noexcept
Definition: StringView.h:71
constexpr size_type find(const CharT *s, size_type pos=0) const noexcept
Definition: StringView.h:267
constexpr size_type rfind(const CharT *s, size_type pos=npos) const noexcept
Definition: StringView.h:331
size_type find(CharT c, size_type pos=0) const noexcept
Definition: StringView.h:227
size_type find_first_not_of(CharT c, size_type pos=0) const noexcept
Definition: StringView.h:417
constexpr int compare(size_type pos1, size_type n1, const CharT *s) const
Definition: StringView.h:184
constexpr basic_string_view(const basic_string_view &) noexcept=default
constexpr int compare(size_type pos1, size_type n1, const basic_string_view &s) const
Definition: StringView.h:167
constexpr int compare(size_type pos1, size_type n1, const CharT *s, size_type n2) const noexcept(false)
Definition: StringView.h:189
constexpr const_iterator end() const noexcept
Definition: StringView.h:73
value_type * pointer
Definition: StringView.h:32
Traits traits_type
Definition: StringView.h:30
constexpr basic_string_view(const CharT *s, size_type length) noexcept
Definition: StringView.h:52
void remove_suffix(size_type n) noexcept
Definition: StringView.h:131
constexpr size_type find(const basic_string_view &s, size_type pos=0) const noexcept
Definition: StringView.h:222
constexpr size_type find_first_of(basic_string_view s, size_type pos=0) const noexcept
Definition: StringView.h:336
constexpr const_iterator cbegin() const noexcept
Definition: StringView.h:75
const_reference front() const noexcept
Definition: StringView.h:109
size_type copy(CharT *s, size_type n, size_type pos=0) const
Definition: StringView.h:141
constexpr const_reverse_iterator rend() const noexcept
Definition: StringView.h:81
size_type find_last_of(const CharT *s, size_type pos, size_type n) const noexcept
Definition: StringView.h:375
const_reference operator[](size_type pos) const noexcept
Definition: StringView.h:97
constexpr size_type find_last_of(basic_string_view s, size_type pos=npos) const noexcept
Definition: StringView.h:365
constexpr const_reverse_iterator crbegin() const noexcept
Definition: StringView.h:83
ptrdiff_t difference_type
Definition: StringView.h:41
size_t size_type
Definition: StringView.h:40
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: StringView.h:38
constexpr const_reverse_iterator crend() const noexcept
Definition: StringView.h:85
constexpr bool ends_with(const CharT *s) const noexcept
Definition: StringView.h:219
value_type & reference
Definition: StringView.h:34
size_type find_first_not_of(const CharT *s, size_type pos, size_type n) const noexcept
Definition: StringView.h:436
size_type rfind(const CharT *s, size_type pos, size_type n) const noexcept
Definition: StringView.h:307
constexpr size_type find_first_not_of(const CharT *s, size_type pos=0) const noexcept
Definition: StringView.h:460
constexpr const_iterator cend() const noexcept
Definition: StringView.h:77
const_reference at(size_type pos) const
Definition: StringView.h:103
static constexpr size_type npos
Definition: StringView.h:42
constexpr bool empty() const noexcept
Definition: StringView.h:93
constexpr size_type size() const noexcept
Definition: StringView.h:87
constexpr basic_string_view(const CharT *s) noexcept
Definition: StringView.h:50
const_reverse_iterator reverse_iterator
Definition: StringView.h:39
size_type find_last_not_of(CharT c, size_type pos=npos) const noexcept
Definition: StringView.h:474
basic_string_view & operator=(const basic_string_view &) noexcept=default
constexpr bool ends_with(const basic_string_view &other) const noexcept
Definition: StringView.h:209
constexpr bool starts_with(const CharT *s) const noexcept
Definition: StringView.h:204
size_type find(const CharT *s, size_type pos, size_type n) const noexcept
Definition: StringView.h:241
size_type find_last_not_of(const CharT *s, size_type pos, size_type n) const noexcept
Definition: StringView.h:495
void remove_prefix(size_type n) noexcept
Definition: StringView.h:124
size_type find_last_not_of(basic_string_view s, size_type pos=npos) const noexcept
Definition: StringView.h:465
size_type find_first_not_of(basic_string_view s, size_type pos=0) const noexcept
Definition: StringView.h:408
basic_string_view substr(size_type pos=0, size_type n=npos) const noexcept(false)
Definition: StringView.h:149
size_type rfind(basic_string_view s, size_type pos=npos) const noexcept
Definition: StringView.h:272
int compare(const basic_string_view &s) const noexcept
Definition: StringView.h:156
constexpr bool ends_with(CharT c) const noexcept
Definition: StringView.h:214
constexpr int compare(size_type pos1, size_type n1, const basic_string_view &s, size_type pos2, size_type n2) const
Definition: StringView.h:172
const_iterator iterator
Definition: StringView.h:37
constexpr size_type find_last_of(const CharT *s, size_type pos=npos) const noexcept
Definition: StringView.h:403
constexpr const_reverse_iterator rbegin() const noexcept
Definition: StringView.h:79
constexpr size_type max_size() const noexcept
Definition: StringView.h:91
constexpr size_type find_last_of(CharT c, size_type pos=npos) const noexcept
Definition: StringView.h:370
constexpr size_type find_first_of(const CharT *s, size_type pos=0) const noexcept
Definition: StringView.h:360
size_type rfind(CharT c, size_type pos=npos) const noexcept
Definition: StringView.h:281
const value_type & const_reference
Definition: StringView.h:35
constexpr bool starts_with(CharT c) const noexcept
Definition: StringView.h:199
const value_type * const_pointer
Definition: StringView.h:33
constexpr size_type find_last_not_of(const CharT *s, size_type pos=npos) const noexcept
Definition: StringView.h:521
const value_type * const_iterator
Definition: StringView.h:36
constexpr basic_string_view() noexcept
Definition: StringView.h:46
CharT value_type
Definition: StringView.h:31
constexpr size_type find_first_of(CharT c, size_type pos=0) const noexcept
Definition: StringView.h:341
const_reference back() const noexcept
Definition: StringView.h:115
constexpr const_pointer data() const noexcept
Definition: StringView.h:121
constexpr size_type length() const noexcept
Definition: StringView.h:89
constexpr int compare(const CharT *s) const noexcept
Definition: StringView.h:182
void swap(basic_string_view &other) noexcept
Definition: StringView.h:133
constexpr bool starts_with(const basic_string_view &other) const noexcept
Definition: StringView.h:194
size_type find_first_of(const CharT *s, size_type pos, size_type n) const noexcept
Definition: StringView.h:343
basic_string_view< char32_t > u32string_view
Definition: StringView.h:810
basic_string_view< char > string_view
Definition: StringView.h:808
constexpr bool operator<=(const basic_string_view< CharT, Traits > &lhs, const basic_string_view< CharT, Traits > &rhs) noexcept
Definition: StringView.h:760
bool operator<(const basic_string_view< CharT, Traits > &lhs, const basic_string_view< CharT, Traits > &rhs) noexcept
Definition: StringView.h:710
constexpr bool operator>=(const basic_string_view< CharT, Traits > &lhs, const basic_string_view< CharT, Traits > &rhs) noexcept
Definition: StringView.h:785
constexpr bool operator>(const basic_string_view< CharT, Traits > &lhs, const basic_string_view< CharT, Traits > &rhs) noexcept
Definition: StringView.h:735
basic_string_view< wchar_t > wstring_view
Definition: StringView.h:811
basic_string_view< char16_t > u16string_view
Definition: StringView.h:809
bool operator==(const basic_string_view< CharT, Traits > &lhs, const basic_string_view< CharT, Traits > &rhs) noexcept
Definition: StringView.h:660
bool operator!=(const basic_string_view< CharT, Traits > &lhs, const basic_string_view< CharT, Traits > &rhs) noexcept
Definition: StringView.h:685
Definition: Api.h:17
newitem type
Definition: cJSON.cpp:2724
char const int length
Definition: cJSON.h:181
cJSON * n
Definition: cJSON.cpp:2560
copy
Definition: cJSON.cpp:432
return true
Definition: cJSON.cpp:2306
Definition: StringView.h:846