Embedded Template Library 1.0
Loading...
Searching...
No Matches
string_utilities.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) 2020 John Wellbelove, John Lagerquist
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_UTILITIES_INCLUDED
32#define ETL_STRING_UTILITIES_INCLUDED
33
34#include "platform.h"
35#include "algorithm.h"
36#include "char_traits.h"
37#include "enum_type.h"
38#include "memory.h"
39#include "optional.h"
40
41#include <ctype.h>
42#include <stdint.h>
43
44#include "private/minmax_push.h"
45
46namespace etl
47{
48 //***************************************************************************
50 //***************************************************************************
52 {
53 enum enum_type
54 {
55 LEFT,
56 RIGHT,
57 };
58
60 ETL_ENUM_TYPE(LEFT, "left")
61 ETL_ENUM_TYPE(RIGHT, "right")
62 ETL_END_ENUM_TYPE
63 };
64
65 //***************************************************************************
67 //***************************************************************************
68 template <typename TChar>
69 struct whitespace;
70
71 template <>
72 struct whitespace<char>
73 {
74 static ETL_CONSTEXPR const char* value()
75 {
76 return " \t\n\r\f\v";
77 }
78 };
79
80#if ETL_USING_CPP20
81 template <>
82 struct whitespace<char8_t>
83 {
84 static ETL_CONSTEXPR const char8_t* value()
85 {
86 return u8" \t\n\r\f\v";
87 }
88 };
89#endif
90
91 template <>
92 struct whitespace<wchar_t>
93 {
94 static ETL_CONSTEXPR const wchar_t* value()
95 {
96 return L" \t\n\r\f\v";
97 }
98 };
99
100#if ETL_USING_CPP11
101 template <>
102 struct whitespace<char16_t>
103 {
104 static ETL_CONSTEXPR const char16_t* value()
105 {
106 return u" \t\n\r\f\v";
107 }
108 };
109
110 template <>
111 struct whitespace<char32_t>
112 {
113 static ETL_CONSTEXPR const char32_t* value()
114 {
115 return U" \t\n\r\f\v";
116 }
117 };
118#endif
119
120#if ETL_USING_CPP17
121 template <typename TChar>
122 inline constexpr const TChar* whitespace_v = whitespace<TChar>::value();
123#endif
124
125 //***************************************************************************
128 //***************************************************************************
129 template <typename TIString>
130 void trim_from_left(TIString& s, typename TIString::const_pointer trim_characters)
131 {
132 typename TIString::size_type position = s.find_first_not_of(trim_characters);
133 s.erase(0U, position);
134 }
135
136 //***************************************************************************
139 //***************************************************************************
140 template <typename TIString>
145
146 //***************************************************************************
149 //***************************************************************************
150 template <typename TStringView>
151 TStringView trim_from_view_left(const TStringView& view, typename TStringView::const_pointer trim_characters)
152 {
153 typename TStringView::size_type first = view.find_first_not_of(trim_characters);
154
155 typename TStringView::const_pointer pbegin = view.data() + view.size();
156
157 if (first != TStringView::npos)
158 {
159 pbegin = view.data() + first;
160 }
161
162 return TStringView(pbegin, static_cast<size_t>(etl::distance(pbegin, view.data() + view.size())));
163 }
164
165 //***************************************************************************
168 //***************************************************************************
169 template <typename TStringView>
174
175 //***************************************************************************
178 //***************************************************************************
179 template <typename TIString>
180 void trim_left(TIString& s, typename TIString::const_pointer delimiters)
181 {
182 typename TIString::size_type p = s.find_first_of(delimiters);
183
184 if (p == TIString::npos)
185 {
186 s.clear();
187 }
188 else
189 {
190 s.erase(0, p);
191 }
192 }
193
194 //***************************************************************************
197 //***************************************************************************
198 template <typename TStringView>
199 TStringView trim_view_left(const TStringView& view, typename TStringView::const_pointer delimiters)
200 {
201 typename TStringView::size_type first = view.find_first_of(delimiters);
202
203 typename TStringView::const_pointer pbegin = view.data();
204
205 if (first != TStringView::npos)
206 {
207 pbegin += first;
208 return TStringView(pbegin, view.size() - first);
209 }
210 else
211 {
212 return TStringView(pbegin, typename TStringView::size_type(0U));
213 }
214 }
215
216 //***************************************************************************
219 //***************************************************************************
220 template <typename TIString>
221 void trim_from_right(TIString& s, typename TIString::const_pointer trim_characters)
222 {
223 s.erase(s.find_last_not_of(trim_characters) + 1);
224 }
225
226 //***************************************************************************
229 //***************************************************************************
230 template <typename TIString>
235
236 //***************************************************************************
239 //***************************************************************************
240 template <typename TStringView>
241 TStringView trim_from_view_right(const TStringView& view, typename TStringView::const_pointer trim_characters)
242 {
243 typename TStringView::size_type last = view.find_last_not_of(trim_characters) + 1;
244
245 typename TStringView::const_pointer pend = view.data();
246
247 if (last != TStringView::npos)
248 {
249 pend += last;
250 }
251
252 return TStringView(view.data(), static_cast<size_t>(etl::distance(view.data(), pend)));
253 }
254
255 //***************************************************************************
258 //***************************************************************************
259 template <typename TStringView>
260 TStringView trim_view_whitespace_right(TStringView& view)
261 {
263 }
264
265 //***************************************************************************
267 //***************************************************************************
268 template <typename TIString>
269 void trim_right(TIString& s, typename TIString::const_pointer delimiters)
270 {
271 typename TIString::size_type p = s.find_last_of(delimiters);
272
273 if (p == TIString::npos)
274 {
275 s.clear();
276 }
277 else
278 {
279 ++p;
280
281 if (p != s.size())
282 {
283 s.erase(p);
284 }
285 }
286 }
287
288 //***************************************************************************
290 //***************************************************************************
291 template <typename TStringView>
292 TStringView trim_view_right(const TStringView& view, typename TStringView::const_pointer delimiters)
293 {
294 typename TStringView::size_type last = view.find_last_of(delimiters) + 1;
295
296 typename TStringView::const_pointer pend = view.data();
297
298 if (last != TStringView::npos)
299 {
300 pend += last;
301 return TStringView(view.data(), static_cast<size_t>(etl::distance(view.data(), pend)));
302 }
303 else
304 {
305 return TStringView(view.data(), typename TStringView::size_type(0U));
306 }
307 }
308
309 //***************************************************************************
312 //***************************************************************************
313 template <typename TIString>
314 void trim_from(TIString& s, typename TIString::const_pointer trim_characters)
315 {
316 trim_from_left(s, trim_characters);
317 trim_from_right(s, trim_characters);
318 }
319
320 //***************************************************************************
323 //***************************************************************************
324 template <typename TIString>
329
330 //***************************************************************************
333 //***************************************************************************
334 template <typename TStringView>
335 TStringView trim_from_view(const TStringView& view, typename TStringView::const_pointer trim_characters)
336 {
337 typename TStringView::size_type first = view.find_first_not_of(trim_characters);
338 typename TStringView::size_type last = view.find_last_not_of(trim_characters) + 1;
339
340 typename TStringView::const_pointer pbegin = view.data();
341 typename TStringView::const_pointer pend = view.data();
342
343 if (first != TStringView::npos)
344 {
345 pbegin += first;
346 }
347
348 if (last != TStringView::npos)
349 {
350 pend += last;
351 }
352
353 return TStringView(pbegin, static_cast<size_t>(etl::distance(pbegin, pend)));
354 }
355
356 //***************************************************************************
359 //***************************************************************************
360 template <typename TStringView>
361 TStringView trim_view_whitespace(const TStringView& view)
362 {
364 }
365
366 //***************************************************************************
369 //***************************************************************************
370 template <typename TIString>
371 void trim(TIString& s, typename TIString::const_pointer delimiters)
372 {
373 trim_left(s, delimiters);
374 trim_right(s, delimiters);
375 }
376
377 //***************************************************************************
380 //***************************************************************************
381 template <typename TStringView>
382 TStringView trim_view(const TStringView& view, typename TStringView::const_pointer delimiters)
383 {
384 typename TStringView::size_type first = view.find_first_of(delimiters);
385 typename TStringView::size_type last = view.find_last_of(delimiters) + 1;
386
387 typename TStringView::const_pointer pbegin = view.data();
388 typename TStringView::const_pointer pend = view.data();
389
390 if (first != TStringView::npos)
391 {
392 pbegin += first;
393 }
394
395 if (last != TStringView::npos)
396 {
397 pend += last;
398 }
399
400 return TStringView(pbegin, static_cast<size_t>(etl::distance(pbegin, pend)));
401 }
402
403 //***************************************************************************
405 //***************************************************************************
406 template <typename TIString>
407 void left_n(TIString& s, typename TIString::size_type n)
408 {
409 n = (n > s.size()) ? s.size() : n;
410
411 s.erase(s.begin() + static_cast<typename TIString::difference_type>(n), s.end());
412 }
413
414 //***************************************************************************
416 //***************************************************************************
417 template <typename TStringView>
418 TStringView left_n_view(const TStringView& view, typename TStringView::size_type n)
419 {
420 n = (n > view.size()) ? view.size() : n;
421
422 return TStringView(etl::addressof(*view.begin()), n);
423 }
424
425 //***************************************************************************
427 //***************************************************************************
428 template <typename TIString>
429 void right_n(TIString& s, typename TIString::size_type n)
430 {
431 n = (n > s.size()) ? s.size() : n;
432
433 s.erase(s.begin(), s.end() - static_cast<typename TIString::difference_type>(n));
434 }
435
436 //***************************************************************************
438 //***************************************************************************
439 template <typename TStringView>
440 TStringView right_n_view(const TStringView& view, typename TStringView::size_type n)
441 {
442 n = (n > view.size()) ? view.size() : n;
443
444 return TStringView(view.data() + view.size() - n, n);
445 }
446
447 //***************************************************************************
450 //***************************************************************************
451 template <typename TIString>
452 void reverse(TIString& s)
453 {
454 etl::reverse(s.begin(), s.end());
455 }
456
457 //***************************************************************************
459 //***************************************************************************
460 template <typename TIString, typename TPair>
461 void replace_characters(TIString& s, const TPair* pairsbegin, const TPair* pairsend)
462 {
463 while (pairsbegin != pairsend)
464 {
465 etl::replace(s.begin(), s.end(), pairsbegin->first, pairsbegin->second);
466 ++pairsbegin;
467 }
468 }
469
470 //***************************************************************************
472 //***************************************************************************
473 template <typename TIString, typename TPair>
474 void replace_strings(TIString& s, const TPair* pairsbegin, const TPair* pairsend)
475 {
476 while (pairsbegin != pairsend)
477 {
478 const typename TIString::value_type* p_old = pairsbegin->first;
479 const typename TIString::value_type* p_new = pairsbegin->second;
480
481 typename TIString::size_type position = 0U;
482
483 do {
484 position = s.find(p_old, position);
485 if (position != TIString::npos)
486 {
487 s.replace(position, typename TIString::size_type(etl::strlen(p_old)), p_new, typename TIString::size_type(etl::strlen(p_new)));
488 position += typename TIString::size_type(etl::strlen(p_new));
489 }
490 } while (position != TIString::npos);
491
492 ++pairsbegin;
493 }
494 }
495
496 //*********************************************************************
498 //*********************************************************************
499 template <typename TIterator, typename TPointer>
500 TIterator find_first_of(TIterator first, TIterator last, TPointer delimiters)
501 {
502 TIterator itr(first);
503
504 while (itr != last)
505 {
506 TPointer pd = delimiters;
507
508 while (*pd != 0)
509 {
510 if (*itr == *pd)
511 {
512 return itr;
513 }
514
515 ++pd;
516 }
517
518 ++itr;
519 }
520
521 return last;
522 }
523
524 //*********************************************************************
526 //*********************************************************************
527 template <typename TIString, typename TPointer>
528 typename TIString::iterator find_first_of(TIString& s, TPointer delimiters)
529 {
530 return find_first_of(s.begin(), s.end(), delimiters);
531 }
532
533 //*********************************************************************
535 //*********************************************************************
536 template <typename TIString, typename TPointer>
537 typename TIString::const_iterator find_first_of(const TIString& s, TPointer delimiters)
538 {
539 return find_first_of(s.begin(), s.end(), delimiters);
540 }
541
542 //*********************************************************************
544 //*********************************************************************
545 template <typename TIterator, typename TPointer>
546 TIterator find_first_not_of(TIterator first, TIterator last, TPointer delimiters)
547 {
548 TIterator itr(first);
549
550 while (itr != last)
551 {
552 TPointer pd = delimiters;
553
554 bool found = false;
555
556 while (*pd != 0)
557 {
558 if (*itr == *pd)
559 {
560 found = true;
561 break;
562 }
563
564 ++pd;
565 }
566
567 if (!found)
568 {
569 return itr;
570 }
571
572 ++itr;
573 }
574
575 return last;
576 }
577
578 //*********************************************************************
580 //*********************************************************************
581 template <typename TIString, typename TPointer>
582 typename TIString::iterator find_first_not_of(TIString& s, TPointer delimiters)
583 {
584 return find_first_not_of(s.begin(), s.end(), delimiters);
585 }
586
587 //*********************************************************************
589 //*********************************************************************
590 template <typename TIString, typename TPointer>
591 typename TIString::const_iterator find_first_not_of(const TIString& s, TPointer delimiters)
592 {
593 return find_first_not_of(s.begin(), s.end(), delimiters);
594 }
595
596 //*********************************************************************
598 //*********************************************************************
599 template <typename TIterator, typename TPointer>
600 TIterator find_last_of(TIterator first, TIterator last, TPointer delimiters)
601 {
602 if (first == last)
603 {
604 return last;
605 }
606
607 TIterator itr(last);
608 TIterator end(first);
609
610 do {
611 --itr;
612
613 TPointer pd = delimiters;
614
615 while (*pd != 0)
616 {
617 if (*itr == *pd)
618 {
619 return itr;
620 }
621
622 ++pd;
623 }
624 } while (itr != end);
625
626 return last;
627 }
628
629 //*********************************************************************
631 //*********************************************************************
632 template <typename TIString, typename TPointer>
633 typename TIString::iterator find_last_of(TIString& s, TPointer delimiters)
634 {
635 return find_last_of(s.begin(), s.end(), delimiters);
636 }
637
638 //*********************************************************************
640 //*********************************************************************
641 template <typename TIString, typename TPointer>
642 typename TIString::const_iterator find_last_of(const TIString& s, TPointer delimiters)
643 {
644 return find_last_of(s.begin(), s.end(), delimiters);
645 }
646
647 //*********************************************************************
649 //*********************************************************************
650 template <typename TIterator, typename TPointer>
651 TIterator find_last_not_of(TIterator first, TIterator last, TPointer delimiters)
652 {
653 if (first == last)
654 {
655 return last;
656 }
657
658 TIterator itr(last);
659 TIterator end(first);
660
661 do {
662 --itr;
663
664 TPointer pd = delimiters;
665
666 bool found = false;
667
668 while (*pd != 0)
669 {
670 if (*itr == *pd)
671 {
672 found = true;
673 break;
674 }
675
676 ++pd;
677 }
678
679 if (!found)
680 {
681 return itr;
682 }
683 } while (itr != end);
684
685 return last;
686 }
687
688 //*********************************************************************
690 //*********************************************************************
691 template <typename TIString, typename TPointer>
692 typename TIString::iterator find_last_not_of(TIString& s, TPointer delimiters)
693 {
694 return find_last_not_of(s.begin(), s.end(), delimiters);
695 }
696
697 //*********************************************************************
699 //*********************************************************************
700 template <typename TIString, typename TPointer>
701 typename TIString::const_iterator find_last_not_of(const TIString& s, TPointer delimiters)
702 {
703 return find_last_not_of(s.begin(), s.end(), delimiters);
704 }
705
706 //***************************************************************************
708 //***************************************************************************
710 template <typename TInput, typename TStringView>
711 etl::optional<TStringView> get_token(const TInput& input, typename TInput::const_pointer delimiters, const etl::optional<TStringView>& last_view,
712 bool ignore_empty_tokens)
713 {
714 typedef typename TInput::const_pointer const_pointer;
715
716 bool token_found = false;
717 typename TStringView::size_type position = 0U;
718 TStringView view = last_view.value_or(TStringView());
719 const_pointer begin_ptr = input.data();
720
721 if (begin_ptr == ETL_NULLPTR)
722 {
724 }
725
726 const_pointer end_ptr = begin_ptr + input.size();
727
728 while (!token_found)
729 {
730 // Does the last view have valid data?
731 if (view.data() != ETL_NULLPTR)
732 {
733 position = static_cast<typename TStringView::size_type>(etl::distance(begin_ptr, view.data() + view.size() + 1U));
734
735 // Have we reached the end of the string?
736 if (position > input.size())
737 {
738 return etl::optional<TStringView>();
739 }
740 }
741
742 // Look for the next token.
743 const_pointer first_ptr = begin_ptr + position;
744 const_pointer last_ptr = find_first_of(first_ptr, end_ptr, delimiters);
745
746 view = TStringView(first_ptr, static_cast<size_t>(etl::distance(first_ptr, last_ptr)));
747
748 token_found = ((view.size() != 0U) || !ignore_empty_tokens);
749 }
750
751 return etl::optional<TStringView>(view);
752 }
754
755 //***************************************************************************
776 //***************************************************************************
777 template <typename TInput, typename TOutput>
778 bool get_token_list(const TInput& input, TOutput& output, typename TInput::const_pointer delimiters, bool ignore_empty_tokens,
779 size_t max_n_tokens = etl::integral_limits<size_t>::max)
780 {
781 typedef typename TOutput::value_type string_view_t;
782
784
785 size_t count = 0;
786 while ((token = etl::get_token(input, delimiters, token, ignore_empty_tokens)) && (count != output.max_size()) && (count != max_n_tokens))
787 {
788 output.push_back(token.value());
789 ++count;
790 }
791
792 bool all_tokens_found = (token.has_value() == false);
793
794 return all_tokens_found;
795 }
796
797 //***************************************************************************
799 //***************************************************************************
800 template <typename TIString>
801 void pad_left(TIString& s, typename TIString::size_type required_size, typename TIString::value_type pad_char)
802 {
803 required_size = etl::min(required_size, s.max_size());
804
805 if (required_size > s.size())
806 {
807 required_size -= s.size();
808 s.insert(typename TIString::size_type(0U), required_size, pad_char);
809 }
810 }
811
812 //***************************************************************************
814 //***************************************************************************
815 template <typename TIString>
816 void pad_right(TIString& s, typename TIString::size_type required_size, typename TIString::value_type pad_char)
817 {
818 required_size = etl::min(required_size, s.max_size());
819
820 if (required_size > s.size())
821 {
822 required_size -= s.size();
823 s.insert(s.size(), required_size, pad_char);
824 }
825 }
826
827 //***************************************************************************
829 //***************************************************************************
830 template <typename TIString>
831 void pad(TIString& s, typename TIString::size_type required_size, string_pad_direction pad_direction, typename TIString::value_type pad_char)
832 {
833 switch (int(pad_direction))
834 {
835 case string_pad_direction::LEFT:
836 {
837 pad_left(s, required_size, pad_char);
838 break;
839 }
840
841 case string_pad_direction::RIGHT:
842 {
843 pad_right(s, required_size, pad_char);
844 break;
845 }
846
847 default:
848 {
849 break;
850 }
851 }
852 }
853
854 //***************************************************************************
856 //***************************************************************************
857 template <typename TString>
858 void to_upper_case(TString& s)
859 {
860 etl::transform(s.begin(), s.end(), s.begin(), ::toupper);
861 }
862
863 //***************************************************************************
865 //***************************************************************************
866 template <typename TString>
867 void to_lower_case(TString& s)
868 {
869 etl::transform(s.begin(), s.end(), s.begin(), ::tolower);
870 }
871
872 //***************************************************************************
874 //***************************************************************************
875 template <typename TString>
876 void to_sentence_case(TString& s)
877 {
878 typename TString::iterator itr = s.begin();
879
880 *itr = typename TString::value_type(::toupper(*itr));
881 ++itr;
882
883 etl::transform(itr, s.end(), itr, ::tolower);
884 }
885
886 //***************************************************************************
892 //***************************************************************************
894 {
895 size_t count;
896 bool truncated;
897 bool terminated;
898 };
899
900 template <typename T>
901 str_n_copy_result str_n_copy(const T* src, size_t n, T* dst)
902 {
903 if ((src == ETL_NULLPTR) || (dst == ETL_NULLPTR))
904 {
905 str_n_copy_result result = {0, false, false};
906 return result;
907 }
908
909 size_t count = 0;
910
911 while ((count != n) && (*src != 0))
912 {
913 *dst++ = *src++;
914 ++count;
915 }
916
917 // Did we stop because of a terminating zero?
918 if (count != n)
919 {
920 // Yes we did.
921 *dst = 0;
922 str_n_copy_result result = {count, false, true};
923 return result;
924 }
925 else
926 {
927 // No. Truncation depends on the next src character being a terminating
928 // zero or not.
929 str_n_copy_result result = {count, *src != 0, false};
930 return result;
931 }
932 }
933} // namespace etl
934
935#include "private/minmax_pop.h"
936
937#endif
Definition optional.h:1273
#define ETL_DECLARE_ENUM_TYPE(TypeName, ValueType)
Definition enum_type.h:90
Definition integral_limits.h:518
ETL_CONSTEXPR17 etl::enable_if<!etl::is_same< T, etl::nullptr_t >::value, T >::type * addressof(T &t)
Definition addressof.h:52
bitset_ext
Definition absolute.h:40
TIterator find_first_not_of(TIterator first, TIterator last, TPointer delimiters)
Find first not of any of delimiters within the string.
Definition string_utilities.h:546
void trim_from_left(TIString &s, typename TIString::const_pointer trim_characters)
Definition string_utilities.h:130
TStringView trim_from_view_right(const TStringView &view, typename TStringView::const_pointer trim_characters)
Definition string_utilities.h:241
void trim(TIString &s, typename TIString::const_pointer delimiters)
Definition string_utilities.h:371
TIterator find_first_of(TIterator first, TIterator last, TPointer delimiters)
Find first of any of delimiters within the string.
Definition string_utilities.h:500
void to_lower_case(TString &s)
to_lower_case
Definition string_utilities.h:867
void trim_whitespace_right(TIString &s)
Definition string_utilities.h:231
void pad_right(TIString &s, typename TIString::size_type required_size, typename TIString::value_type pad_char)
pad_right
Definition string_utilities.h:816
void pad(TIString &s, typename TIString::size_type required_size, string_pad_direction pad_direction, typename TIString::value_type pad_char)
pad
Definition string_utilities.h:831
void right_n(TIString &s, typename TIString::size_type n)
Get up to the last n characters.
Definition string_utilities.h:429
void trim_left(TIString &s, typename TIString::const_pointer delimiters)
Definition string_utilities.h:180
TStringView left_n_view(const TStringView &view, typename TStringView::size_type n)
Get a view of up to the first n characters.
Definition string_utilities.h:418
void replace_characters(TIString &s, const TPair *pairsbegin, const TPair *pairsend)
replace_characters
Definition string_utilities.h:461
void to_sentence_case(TString &s)
to_sentence_case
Definition string_utilities.h:876
TIterator find_last_of(TIterator first, TIterator last, TPointer delimiters)
Find last of any of delimiters within the string.
Definition string_utilities.h:600
void trim_from_right(TIString &s, typename TIString::const_pointer trim_characters)
Definition string_utilities.h:221
TStringView trim_view(const TStringView &view, typename TStringView::const_pointer delimiters)
Definition string_utilities.h:382
TStringView trim_view_whitespace(const TStringView &view)
Definition string_utilities.h:361
TStringView trim_view_left(const TStringView &view, typename TStringView::const_pointer delimiters)
Definition string_utilities.h:199
void trim_right(TIString &s, typename TIString::const_pointer delimiters)
trim_right
Definition string_utilities.h:269
TStringView trim_view_whitespace_right(TStringView &view)
Definition string_utilities.h:260
TStringView trim_from_view(const TStringView &view, typename TStringView::const_pointer trim_characters)
Definition string_utilities.h:335
void trim_whitespace_left(TIString &s)
Definition string_utilities.h:141
bool get_token_list(const TInput &input, TOutput &output, typename TInput::const_pointer delimiters, bool ignore_empty_tokens, size_t max_n_tokens=etl::integral_limits< size_t >::max)
Splits a string of tokens to a set of views, according to a set of delimiters. The tokenisation stops...
Definition string_utilities.h:778
void pad_left(TIString &s, typename TIString::size_type required_size, typename TIString::value_type pad_char)
pad_left
Definition string_utilities.h:801
TStringView trim_view_whitespace_left(TStringView &s)
Definition string_utilities.h:170
TIterator find_last_not_of(TIterator first, TIterator last, TPointer delimiters)
Find last not of any of delimiters within the string.
Definition string_utilities.h:651
void left_n(TIString &s, typename TIString::size_type n)
Get up to the first n characters.
Definition string_utilities.h:407
void to_upper_case(TString &s)
to_upper_case
Definition string_utilities.h:858
void trim_whitespace(TIString &s)
Definition string_utilities.h:325
TStringView right_n_view(const TStringView &view, typename TStringView::size_type n)
Get a view of up to the last n characters.
Definition string_utilities.h:440
void trim_from(TIString &s, typename TIString::const_pointer trim_characters)
Definition string_utilities.h:314
TStringView trim_from_view_left(const TStringView &view, typename TStringView::const_pointer trim_characters)
Definition string_utilities.h:151
void replace_strings(TIString &s, const TPair *pairsbegin, const TPair *pairsend)
replace_strings
Definition string_utilities.h:474
TStringView trim_view_right(const TStringView &view, typename TStringView::const_pointer delimiters)
trim_view_right
Definition string_utilities.h:292
ETL_CONSTEXPR14 size_t strlen(const T *t) ETL_NOEXCEPT
Alternative strlen for all character types.
Definition char_traits.h:293
ETL_CONSTEXPR TContainer::iterator end(TContainer &container)
Definition iterator.h:997
Definition string_utilities.h:894
string_pad_direction
Definition string_utilities.h:52
whitespace
Definition string_utilities.h:69