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);
337#if ETL_HAS_STRING_TRUNCATION_CHECKS || ETL_HAS_STRING_CLEAR_AFTER_USE
348 template <
typename T>
355 typedef T value_type;
356 typedef T& reference;
357 typedef const T& const_reference;
359 typedef const T* const_pointer;
361 typedef const T* const_iterator;
362 typedef ETL_OR_STD::reverse_iterator<iterator> reverse_iterator;
363 typedef ETL_OR_STD::reverse_iterator<const_iterator> const_reverse_iterator;
365 typedef typename etl::iterator_traits<iterator>::difference_type difference_type;
398 const_iterator
end()
const
427 return reverse_iterator(
end());
436 return const_reverse_iterator(
end());
445 return reverse_iterator(
begin());
452 const_reverse_iterator
rend()
const
454 return const_reverse_iterator(
begin());
463 return const_reverse_iterator(
cend());
470 const_reverse_iterator
crend()
const
472 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;
585 reference
at(size_type i)
598 const_reference
at(size_type i)
const
631 return p_buffer[
size() - 1];
641 return p_buffer[
size() - 1];
657 ETL_CONSTEXPR const_pointer
data()
const
707 if (sublength == npos)
709 sublength = other.
size() - subposition;
726 template <
typename TIterator>
727 void assign(TIterator first, TIterator last)
729 append_impl(
begin(), first, last,
false,
false);
739 append_impl(
begin(), str,
false,
false);
748 void assign(const_pointer str, size_type n)
750 append_impl(
begin(), str, str + n,
false,
false);
756 template <
typename TOtherTraits>
759 append_impl(
begin(), view.
begin(), view.
end(),
false,
false);
772#if ETL_HAS_STRING_TRUNCATION_CHECKS
775 #if ETL_HAS_ERROR_ON_STRING_TRUNCATION
782 etl::fill_n(
begin(), n, c);
810#if ETL_HAS_STRING_TRUNCATION_CHECKS
813 #if ETL_HAS_ERROR_ON_STRING_TRUNCATION
851 if (sublength == npos)
853 sublength = str.
size() - subposition;
868 template <
class TIterator>
871 append_impl(
end(), first, last,
false,
false);
882 append_impl(
end(), str,
false,
false);
894 append_impl(
end(), str, str + n,
false,
false);
903 template <
typename TOtherTraits>
906 append_impl(
end(), view.
begin(), view.
end(),
false,
false);
920#if ETL_HAS_STRING_TRUNCATION_CHECKS
923 #if ETL_HAS_ERROR_ON_STRING_TRUNCATION
928 n = etl::min(n,
size_t(free_space));
930 etl::fill_n(
end(), n, c);
942 iterator
insert(const_iterator position, T value)
952 if (position !=
end())
957 *insert_position = value;
962 *insert_position = value;
969 if (position !=
end())
973 *insert_position = value;
976#if ETL_HAS_STRING_TRUNCATION_CHECKS
979 #if ETL_HAS_ERROR_ON_STRING_TRUNCATION
987 return insert_position;
996 iterator
insert(const_iterator position, size_type n, T value)
1009 const size_type start =
static_cast<size_type
>(etl::distance(
cbegin(), position));
1014#if ETL_HAS_STRING_TRUNCATION_CHECKS
1017 #if ETL_HAS_ERROR_ON_STRING_TRUNCATION
1029#if ETL_HAS_STRING_TRUNCATION_CHECKS
1032 #if ETL_HAS_ERROR_ON_STRING_TRUNCATION
1039 etl::fill(insert_position,
end(), value);
1044 const size_type shift_amount = n;
1045 const size_type to_position = start + shift_amount;
1046 const size_type remaining_characters =
current_size - start;
1047 const size_type max_shift_characters =
CAPACITY - start - shift_amount;
1048 const size_type characters_to_shift = etl::min(max_shift_characters, remaining_characters);
1051 if ((start + shift_amount + remaining_characters) >
CAPACITY)
1055#if ETL_HAS_STRING_TRUNCATION_CHECKS
1058 #if ETL_HAS_ERROR_ON_STRING_TRUNCATION
1068 etl::mem_move(insert_position, insert_position + characters_to_shift,
begin() + to_position);
1069 etl::fill(insert_position, insert_position + shift_amount, value);
1085 template <
typename TIterator>
1086 iterator
insert(const_iterator position, TIterator first, TIterator last)
1098 const size_type start =
static_cast<size_type
>(etl::distance(
begin(), position_));
1099 const size_type n =
static_cast<size_type
>(etl::distance(first, last));
1104#if ETL_HAS_STRING_TRUNCATION_CHECKS
1107 #if ETL_HAS_ERROR_ON_STRING_TRUNCATION
1119#if ETL_HAS_STRING_TRUNCATION_CHECKS
1122 #if ETL_HAS_ERROR_ON_STRING_TRUNCATION
1130 position_ = copy_characters(first,
static_cast<size_t>(etl::distance(position_,
end())), position_);
1135 const size_type shift_amount = n;
1136 const size_type to_position = start + shift_amount;
1137 const size_type remaining_characters =
current_size - start;
1138 const size_type max_shift_characters =
CAPACITY - start - shift_amount;
1139 const size_type characters_to_shift = etl::min(max_shift_characters, remaining_characters);
1142 if ((start + shift_amount + remaining_characters) >
CAPACITY)
1146#if ETL_HAS_STRING_TRUNCATION_CHECKS
1149 #if ETL_HAS_ERROR_ON_STRING_TRUNCATION
1163 position_ = copy_characters(first,
static_cast<size_t>(etl::distance(first, last)), position_);
1178 template <
typename TOtherTraits>
1195#if ETL_HAS_STRING_TRUNCATION_CHECKS
1200 #if ETL_HAS_ERROR_ON_STRING_TRUNCATION
1214 template <
typename TOtherTraits>
1237 if ((sublength == npos) || (subposition + sublength > str.
size()))
1239 sublength = str.
size() - subposition;
1244#if ETL_HAS_STRING_TRUNCATION_CHECKS
1249 #if ETL_HAS_ERROR_ON_STRING_TRUNCATION
1265 template <
typename TOtherTraits>
1271 if ((sublength == npos) || (subposition + sublength > view.
size()))
1273 sublength = view.
size() - subposition;
1334 length_ = etl::min(length_,
size() - position);
1363 iterator
erase(const_iterator i_element)
1384 iterator
erase(const_iterator first, const_iterator last)
1391 if (first_ == last_)
1397 size_type n_delete =
static_cast<size_type
>(etl::distance(first_, last_));
1420 size_type
copy(pointer dest, size_type count, size_type pos = 0)
const
1426 count = etl::min(count,
size() - pos);
1430 count =
size() - pos;
1450 return find_impl(str.
begin(), str.
end(), str.
size(), pos);
1458 template <
typename TOtherTraits>
1461 return find_impl(view.
begin(), view.
end(), view.
size(), pos);
1469 size_type
find(const_pointer s, size_type pos = 0)
const
1473 return find_impl(s, s + sz, sz, pos);
1482 size_type
find(const_pointer s, size_type pos, size_type n)
const
1486 return find_impl(s, s + n, sz, pos);
1494 size_type
find(T c, size_type position = 0)
const
1496 const_iterator i = etl::find(
begin() + position,
end(), c);
1500 return static_cast<size_type
>(etl::distance(
begin(), i));
1515 return rfind_impl(str.
rbegin(), str.
rend(), str.
size(), position);
1523 template <
typename TOtherTraits>
1534 size_type
rfind(const_pointer s, size_type position = npos)
const
1538 const_reverse_iterator srbegin(s + len);
1539 const_reverse_iterator srend(s);
1541 return rfind_impl(srbegin, srend, len, position);
1549 size_type
rfind(const_pointer s, size_type position, size_type length_)
const
1551 const_reverse_iterator srbegin(s + length_);
1552 const_reverse_iterator srend(s);
1554 return rfind_impl(srbegin, srend, length_, position);
1562 size_type
rfind(T c, size_type position = npos)
const
1564 if (position >=
size())
1569 position =
size() - position;
1571 const_reverse_iterator i = etl::find(
rbegin() +
static_cast<difference_type
>(position),
rend(), c);
1575 return size() -
static_cast<size_type
>(etl::distance(
rbegin(), i)) - 1;
1588 return find(str) != npos;
1594 template <
typename TOtherTraits>
1597 return find(view) != npos;
1605 return find(s) != npos;
1613 return find(c) != npos;
1627 template <
typename TOtherTraits>
1640 return compare(0, len, s, len) == 0;
1667 template <
typename TOtherTraits>
1712 length_ = etl::min(length_,
size() - position);
1723 template <
typename TOtherTraits>
1729 length_ = etl::min(length_,
size() - position);
1731 return replace_impl(
begin() + position,
begin() + position + length_, view.
begin(), view.
size(),
false);
1751 template <
typename TOtherTraits>
1754 return replace_impl(first, last, view.
begin(), view.
size(),
false);
1767 length_ = etl::min(length_,
size() - position);
1768 sublength = etl::min(sublength, str.
size() - subposition);
1777 template <
typename TOtherTraits>
1779 size_type sublength)
1785 length_ = etl::min(length_,
size() - position);
1786 sublength = etl::min(sublength, view.
size() - subposition);
1788 return replace_impl(
begin() + position,
begin() + position + length_, view.
begin() + subposition, sublength,
false);
1799 length_ = etl::min(length_,
size() - position);
1815 return replace_impl(first, last, s, n,
false);
1821 template <
typename TIterator>
1825 return replace_impl(first, last, s,
etl::strlen(s),
false);
1831 template <
size_t Size>
1834 return replace_impl(first, last, literal, Size,
false);
1846 length_ = etl::min(length_,
size() - position);
1848 return replace_impl(
begin() + position,
begin() + position + length_, s, n,
false);
1859 length_ = etl::min(length_,
size() - position);
1862 erase(position, length_);
1880 erase(first_, last_);
1892 template <
typename TIterator>
1900 erase(first_, last_);
1903 insert(first_, first_replace, last_replace);
1913 return compare(p_buffer, p_buffer +
size(), str.p_buffer, str.p_buffer + str.
size());
1919 template <
typename TOtherTraits>
1933 length_ = etl::min(length_,
size() - position);
1935 return compare(p_buffer + position, p_buffer + position + length_, str.p_buffer, str.p_buffer + str.
size());
1941 template <
typename TOtherTraits>
1944 return compare(p_buffer + position, p_buffer + position + length_, view.
data(), view.
data() + view.
size());
1950 int compare(size_type position, size_type length_,
const ibasic_string& str, size_type subposition, size_type sublength)
const
1956 length_ = etl::min(length_,
size() - position);
1957 sublength = etl::min(sublength, str.
size() - subposition);
1959 return compare(p_buffer + position, p_buffer + position + length_, str.p_buffer + subposition, str.p_buffer + subposition + sublength);
1966 template <
typename TOtherTraits>
1968 size_type sublength)
const
1974 length_ = etl::min(length_,
size() - position);
1975 sublength = etl::min(sublength, view.
size() - subposition);
1977 return compare(p_buffer + position, p_buffer + position + length_, view.
data() + subposition, view.
data() + subposition + sublength);
1991 int compare(size_type position, size_type length_, const_pointer s)
const
1993 return compare(p_buffer + position, p_buffer + position + length_, s, s +
etl::strlen(s));
1999 int compare(size_type position, size_type length_, const_pointer s, size_type n)
const
2001 return compare(p_buffer + position, p_buffer + position + length_, s, s + n);
2029 template <
typename TOtherTraits>
2043 if (position <
size())
2045 for (size_type i = position; i <
size(); ++i)
2047 for (size_type j = 0; j < n; ++j)
2049 if (p_buffer[i] == s[j])
2067 if (position <
size())
2069 for (size_type i = position; i <
size(); ++i)
2071 if (p_buffer[i] == c)
2106 template <
typename TOtherTraits>
2118 size_type
find_last_of(const_pointer s, size_type position, size_type n)
const
2125 position = etl::min(position,
size() - 1);
2127 const_reverse_iterator it =
rbegin() +
static_cast<difference_type
>(
size() - position - 1);
2129 while (it !=
rend())
2131 for (size_type j = 0; j < n; ++j)
2133 if (p_buffer[position] == s[j])
2158 position = etl::min(position,
size() - 1);
2160 const_reverse_iterator it =
rbegin() +
static_cast<difference_type
>(
size() - position - 1);
2162 while (it !=
rend())
2164 if (p_buffer[position] == c)
2201 template <
typename TOtherTraits>
2215 if (position <
size())
2217 for (size_type i = position; i <
size(); ++i)
2221 for (size_type j = 0; j < n; ++j)
2223 if (p_buffer[i] == s[j])
2246 if (position <
size())
2248 for (size_type i = position; i <
size(); ++i)
2250 if (*(p_buffer + i) != c)
2285 template <
typename TOtherTraits>
2304 position = etl::min(position,
size() - 1);
2306 const_reverse_iterator it =
rbegin() +
static_cast<difference_type
>(
size() - position - 1);
2308 while (it !=
rend())
2312 for (size_type j = 0; j < n; ++j)
2314 if (p_buffer[position] == s[j])
2342 position = etl::min(position,
size() - 1);
2344 const_reverse_iterator it =
rbegin() +
static_cast<difference_type
>(
size() - position - 1);
2346 while (it !=
rend())
2348 if (p_buffer[position] != c)
2386 template <
typename TOtherTraits>
2407 template <
typename TOtherTraits>
2430 append(size_type(1), rhs);
2435#if ETL_HAS_ISTRING_REPAIR
2439 virtual void repair() = 0;
2447#if ETL_HAS_STRING_TRUNCATION_CHECKS
2460#if ETL_HAS_STRING_TRUNCATION_CHECKS
2475 , p_buffer(p_buffer_)
2486#if ETL_HAS_STRING_TRUNCATION_CHECKS
2496 p_buffer = p_buffer_;
2509 if ((first == last) && (s == ETL_NULLPTR ||
length == 0U))
2526 const bool source_overlaps = (s != ETL_NULLPTR) && (s >= p_buffer) && (s < p_buffer +
current_size);
2528 if (source_overlaps)
2532 erase(first_, last_);
2534 if (s != ETL_NULLPTR &&
length != 0U)
2544 const size_type remove_index = size_type(first_ - p_buffer);
2545 const size_type remove_length = size_type(last_ - first_);
2546 const size_type free_space =
CAPACITY - remove_index;
2549 size_type insert_length = (s == ETL_NULLPTR) ? 0U :
length;
2552 if (insert_length > free_space)
2554 insert_length = free_space;
2558 size_type tail_index = remove_index + remove_length;
2560 size_type tail_space = free_space - insert_length;
2562#if ETL_HAS_STRING_TRUNCATION_CHECKS
2568 if (tail_space < tail_length)
2570 tail_length = tail_space;
2574 if (insert_length == remove_length)
2579 else if (insert_length > remove_length)
2583 etl::mem_move(&p_buffer[tail_index], tail_length, &p_buffer[remove_index + insert_length]);
2595 etl::mem_move(&p_buffer[tail_index], tail_length, &p_buffer[remove_index + insert_length]);
2598 current_size = remove_index + insert_length + tail_length;
2609 static int compare(const_pointer first1, const_pointer last1, const_pointer first2, const_pointer last2)
2611 typedef typename etl::make_unsigned<value_type>::type type;
2613 difference_type length1 = etl::distance(first1, last1);
2614 difference_type length2 = etl::distance(first2, last2);
2615 difference_type compare_length = etl::min(length1, length2);
2618 while (compare_length != 0)
2620 if (
static_cast<type
>(*first1) <
static_cast<type
>(*first2))
2625 else if (
static_cast<type
>(*first1) >
static_cast<type
>(*first2))
2637 if (length1 < length2)
2643 if (length1 > length2)
2658#if ETL_HAS_STRING_CLEAR_AFTER_USE
2679#if defined(ETL_POLYMORPHIC_STRINGS) || defined(ETL_POLYMORPHIC_CONTAINERS) || defined(ETL_ISTRING_REPAIR_ENABLE)
2690#if ETL_HAS_STRING_CLEAR_AFTER_USE
2705 return const_cast<iterator
>(itr);
2713 return (ptr >= p_buffer) && (ptr <= (p_buffer +
CAPACITY));
2722 template <
typename TIterator1>
2724 typename etl::enable_if< etl::is_pointer<typename etl::remove_reference<TIterator1>::type>::value
2727 copy_characters(TIterator1 from,
size_t n,
iterator to)
2738 template <
typename TIterator1>
2740 typename etl::enable_if< !(etl::is_pointer<typename etl::remove_reference<TIterator1>::type>::value
2743 copy_characters(TIterator1 from,
size_t n, iterator to)
2749 *to++ =
static_cast<value_type
>(*from++);
2760 template <
typename TIterator>
2761 typename etl::enable_if< !etl::is_pointer< typename etl::remove_reference<TIterator>::type>::value>::type
2762 append_impl(iterator position, TIterator first, TIterator last,
bool truncated,
bool secure)
2764 difference_type start = etl::distance(p_buffer, position);
2765 difference_type count = etl::distance(first, last);
2766 difference_type free_space = etl::distance(position, p_buffer +
CAPACITY);
2768#if ETL_IS_DEBUG_BUILD
2769 ETL_ASSERT(count >= 0, ETL_ERROR(string_iterator));
2772#if ETL_HAS_STRING_TRUNCATION_CHECKS
2775 #if ETL_HAS_ERROR_ON_STRING_TRUNCATION
2782#if ETL_HAS_STRING_CLEAR_AFTER_USE
2792 count = etl::min(count, free_space);
2793 copy_characters(first,
size_t(count), position);
2803 void append_impl(iterator position, const_pointer src,
bool truncated,
bool secure)
2805 if (src == ETL_NULLPTR)
2811 append_impl(position, src, get_string_length(src),
truncated, secure);
2817 void append_impl(iterator position, const_pointer src,
size_t length,
bool truncated,
bool secure)
2819 size_t start =
static_cast<size_t>(etl::distance(p_buffer, position));
2820 size_t free_space =
static_cast<size_t>(etl::distance(position, p_buffer +
CAPACITY));
2821 size_t count = etl::min(
length, free_space);
2823#if ETL_IS_DEBUG_BUILD
2832#if ETL_HAS_STRING_TRUNCATION_CHECKS
2834 #if ETL_HAS_ERROR_ON_STRING_TRUNCATION
2841#if ETL_HAS_STRING_CLEAR_AFTER_USE
2856 template <
typename TIterator>
2857 typename etl::enable_if< etl::is_pointer< typename etl::remove_reference<TIterator>::type>::value>::type
2858 append_impl(iterator position, TIterator first, TIterator last,
bool truncated,
bool secure)
2860 append_impl(position, first,
size_t(etl::distance(first, last)),
truncated ||
is_truncated(), secure);
2866 template <
typename TIterator>
2867 size_type find_impl(TIterator first, TIterator last, size_type sz, size_type pos = 0)
const
2869 if ((pos + sz) >
size())
2874 const_iterator iposition = etl::search(
begin() + pos,
end(), first, last);
2876 if (iposition ==
end())
2882 return static_cast<size_type
>(etl::distance(
begin(), iposition));
2889 template <
typename TIterator>
2890 size_type rfind_impl(TIterator rfirst, TIterator rlast, size_type sz, size_type pos = 0)
const
2904 const_reverse_iterator iposition = etl::search(
rbegin() +
static_cast<difference_type
>(pos),
rend(), rfirst, rlast);
2906 if (iposition ==
rend())
2912 return size() - sz -
static_cast<size_type
>(etl::distance(
rbegin(), iposition));
2919 template <
typename U>
2920 static typename etl::enable_if<
sizeof(U) ==
sizeof(
char),
size_t>::type get_string_length(
const U* str)
2922 return ::strlen(
reinterpret_cast<const char*
>(str));
2925#if ETL_USING_LIBC_WCHAR_H
2929 template <
typename U>
2930 static typename etl::enable_if<
sizeof(U) ==
sizeof(
wchar_t),
size_t>::type get_string_length(
const U* str)
2932 return ::wcslen(
reinterpret_cast<const wchar_t*
>(str));
2939 template <
typename U>
2941#if ETL_USING_LIBC_WCHAR_H
2942 typename etl::enable_if<(
sizeof(U) !=
sizeof(char)) && (
sizeof(U) !=
sizeof(
wchar_t)),
size_t>::type
2944 typename etl::enable_if<(
sizeof(U) !=
sizeof(char)),
size_t>::type
2946 get_string_length(
const U* str)
2948 if (str == ETL_NULLPTR)
2960 return size_t(
end - str) - 1;
2971 template <
typename T>
2984 template <
typename T>
2997 template <
typename T>
3010 template <
typename T>
3013 return !(lhs == rhs);
3023 template <
typename T>
3026 return !(lhs == rhs);
3036 template <
typename T>
3039 return !(lhs == rhs);
3049 template <
typename T>
3052 return etl::lexicographical_compare(lhs.
begin(), lhs.
end(), rhs.
begin(), rhs.
end());
3062 template <
typename T>
3075 template <
typename T>
3088 template <
typename T>
3101 template <
typename T>
3114 template <
typename T>
3128 template <
typename T>
3131 return !(lhs > rhs);
3142 template <
typename T>
3145 return !(lhs > rhs);
3156 template <
typename T>
3159 return !(lhs > rhs);
3170 template <
typename T>
3173 return !(lhs < rhs);
3184 template <
typename T>
3187 return !(lhs < rhs);
3198 template <
typename T>
3201 return !(lhs < rhs);
3211#if ETL_USING_STD_OSTREAM
3212 template <
typename T>
3215 os.write(str.
data(),
static_cast<std::streamsize
>(str.
size()));
3221#undef ETL_USING_WCHAR_T_H
String view.
Definition string_view.h:117
ETL_CONSTEXPR const_iterator cbegin() const ETL_NOEXCEPT
Returns a const iterator to the beginning of the array.
Definition string_view.h:239
ETL_CONSTEXPR size_t size() const ETL_NOEXCEPT
Returns the size of the array.
Definition string_view.h:307
ETL_CONSTEXPR const_reverse_iterator rend() const ETL_NOEXCEPT
Returns a const reverse iterator to the end of the array.
Definition string_view.h:279
ETL_CONSTEXPR const_pointer data() const ETL_NOEXCEPT
Returns a const pointer to the first element of the internal storage.
Definition string_view.h:223
ETL_CONSTEXPR const_iterator end() const ETL_NOEXCEPT
Returns a const iterator to the end of the array.
Definition string_view.h:247
ETL_CONSTEXPR const_iterator begin() const ETL_NOEXCEPT
Returns a const iterator to the beginning of the array.
Definition string_view.h:231
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:263
Definition basic_string.h:350
int compare(size_type position, size_type length_, const ibasic_string &str) const
Compare position / length with string.
Definition basic_string.h:1928
ibasic_string & append(TIterator first, TIterator last)
Definition basic_string.h:869
size_type find_last_of(const_pointer s, size_type position=npos) const
Definition basic_string.h:2096
size_type rfind(const_pointer s, size_type position=npos) const
Definition basic_string.h:1534
ibasic_string & replace(const_iterator first, const_iterator last, const etl::basic_string_view< T, TOtherTraits > &view)
Definition basic_string.h:1752
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:1822
etl::ibasic_string< T > & insert(size_type position, const etl::ibasic_string< T > &str)
Definition basic_string.h:1189
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:1832
size_type find_last_not_of(const_pointer s, size_type position=npos) const
Definition basic_string.h:2275
size_type find(const_pointer s, size_type pos=0) const
Definition basic_string.h:1469
ibasic_string & operator=(const ibasic_string &rhs)
Assignment operator.
Definition basic_string.h:2363
ibasic_string & append(const ibasic_string &str, size_type subposition, size_type sublength=npos)
Definition basic_string.h:849
const_reverse_iterator rbegin() const
Definition basic_string.h:434
bool contains(const etl::ibasic_string< T > &str) const
Checks that the string is within this string.
Definition basic_string.h:1586
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:701
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:1266
pointer data_end()
Definition basic_string.h:666
iterator erase(const_iterator first, const_iterator last)
Definition basic_string.h:1384
iterator insert(const_iterator position, TIterator first, TIterator last)
Definition basic_string.h:1086
bool is_within_buffer(const_pointer ptr) const
Checks if a pointer is within the buffer.
Definition basic_string.h:2711
bool contains(value_type c) const
Checks that character is within this string.
Definition basic_string.h:1611
size_type find_last_of(const ibasic_string< T > &str, size_type position=npos) const
Definition basic_string.h:2086
size_type find_first_of(value_type c, size_type position=0) const
Definition basic_string.h:2065
bool starts_with(const etl::ibasic_string< T > &str) const
Checks that the string is the start of this string.
Definition basic_string.h:1619
size_type find(T c, size_type position=0) const
Definition basic_string.h:1494
ibasic_string & replace(size_type position, size_type length_, const etl::basic_string_view< T, TOtherTraits > &view, size_type subposition, size_type sublength)
Definition basic_string.h:1778
bool ends_with(value_type c) const
Checks that the character is the end of this string.
Definition basic_string.h:1696
void pop_back()
Definition basic_string.h:824
size_type rfind(const ibasic_string< T > &str, size_type position=npos) const
Definition basic_string.h:1513
bool contains(const_pointer s) const
Checks that text is within this string.
Definition basic_string.h:1603
etl::ibasic_string< T > & insert(size_type position, const etl::basic_string_view< T, TOtherTraits > &view)
Definition basic_string.h:1215
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:2445
ibasic_string & replace(size_type position, size_type length_, const_pointer s, size_type n)
Definition basic_string.h:1841
iterator to_iterator(const_iterator itr) const
Convert from const_iterator to iterator.
Definition basic_string.h:2703
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:1854
const_reference operator[](size_type i) const
Definition basic_string.h:572
ibasic_string & replace(const_iterator first, const_iterator last, const ibasic_string &str)
Definition basic_string.h:1740
size_type find_first_of(const ibasic_string< T > &str, size_type position=0) const
Definition basic_string.h:2009
size_type find_first_of(const etl::basic_string_view< T, TOtherTraits > &view, size_type position=0) const
Definition basic_string.h:2030
const_reference back() const
Definition basic_string.h:638
void assign(const_pointer str, size_type n)
Definition basic_string.h:748
const_iterator begin() const
Definition basic_string.h:380
size_type find_last_of(const_pointer s, size_type position, size_type n) const
Definition basic_string.h:2118
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:1668
reverse_iterator rbegin()
Definition basic_string.h:425
ibasic_string & replace(const_iterator first, const_iterator last, TIterator first_replace, TIterator last_replace)
Definition basic_string.h:1893
void resize(size_type new_size)
Definition basic_string.h:480
size_type find_last_not_of(const_pointer s, size_type position, size_type n) const
Definition basic_string.h:2297
ibasic_string & replace(size_type position, size_type length_, const etl::basic_string_view< T, TOtherTraits > &view)
Definition basic_string.h:1724
size_type find_first_not_of(const_pointer s, size_type position=0) const
Definition basic_string.h:2191
size_type rfind(T c, size_type position=npos) const
Definition basic_string.h:1562
etl::ibasic_string< T > & erase(size_type position, size_type length_=npos)
Definition basic_string.h:1329
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:1991
iterator insert(const_iterator position, size_type n, T value)
Definition basic_string.h:996
ibasic_string & append(const etl::basic_string_view< T, TOtherTraits > &view)
Definition basic_string.h:904
const_reference at(size_type i) const
Definition basic_string.h:598
void assign(const etl::basic_string_view< T, TOtherTraits > &view)
Assigns values to the string from a view.
Definition basic_string.h:757
ibasic_string & operator+=(const_pointer rhs)
+= operator.
Definition basic_string.h:2418
void clear()
Clears the string.
Definition basic_string.h:790
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:1950
reverse_iterator rend()
Definition basic_string.h:443
ibasic_string & operator=(const etl::basic_string_view< T, TOtherTraits > &view)
Assignment operator.
Definition basic_string.h:2387
size_type find_last_of(const etl::basic_string_view< T, TOtherTraits > &view, size_type position=npos) const
Definition basic_string.h:2107
iterator erase(iterator i_element)
Definition basic_string.h:1347
ibasic_string & append(const_pointer str, size_type n)
Definition basic_string.h:892
const_reverse_iterator crend() const
Definition basic_string.h:470
bool contains(const etl::basic_string_view< T, TOtherTraits > &view) const
Checks that the view is within this string.
Definition basic_string.h:1595
reference at(size_type i)
Definition basic_string.h:585
size_type rfind(const etl::basic_string_view< T, TOtherTraits > &view, size_type pos=0) const
Definition basic_string.h:1524
bool starts_with(value_type c) const
Checks that the character is the start of this string.
Definition basic_string.h:1646
int compare(const etl::basic_string_view< T, TOtherTraits > &view) const
Compare with etl::basic_string_view.
Definition basic_string.h:1920
~ibasic_string()
Destructor.
Definition basic_string.h:2688
size_type find(const_pointer s, size_type pos, size_type n) const
Definition basic_string.h:1482
size_type find_first_of(const_pointer s, size_type position=0) const
Definition basic_string.h:2019
ibasic_string & replace(size_type position, size_type length_, const ibasic_string &str, size_type subposition, size_type sublength)
Definition basic_string.h:1761
iterator begin()
Definition basic_string.h:371
iterator end()
Definition basic_string.h:389
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:1873
ibasic_string & replace(const_iterator first, const_iterator last, const_pointer s, size_type n)
Definition basic_string.h:1813
void assign(TIterator first, TIterator last)
Definition basic_string.h:727
etl::ibasic_string< T > & insert(size_type position, const etl::ibasic_string< T > &str, size_type subposition, size_type sublength)
Definition basic_string.h:1232
size_type find(const ibasic_string< T > &str, size_type pos=0) const
Definition basic_string.h:1448
void push_back(T value)
Definition basic_string.h:801
size_type find_first_not_of(const_pointer s, size_type position, size_type n) const
Definition basic_string.h:2213
const_reverse_iterator crbegin() const
Definition basic_string.h:461
iterator insert(const_iterator position, T value)
Definition basic_string.h:942
ibasic_string & operator=(const_pointer rhs)
Assignment operator.
Definition basic_string.h:2376
etl::ibasic_string< T > & insert(size_type position, const_pointer s, size_type n)
Definition basic_string.h:1301
ibasic_string & replace(size_type position, size_type length_, const ibasic_string &str)
Definition basic_string.h:1707
ibasic_string(T *p_buffer_, size_type MAX_SIZE_)
Constructor.
Definition basic_string.h:2473
bool ends_with(const_pointer s) const
Checks that the string is the end of this string.
Definition basic_string.h:1681
etl::ibasic_string< T > & insert(size_type position, size_type n, value_type c)
Definition basic_string.h:1315
const_reverse_iterator rend() const
Definition basic_string.h:452
size_type find_last_not_of(const ibasic_string< T > &str, size_type position=npos) const
Definition basic_string.h:2265
size_type find(const etl::basic_string_view< T, TOtherTraits > &view, size_type pos=0) const
Definition basic_string.h:1459
const_pointer data_end() const
Definition basic_string.h:675
void assign(const etl::ibasic_string< T > &other)
Definition basic_string.h:685
const_iterator cend() const
Definition basic_string.h:416
const_pointer c_str() const
Return a pointer to a C string.
Definition basic_string.h:1409
void resize(size_type new_size, T value)
Definition basic_string.h:491
ETL_CONSTEXPR const_pointer data() const
Definition basic_string.h:657
const_reference front() const
Definition basic_string.h:618
ibasic_string & operator+=(const etl::basic_string_view< T, TOtherTraits > &rhs)
+= operator.
Definition basic_string.h:2408
pointer data()
Definition basic_string.h:648
size_type find_first_not_of(value_type c, size_type position=0) const
Definition basic_string.h:2244
ibasic_string & append(const_pointer str)
Definition basic_string.h:880
ibasic_string & append(size_type n, T c)
Definition basic_string.h:916
size_type find_first_not_of(const ibasic_string< T > &str, size_type position=0) const
Definition basic_string.h:2181
size_type find_last_of(value_type c, size_type position=npos) const
Definition basic_string.h:2151
size_type copy(pointer dest, size_type count, size_type pos=0) const
Definition basic_string.h:1420
ibasic_string & append(const ibasic_string &str)
Definition basic_string.h:836
size_type find_last_not_of(const etl::basic_string_view< T, TOtherTraits > &view, size_type position=npos) const
Definition basic_string.h:2286
ibasic_string & operator+=(T rhs)
+= operator.
Definition basic_string.h:2428
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:1794
reference front()
Definition basic_string.h:608
reference back()
Definition basic_string.h:628
bool starts_with(const_pointer s) const
Checks that the string is the start of this string.
Definition basic_string.h:1636
const_iterator cbegin() const
Definition basic_string.h:407
size_type find_first_not_of(const etl::basic_string_view< T, TOtherTraits > &view, size_type position=0) const
Definition basic_string.h:2202
int compare(size_type position, size_type length_, const etl::basic_string_view< T, TOtherTraits > &view, size_type subposition, size_type sublength) const
Definition basic_string.h:1967
void assign(size_type n, T c)
Definition basic_string.h:768
void initialise()
Initialise the string.
Definition basic_string.h:2482
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:1628
ibasic_string & operator+=(const ibasic_string &rhs)
+= operator.
Definition basic_string.h:2397
void trim_to_terminator()
Definition basic_string.h:2458
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:1999
size_type rfind(const_pointer s, size_type position, size_type length_) const
Definition basic_string.h:1549
bool ends_with(const etl::ibasic_string< T > &str) const
Checks that the string is the end of this string.
Definition basic_string.h:1654
size_type find_first_of(const_pointer s, size_type position, size_type n) const
Definition basic_string.h:2041
int compare(const ibasic_string &str) const
Compare with string.
Definition basic_string.h:1911
const_iterator end() const
Definition basic_string.h:398
iterator erase(const_iterator i_element)
Definition basic_string.h:1363
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:1942
etl::ibasic_string< T > & insert(size_type position, const_pointer s)
Definition basic_string.h:1286
void assign(const_pointer str)
Definition basic_string.h:737
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:2494
iterator insert(const_iterator position, const etl::basic_string_view< T, TOtherTraits > &view)
Definition basic_string.h:1179
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:335
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:334
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:511
ETL_EXCEPTION_CONSTEXPR exception(string_type reason_, string_type, numeric_type)
Constructor.
Definition exception.h:81
Definition exception.h:59
Definition integral_limits.h:518
void memory_clear_range(volatile T *begin, size_t n)
Definition memory.h:2561
Definition basic_string.h:157
bitset_ext
Definition absolute.h:40
ETL_CONSTEXPR14 bool operator==(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1081
T * mem_move(const T *sb, const T *se, T *db) ETL_NOEXCEPT
Definition memory.h:2877
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:3213
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:2974
bool operator>(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1133
bool operator>=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1147
ETL_CONSTEXPR14 bool operator!=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1093
T * mem_copy(const T *sb, const T *se, T *db) ETL_NOEXCEPT
Definition memory.h:2835
ETL_CONSTEXPR14 size_t strlen(const T *t) ETL_NOEXCEPT
Alternative strlen for all character types.
Definition char_traits.h:293
bool operator<(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1106
bool operator<=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1120
iterator
Definition iterator.h:424
remove_pointer
Definition type_traits.h:147