31#ifndef ETL_STRING_UTILITIES_INCLUDED
32#define ETL_STRING_UTILITIES_INCLUDED
60 ETL_ENUM_TYPE(LEFT,
"left")
61 ETL_ENUM_TYPE(RIGHT,
"right")
68 template <
typename TChar>
74 static ETL_CONSTEXPR
const char* value()
83 static ETL_CONSTEXPR
const wchar_t* value()
85 return L" \t\n\r\f\v";
93 static ETL_CONSTEXPR
const char16_t* value()
95 return u
" \t\n\r\f\v";
100 struct whitespace<char32_t>
102 static ETL_CONSTEXPR
const char32_t* value()
104 return U
" \t\n\r\f\v";
110 template <
typename TChar>
111 inline constexpr const TChar* whitespace_v = whitespace<TChar>::value();
118 template <
typename TIString>
121 typename TIString::size_type position =
s.find_first_not_of(
trim_characters);
122 s.erase(0U, position);
129 template <
typename TIString>
139 template <
typename TStringView>
144 typename TStringView::const_pointer pbegin =
view.data() +
view.size();
146 if (first != TStringView::npos)
148 pbegin =
view.data() + first;
158 template <
typename TStringView>
168 template <
typename TIString>
171 typename TIString::size_type p =
s.find_first_of(
delimiters);
173 if (p == TIString::npos)
187 template <
typename TStringView>
190 typename TStringView::size_type first =
view.find_first_of(
delimiters);
192 typename TStringView::const_pointer pbegin =
view.data();
194 if (first != TStringView::npos)
201 return TStringView(pbegin,
typename TStringView::size_type(0U));
209 template <
typename TIString>
219 template <
typename TIString>
229 template <
typename TStringView>
234 typename TStringView::const_pointer pend =
view.data();
236 if (last != TStringView::npos)
248 template <
typename TStringView>
257 template <
typename TIString>
260 typename TIString::size_type p =
s.find_last_of(
delimiters);
262 if (p == TIString::npos)
280 template <
typename TStringView>
283 typename TStringView::size_type last =
view.find_last_of(
delimiters) + 1;
285 typename TStringView::const_pointer pend =
view.data();
287 if (last != TStringView::npos)
302 template <
typename TIString>
313 template <
typename TIString>
323 template <
typename TStringView>
329 typename TStringView::const_pointer pbegin =
view.data();
330 typename TStringView::const_pointer pend =
view.data();
332 if (first != TStringView::npos)
337 if (last != TStringView::npos)
342 return TStringView(pbegin, etl::distance(pbegin, pend));
349 template <
typename TStringView>
359 template <
typename TIString>
370 template <
typename TStringView>
373 typename TStringView::size_type first =
view.find_first_of(
delimiters);
374 typename TStringView::size_type last =
view.find_last_of(
delimiters) + 1;
376 typename TStringView::const_pointer pbegin =
view.data();
377 typename TStringView::const_pointer pend =
view.data();
379 if (first != TStringView::npos)
384 if (last != TStringView::npos)
389 return TStringView(pbegin, etl::distance(pbegin, pend));
395 template <
typename TIString>
398 n = (
n >
s.size()) ?
s.size() :
n;
400 s.erase(
s.begin() +
n,
s.end());
406 template <
typename TStringView>
417 template <
typename TIString>
420 n = (
n >
s.size()) ?
s.size() :
n;
422 s.erase(
s.begin(),
s.end() -
n);
428 template <
typename TStringView>
440 template <
typename TIString>
443 etl::reverse(
s.begin(),
s.end());
449 template <
typename TIString,
typename TPair>
464 template <
typename TIString,
typename TPair>
474 typename TIString::size_type position = 0U;
478 position =
s.find(
p_old, position);
479 if (position != TIString::npos)
484 }
while (position != TIString::npos);
493 template <
typename TIterator,
typename TPo
inter>
521 template <
typename TIString,
typename TPo
inter>
530 template <
typename TIString,
typename TPo
inter>
539 template <
typename TIterator,
typename TPo
inter>
575 template <
typename TIString,
typename TPo
inter>
584 template <
typename TIString,
typename TPo
inter>
593 template <
typename TIterator,
typename TPo
inter>
619 }
while (itr !=
end);
627 template <
typename TIString,
typename TPo
inter>
636 template <
typename TIString,
typename TPo
inter>
645 template <
typename TIterator,
typename TPo
inter>
679 }
while (itr !=
end);
687 template <
typename TIString,
typename TPo
inter>
696 template <
typename TIString,
typename TPo
inter>
705 template <
typename TInput,
typename TStringView>
708 typedef typename TInput::const_pointer const_pointer;
711 typename TStringView::size_type position = 0U;
725 if (
view.data() != ETL_NULLPTR)
730 if (position > input.size())
751 template <
typename TIString>
766 template <
typename TIString>
781 template <
typename TIString>
786 case string_pad_direction::LEFT:
792 case string_pad_direction::RIGHT:
808 template <
typename TString>
811 etl::transform(
s.begin(),
s.end(),
s.begin(), ::toupper);
817 template <
typename TString>
820 etl::transform(
s.begin(),
s.end(),
s.begin(), ::tolower);
826 template <
typename TString>
829 typename TString::iterator itr =
s.begin();
831 *itr =
typename TString::value_type(::toupper(*itr));
834 etl::transform(itr,
s.end(), itr, ::tolower);
ETL_CONSTEXPR17 T * addressof(T &t)
Definition addressof.h:51
bitset_ext
Definition absolute.h:38
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:540
void trim_from_left(TIString &s, typename TIString::const_pointer trim_characters)
Definition string_utilities.h:119
TStringView trim_from_view_right(const TStringView &view, typename TStringView::const_pointer trim_characters)
Definition string_utilities.h:230
void trim(TIString &s, typename TIString::const_pointer delimiters)
Definition string_utilities.h:360
TIterator find_first_of(TIterator first, TIterator last, TPointer delimiters)
Find first of any of delimiters within the string.
Definition string_utilities.h:494
void to_lower_case(TString &s)
to_lower_case
Definition string_utilities.h:818
void trim_whitespace_right(TIString &s)
Definition string_utilities.h:220
void pad_right(TIString &s, typename TIString::size_type required_size, typename TIString::value_type pad_char)
pad_right
Definition string_utilities.h:767
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:782
void right_n(TIString &s, typename TIString::size_type n)
Get up to the last n characters.
Definition string_utilities.h:418
void trim_left(TIString &s, typename TIString::const_pointer delimiters)
Definition string_utilities.h:169
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:407
void replace_characters(TIString &s, const TPair *pairsbegin, const TPair *pairsend)
replace_characters
Definition string_utilities.h:450
void to_sentence_case(TString &s)
to_sentence_case
Definition string_utilities.h:827
TIterator find_last_of(TIterator first, TIterator last, TPointer delimiters)
Find last of any of delimiters within the string.
Definition string_utilities.h:594
void trim_from_right(TIString &s, typename TIString::const_pointer trim_characters)
Definition string_utilities.h:210
TStringView trim_view(const TStringView &view, typename TStringView::const_pointer delimiters)
Definition string_utilities.h:371
TStringView trim_view_whitespace(const TStringView &view)
Definition string_utilities.h:350
TStringView trim_view_left(const TStringView &view, typename TStringView::const_pointer delimiters)
Definition string_utilities.h:188
void trim_right(TIString &s, typename TIString::const_pointer delimiters)
trim_right
Definition string_utilities.h:258
TStringView trim_view_whitespace_right(TStringView &view)
Definition string_utilities.h:249
TStringView trim_from_view(const TStringView &view, typename TStringView::const_pointer trim_characters)
Definition string_utilities.h:324
void trim_whitespace_left(TIString &s)
Definition string_utilities.h:130
void pad_left(TIString &s, typename TIString::size_type required_size, typename TIString::value_type pad_char)
pad_left
Definition string_utilities.h:752
TStringView trim_view_whitespace_left(TStringView &s)
Definition string_utilities.h:159
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:706
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:646
void left_n(TIString &s, typename TIString::size_type n)
Get up to the first n characters.
Definition string_utilities.h:396
void to_upper_case(TString &s)
to_upper_case
Definition string_utilities.h:809
void trim_whitespace(TIString &s)
Definition string_utilities.h:314
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:429
void trim_from(TIString &s, typename TIString::const_pointer trim_characters)
Definition string_utilities.h:303
TStringView trim_from_view_left(const TStringView &view, typename TStringView::const_pointer trim_characters)
Definition string_utilities.h:140
void replace_strings(TIString &s, const TPair *pairsbegin, const TPair *pairsend)
replace_strings
Definition string_utilities.h:465
ETL_CONSTEXPR size_t strlen(const T *t)
Alternative strlen for all character types.
Definition char_traits.h:267
TStringView trim_view_right(const TStringView &view, typename TStringView::const_pointer delimiters)
trim_view_right
Definition string_utilities.h:281
ETL_CONSTEXPR TContainer::iterator end(TContainer &container)
Definition iterator.h:961
pair holds two objects of arbitrary type
Definition utility.h:164
T1 first
first is a copy of the first object
Definition utility.h:168
T2 second
second is a copy of the second object
Definition utility.h:169
string_pad_direction
Definition string_utilities.h:52
whitespace
Definition string_utilities.h:69