31 #ifndef ETL_U16STRING_INCLUDED
32 #define ETL_U16STRING_INCLUDED
39 #if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
40 #include <initializer_list>
47 typedef ibasic_string<char16_t> iu16string;
54 template <const
size_t MAX_SIZE_>
62 typedef iu16string::value_type value_type;
64 static const size_t MAX_SIZE = MAX_SIZE_;
70 :
iu16string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
80 :
iu16string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
90 :
iu16string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
102 :
iu16string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
113 ETL_EXPLICIT_STRING_FROM_CHAR
u16string(
const value_type* text)
114 :
iu16string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
125 :
iu16string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
127 this->
assign(text, text + count);
136 :
iu16string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
148 template <
typename TIterator>
150 :
iu16string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
152 this->
assign(first, last);
155 #if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
159 u16string(std::initializer_list<value_type> init)
160 :
iu16string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
162 this->
assign(init.begin(), init.end());
171 :
iu16string(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
185 if (position !=
size())
189 length_ = etl::min(length_,
size() - position);
191 new_string.
assign(buffer + position, buffer + position + length_);
224 #ifdef ETL_ISTRING_REPAIR_ENABLE
233 value_type buffer[MAX_SIZE + 1];
247 typedef iu16string::value_type value_type;
296 u16string_ext(
const value_type* text, value_type* buffer, size_type buffer_size)
315 u16string_ext(
const value_type* text, size_type count, value_type* buffer, size_type buffer_size)
318 this->
assign(text, text + count);
326 u16string_ext(size_type count, value_type c, value_type* buffer, size_type buffer_size)
339 template <
typename TIterator>
340 u16string_ext(TIterator first, TIterator last, value_type* buffer, size_type buffer_size)
343 this->
assign(first, last);
346 #if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
350 u16string_ext(std::initializer_list<value_type> init, value_type* buffer, size_type buffer_size)
353 this->
assign(init.begin(), init.end());
408 #ifdef ETL_ISTRING_REPAIR_ENABLE
427 struct hash<
etl::iu16string>
431 return etl::private_hash::generic_hash<size_t>(
reinterpret_cast<const uint8_t*
>(&text[0]),
432 reinterpret_cast<const uint8_t*
>(&text[text.
size()]));
436 template <const
size_t SIZE>
437 struct hash<
etl::u16string<SIZE> >
441 return etl::private_hash::generic_hash<size_t>(
reinterpret_cast<const uint8_t*
>(&text[0]),
442 reinterpret_cast<const uint8_t*
>(&text[text.
size()]));
447 struct hash<
etl::u16string_ext >
451 return etl::private_hash::generic_hash<size_t>(
reinterpret_cast<const uint8_t*
>(&text[0]),
452 reinterpret_cast<const uint8_t*
>(&text[text.
size()]));
460 template<
size_t ARRAY_SIZE>
463 return etl::u16string<ARRAY_SIZE == 1 ? 1 : ARRAY_SIZE - 1>(text, ARRAY_SIZE - 1);
469 template<const
size_t MAX_SIZE, const
size_t SIZE>
String view.
Definition: string_view.h:104
const_iterator begin() const
Returns a const iterator to the beginning of the array.
Definition: string_view.h:201
const_iterator end() const
Returns a const iterator to the end of the array.
Definition: string_view.h:217
Definition: basic_string.h:321
void resize(size_type new_size)
Definition: basic_string.h:451
void assign(const etl::ibasic_string< T > &other)
Definition: basic_string.h:590
void initialise()
Initialise the string.
Definition: basic_string.h:2201
void repair_buffer(T *p_buffer_)
Fix the internal pointers after a low level memory copy.
Definition: basic_string.h:2214
size_type length() const
Definition: basic_string.h:177
size_type current_size
The current number of elements in the string.
Definition: basic_string.h:306
size_type size() const
Definition: basic_string.h:168
Definition: basic_string.h:108
Definition: u16string.h:241
u16string_ext(size_type count, value_type c, value_type *buffer, size_type buffer_size)
Definition: u16string.h:326
u16string_ext(value_type *buffer, size_type buffer_size)
Constructor.
Definition: u16string.h:252
u16string_ext(const etl::u16string_view &view, value_type *buffer, size_type buffer_size)
Definition: u16string.h:361
u16string_ext(const value_type *text, size_type count, value_type *buffer, size_type buffer_size)
Definition: u16string.h:315
u16string_ext(const etl::iu16string &other, value_type *buffer, size_type buffer_size, size_type position, size_type length=npos)
Definition: u16string.h:284
u16string_ext(const etl::iu16string &other, value_type *buffer, size_type buffer_size)
Definition: u16string.h:272
u16string_ext(TIterator first, TIterator last, value_type *buffer, size_type buffer_size)
Definition: u16string.h:340
void repair()
Fix the internal pointers after a low level memory copy.
Definition: u16string.h:407
u16string_ext(const value_type *text, value_type *buffer, size_type buffer_size)
Definition: u16string.h:296
u16string_ext(const etl::u16string_ext &other, value_type *buffer, size_type buffer_size)
Definition: u16string.h:262
u16string_ext & operator=(const u16string_ext &rhs)
Assignment operator.
Definition: u16string.h:370
Definition: u16string.h:56
u16string(const etl::iu16string &other)
Definition: u16string.h:89
etl::u16string< MAX_SIZE_ > substr(size_type position=0, size_type length_=npos) const
Definition: u16string.h:181
u16string(const etl::iu16string &other, size_type position, size_type length=npos)
Definition: u16string.h:101
u16string(size_type count, value_type c)
Definition: u16string.h:135
u16string & operator=(const u16string &rhs)
Assignment operator.
Definition: u16string.h:200
u16string(const etl::u16string_view &view)
Definition: u16string.h:170
u16string(const etl::u16string< MAX_SIZE_ > &other)
Definition: u16string.h:79
u16string()
Constructor.
Definition: u16string.h:69
u16string(const value_type *text, size_type count)
Definition: u16string.h:124
void repair()
Fix the internal pointers after a low level memory copy.
Definition: u16string.h:223
u16string(TIterator first, TIterator last)
Definition: u16string.h:149
#define ETL_ASSERT(b, e)
Definition: error_handler.h:290
Definition: absolute.h:37
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:487
size_t strlen(const T *t)
Alternative strlen for all character types.
Definition: char_traits.h:247
etl::string< ARRAY_SIZE - 1 > make_string(const char(&text)[ARRAY_SIZE])
Hash function.
Definition: string.h:478
Character traits for any character type.
Definition: char_traits.h:97