31#ifndef ETL_BASIC_STRING_INCLUDED
32#define ETL_BASIC_STRING_INCLUDED
53#if ETL_USING_LIBC_WCHAR_H
57#if ETL_USING_STL && ETL_USING_CPP17
58 #include <string_view>
61#if ETL_USING_STD_OSTREAM
76 template <
typename T,
typename TTraits>
90 string_exception(string_type reason_, string_type file_name_, numeric_type line_number_)
91 :
exception(reason_, file_name_, line_number_)
104 string_empty(string_type file_name_, numeric_type line_number_)
105 : string_exception(ETL_ERROR_TEXT(
"string:empty", ETL_BASIC_STRING_FILE_ID
"A"), file_name_, line_number_)
118 string_out_of_bounds(string_type file_name_, numeric_type line_number_)
119 : string_exception(ETL_ERROR_TEXT(
"string:bounds", ETL_BASIC_STRING_FILE_ID
"B"), file_name_, line_number_)
132 string_iterator(string_type file_name_, numeric_type line_number_)
133 : string_exception(ETL_ERROR_TEXT(
"string:iterator", ETL_BASIC_STRING_FILE_ID
"C"), file_name_, line_number_)
146 string_truncation(string_type file_name_, numeric_type line_number_)
147 : string_exception(ETL_ERROR_TEXT(
"string:truncation", ETL_BASIC_STRING_FILE_ID
"D"), file_name_, line_number_)
159 template <
typename T =
void>
164 typedef size_t size_type;
166 static ETL_CONSTANT uint_least8_t IS_TRUNCATED = etl::bit<0>::value;
167 static ETL_CONSTANT uint_least8_t CLEAR_AFTER_USE = etl::bit<1>::value;
172 template <
typename T>
173 ETL_CONSTANT uint_least8_t string_base_statics<T>::IS_TRUNCATED;
175 template <
typename T>
176 ETL_CONSTANT uint_least8_t string_base_statics<T>::CLEAR_AFTER_USE;
178 template <
typename T>
179 ETL_CONSTANT
typename string_base_statics<T>::size_type string_base_statics<T>::npos;
187 typedef size_t size_type;
258#if ETL_HAS_STRING_TRUNCATION_CHECKS
259 return flags.test<IS_TRUNCATED>();
276#if ETL_HAS_STRING_TRUNCATION_CHECKS
282 flags.set<IS_TRUNCATED,
false>();
286#if ETL_HAS_STRING_CLEAR_AFTER_USE
292 flags.set<CLEAR_AFTER_USE>();
301#if ETL_HAS_STRING_CLEAR_AFTER_USE
302 return flags.test<CLEAR_AFTER_USE>();
319#if ETL_HAS_STRING_TRUNCATION_CHECKS
325 flags.set<IS_TRUNCATED>(status);
339#if ETL_HAS_STRING_TRUNCATION_CHECKS || ETL_HAS_STRING_CLEAR_AFTER_USE
349 template <
typename T>
356 typedef T value_type;
357 typedef T& reference;
358 typedef const T& const_reference;
360 typedef const T* const_pointer;
362 typedef const T* const_iterator;
363 typedef ETL_OR_STD::reverse_iterator<iterator> reverse_iterator;
364 typedef ETL_OR_STD::reverse_iterator<const_iterator> const_reverse_iterator;
366 typedef typename etl::iterator_traits<iterator>::difference_type difference_type;
399 const_iterator
end()
const
428 return reverse_iterator(
end());
437 return const_reverse_iterator(
end());
446 return reverse_iterator(
begin());
453 const_reverse_iterator
rend()
const
455 return const_reverse_iterator(
begin());
464 return const_reverse_iterator(
cend());
471 const_reverse_iterator
crend()
const
473 return const_reverse_iterator(
cbegin());
495#if ETL_HAS_STRING_TRUNCATION_CHECKS
498#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
504 new_size = etl::min(new_size,
CAPACITY);
509 etl::fill(p_buffer +
current_size, p_buffer + new_size, value);
513 p_buffer[new_size] = 0;
520 template <
typename TOperation>
540 new_size = etl::min(new_size,
CAPACITY);
543 p_buffer[new_size] = 0;
584 reference
at(size_type i)
596 const_reference
at(size_type i)
const
629 return p_buffer[
size() - 1];
639 return p_buffer[
size() - 1];
655 ETL_CONSTEXPR const_pointer
data()
const
705 if (sublength == npos)
707 sublength = other.
size() - subposition;
723 template <
typename TIterator>
724 void assign(TIterator first, TIterator last)
726 append_impl(
begin(), first, last,
false,
false);
736 append_impl(
begin(), str,
false,
false);
745 void assign(const_pointer str, size_type n)
747 append_impl(
begin(), str, str + n,
false,
false);
753 template <
typename TOtherTraits>
756 append_impl(
begin(), view.
begin(), view.
end(),
false,
false);
769#if ETL_HAS_STRING_TRUNCATION_CHECKS
772#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
779 etl::fill_n(
begin(), n, c);
807#if ETL_HAS_STRING_TRUNCATION_CHECKS
810#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
848 if (sublength == npos)
850 sublength = str.
size() - subposition;
865 template <
class TIterator>
868 append_impl(
end(), first, last,
false,
false);
879 append_impl(
end(), str,
false,
false);
891 append_impl(
end(), str, str + n,
false,
false);
900 template <
typename TOtherTraits>
903 append_impl(
end(), view.
begin(), view.
end(),
false,
false);
917#if ETL_HAS_STRING_TRUNCATION_CHECKS
920#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
925 n = etl::min(n,
size_t(free_space));
927 etl::fill_n(
end(), n, c);
939 iterator
insert(const_iterator position, T value)
949 if (position !=
end())
954 *insert_position = value;
959 *insert_position = value;
966 if (position !=
end())
970 *insert_position = value;
973#if ETL_HAS_STRING_TRUNCATION_CHECKS
976#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
984 return insert_position;
993 iterator
insert(const_iterator position, size_type n, T value)
1006 const size_type start = etl::distance(
cbegin(), position);
1011#if ETL_HAS_STRING_TRUNCATION_CHECKS
1014#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
1026#if ETL_HAS_STRING_TRUNCATION_CHECKS
1029#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
1036 etl::fill(insert_position,
end(), value);
1041 const size_type shift_amount = n;
1042 const size_type to_position = start + shift_amount;
1043 const size_type remaining_characters =
current_size - start;
1044 const size_type max_shift_characters =
CAPACITY - start - shift_amount;
1045 const size_type characters_to_shift = etl::min(max_shift_characters, remaining_characters);
1048 if ((start + shift_amount + remaining_characters) >
CAPACITY)
1052#if ETL_HAS_STRING_TRUNCATION_CHECKS
1055#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
1065 etl::mem_move(insert_position, insert_position + characters_to_shift,
begin() + to_position);
1066 etl::fill(insert_position, insert_position + shift_amount, value);
1081 template <
typename TIterator>
1082 iterator
insert(const_iterator position, TIterator first, TIterator last)
1094 const size_type start = etl::distance(
begin(), position_);
1095 const size_type n = etl::distance(first, last);
1100#if ETL_HAS_STRING_TRUNCATION_CHECKS
1103#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
1115#if ETL_HAS_STRING_TRUNCATION_CHECKS
1118#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
1126 position_ = copy_characters(first, etl::distance(position_,
end()), position_);
1131 const size_type shift_amount = n;
1132 const size_type to_position = start + shift_amount;
1133 const size_type remaining_characters =
current_size - start;
1134 const size_type max_shift_characters =
CAPACITY - start - shift_amount;
1135 const size_type characters_to_shift = etl::min(max_shift_characters, remaining_characters);
1138 if ((start + shift_amount + remaining_characters) >
CAPACITY)
1142#if ETL_HAS_STRING_TRUNCATION_CHECKS
1145#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
1158 position_ = copy_characters(first, etl::distance(first, last), position_);
1172 template <
typename TOtherTraits>
1189#if ETL_HAS_STRING_TRUNCATION_CHECKS
1194#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
1208 template <
typename TOtherTraits>
1230 if ((sublength == npos) || (subposition + sublength > str.
size()))
1232 sublength = str.
size() - subposition;
1237#if ETL_HAS_STRING_TRUNCATION_CHECKS
1242#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
1258 template <
typename TOtherTraits>
1264 if ((sublength == npos) || (subposition + sublength > view.
size()))
1266 sublength = view.
size() - subposition;
1326 length_ = etl::min(length_,
size() - position);
1353 iterator
erase(const_iterator i_element)
1373 iterator
erase(const_iterator first, const_iterator last)
1380 if (first_ == last_)
1386 size_type n_delete = etl::distance(first_, last_);
1409 size_type
copy(pointer dest, size_type count, size_type pos = 0)
const
1415 count = etl::min(count,
size() - pos);
1419 count =
size() - pos;
1439 return find_impl(str.
begin(), str.
end(), str.
size(), pos);
1447 template <
typename TOtherTraits>
1450 return find_impl(view.
begin(), view.
end(), view.
size(), pos);
1458 size_type
find(const_pointer s, size_type pos = 0)
const
1462 return find_impl(s, s + sz, sz, pos);
1471 size_type
find(const_pointer s, size_type pos, size_type n)
const
1475 return find_impl(s, s + n, sz, pos);
1483 size_type
find(T c, size_type position = 0)
const
1485 const_iterator i = etl::find(
begin() + position,
end(), c);
1489 return etl::distance(
begin(), i);
1504 return rfind_impl(str.
rbegin(), str.
rend(), str.
size(), position);
1512 template <
typename TOtherTraits>
1523 size_type
rfind(const_pointer s, size_type position = npos)
const
1527 const_reverse_iterator srbegin(s + len);
1528 const_reverse_iterator srend(s);
1530 return rfind_impl(srbegin, srend, len, position);
1538 size_type
rfind(const_pointer s, size_type position, size_type length_)
const
1540 const_reverse_iterator srbegin(s + length_);
1541 const_reverse_iterator srend(s);
1543 return rfind_impl(srbegin, srend, length_, position);
1551 size_type
rfind(T c, size_type position = npos)
const
1553 if (position >=
size())
1558 position =
size() - position;
1560 const_reverse_iterator i = etl::find(
rbegin() + position,
rend(), c);
1564 return size() - etl::distance(
rbegin(), i) - 1;
1577 return find(str) != npos;
1583 template <
typename TOtherTraits>
1586 return find(view) != npos;
1594 return find(s) != npos;
1602 return find(c) != npos;
1616 template <
typename TOtherTraits>
1629 return compare(0, len, s, len) == 0;
1656 template <
typename TOtherTraits>
1701 length_ = etl::min(length_,
size() - position);
1712 template <
typename TOtherTraits>
1718 length_ = etl::min(length_,
size() - position);
1720 return replace_impl(
begin() + position,
begin() + position + length_, view.
begin(), view.
size(),
false);
1740 template <
typename TOtherTraits>
1743 return replace_impl(first, last, view.
begin(), view.
size(),
false);
1755 length_ = etl::min(length_,
size() - position);
1756 sublength = etl::min(sublength, str.
size() - subposition);
1764 template <
typename TOtherTraits>
1771 length_ = etl::min(length_,
size() - position);
1772 sublength = etl::min(sublength, view.
size() - subposition);
1774 return replace_impl(
begin() + position,
begin() + position + length_, view.
begin() + subposition, sublength,
false);
1785 length_ = etl::min(length_,
size() - position);
1801 return replace_impl(first, last, s, n,
false);
1807 template <
typename TIterator>
1809 replace(const_iterator first, const_iterator last, TIterator s)
1811 return replace_impl(first, last, s,
etl::strlen(s),
false);
1817 template <
size_t Size>
1820 return replace_impl(first, last, literal, Size,
false);
1831 length_ = etl::min(length_,
size() - position);
1833 return replace_impl(
begin() + position,
begin() + position + length_, s, n,
false);
1844 length_ = etl::min(length_,
size() - position);
1847 erase(position, length_);
1865 erase(first_, last_);
1876 template <
typename TIterator>
1884 erase(first_, last_);
1887 insert(first_, first_replace, last_replace);
1900 str.p_buffer + str.
size());
1906 template <
typename TOtherTraits>
1923 length_ = etl::min(length_,
size() - position);
1925 return compare(p_buffer + position,
1926 p_buffer + position + length_,
1928 str.p_buffer + str.
size());
1934 template <
typename TOtherTraits>
1937 return compare(p_buffer + position,
1938 p_buffer + position + length_,
1946 int compare(size_type position, size_type length_,
const ibasic_string& str, size_type subposition, size_type sublength)
const
1952 length_ = etl::min(length_,
size() - position);
1953 sublength = etl::min(sublength, str.
size() - subposition);
1955 return compare(p_buffer + position,
1956 p_buffer + position + length_,
1957 str.p_buffer + subposition,
1958 str.p_buffer + subposition + sublength);
1964 template <
typename TOtherTraits>
1971 length_ = etl::min(length_,
size() - position);
1972 sublength = etl::min(sublength, view.
size() - subposition);
1974 return compare(p_buffer + position,
1975 p_buffer + position + length_,
1976 view.
data() + subposition,
1977 view.
data() + subposition + sublength);
1994 int compare(size_type position, size_type length_, const_pointer s)
const
1996 return compare(p_buffer + position,
1997 p_buffer + position + length_,
2005 int compare(size_type position, size_type length_, const_pointer s, size_type n)
const
2007 return compare(p_buffer + position,
2008 p_buffer + position + length_,
2038 template <
typename TOtherTraits>
2052 if (position <
size())
2054 for (size_type i = position; i <
size(); ++i)
2056 for (size_type j = 0; j < n; ++j)
2058 if (p_buffer[i] == s[j])
2076 if (position <
size())
2078 for (size_type i = position; i <
size(); ++i)
2080 if (p_buffer[i] == c)
2115 template <
typename TOtherTraits>
2127 size_type
find_last_of(const_pointer s, size_type position, size_type n)
const
2134 position = etl::min(position,
size() - 1);
2136 const_reverse_iterator it =
rbegin() +
size() - position - 1;
2138 while (it !=
rend())
2140 for (size_type j = 0; j < n; ++j)
2142 if (p_buffer[position] == s[j])
2167 position = etl::min(position,
size() - 1);
2169 const_reverse_iterator it =
rbegin() +
size() - position - 1;
2171 while (it !=
rend())
2173 if (p_buffer[position] == c)
2210 template <
typename TOtherTraits>
2224 if (position <
size())
2226 for (size_type i = position; i <
size(); ++i)
2230 for (size_type j = 0; j < n; ++j)
2232 if (p_buffer[i] == s[j])
2255 if (position <
size())
2257 for (size_type i = position; i <
size(); ++i)
2259 if (*(p_buffer + i) != c)
2294 template <
typename TOtherTraits>
2313 position = etl::min(position,
size() - 1);
2315 const_reverse_iterator it =
rbegin() +
size() - position - 1;
2317 while (it !=
rend())
2321 for (size_type j = 0; j < n; ++j)
2323 if (p_buffer[position] == s[j])
2351 position = etl::min(position,
size() - 1);
2353 const_reverse_iterator it =
rbegin() +
size() - position - 1;
2355 while (it !=
rend())
2357 if (p_buffer[position] != c)
2395 template <
typename TOtherTraits>
2416 template <
typename TOtherTraits>
2439 append(size_type(1), rhs);
2444#if ETL_HAS_ISTRING_REPAIR
2448 virtual void repair() = 0;
2456#if ETL_HAS_STRING_TRUNCATION_CHECKS
2469#if ETL_HAS_STRING_TRUNCATION_CHECKS
2495#if ETL_HAS_STRING_TRUNCATION_CHECKS
2505 p_buffer = p_buffer_;
2518 if ((first == last) && (s == ETL_NULLPTR ||
length == 0U))
2535 const bool source_overlaps = (s != ETL_NULLPTR) &&
2539 if (source_overlaps)
2543 erase(first_, last_);
2545 if (s != ETL_NULLPTR &&
length != 0U)
2555 const size_type remove_index = size_type(first_ - p_buffer);
2556 const size_type remove_length = size_type(last_ - first_);
2557 const size_type free_space =
CAPACITY - remove_index;
2559 size_type insert_length = (s == ETL_NULLPTR) ? 0U :
length;
2562 if (insert_length > free_space)
2564 insert_length = free_space;
2568 size_type tail_index = remove_index + remove_length;
2570 size_type tail_space = free_space - insert_length;
2572#if ETL_HAS_STRING_TRUNCATION_CHECKS
2577 if (tail_space < tail_length)
2579 tail_length = tail_space;
2583 if (insert_length == remove_length)
2588 else if (insert_length > remove_length)
2592 etl::mem_move(&p_buffer[tail_index], tail_length, &p_buffer[remove_index + insert_length]);
2604 etl::mem_copy(&p_buffer[tail_index], tail_length, &p_buffer[remove_index + insert_length]);
2607 current_size = remove_index + insert_length + tail_length;
2618 static int compare(const_pointer first1, const_pointer last1,
2619 const_pointer first2, const_pointer last2)
2621 typedef typename etl::make_unsigned<value_type>::type type;
2623 difference_type length1 = etl::distance(first1, last1);
2624 difference_type length2 = etl::distance(first2, last2);
2625 difference_type compare_length = etl::min(length1, length2);
2628 while (compare_length != 0)
2630 if (
static_cast<type
>(*first1) <
static_cast<type
>(*first2))
2635 else if (
static_cast<type
>(*first1) >
static_cast<type
>(*first2))
2647 if (length1 < length2)
2653 if (length1 > length2)
2668#if ETL_HAS_STRING_CLEAR_AFTER_USE
2689#if defined(ETL_POLYMORPHIC_STRINGS) || defined(ETL_POLYMORPHIC_CONTAINERS) || defined(ETL_ISTRING_REPAIR_ENABLE)
2697#if ETL_HAS_STRING_CLEAR_AFTER_USE
2712 return const_cast<iterator
>(itr);
2720 return (ptr >= p_buffer) && (ptr <= (p_buffer +
CAPACITY));
2729 template <
typename TIterator1>
2732 copy_characters(TIterator1 from,
size_t n,
iterator to)
2743 template <
typename TIterator1>
2746 copy_characters(TIterator1 from,
size_t n, iterator to)
2762 template <
typename TIterator>
2763 void append_impl(iterator position, TIterator first, TIterator last,
bool truncated,
bool secure)
2765 difference_type start = etl::distance(p_buffer, position);
2766 difference_type count = etl::distance(first, last);
2767 difference_type free_space = etl::distance(position, p_buffer +
CAPACITY);
2769#if ETL_IS_DEBUG_BUILD
2770 ETL_ASSERT(count >= 0, ETL_ERROR(string_iterator));
2773#if ETL_HAS_STRING_TRUNCATION_CHECKS
2776#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
2783#if ETL_HAS_STRING_CLEAR_AFTER_USE
2793 count = etl::min(count, free_space);
2794 copy_characters(first,
size_t(count), position);
2804 void append_impl(iterator position, const_pointer src,
bool truncated,
bool secure)
2806 if (src == ETL_NULLPTR)
2812 difference_type start = etl::distance(p_buffer, position);
2813 difference_type free_space = etl::distance(position, p_buffer +
CAPACITY);
2815 pointer dst = position;
2816 size_t length = get_string_length(src);
2817 size_t count = (
length < size_t(free_space)) ?
length : size_t(free_space);
2824#if ETL_HAS_STRING_TRUNCATION_CHECKS
2826#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
2833#if ETL_HAS_STRING_CLEAR_AFTER_USE
2848 template <
typename TIterator>
2849 size_type find_impl(TIterator first, TIterator last, size_type sz, size_type pos = 0)
const
2851 if ((pos + sz) >
size())
2856 const_iterator iposition = etl::search(
begin() + pos,
end(), first, last);
2858 if (iposition ==
end())
2864 return etl::distance(
begin(), iposition);
2871 template <
typename TIterator>
2872 size_type rfind_impl(TIterator rfirst, TIterator rlast, size_type sz, size_type pos = 0)
const
2886 const_reverse_iterator iposition = etl::search(
rbegin() + pos,
rend(), rfirst, rlast);
2888 if (iposition ==
rend())
2894 return size() - sz - etl::distance(
rbegin(), iposition);
2901 template <
typename U>
2903 typename etl::enable_if<
sizeof(U) ==
sizeof(
char),
size_t>::type
2904 get_string_length(
const U* str)
2906 return ::strlen(
reinterpret_cast<const char*
>(str));
2909#if ETL_USING_LIBC_WCHAR_H
2913 template <
typename U>
2915 typename etl::enable_if<
sizeof(U) ==
sizeof(
wchar_t),
size_t>::type
2916 get_string_length(
const U* str)
2918 return ::wcslen(
reinterpret_cast<const wchar_t*
>(str));
2925 template <
typename U>
2927#if ETL_USING_LIBC_WCHAR_H
2928 typename etl::enable_if<(
sizeof(U) !=
sizeof(char)) && (
sizeof(U) !=
sizeof(
wchar_t)),
size_t>::type
2930 typename etl::enable_if<(
sizeof(U) !=
sizeof(char)),
size_t>::type
2932 get_string_length(
const U* str)
2934 if (str == ETL_NULLPTR)
2946 return size_t(
end - str) - 1;
2957 template <
typename T>
2970 template <
typename T>
2983 template <
typename T>
2996 template <
typename T>
2999 return !(lhs == rhs);
3009 template <
typename T>
3012 return !(lhs == rhs);
3022 template <
typename T>
3025 return !(lhs == rhs);
3035 template <
typename T>
3038 return etl::lexicographical_compare(lhs.
begin(), lhs.
end(), rhs.
begin(), rhs.
end());
3048 template <
typename T>
3061 template <
typename T>
3075 template <
typename T>
3088 template <
typename T>
3101 template <
typename T>
3115 template <
typename T>
3118 return !(lhs > rhs);
3128 template <
typename T>
3131 return !(lhs > rhs);
3141 template <
typename T>
3144 return !(lhs > rhs);
3155 template <
typename T>
3158 return !(lhs < rhs);
3168 template <
typename T>
3171 return !(lhs < rhs);
3181 template <
typename T>
3184 return !(lhs < rhs);
3194#if ETL_USING_STD_OSTREAM
3195 template <
typename T>
3196 std::basic_ostream<T, std::char_traits<T> > &
operator<<(std::basic_ostream<T, std::char_traits<T> > &os,
3205#undef ETL_USING_WCHAR_T_H
String view.
Definition string_view.h:104
ETL_CONSTEXPR const_iterator cbegin() const ETL_NOEXCEPT
Returns a const iterator to the beginning of the array.
Definition string_view.h:212
ETL_CONSTEXPR size_t size() const ETL_NOEXCEPT
Returns the size of the array.
Definition string_view.h:280
ETL_CONSTEXPR const_reverse_iterator rend() const ETL_NOEXCEPT
Returns a const reverse iterator to the end of the array.
Definition string_view.h:252
ETL_CONSTEXPR const_pointer data() const ETL_NOEXCEPT
Returns a const pointer to the first element of the internal storage.
Definition string_view.h:196
ETL_CONSTEXPR const_iterator end() const ETL_NOEXCEPT
Returns a const iterator to the end of the array.
Definition string_view.h:220
ETL_CONSTEXPR const_iterator begin() const ETL_NOEXCEPT
Returns a const iterator to the beginning of the array.
Definition string_view.h:204
ETL_CONSTEXPR const_reverse_iterator rbegin() const ETL_NOEXCEPT
Returns a const reverse iterator to the reverse beginning of the array.
Definition string_view.h:236
Definition basic_string.h:351
int compare(size_type position, size_type length_, const ibasic_string &str) const
Compare position / length with string.
Definition basic_string.h:1918
ibasic_string & append(TIterator first, TIterator last)
Definition basic_string.h:866
size_type find_last_of(const_pointer s, size_type position=npos) const
Definition basic_string.h:2105
size_type rfind(const_pointer s, size_type position=npos) const
Definition basic_string.h:1523
ibasic_string & replace(const_iterator first, const_iterator last, const etl::basic_string_view< T, TOtherTraits > &view)
Definition basic_string.h:1741
etl::enable_if< etl::is_same< TIterator, const_pointer >::value, ibasic_string >::type & replace(const_iterator first, const_iterator last, TIterator s)
Replace characters from 'first' to 'last' with pointed to string.
Definition basic_string.h:1809
etl::ibasic_string< T > & insert(size_type position, const etl::ibasic_string< T > &str)
Definition basic_string.h:1183
ibasic_string & replace(const_iterator first, const_iterator last, const value_type(&literal)[Size])
Replace characters from 'first' 'last' with pointed to literal string.
Definition basic_string.h:1818
size_type find_last_not_of(const_pointer s, size_type position=npos) const
Definition basic_string.h:2284
size_type find(const_pointer s, size_type pos=0) const
Definition basic_string.h:1458
ibasic_string & operator=(const ibasic_string &rhs)
Assignment operator.
Definition basic_string.h:2372
ibasic_string & append(const ibasic_string &str, size_type subposition, size_type sublength=npos)
Definition basic_string.h:846
const_reverse_iterator rbegin() const
Definition basic_string.h:435
bool contains(const etl::ibasic_string< T > &str) const
Checks that the string is within this string.
Definition basic_string.h:1575
reference operator[](size_type i)
Definition basic_string.h:561
void assign(const etl::ibasic_string< T > &other, size_type subposition, size_type sublength)
Definition basic_string.h:699
etl::ibasic_string< T > & insert(size_type position, const etl::basic_string_view< T, TOtherTraits > &view, size_type subposition, size_type sublength)
Definition basic_string.h:1259
pointer data_end()
Definition basic_string.h:664
iterator erase(const_iterator first, const_iterator last)
Definition basic_string.h:1373
iterator insert(const_iterator position, TIterator first, TIterator last)
Definition basic_string.h:1082
bool is_within_buffer(const_pointer ptr) const
Checks if a pointer is within the buffer.
Definition basic_string.h:2718
bool contains(value_type c) const
Checks that character is within this string.
Definition basic_string.h:1600
size_type find_last_of(const ibasic_string< T > &str, size_type position=npos) const
Definition basic_string.h:2095
size_type find_first_of(value_type c, size_type position=0) const
Definition basic_string.h:2074
bool starts_with(const etl::ibasic_string< T > &str) const
Checks that the string is the start of this string.
Definition basic_string.h:1608
size_type find(T c, size_type position=0) const
Definition basic_string.h:1483
ibasic_string & replace(size_type position, size_type length_, const etl::basic_string_view< T, TOtherTraits > &view, size_type subposition, size_type sublength)
Replace characters from 'position' of 'length' with 'view' from 'subposition' of 'sublength'.
Definition basic_string.h:1765
bool ends_with(value_type c) const
Checks that the character is the end of this string.
Definition basic_string.h:1685
void pop_back()
Definition basic_string.h:821
size_type rfind(const ibasic_string< T > &str, size_type position=npos) const
Definition basic_string.h:1502
bool contains(const_pointer s) const
Checks that text is within this string.
Definition basic_string.h:1592
etl::ibasic_string< T > & insert(size_type position, const etl::basic_string_view< T, TOtherTraits > &view)
Definition basic_string.h:1209
void resize_and_overwrite(size_type new_size, TOperation operation)
Resizes the string and overwrites to data using the operation.
Definition basic_string.h:521
void initialize_free_space()
Clears the free space to string terminator value.
Definition basic_string.h:2454
ibasic_string & replace(size_type position, size_type length_, const_pointer s, size_type n)
Replace characters from 'position' of 'length' with 'n' characters from pointed to string.
Definition basic_string.h:1826
iterator to_iterator(const_iterator itr) const
Convert from const_iterator to iterator.
Definition basic_string.h:2710
ibasic_string & replace(size_type position, size_type length_, size_type n, value_type c)
Replace characters from 'position' of 'length' with 'n' copies of 'c'.
Definition basic_string.h:1839
ibasic_string & replace(const_iterator first, const_iterator last, const ibasic_string &str)
Definition basic_string.h:1729
size_type find_first_of(const ibasic_string< T > &str, size_type position=0) const
Definition basic_string.h:2018
size_type find_first_of(const etl::basic_string_view< T, TOtherTraits > &view, size_type position=0) const
Definition basic_string.h:2039
const_reference back() const
Definition basic_string.h:636
void assign(const_pointer str, size_type n)
Definition basic_string.h:745
const_iterator begin() const
Definition basic_string.h:381
size_type find_last_of(const_pointer s, size_type position, size_type n) const
Definition basic_string.h:2127
bool ends_with(const etl::basic_string_view< T, TOtherTraits > &view) const
Checks that the view is the end of this string.
Definition basic_string.h:1657
reverse_iterator rbegin()
Definition basic_string.h:426
ibasic_string & replace(const_iterator first, const_iterator last, TIterator first_replace, TIterator last_replace)
Replace characters from 'first' of 'last' with characters from 'first_replace' to 'last_replace'.
Definition basic_string.h:1877
void resize(size_type new_size)
Definition basic_string.h:481
size_type find_last_not_of(const_pointer s, size_type position, size_type n) const
Definition basic_string.h:2306
ibasic_string & replace(size_type position, size_type length_, const etl::basic_string_view< T, TOtherTraits > &view)
Definition basic_string.h:1713
size_type find_first_not_of(const_pointer s, size_type position=0) const
Definition basic_string.h:2200
size_type rfind(T c, size_type position=npos) const
Definition basic_string.h:1551
etl::ibasic_string< T > & erase(size_type position, size_type length_=npos)
Definition basic_string.h:1321
int compare(const value_type *s) const
Compare with C string.
Definition basic_string.h:1983
int compare(size_type position, size_type length_, const_pointer s) const
Compare position / length with C string.
Definition basic_string.h:1994
iterator insert(const_iterator position, size_type n, T value)
Definition basic_string.h:993
ibasic_string & append(const etl::basic_string_view< T, TOtherTraits > &view)
Definition basic_string.h:901
const_reference at(size_type i) const
Definition basic_string.h:596
void assign(const etl::basic_string_view< T, TOtherTraits > &view)
Assigns values to the string from a view.
Definition basic_string.h:754
void clear()
Clears the string.
Definition basic_string.h:787
int compare(size_type position, size_type length_, const ibasic_string &str, size_type subposition, size_type sublength) const
Compare position / length with string / subposition / sublength.
Definition basic_string.h:1946
reverse_iterator rend()
Definition basic_string.h:444
size_type find_last_of(const etl::basic_string_view< T, TOtherTraits > &view, size_type position=npos) const
Definition basic_string.h:2116
iterator erase(iterator i_element)
Definition basic_string.h:1338
ibasic_string & append(const_pointer str, size_type n)
Definition basic_string.h:889
const_reverse_iterator crend() const
Definition basic_string.h:471
bool contains(const etl::basic_string_view< T, TOtherTraits > &view) const
Checks that the view is within this string.
Definition basic_string.h:1584
reference at(size_type i)
Definition basic_string.h:584
size_type rfind(const etl::basic_string_view< T, TOtherTraits > &view, size_type pos=0) const
Definition basic_string.h:1513
bool starts_with(value_type c) const
Checks that the character is the start of this string.
Definition basic_string.h:1635
int compare(const etl::basic_string_view< T, TOtherTraits > &view) const
Compare with etl::basic_string_view.
Definition basic_string.h:1907
~ibasic_string()
Destructor.
Definition basic_string.h:2695
size_type find(const_pointer s, size_type pos, size_type n) const
Definition basic_string.h:1471
size_type find_first_of(const_pointer s, size_type position=0) const
Definition basic_string.h:2028
ibasic_string & replace(size_type position, size_type length_, const ibasic_string &str, size_type subposition, size_type sublength)
Replace characters from 'position' of 'length' with 'str' from 'subposition' of 'sublength'.
Definition basic_string.h:1749
iterator begin()
Definition basic_string.h:372
iterator end()
Definition basic_string.h:390
ibasic_string & replace(const_iterator first, const_iterator last, size_type n, value_type c)
Replace characters from 'first' of 'last' with 'n' copies of 'c'.
Definition basic_string.h:1858
ibasic_string & replace(const_iterator first, const_iterator last, const_pointer s, size_type n)
Definition basic_string.h:1799
void assign(TIterator first, TIterator last)
Definition basic_string.h:724
etl::ibasic_string< T > & insert(size_type position, const etl::ibasic_string< T > &str, size_type subposition, size_type sublength)
Definition basic_string.h:1225
size_type find(const ibasic_string< T > &str, size_type pos=0) const
Definition basic_string.h:1437
void push_back(T value)
Definition basic_string.h:798
size_type find_first_not_of(const_pointer s, size_type position, size_type n) const
Definition basic_string.h:2222
const_reverse_iterator crbegin() const
Definition basic_string.h:462
iterator insert(const_iterator position, T value)
Definition basic_string.h:939
etl::ibasic_string< T > & insert(size_type position, const_pointer s, size_type n)
Definition basic_string.h:1293
ibasic_string & replace(size_type position, size_type length_, const ibasic_string &str)
Definition basic_string.h:1696
ibasic_string(T *p_buffer_, size_type MAX_SIZE_)
Constructor.
Definition basic_string.h:2482
bool ends_with(const_pointer s) const
Checks that the string is the end of this string.
Definition basic_string.h:1670
etl::ibasic_string< T > & insert(size_type position, size_type n, value_type c)
Definition basic_string.h:1307
const_reverse_iterator rend() const
Definition basic_string.h:453
size_type find_last_not_of(const ibasic_string< T > &str, size_type position=npos) const
Definition basic_string.h:2274
size_type find(const etl::basic_string_view< T, TOtherTraits > &view, size_type pos=0) const
Definition basic_string.h:1448
const_pointer data_end() const
Definition basic_string.h:673
void assign(const etl::ibasic_string< T > &other)
Definition basic_string.h:683
const_iterator cend() const
Definition basic_string.h:417
const_pointer c_str() const
Return a pointer to a C string.
Definition basic_string.h:1398
void resize(size_type new_size, T value)
Definition basic_string.h:491
ETL_CONSTEXPR const_pointer data() const
Definition basic_string.h:655
const_reference front() const
Definition basic_string.h:616
pointer data()
Definition basic_string.h:646
size_type find_first_not_of(value_type c, size_type position=0) const
Definition basic_string.h:2253
ibasic_string & append(const_pointer str)
Definition basic_string.h:877
ibasic_string & append(size_type n, T c)
Definition basic_string.h:913
size_type find_first_not_of(const ibasic_string< T > &str, size_type position=0) const
Definition basic_string.h:2190
size_type find_last_of(value_type c, size_type position=npos) const
Definition basic_string.h:2160
size_type copy(pointer dest, size_type count, size_type pos=0) const
Definition basic_string.h:1409
ibasic_string & append(const ibasic_string &str)
Definition basic_string.h:833
size_type find_last_not_of(const etl::basic_string_view< T, TOtherTraits > &view, size_type position=npos) const
Definition basic_string.h:2295
ibasic_string & replace(size_type position, size_type length_, const_pointer s)
Replace characters from 'position' of 'length' with pointed to string.
Definition basic_string.h:1780
reference front()
Definition basic_string.h:606
reference back()
Definition basic_string.h:626
bool starts_with(const_pointer s) const
Checks that the string is the start of this string.
Definition basic_string.h:1625
const_iterator cbegin() const
Definition basic_string.h:408
size_type find_first_not_of(const etl::basic_string_view< T, TOtherTraits > &view, size_type position=0) const
Definition basic_string.h:2211
int compare(size_type position, size_type length_, const etl::basic_string_view< T, TOtherTraits > &view, size_type subposition, size_type sublength) const
Compare position / length with etl::basic_string_view. / subposition / sublength.
Definition basic_string.h:1965
void assign(size_type n, T c)
Definition basic_string.h:765
void initialise()
Initialise the string.
Definition basic_string.h:2491
bool starts_with(const etl::basic_string_view< T, TOtherTraits > &view) const
Checks that the view is the start of this string.
Definition basic_string.h:1617
ibasic_string & operator+=(const ibasic_string &rhs)
+= operator.
Definition basic_string.h:2406
void trim_to_terminator()
Definition basic_string.h:2467
void uninitialized_resize(size_type new_size)
Definition basic_string.h:538
int compare(size_type position, size_type length_, const_pointer s, size_type n) const
Compare position / length with C string / n.
Definition basic_string.h:2005
size_type rfind(const_pointer s, size_type position, size_type length_) const
Definition basic_string.h:1538
bool ends_with(const etl::ibasic_string< T > &str) const
Checks that the string is the end of this string.
Definition basic_string.h:1643
size_type find_first_of(const_pointer s, size_type position, size_type n) const
Definition basic_string.h:2050
int compare(const ibasic_string &str) const
Compare with string.
Definition basic_string.h:1895
const_iterator end() const
Definition basic_string.h:399
iterator erase(const_iterator i_element)
Definition basic_string.h:1353
int compare(size_type position, size_type length_, const etl::basic_string_view< T, TOtherTraits > &view) const
Compare position / length with etl::basic_string_view.
Definition basic_string.h:1935
etl::ibasic_string< T > & insert(size_type position, const_pointer s)
Definition basic_string.h:1279
void assign(const_pointer str)
Definition basic_string.h:734
void fill(T value)
Definition basic_string.h:551
void repair_buffer(T *p_buffer_)
Fix the internal pointers after a low level memory copy.
Definition basic_string.h:2503
iterator insert(const_iterator position, const etl::basic_string_view< T, TOtherTraits > &view)
Definition basic_string.h:1173
Definition basic_string.h:161
Definition basic_string.h:184
void set_secure()
Sets the 'secure' flag to the requested state.
Definition basic_string.h:290
bool is_secure() const
Gets the 'secure' state flag.
Definition basic_string.h:299
const size_type CAPACITY
The maximum number of elements in the string.
Definition basic_string.h:337
bool full() const
Definition basic_string.h:220
~string_base()
Destructor.
Definition basic_string.h:332
ETL_DEPRECATED bool truncated() const
Definition basic_string.h:271
void set_truncated(bool status)
Sets the 'truncated' flag.
Definition basic_string.h:323
size_type max_size() const
Definition basic_string.h:238
string_base(size_type max_size_)
Constructor.
Definition basic_string.h:313
void clear_truncated()
Clears the 'truncated' flag.
Definition basic_string.h:280
size_type length() const
Definition basic_string.h:202
size_type current_size
The current number of elements in the string.
Definition basic_string.h:336
size_type available() const
Definition basic_string.h:247
bool empty() const
Definition basic_string.h:211
size_type capacity() const
Definition basic_string.h:229
bool is_truncated() const
Definition basic_string.h:256
size_type size() const
Definition basic_string.h:193
Definition basic_string.h:87
Definition basic_string.h:129
Definition basic_string.h:115
Definition basic_string.h:143
#define ETL_ASSERT(b, e)
Definition error_handler.h:356
ETL_CONSTEXPR exception(string_type reason_, string_type, numeric_type line_)
Constructor.
Definition exception.h:69
Definition exception.h:47
Definition integral_limits.h:516
void memory_clear_range(volatile T *begin, size_t n)
Definition memory.h:2018
enable_if
Definition type_traits_generator.h:1254
is_pointer
Definition type_traits_generator.h:1164
remove_pointer
Definition type_traits_generator.h:951
Definition basic_string.h:157
bitset_ext
Definition absolute.h:39
T * mem_move(const T *sb, const T *se, T *db) ETL_NOEXCEPT
Definition memory.h:2339
std::basic_ostream< T, std::char_traits< T > > & operator<<(std::basic_ostream< T, std::char_traits< T > > &os, const etl::ibasic_string< T > &str)
Definition basic_string.h:3196
etl::enable_if< etl::is_pointer< TPointer >::value &&!etl::is_const< TPointer >::value &&etl::is_integral< T >::value &&sizeof(T)==1, TPointer >::type mem_set(TPointer db, const TPointer de, T value) ETL_NOEXCEPT
Definition memory.h:2445
bool operator>(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1190
bool operator>=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1202
bool operator!=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1151
bool operator==(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1139
T * mem_copy(const T *sb, const T *se, T *db) ETL_NOEXCEPT
Definition memory.h:2289
ETL_CONSTEXPR14 size_t strlen(const T *t) ETL_NOEXCEPT
Alternative strlen for all character types.
Definition char_traits.h:287
bool operator<(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1163
bool operator<=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1178
iterator
Definition iterator.h:399