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