Embedded Template Library  1.0
string_utilities.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) 2020 John Wellbelove, John Lagerquist
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_UTILITIES_INCLUDED
32 #define ETL_STRING_UTILITIES_INCLUDED
33 
34 #include "platform.h"
35 #include "algorithm.h"
36 #include "enum_type.h"
37 #include "memory.h"
38 #include "char_traits.h"
39 #include "optional.h"
40 
41 #include <stdint.h>
42 
43 namespace etl
44 {
45  //***************************************************************************
47  //***************************************************************************
49  {
50  enum enum_type
51  {
52  LEFT,
53  RIGHT,
54  };
55 
56  ETL_DECLARE_ENUM_TYPE(string_pad_direction, int)
57  ETL_ENUM_TYPE(LEFT, "left")
58  ETL_ENUM_TYPE(RIGHT, "right")
59  ETL_END_ENUM_TYPE
60  };
61 
62  //***************************************************************************
64  //***************************************************************************
65  template <typename TChar>
66  struct whitespace;
67 
68  template <>
69  struct whitespace<char>
70  {
71  static ETL_CONSTEXPR const char* value()
72  {
73  return " \t\n\r\f\v";
74  }
75  };
76 
77  template <>
78  struct whitespace<wchar_t>
79  {
80  static ETL_CONSTEXPR const wchar_t* value()
81  {
82  return L" \t\n\r\f\v";
83  }
84  };
85 
86  template <>
87  struct whitespace<char16_t>
88  {
89  static ETL_CONSTEXPR const char16_t* value()
90  {
91  return u" \t\n\r\f\v";
92  }
93  };
94 
95  template <>
96  struct whitespace<char32_t>
97  {
98  static ETL_CONSTEXPR const char32_t* value()
99  {
100  return U" \t\n\r\f\v";
101  }
102  };
103 
104 #if ETL_CPP17_SUPPORTED
105  template <typename TChar>
106  inline constexpr const TChar* whitespace_v = whitespace<TChar>::value();
107 #endif
108 
109  //***************************************************************************
112  //***************************************************************************
113  template <typename TIString>
114  void trim_from_left(TIString& s, typename TIString::const_pointer trim_characters)
115  {
116  typename TIString::size_type position = s.find_first_not_of(trim_characters);
117  s.erase(0U, position);
118  }
119 
120  //***************************************************************************
123  //***************************************************************************
124  template <typename TIString>
125  void trim_whitespace_left(TIString& s)
126  {
128  }
129 
130  //***************************************************************************
133  //***************************************************************************
134  template <typename TStringView>
135  TStringView trim_from_view_left(const TStringView& view, typename TStringView::const_pointer trim_characters)
136  {
137  typename TStringView::size_type first = view.find_first_not_of(trim_characters);
138 
139  typename TStringView::const_pointer pbegin = view.data() + view.size();
140 
141  if (first != TStringView::npos)
142  {
143  pbegin = view.data() + first;
144  }
145 
146  return TStringView(pbegin, etl::distance(pbegin, view.data() + view.size()));
147  }
148 
149  //***************************************************************************
152  //***************************************************************************
153  template <typename TStringView>
154  TStringView trim_view_whitespace_left(TStringView& s)
155  {
157  }
158 
159  //***************************************************************************
162  //***************************************************************************
163  template <typename TIString>
164  void trim_left(TIString& s, typename TIString::const_pointer delimiters)
165  {
166  typename TIString::size_type p = s.find_first_of(delimiters);
167 
168  if (p == TIString::npos)
169  {
170  s.clear();
171  }
172  else
173  {
174  s.erase(0, p);
175  }
176  }
177 
178  //***************************************************************************
181  //***************************************************************************
182  template <typename TStringView>
183  TStringView trim_view_left(const TStringView& view, typename TStringView::const_pointer delimiters)
184  {
185  typename TStringView::size_type first = view.find_first_of(delimiters);
186 
187  typename TStringView::const_pointer pbegin = view.data();
188 
189  if (first != TStringView::npos)
190  {
191  pbegin += first;
192  return TStringView(pbegin, view.size() - first);
193  }
194  else
195  {
196  return TStringView(pbegin, typename TStringView::size_type(0U));
197  }
198  }
199 
200  //***************************************************************************
203  //***************************************************************************
204  template <typename TIString>
205  void trim_from_right(TIString& s, typename TIString::const_pointer trim_characters)
206  {
207  s.erase(s.find_last_not_of(trim_characters) + 1);
208  }
209 
210  //***************************************************************************
213  //***************************************************************************
214  template <typename TIString>
215  void trim_whitespace_right(TIString& s)
216  {
218  }
219 
220  //***************************************************************************
223  //***************************************************************************
224  template <typename TStringView>
225  TStringView trim_from_view_right(const TStringView& view, typename TStringView::const_pointer trim_characters)
226  {
227  typename TStringView::size_type last = view.find_last_not_of(trim_characters) + 1;
228 
229  typename TStringView::const_pointer pend = view.data();
230 
231  if (last != TStringView::npos)
232  {
233  pend += last;
234  }
235 
236  return TStringView(view.data(), etl::distance(view.data(), pend));
237  }
238 
239  //***************************************************************************
242  //***************************************************************************
243  template <typename TStringView>
244  TStringView trim_view_whitespace_right(TStringView& view)
245  {
247  }
248 
249  //***************************************************************************
251  //***************************************************************************
252  template <typename TIString>
253  void trim_right(TIString& s, typename TIString::const_pointer delimiters)
254  {
255  typename TIString::size_type p = s.find_last_of(delimiters);
256 
257  if (p == TIString::npos)
258  {
259  s.clear();
260  }
261  else
262  {
263  ++p;
264 
265  if (p != s.size())
266  {
267  s.erase(p);
268  }
269  }
270  }
271 
272  //***************************************************************************
274  //***************************************************************************
275  template <typename TStringView>
276  TStringView trim_view_right(const TStringView& view, typename TStringView::const_pointer delimiters)
277  {
278  typename TStringView::size_type last = view.find_last_of(delimiters) + 1;
279 
280  typename TStringView::const_pointer pend = view.data();
281 
282  if (last != TStringView::npos)
283  {
284  pend += last;
285  return TStringView(view.data(), etl::distance(view.data(), pend));
286  }
287  else
288  {
289  return TStringView(view.data(), typename TStringView::size_type(0U));
290  }
291  }
292 
293  //***************************************************************************
296  //***************************************************************************
297  template <typename TIString>
298  void trim_from(TIString& s, typename TIString::const_pointer trim_characters)
299  {
300  trim_from_left(s, trim_characters);
301  trim_from_right(s, trim_characters);
302  }
303 
304  //***************************************************************************
307  //***************************************************************************
308  template <typename TIString>
309  void trim_whitespace(TIString& s)
310  {
312  }
313 
314  //***************************************************************************
317  //***************************************************************************
318  template <typename TStringView>
319  TStringView trim_from_view(const TStringView& view, typename TStringView::const_pointer trim_characters)
320  {
321  typename TStringView::size_type first = view.find_first_not_of(trim_characters);
322  typename TStringView::size_type last = view.find_last_not_of(trim_characters) + 1;
323 
324  typename TStringView::const_pointer pbegin = view.data();
325  typename TStringView::const_pointer pend = view.data();
326 
327  if (first != TStringView::npos)
328  {
329  pbegin += first;
330  }
331 
332  if (last != TStringView::npos)
333  {
334  pend += last;
335  }
336 
337  return TStringView(pbegin, etl::distance(pbegin, pend));
338  }
339 
340  //***************************************************************************
343  //***************************************************************************
344  template <typename TStringView>
345  TStringView trim_view_whitespace(const TStringView& view)
346  {
348  }
349 
350  //***************************************************************************
353  //***************************************************************************
354  template <typename TIString>
355  void trim(TIString& s, typename TIString::const_pointer delimiters)
356  {
357  trim_left(s, delimiters);
358  trim_right(s, delimiters);
359  }
360 
361  //***************************************************************************
364  //***************************************************************************
365  template <typename TStringView>
366  TStringView trim_view(const TStringView& view, typename TStringView::const_pointer delimiters)
367  {
368  typename TStringView::size_type first = view.find_first_of(delimiters);
369  typename TStringView::size_type last = view.find_last_of(delimiters) + 1;
370 
371  typename TStringView::const_pointer pbegin = view.data();
372  typename TStringView::const_pointer pend = view.data();
373 
374  if (first != TStringView::npos)
375  {
376  pbegin += first;
377  }
378 
379  if (last != TStringView::npos)
380  {
381  pend += last;
382  }
383 
384  return TStringView(pbegin, etl::distance(pbegin, pend));
385  }
386 
387  //***************************************************************************
389  //***************************************************************************
390  template <typename TIString>
391  void left_n(TIString& s, typename TIString::size_type n)
392  {
393  n = (n > s.size()) ? s.size() : n;
394 
395  s.erase(s.begin() + n, s.end());
396  }
397 
398  //***************************************************************************
400  //***************************************************************************
401  template <typename TStringView>
402  TStringView left_n_view(const TStringView& view, typename TStringView::size_type n)
403  {
404  n = (n > view.size()) ? view.size() : n;
405 
406  return TStringView(etl::addressof(*view.begin()), n);
407  }
408 
409  //***************************************************************************
411  //***************************************************************************
412  template <typename TIString>
413  void right_n(TIString& s, typename TIString::size_type n)
414  {
415  n = (n > s.size()) ? s.size() : n;
416 
417  s.erase(s.begin(), s.end() - n);
418  }
419 
420  //***************************************************************************
422  //***************************************************************************
423  template <typename TStringView>
424  TStringView right_n_view(const TStringView& view, typename TStringView::size_type n)
425  {
426  n = (n > view.size()) ? view.size() : n;
427 
428  return TStringView(view.data() + view.size() - n, n);
429  }
430 
431  //***************************************************************************
434  //***************************************************************************
435  template <typename TIString>
436  void reverse(TIString& s)
437  {
438  etl::reverse(s.begin(), s.end());
439  }
440 
441  //***************************************************************************
443  //***************************************************************************
444  template <typename TIString, typename TPair>
445  void replace_characters(TIString& s,
446  const TPair* pairsbegin,
447  const TPair* pairsend)
448  {
449  while (pairsbegin != pairsend)
450  {
451  etl::replace(s.begin(), s.end(), pairsbegin->first, pairsbegin->second);
452  ++pairsbegin;
453  }
454  }
455 
456  //***************************************************************************
458  //***************************************************************************
459  template <typename TIString, typename TPair>
460  void replace_strings(TIString& s,
461  const TPair* pairsbegin,
462  const TPair* pairsend)
463  {
464  while (pairsbegin != pairsend)
465  {
466  const typename TIString::value_type* p_old = pairsbegin->first;
467  const typename TIString::value_type* p_new = pairsbegin->second;
468 
469  typename TIString::size_type position = 0U;
470 
471  do
472  {
473  position = s.find(p_old, position);
474  if (position != TIString::npos)
475  {
476  s.replace(position, typename TIString::size_type(etl::strlen(p_old)), p_new, typename TIString::size_type(etl::strlen(p_new)));
477  position += typename TIString::size_type(etl::strlen(p_new));
478  }
479  } while (position != TIString::npos);
480 
481  ++pairsbegin;
482  }
483  }
484 
485  //*********************************************************************
487  //*********************************************************************
488  template <typename TIterator, typename TPointer>
489  TIterator find_first_of(TIterator first, TIterator last, TPointer delimiters)
490  {
491  TIterator itr(first);
492 
493  while (itr != last)
494  {
495  TPointer pd = delimiters;
496 
497  while (*pd != 0)
498  {
499  if (*itr == *pd)
500  {
501  return itr;
502  }
503 
504  ++pd;
505  }
506 
507  ++itr;
508  }
509 
510  return last;
511  }
512 
513  //*********************************************************************
515  //*********************************************************************
516  template <typename TIString, typename TPointer>
517  typename TIString::iterator find_first_of(TIString& s, TPointer delimiters)
518  {
519  return find_first_of(s.begin(), s.end(), delimiters);
520  }
521 
522  //*********************************************************************
524  //*********************************************************************
525  template <typename TIString, typename TPointer>
526  typename TIString::const_iterator find_first_of(const TIString& s, TPointer delimiters)
527  {
528  return find_first_of(s.begin(), s.end(), delimiters);
529  }
530 
531  //*********************************************************************
533  //*********************************************************************
534  template <typename TIterator, typename TPointer>
535  TIterator find_first_not_of(TIterator first, TIterator last, TPointer delimiters)
536  {
537  TIterator itr(first);
538 
539  while (itr != last)
540  {
541  TPointer pd = delimiters;
542 
543  bool found = false;
544 
545  while (*pd != 0)
546  {
547  if (*itr == *pd)
548  {
549  found = true;
550  break;
551  }
552 
553  ++pd;
554  }
555 
556  if (!found)
557  {
558  return itr;
559  }
560 
561  ++itr;
562  }
563 
564  return last;
565  }
566 
567  //*********************************************************************
569  //*********************************************************************
570  template <typename TIString, typename TPointer>
571  typename TIString::iterator find_first_not_of(TIString& s, TPointer delimiters)
572  {
573  return find_first_not_of(s.begin(), s.end(), delimiters);
574  }
575 
576  //*********************************************************************
578  //*********************************************************************
579  template <typename TIString, typename TPointer>
580  typename TIString::const_iterator find_first_not_of(const TIString& s, TPointer delimiters)
581  {
582  return find_first_not_of(s.begin(), s.end(), delimiters);
583  }
584 
585  //*********************************************************************
587  //*********************************************************************
588  template <typename TIterator, typename TPointer>
589  TIterator find_last_of(TIterator first, TIterator last, TPointer delimiters)
590  {
591  if (first == last)
592  {
593  return last;
594  }
595 
596  TIterator itr(last);
597  TIterator end(first);
598 
599  do
600  {
601  --itr;
602 
603  TPointer pd = delimiters;
604 
605  while (*pd != 0)
606  {
607  if (*itr == *pd)
608  {
609  return itr;
610  }
611 
612  ++pd;
613  }
614  } while (itr != end);
615 
616  return last;
617  }
618 
619  //*********************************************************************
621  //*********************************************************************
622  template <typename TIString, typename TPointer>
623  typename TIString::iterator find_last_of(TIString& s, TPointer delimiters)
624  {
625  return find_last_of(s.begin(), s.end(), delimiters);
626  }
627 
628  //*********************************************************************
630  //*********************************************************************
631  template <typename TIString, typename TPointer>
632  typename TIString::const_iterator find_last_of(const TIString& s, TPointer delimiters)
633  {
634  return find_last_of(s.begin(), s.end(), delimiters);
635  }
636 
637  //*********************************************************************
639  //*********************************************************************
640  template <typename TIterator, typename TPointer>
641  TIterator find_last_not_of(TIterator first, TIterator last, TPointer delimiters)
642  {
643  if (first == last)
644  {
645  return last;
646  }
647 
648  TIterator itr(last);
649  TIterator end(first);
650 
651  do
652  {
653  --itr;
654 
655  TPointer pd = delimiters;
656 
657  bool found = false;
658 
659  while (*pd != 0)
660  {
661  if (*itr == *pd)
662  {
663  found = true;
664  break;
665  }
666 
667  ++pd;
668  }
669 
670  if (!found)
671  {
672  return itr;
673  }
674  } while (itr != end);
675 
676  return last;
677  }
678 
679  //*********************************************************************
681  //*********************************************************************
682  template <typename TIString, typename TPointer>
683  typename TIString::iterator find_last_not_of(TIString& s, TPointer delimiters)
684  {
685  return find_last_not_of(s.begin(), s.end(), delimiters);
686  }
687 
688  //*********************************************************************
690  //*********************************************************************
691  template <typename TIString, typename TPointer>
692  typename TIString::const_iterator find_last_not_of(const TIString& s, TPointer delimiters)
693  {
694  return find_last_not_of(s.begin(), s.end(), delimiters);
695  }
696 
697  //***************************************************************************
699  //***************************************************************************
700  template <typename TInput, typename TStringView>
701  etl::optional<TStringView> get_token(const TInput& input, typename TInput::const_pointer delimiters, const etl::optional<TStringView>& last_view, bool ignore_empty_tokens)
702  {
703  typedef typename TInput::const_pointer const_pointer;
704 
705  bool token_found = false;
706  typename TStringView::size_type position = 0U;
707  TStringView view = last_view.value_or(TStringView());
708  const_pointer begin_ptr = input.data();
709 
710  if (begin_ptr == ETL_NULLPTR)
711  {
713  }
714 
715  const_pointer end_ptr = begin_ptr + input.size();
716 
717  while (!token_found)
718  {
719  // Does the last view have valid data?
720  if (view.data() != ETL_NULLPTR)
721  {
722  position = etl::distance(begin_ptr, view.data() + view.size() + 1U);
723 
724  // Have we reached the end of the string?
725  if (position > input.size())
726  {
728  }
729  }
730 
731  // Look for the next token.
732  const_pointer first_ptr = begin_ptr + position;
733  const_pointer last_ptr = find_first_of(first_ptr, end_ptr, delimiters);
734 
735  view = TStringView(first_ptr, etl::distance(first_ptr, last_ptr));
736 
737  token_found = ((view.size() != 0U) || !ignore_empty_tokens);
738  }
739 
740  return etl::optional<TStringView>(view);
741  }
742 
743  //***************************************************************************
745  //***************************************************************************
746  template <typename TIString>
747  void pad_left(TIString& s, typename TIString::size_type required_size, typename TIString::value_type pad_char)
748  {
749  required_size = etl::min(required_size, s.max_size());
750 
751  if (required_size > s.size())
752  {
753  required_size -= s.size();
754  s.insert(typename TIString::size_type(0U), required_size, pad_char);
755  }
756  }
757 
758  //***************************************************************************
760  //***************************************************************************
761  template <typename TIString>
762  void pad_right(TIString& s, typename TIString::size_type required_size, typename TIString::value_type pad_char)
763  {
764  required_size = etl::min(required_size, s.max_size());
765 
766  if (required_size > s.size())
767  {
768  required_size -= s.size();
769  s.insert(s.size(), required_size, pad_char);
770  }
771  }
772 
773  //***************************************************************************
775  //***************************************************************************
776  template <typename TIString>
777  void pad(TIString& s, typename TIString::size_type required_size, string_pad_direction pad_direction, typename TIString::value_type pad_char)
778  {
779  switch (int(pad_direction))
780  {
781  case string_pad_direction::LEFT:
782  {
783  pad_left(s, required_size, pad_char);
784  break;
785  }
786 
787  case string_pad_direction::RIGHT:
788  {
789  pad_right(s, required_size, pad_char);
790  break;
791  }
792 
793  default:
794  {
795  break;
796  }
797  }
798  }
799 
800  //***************************************************************************
802  //***************************************************************************
803  template <typename TString>
804  void to_upper_case(TString& s)
805  {
806  etl::transform(s.begin(), s.end(), s.begin(), ::toupper);
807  }
808 
809  //***************************************************************************
811  //***************************************************************************
812  template <typename TString>
813  void to_lower_case(TString& s)
814  {
815  etl::transform(s.begin(), s.end(), s.begin(), ::tolower);
816  }
817 
818  //***************************************************************************
820  //***************************************************************************
821  template <typename TString>
822  void to_sentence_case(TString& s)
823  {
824  typename TString::iterator itr = s.begin();
825 
826  *itr = typename TString::value_type(::toupper(*itr));
827  ++itr;
828 
829  etl::transform(itr, s.end(), itr, ::tolower);
830  }
831 }
832 
833 #endif
Definition: optional.h:108
T value_or(T default_value) const
Gets the value or a default if no valid.
Definition: optional.h:388
ETL_CONSTEXPR TContainer::iterator end(TContainer &container)
Definition: container.h:99
T * addressof(T &t)
Definition: memory.h:61
Definition: absolute.h:37
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:535
void trim_from_left(TIString &s, typename TIString::const_pointer trim_characters)
Definition: string_utilities.h:114
TStringView trim_from_view_right(const TStringView &view, typename TStringView::const_pointer trim_characters)
Definition: string_utilities.h:225
void trim(TIString &s, typename TIString::const_pointer delimiters)
Definition: string_utilities.h:355
TIterator find_first_of(TIterator first, TIterator last, TPointer delimiters)
Find first of any of delimiters within the string.
Definition: string_utilities.h:489
void to_lower_case(TString &s)
to_lower_case
Definition: string_utilities.h:813
void trim_whitespace_right(TIString &s)
Definition: string_utilities.h:215
void pad_right(TIString &s, typename TIString::size_type required_size, typename TIString::value_type pad_char)
pad_right
Definition: string_utilities.h:762
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:777
void right_n(TIString &s, typename TIString::size_type n)
Get up to the last n characters.
Definition: string_utilities.h:413
void trim_left(TIString &s, typename TIString::const_pointer delimiters)
Definition: string_utilities.h:164
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:402
void replace_characters(TIString &s, const TPair *pairsbegin, const TPair *pairsend)
replace_characters
Definition: string_utilities.h:445
void to_sentence_case(TString &s)
to_sentence_case
Definition: string_utilities.h:822
TIterator find_last_of(TIterator first, TIterator last, TPointer delimiters)
Find last of any of delimiters within the string.
Definition: string_utilities.h:589
size_t strlen(const T *t)
Alternative strlen for all character types.
Definition: char_traits.h:247
void trim_from_right(TIString &s, typename TIString::const_pointer trim_characters)
Definition: string_utilities.h:205
TStringView trim_view(const TStringView &view, typename TStringView::const_pointer delimiters)
Definition: string_utilities.h:366
TStringView trim_view_whitespace(const TStringView &view)
Definition: string_utilities.h:345
TStringView trim_view_left(const TStringView &view, typename TStringView::const_pointer delimiters)
Definition: string_utilities.h:183
void trim_right(TIString &s, typename TIString::const_pointer delimiters)
trim_right
Definition: string_utilities.h:253
TStringView trim_view_whitespace_right(TStringView &view)
Definition: string_utilities.h:244
TStringView trim_from_view(const TStringView &view, typename TStringView::const_pointer trim_characters)
Definition: string_utilities.h:319
void trim_whitespace_left(TIString &s)
Definition: string_utilities.h:125
void pad_left(TIString &s, typename TIString::size_type required_size, typename TIString::value_type pad_char)
pad_left
Definition: string_utilities.h:747
TStringView trim_view_whitespace_left(TStringView &s)
Definition: string_utilities.h:154
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:641
void left_n(TIString &s, typename TIString::size_type n)
Get up to the first n characters.
Definition: string_utilities.h:391
void to_upper_case(TString &s)
to_upper_case
Definition: string_utilities.h:804
void trim_whitespace(TIString &s)
Definition: string_utilities.h:309
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:424
void trim_from(TIString &s, typename TIString::const_pointer trim_characters)
Definition: string_utilities.h:298
etl::optional< TStringView > get_token(const TInput &input, typename TInput::const_pointer delimiters, const etl::optional< TStringView > &last_view, bool ignore_empty_tokens)
get_token
Definition: string_utilities.h:701
TStringView trim_from_view_left(const TStringView &view, typename TStringView::const_pointer trim_characters)
Definition: string_utilities.h:135
void replace_strings(TIString &s, const TPair *pairsbegin, const TPair *pairsend)
replace_strings
Definition: string_utilities.h:460
TStringView trim_view_right(const TStringView &view, typename TStringView::const_pointer delimiters)
trim_view_right
Definition: string_utilities.h:276
string_pad_direction
Definition: string_utilities.h:49
whitespace
Definition: string_utilities.h:66