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()
84 static ETL_CONSTEXPR
const char8_t* value()
86 return u8" \t\n\r\f\v";
94 static ETL_CONSTEXPR
const wchar_t* value()
96 return L" \t\n\r\f\v";
104 static ETL_CONSTEXPR
const char16_t* value()
106 return u
" \t\n\r\f\v";
111 struct whitespace<char32_t>
113 static ETL_CONSTEXPR
const char32_t* value()
115 return U
" \t\n\r\f\v";
121 template <
typename TChar>
122 inline constexpr const TChar* whitespace_v = whitespace<TChar>::value();
129 template <
typename TIString>
132 typename TIString::size_type position =
s.find_first_not_of(
trim_characters);
133 s.erase(0
U, position);
140 template <
typename TIString>
150 template <
typename TStringView>
155 typename TStringView::const_pointer pbegin =
view.data() +
view.size();
157 if (first != TStringView::npos)
159 pbegin =
view.data() + first;
169 template <
typename TStringView>
179 template <
typename TIString>
182 typename TIString::size_type p =
s.find_first_of(
delimiters);
184 if (p == TIString::npos)
198 template <
typename TStringView>
201 typename TStringView::size_type first =
view.find_first_of(
delimiters);
203 typename TStringView::const_pointer pbegin =
view.data();
205 if (first != TStringView::npos)
212 return TStringView(pbegin,
typename TStringView::size_type(0
U));
220 template <
typename TIString>
230 template <
typename TIString>
240 template <
typename TStringView>
245 typename TStringView::const_pointer pend =
view.data();
247 if (last != TStringView::npos)
259 template <
typename TStringView>
268 template <
typename TIString>
271 typename TIString::size_type p =
s.find_last_of(
delimiters);
273 if (p == TIString::npos)
291 template <
typename TStringView>
294 typename TStringView::size_type last =
view.find_last_of(
delimiters) + 1;
296 typename TStringView::const_pointer pend =
view.data();
298 if (last != TStringView::npos)
313 template <
typename TIString>
324 template <
typename TIString>
334 template <
typename TStringView>
340 typename TStringView::const_pointer pbegin =
view.data();
341 typename TStringView::const_pointer pend =
view.data();
343 if (first != TStringView::npos)
348 if (last != TStringView::npos)
353 return TStringView(pbegin, etl::distance(pbegin, pend));
360 template <
typename TStringView>
370 template <
typename TIString>
381 template <
typename TStringView>
384 typename TStringView::size_type first =
view.find_first_of(
delimiters);
385 typename TStringView::size_type last =
view.find_last_of(
delimiters) + 1;
387 typename TStringView::const_pointer pbegin =
view.data();
388 typename TStringView::const_pointer pend =
view.data();
390 if (first != TStringView::npos)
395 if (last != TStringView::npos)
400 return TStringView(pbegin, etl::distance(pbegin, pend));
406 template <
typename TIString>
409 n = (
n >
s.size()) ?
s.size() :
n;
411 s.erase(
s.begin() +
n,
s.end());
417 template <
typename TStringView>
428 template <
typename TIString>
431 n = (
n >
s.size()) ?
s.size() :
n;
433 s.erase(
s.begin(),
s.end() -
n);
439 template <
typename TStringView>
451 template <
typename TIString>
454 etl::reverse(
s.begin(),
s.end());
460 template <
typename TIString,
typename TPair>
475 template <
typename TIString,
typename TPair>
485 typename TIString::size_type position = 0
U;
489 position =
s.find(
p_old, position);
490 if (position != TIString::npos)
495 }
while (position != TIString::npos);
504 template <
typename TIterator,
typename TPo
inter>
532 template <
typename TIString,
typename TPo
inter>
541 template <
typename TIString,
typename TPo
inter>
550 template <
typename TIterator,
typename TPo
inter>
586 template <
typename TIString,
typename TPo
inter>
595 template <
typename TIString,
typename TPo
inter>
604 template <
typename TIterator,
typename TPo
inter>
630 }
while (itr !=
end);
638 template <
typename TIString,
typename TPo
inter>
647 template <
typename TIString,
typename TPo
inter>
656 template <
typename TIterator,
typename TPo
inter>
690 }
while (itr !=
end);
698 template <
typename TIString,
typename TPo
inter>
707 template <
typename TIString,
typename TPo
inter>
716 template <
typename TInput,
typename TStringView>
719 typedef typename TInput::const_pointer const_pointer;
722 typename TStringView::size_type position = 0
U;
736 if (
view.data() != ETL_NULLPTR)
741 if (position > input.size())
762 template <
typename TIString>
777 template <
typename TIString>
792 template <
typename TIString>
797 case string_pad_direction::LEFT:
803 case string_pad_direction::RIGHT:
819 template <
typename TString>
822 etl::transform(
s.begin(),
s.end(),
s.begin(), ::toupper);
828 template <
typename TString>
831 etl::transform(
s.begin(),
s.end(),
s.begin(), ::tolower);
837 template <
typename TString>
840 typename TString::iterator itr =
s.begin();
842 *itr =
typename TString::value_type(::toupper(*itr));
845 etl::transform(itr,
s.end(), itr, ::tolower);
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: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:551
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:505
void to_lower_case(TString &s)
to_lower_case
Definition string_utilities.h:829
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:778
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:793
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:838
TIterator find_last_of(TIterator first, TIterator last, TPointer delimiters)
Find last of any of delimiters within the string.
Definition string_utilities.h:605
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
ETL_CONSTEXPR14 size_t strlen(const T *t)
Alternative strlen for all character types.
Definition char_traits.h:285
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
void pad_left(TIString &s, typename TIString::size_type required_size, typename TIString::value_type pad_char)
pad_left
Definition string_utilities.h:763
TStringView trim_view_whitespace_left(TStringView &s)
Definition string_utilities.h:170
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:717
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:657
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:820
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:476
TStringView trim_view_right(const TStringView &view, typename TStringView::const_pointer delimiters)
trim_view_right
Definition string_utilities.h:292
ETL_CONSTEXPR TContainer::iterator end(TContainer &container)
Definition iterator.h:992
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