31#ifndef ETL_U8STRING_INCLUDED
32#define ETL_U8STRING_INCLUDED
47#if ETL_USING_CPP11 && ETL_HAS_NATIVE_CHAR8_T
48 inline namespace literals
50 inline namespace string_literals
52 inline constexpr etl::u8string_view
operator ""_sv(
const char8_t* str,
size_t length) ETL_NOEXCEPT
54 return etl::u8string_view{ str, length };
60 typedef etl::ibasic_string<char8_t> iu8string;
67 template <
size_t MAX_SIZE_>
72 typedef iu8string base_type;
73 typedef iu8string interface_type;
75 typedef iu8string::value_type value_type;
77 static ETL_CONSTANT
size_t MAX_SIZE = MAX_SIZE_;
83 : iu8string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
93 : iu8string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
104 : iu8string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
117 : iu8string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
129 ETL_EXPLICIT_STRING_FROM_CHAR
u8string(
const value_type* text)
130 : iu8string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
142 : iu8string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
145 this->
assign(text, text + count);
154 : iu8string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
166 template <
typename TIterator>
168 : iu8string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
171 this->
assign(first, last);
174#if ETL_HAS_INITIALIZER_LIST
178 u8string(std::initializer_list<value_type> init)
179 : iu8string(reinterpret_cast<
value_type*>(&buffer), MAX_SIZE)
182 this->
assign(init.begin(), init.end());
191 : iu8string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
206 if (position != this->
size())
210 length_ = etl::min(length_, this->
size() - position);
212 new_string.
assign(buffer + position, buffer + position + length_);
268#if ETL_HAS_ISTRING_REPAIR
269 virtual void repair() ETL_OVERRIDE
282 template <
size_t MAX_SIZE_>
283 ETL_CONSTANT
size_t u8string<MAX_SIZE_>::MAX_SIZE;
293 typedef iu8string base_type;
294 typedef iu8string interface_type;
296 typedef iu8string::value_type value_type;
297 typedef iu8string::size_type size_type;
303 : iu8string(buffer, buffer_size - 1U)
313 : iu8string(buffer, buffer_size - 1U)
317 this->current_size = other.size();
330 u8string_ext(
const etl::iu8string& other, value_type* buffer, size_type buffer_size)
331 : iu8string(buffer, buffer_size - 1U)
335 this->current_size = other.size();
350 u8string_ext(
const etl::iu8string& other, value_type* buffer, size_type buffer_size, size_type position, size_type
length = npos)
351 : iu8string(buffer, buffer_size - 1U)
370 template <
typename TPo
inter>
373 : iu8string(buffer, buffer_size - 1U)
390 template <
size_t Size>
391 u8string_ext(
const value_type (&literal)[Size], value_type* buffer, size_type buffer_size)
392 : iu8string(buffer, buffer_size - 1U)
410 u8string_ext(
const value_type* text, size_type count, value_type* buffer, size_type buffer_size)
411 : iu8string(buffer, buffer_size - 1U)
420 this->
assign(text, text + count);
429 u8string_ext(size_type count, value_type c, value_type* buffer, size_type buffer_size)
430 : iu8string(buffer, buffer_size - 1U)
440 explicit u8string_ext(
const etl::u8string_view& view, value_type* buffer, size_type buffer_size)
441 : iu8string(buffer, buffer_size - 1U)
445 this->current_size = view.size();
450 this->assign(view.begin(), view.end());
460 template <
typename TIterator>
462 : iu8string(buffer, buffer_size - 1U)
471 this->
assign(first, last);
475#if ETL_HAS_INITIALIZER_LIST
480 : iu8string(buffer, buffer_size - 1U)
483 this->
assign(init.begin(), init.end());
536#if ETL_HAS_ISTRING_REPAIR
537 virtual void repair() ETL_OVERRIDE
555#if ETL_USING_8BIT_TYPES
558 struct hash<
etl::iu8string>
560 size_t operator()(
const etl::iu8string& text)
const
562 return etl::private_hash::generic_hash<size_t>(
reinterpret_cast<const uint8_t*
>(text.
data()),
563 reinterpret_cast<const uint8_t*
>(text.
data() + text.
size()));
567 template <
size_t SIZE>
570 size_t operator()(
const etl::u8string<SIZE>& text)
const
572 return etl::private_hash::generic_hash<size_t>(
reinterpret_cast<const uint8_t*
>(text.
data()),
573 reinterpret_cast<const uint8_t*
>(text.
data() + text.
size()));
580 size_t operator()(
const etl::u8string_ext& text)
const
582 return etl::private_hash::generic_hash<size_t>(
reinterpret_cast<const uint8_t*
>(text.
data()),
583 reinterpret_cast<const uint8_t*
>(text.
data() + text.
size()));
592 template<
size_t Array_Size>
601 template<
size_t MAX_SIZE,
size_t SIZE>
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
bool is_within_buffer(const_pointer ptr) const
Definition basic_string.h:2718
void resize(size_type new_size)
Definition basic_string.h:481
void assign(const etl::ibasic_string< char8_t > &other)
Definition basic_string.h:683
pointer data()
Definition basic_string.h:646
void initialise()
Definition basic_string.h:2491
void repair_buffer(char8_t *p_buffer_)
Definition basic_string.h:2503
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 size() const
Definition basic_string.h:193
Definition basic_string.h:115
Definition u8string.h:290
u8string_ext(TIterator first, TIterator last, value_type *buffer, size_type buffer_size, typename etl::enable_if<!etl::is_integral< TIterator >::value, int >::type=0)
Definition u8string.h:461
u8string_ext(TPointer text, value_type *buffer, size_type buffer_size, typename etl::enable_if< etl::is_same< const value_type *, TPointer >::value, int >::type *=ETL_NULLPTR)
Definition u8string.h:371
u8string_ext & operator=(const u8string_ext &rhs)
Assignment operator.
Definition u8string.h:490
u8string_ext(const etl::u8string_ext &other, value_type *buffer, size_type buffer_size)
Definition u8string.h:312
u8string_ext(const etl::iu8string &other, value_type *buffer, size_type buffer_size, size_type position, size_type length=npos)
Definition u8string.h:350
void repair()
Fix the internal pointers after a low level memory copy.
Definition u8string.h:539
u8string_ext(value_type *buffer, size_type buffer_size)
Constructor.
Definition u8string.h:302
u8string_ext(const value_type *text, size_type count, value_type *buffer, size_type buffer_size)
Definition u8string.h:410
u8string_ext(const etl::iu8string &other, value_type *buffer, size_type buffer_size)
Definition u8string.h:330
u8string_ext(const value_type(&literal)[Size], value_type *buffer, size_type buffer_size)
Definition u8string.h:391
u8string_ext(size_type count, value_type c, value_type *buffer, size_type buffer_size)
Definition u8string.h:429
u8string_ext(const etl::u8string_view &view, value_type *buffer, size_type buffer_size)
Definition u8string.h:440
u8string & operator=(const u8string &rhs)
Assignment operator.
Definition u8string.h:221
u8string(const value_type *text, size_t count)
Definition u8string.h:141
u8string(size_type count, value_type c)
Definition u8string.h:153
void repair()
Fix the internal pointers after a low level memory copy.
Definition u8string.h:271
etl::u8string< MAX_SIZE_ > substr(size_type position=0, size_type length_=npos) const
Definition u8string.h:202
u8string(const etl::u8string_view &view)
Definition u8string.h:190
u8string(const etl::iu8string &other, size_t position, size_t length=npos)
Definition u8string.h:116
u8string(const etl::u8string< MAX_SIZE_ > &other)
Definition u8string.h:92
ETL_EXPLICIT_STRING_FROM_CHAR u8string(const value_type *text)
Definition u8string.h:129
u8string()
Constructor.
Definition u8string.h:82
u8string(TIterator first, TIterator last, typename etl::enable_if<!etl::is_integral< TIterator >::value, int >::type=0)
Definition u8string.h:167
u8string(const etl::iu8string &other)
Definition u8string.h:103
#define ETL_ASSERT(b, e)
Definition error_handler.h:356
ETL_CONSTEXPR17 etl::enable_if<!etl::is_same< T, etl::nullptr_t >::value, T >::type * addressof(T &t)
Definition addressof.h:52
enable_if
Definition type_traits_generator.h:1254
is_same
Definition type_traits_generator.h:1104
bitset_ext
Definition absolute.h:39
etl::string< Array_Size - 1U > make_string(const char(&text)[Array_Size])
Hash function.
Definition string.h:591
etl::string< MAX_SIZE > make_string_with_capacity(const char(&text)[SIZE])
Make string with max capacity from string literal or array.
Definition string.h:600
ETL_CONSTEXPR14 size_t strlen(const T *t) ETL_NOEXCEPT
Alternative strlen for all character types.
Definition char_traits.h:287