31#ifndef ETL_U16STRING_INCLUDED
32#define ETL_U16STRING_INCLUDED
45 inline namespace literals
47 inline namespace string_literals
49 inline constexpr etl::u16string_view
operator""_sv(
const char16_t* str,
size_t length) ETL_NOEXCEPT
51 return etl::u16string_view{str, length};
64 template <
size_t MAX_SIZE_>
69 typedef iu16string base_type;
70 typedef iu16string interface_type;
72 typedef iu16string::value_type value_type;
74 static const size_t MAX_SIZE = MAX_SIZE_;
80 : iu16string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
90 : iu16string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
100 : iu16string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
112 : iu16string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
123 ETL_EXPLICIT_STRING_FROM_CHAR
u16string(
const value_type* text)
124 : iu16string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
135 : iu16string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
137 this->
assign(text, text + count);
146 : iu16string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
158 template <
typename TIterator>
159 u16string(TIterator first, TIterator last,
typename etl::enable_if<!etl::is_integral<TIterator>::value,
int>
::type = 0)
160 : iu16string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
162 this->
assign(first, last);
165#if ETL_HAS_INITIALIZER_LIST
169 u16string(std::initializer_list<value_type> init)
170 : iu16string(reinterpret_cast<
value_type*>(&buffer), MAX_SIZE)
172 this->
assign(init.begin(), init.end());
181 : iu16string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
195 if (position !=
size())
199 length_ = etl::min(length_,
size() - position);
201 new_string.
assign(buffer + position, buffer + position + length_);
243#if ETL_HAS_ISTRING_REPAIR
244 virtual void repair() ETL_OVERRIDE
265 typedef iu16string base_type;
266 typedef iu16string interface_type;
268 typedef iu16string::value_type value_type;
269 typedef iu16string::size_type size_type;
275 : iu16string(buffer, buffer_size - 1U)
284 template <
size_t Size>
286 : iu16string(buffer, Size - 1U)
296 : iu16string(buffer, buffer_size - 1U)
300 this->current_size = other.size();
312 u16string_ext(
const etl::iu16string& other, value_type* buffer, size_type buffer_size)
313 : iu16string(buffer, buffer_size - 1U)
317 this->current_size = other.size();
330 template <
size_t BufferSize>
331 u16string_ext(
const etl::iu16string& other, value_type (&buffer)[BufferSize])
332 : iu16string(buffer, BufferSize - 1U)
336 this->current_size = other.size();
350 u16string_ext(
const etl::iu16string& other, value_type* buffer, size_type buffer_size, size_type position, size_type
length = npos)
351 : iu16string(buffer, buffer_size - 1U)
372 template <
size_t BufferSize>
373 u16string_ext(
const etl::iu16string& other, value_type (&buffer)[BufferSize], size_type position, size_type
length = npos)
374 : iu16string(buffer, BufferSize - 1U)
392 template <
typename TPo
inter>
394 typename etl::enable_if<etl::is_same<const value_type*, TPointer>::value,
int>
::type* = ETL_NULLPTR)
395 : iu16string(buffer, buffer_size - 1U)
412 template <
typename TPo
inter,
size_t BufferSize>
414 typename etl::enable_if<etl::is_same<const value_type*, TPointer>::value,
int>
::type* = ETL_NULLPTR)
415 : iu16string(buffer, BufferSize - 1U)
431 template <
size_t Size>
432 u16string_ext(
const value_type (&literal)[Size], value_type* buffer, size_type buffer_size)
433 : iu16string(buffer, buffer_size - 1U)
450 template <
size_t LiteralSize,
size_t BufferSize>
451 u16string_ext(
const value_type (&literal)[LiteralSize], value_type (&buffer)[BufferSize])
452 : iu16string(buffer, BufferSize - 1U)
469 u16string_ext(
const value_type* text, size_type count, value_type* buffer, size_type buffer_size)
470 : iu16string(buffer, buffer_size - 1U)
478 this->
assign(text, text + count);
488 template <
size_t BufferSize>
489 u16string_ext(
const value_type* text, size_type count, value_type (&buffer)[BufferSize])
490 : iu16string(buffer, BufferSize - 1U)
498 this->
assign(text, text + count);
507 u16string_ext(size_type count, value_type c, value_type* buffer, size_type buffer_size)
508 : iu16string(buffer, buffer_size - 1U)
520 template <
size_t BufferSize>
521 u16string_ext(size_type count, value_type c, value_type (&buffer)[BufferSize])
522 : iu16string(buffer, BufferSize - 1U)
532 explicit u16string_ext(
const etl::u16string_view& view, value_type* buffer, size_type buffer_size)
533 : iu16string(buffer, buffer_size - 1U)
537 this->current_size = view.size();
541 this->assign(view.begin(), view.end());
550 template <
size_t BufferSize>
551 explicit u16string_ext(
const etl::u16string_view& view, value_type (&buffer)[BufferSize])
552 : iu16string(buffer, BufferSize - 1U)
556 this->current_size = view.size();
560 this->assign(view.begin(), view.end());
570 template <
typename TIterator>
571 u16string_ext(TIterator first, TIterator last, value_type* buffer, size_type buffer_size,
572 typename etl::enable_if<!etl::is_integral<TIterator>::value,
int>
::type = 0)
573 : iu16string(buffer, buffer_size - 1U)
577 this->
current_size =
static_cast<size_type
>(etl::distance(first, last));
581 this->
assign(first, last);
592 template <
typename TIterator,
size_t BufferSize>
593 u16string_ext(TIterator first, TIterator last, value_type (&buffer)[BufferSize],
594 typename etl::enable_if<!etl::is_integral<TIterator>::value,
int>
::type = 0)
595 : iu16string(buffer, BufferSize - 1U)
599 this->
current_size =
static_cast<size_type
>(etl::distance(first, last));
603 this->
assign(first, last);
607#if ETL_HAS_INITIALIZER_LIST
612 : iu16string(buffer, buffer_size - 1U)
614 this->
assign(init.begin(), init.end());
622 template <
size_t BufferSize>
623 u16string_ext(std::initializer_list<value_type> init, value_type (&buffer)[BufferSize])
624 : iu16string(buffer, BufferSize - 1U)
626 this->
assign(init.begin(), init.end());
679#if ETL_HAS_ISTRING_REPAIR
680 virtual void repair() ETL_OVERRIDE
698#if ETL_USING_8BIT_TYPES
700 struct hash<
etl::iu16string>
702 size_t operator()(
const etl::iu16string& text)
const
704 return etl::private_hash::generic_hash<size_t>(
reinterpret_cast<const uint8_t*
>(text.
data()),
705 reinterpret_cast<const uint8_t*
>(text.
data() + text.
size()));
709 template <
size_t SIZE>
712 size_t operator()(
const etl::u16string<SIZE>& text)
const
714 return etl::private_hash::generic_hash<size_t>(
reinterpret_cast<const uint8_t*
>(text.
data()),
715 reinterpret_cast<const uint8_t*
>(text.
data() + text.
size()));
722 size_t operator()(
const etl::u16string_ext& text)
const
724 return etl::private_hash::generic_hash<size_t>(
reinterpret_cast<const uint8_t*
>(text.
data()),
725 reinterpret_cast<const uint8_t*
>(text.
data() + text.
size()));
733 template <
size_t Array_Size>
742 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: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
Definition basic_string.h:350
bool is_within_buffer(const_pointer ptr) const
Definition basic_string.h:2711
void resize(size_type new_size)
Definition basic_string.h:480
void assign(const etl::ibasic_string< char16_t > &other)
Definition basic_string.h:685
pointer data()
Definition basic_string.h:648
void initialise()
Definition basic_string.h:2482
void repair_buffer(char16_t *p_buffer_)
Definition basic_string.h:2494
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 size() const
Definition basic_string.h:193
Definition basic_string.h:115
Definition u16string.h:262
u16string_ext & operator=(const u16string_ext &rhs)
Assignment operator.
Definition u16string.h:633
u16string_ext(const value_type(&literal)[LiteralSize], value_type(&buffer)[BufferSize])
Definition u16string.h:451
u16string_ext(size_type count, value_type c, value_type *buffer, size_type buffer_size)
Definition u16string.h:507
u16string_ext & operator=(const etl::u16string_view &view)
Assignment operator.
Definition u16string.h:669
u16string_ext(const etl::iu16string &other, value_type(&buffer)[BufferSize], size_type position, size_type length=npos)
Definition u16string.h:373
u16string_ext(value_type *buffer, size_type buffer_size)
Constructor.
Definition u16string.h:274
u16string_ext(value_type(&buffer)[Size])
Definition u16string.h:285
u16string_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 u16string.h:393
u16string_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 u16string.h:571
u16string_ext(const etl::u16string_view &view, value_type *buffer, size_type buffer_size)
Definition u16string.h:532
u16string_ext(const value_type(&literal)[Size], value_type *buffer, size_type buffer_size)
Definition u16string.h:432
u16string_ext(TIterator first, TIterator last, value_type(&buffer)[BufferSize], typename etl::enable_if<!etl::is_integral< TIterator >::value, int >::type=0)
Definition u16string.h:593
u16string_ext(const value_type *text, size_type count, value_type *buffer, size_type buffer_size)
Definition u16string.h:469
u16string_ext(const etl::iu16string &other, value_type *buffer, size_type buffer_size, size_type position, size_type length=npos)
Definition u16string.h:350
u16string_ext(TPointer text, value_type(&buffer)[BufferSize], typename etl::enable_if< etl::is_same< const value_type *, TPointer >::value, int >::type *=ETL_NULLPTR)
Definition u16string.h:413
u16string_ext(const value_type *text, size_type count, value_type(&buffer)[BufferSize])
Definition u16string.h:489
u16string_ext(const etl::iu16string &other, value_type *buffer, size_type buffer_size)
Definition u16string.h:312
u16string_ext(const etl::u16string_view &view, value_type(&buffer)[BufferSize])
Definition u16string.h:551
u16string_ext & operator=(const value_type *text)
Assignment operator.
Definition u16string.h:659
void repair()
Fix the internal pointers after a low level memory copy.
Definition u16string.h:682
u16string_ext & operator=(const iu16string &rhs)
Assignment operator.
Definition u16string.h:646
u16string_ext(const etl::iu16string &other, value_type(&buffer)[BufferSize])
Definition u16string.h:331
u16string_ext(size_type count, value_type c, value_type(&buffer)[BufferSize])
Definition u16string.h:521
u16string_ext(const etl::u16string_ext &other, value_type *buffer, size_type buffer_size)
Definition u16string.h:295
Definition u16string.h:66
u16string(const etl::iu16string &other)
Definition u16string.h:99
u16string & operator=(const value_type *text)
Assignment operator.
Definition u16string.h:223
u16string(const etl::iu16string &other, size_type position, size_type length=npos)
Definition u16string.h:111
etl::u16string< MAX_SIZE_ > substr(size_type position=0, size_type length_=npos) const
Definition u16string.h:191
u16string(size_type count, value_type c)
Definition u16string.h:145
u16string(TIterator first, TIterator last, typename etl::enable_if<!etl::is_integral< TIterator >::value, int >::type=0)
Definition u16string.h:159
ETL_EXPLICIT_STRING_FROM_CHAR u16string(const value_type *text)
Definition u16string.h:123
u16string & operator=(const u16string &rhs)
Assignment operator.
Definition u16string.h:210
u16string(const etl::u16string_view &view)
Definition u16string.h:180
u16string & operator=(const etl::u16string_view &view)
Assignment operator.
Definition u16string.h:233
u16string(const etl::u16string< MAX_SIZE_ > &other)
Definition u16string.h:89
u16string()
Constructor.
Definition u16string.h:79
u16string(const value_type *text, size_type count)
Definition u16string.h:134
void repair()
Fix the internal pointers after a low level memory copy.
Definition u16string.h:246
#define ETL_ASSERT(b, e)
Definition error_handler.h:511
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:40
etl::string< Array_Size - 1U > make_string(const char(&text)[Array_Size])
Hash function.
Definition string.h:753
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:762
ETL_CONSTEXPR14 size_t strlen(const T *t) ETL_NOEXCEPT
Alternative strlen for all character types.
Definition char_traits.h:293