31#ifndef ETL_WSTRING_INCLUDED
32#define ETL_WSTRING_INCLUDED
45 inline namespace literals
47 inline namespace string_literals
49 inline constexpr etl::wstring_view
operator""_sv(
const wchar_t* str,
size_t length) ETL_NOEXCEPT
51 return etl::wstring_view{str, length};
64 template <
size_t MAX_SIZE_>
69 typedef iwstring base_type;
70 typedef iwstring interface_type;
72 typedef iwstring::value_type value_type;
74 static const size_t MAX_SIZE = MAX_SIZE_;
80 : iwstring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
90 : iwstring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
100 : iwstring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
111 wstring(
const etl::iwstring& other, size_type position, size_type
length = npos)
112 : iwstring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
123 ETL_EXPLICIT_STRING_FROM_CHAR
wstring(
const value_type* text)
124 : iwstring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
134 wstring(
const value_type* text, size_type count)
135 : iwstring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
137 this->
assign(text, text + count);
146 : iwstring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
158 template <
typename TIterator>
159 wstring(TIterator first, TIterator last,
typename etl::enable_if<!etl::is_integral<TIterator>::value,
int>
::type = 0)
160 : iwstring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
162 this->
assign(first, last);
165#if ETL_HAS_INITIALIZER_LIST
169 wstring(std::initializer_list<value_type> init)
170 : iwstring(reinterpret_cast<
value_type*>(&buffer), MAX_SIZE)
172 this->
assign(init.begin(), init.end());
180 explicit wstring(
const etl::wstring_view& view)
181 : iwstring(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 iwstring base_type;
266 typedef iwstring interface_type;
268 typedef iwstring::value_type value_type;
269 typedef iwstring::size_type size_type;
275 : iwstring(buffer, buffer_size - 1U)
284 template <
size_t Size>
286 : iwstring(buffer, Size - 1U)
296 : iwstring(buffer, buffer_size - 1U)
300 this->current_size = other.size();
312 wstring_ext(
const etl::iwstring& other, value_type* buffer, size_type buffer_size)
313 : iwstring(buffer, buffer_size - 1U)
317 this->current_size = other.size();
330 template <
size_t BufferSize>
331 wstring_ext(
const etl::iwstring& other, value_type (&buffer)[BufferSize])
332 : iwstring(buffer, BufferSize - 1U)
336 this->current_size = other.size();
350 wstring_ext(
const etl::iwstring& other, value_type* buffer, size_type buffer_size, size_type position, size_type
length = npos)
351 : iwstring(buffer, buffer_size - 1U)
372 template <
size_t BufferSize>
373 wstring_ext(
const etl::iwstring& other, value_type (&buffer)[BufferSize], size_type position, size_type
length = npos)
374 : iwstring(buffer, BufferSize - 1U)
392 template <
typename TPo
inter>
393 wstring_ext(TPointer text, value_type* buffer, size_type buffer_size,
394 typename etl::enable_if<etl::is_same<const value_type*, TPointer>::value,
int>
::type* = ETL_NULLPTR)
395 : iwstring(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 : iwstring(buffer, BufferSize - 1U)
431 template <
size_t Size>
432 wstring_ext(
const value_type (&literal)[Size], value_type* buffer, size_type buffer_size)
433 : iwstring(buffer, buffer_size - 1U)
450 template <
size_t LiteralSize,
size_t BufferSize>
451 wstring_ext(
const value_type (&literal)[LiteralSize], value_type (&buffer)[BufferSize])
452 : iwstring(buffer, BufferSize - 1U)
469 wstring_ext(
const value_type* text, size_type count, value_type* buffer, size_type buffer_size)
470 : iwstring(buffer, buffer_size - 1U)
478 this->
assign(text, text + count);
488 template <
size_t BufferSize>
489 wstring_ext(
const value_type* text, size_type count, value_type (&buffer)[BufferSize])
490 : iwstring(buffer, BufferSize - 1U)
498 this->
assign(text, text + count);
507 wstring_ext(size_type count, value_type c, value_type* buffer, size_type buffer_size)
508 : iwstring(buffer, buffer_size - 1U)
520 template <
size_t BufferSize>
521 wstring_ext(size_type count, value_type c, value_type (&buffer)[BufferSize])
522 : iwstring(buffer, BufferSize - 1U)
532 explicit wstring_ext(
const etl::wstring_view& view, value_type* buffer, size_type buffer_size)
533 : iwstring(buffer, buffer_size - 1U)
537 this->current_size = view.size();
541 this->assign(view.begin(), view.end());
550 template <
size_t BufferSize>
551 explicit wstring_ext(
const etl::wstring_view& view, value_type (&buffer)[BufferSize])
552 : iwstring(buffer, BufferSize - 1U)
556 this->current_size = view.size();
560 this->assign(view.begin(), view.end());
570 template <
typename TIterator>
571 wstring_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 : iwstring(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 wstring_ext(TIterator first, TIterator last, value_type (&buffer)[BufferSize],
594 typename etl::enable_if<!etl::is_integral<TIterator>::value,
int>
::type = 0)
595 : iwstring(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 : iwstring(buffer, buffer_size - 1U)
614 this->
assign(init.begin(), init.end());
622 template <
size_t BufferSize>
623 wstring_ext(std::initializer_list<value_type> init, value_type (&buffer)[BufferSize])
624 : iwstring(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::iwstring>
702 size_t operator()(
const etl::iwstring& 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>
710 struct hash<etl::
wstring<SIZE> >
712 size_t operator()(
const etl::wstring<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::wstring_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< wchar_t > &other)
Definition basic_string.h:685
pointer data()
Definition basic_string.h:648
void initialise()
Definition basic_string.h:2482
void repair_buffer(wchar_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
wstring_ext(size_type count, value_type c, value_type(&buffer)[BufferSize])
Definition wstring.h:521
wstring_ext(TPointer text, value_type(&buffer)[BufferSize], typename etl::enable_if< etl::is_same< const value_type *, TPointer >::value, int >::type *=ETL_NULLPTR)
Definition wstring.h:413
wstring_ext(const etl::iwstring &other, value_type *buffer, size_type buffer_size)
Definition wstring.h:312
wstring_ext(const etl::iwstring &other, value_type(&buffer)[BufferSize], size_type position, size_type length=npos)
Definition wstring.h:373
wstring_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 wstring.h:393
wstring_ext & operator=(const value_type *text)
Assignment operator.
Definition wstring.h:659
wstring_ext(const value_type(&literal)[LiteralSize], value_type(&buffer)[BufferSize])
Definition wstring.h:451
wstring_ext(size_type count, value_type c, value_type *buffer, size_type buffer_size)
Definition wstring.h:507
wstring_ext & operator=(const iwstring &rhs)
Assignment operator.
Definition wstring.h:646
wstring_ext(value_type *buffer, size_type buffer_size)
Constructor.
Definition wstring.h:274
wstring_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 wstring.h:571
wstring_ext(const value_type *text, size_type count, value_type(&buffer)[BufferSize])
Definition wstring.h:489
wstring_ext & operator=(const wstring_ext &rhs)
Assignment operator.
Definition wstring.h:633
wstring_ext(const value_type(&literal)[Size], value_type *buffer, size_type buffer_size)
Definition wstring.h:432
wstring_ext(const etl::wstring_view &view, value_type *buffer, size_type buffer_size)
Definition wstring.h:532
wstring_ext(const etl::iwstring &other, value_type *buffer, size_type buffer_size, size_type position, size_type length=npos)
Definition wstring.h:350
void repair()
Fix the internal pointers after a low level memory copy.
Definition wstring.h:682
wstring_ext(value_type(&buffer)[Size])
Definition wstring.h:285
wstring_ext(const etl::wstring_view &view, value_type(&buffer)[BufferSize])
Definition wstring.h:551
wstring_ext(TIterator first, TIterator last, value_type(&buffer)[BufferSize], typename etl::enable_if<!etl::is_integral< TIterator >::value, int >::type=0)
Definition wstring.h:593
wstring_ext(const etl::iwstring &other, value_type(&buffer)[BufferSize])
Definition wstring.h:331
wstring_ext(const etl::wstring_ext &other, value_type *buffer, size_type buffer_size)
Definition wstring.h:295
wstring_ext & operator=(const etl::wstring_view &view)
Assignment operator.
Definition wstring.h:669
wstring_ext(const value_type *text, size_type count, value_type *buffer, size_type buffer_size)
Definition wstring.h:469
wstring(const value_type *text, size_type count)
Definition wstring.h:134
wstring(const etl::iwstring &other)
Definition wstring.h:99
wstring(const etl::iwstring &other, size_type position, size_type length=npos)
Definition wstring.h:111
wstring(const etl::wstring_view &view)
Definition wstring.h:180
ETL_EXPLICIT_STRING_FROM_CHAR wstring(const value_type *text)
Definition wstring.h:123
wstring & operator=(const value_type *text)
Assignment operator.
Definition wstring.h:223
wstring & operator=(const wstring &rhs)
Assignment operator.
Definition wstring.h:210
void repair()
Fix the internal pointers after a low level memory copy.
Definition wstring.h:246
wstring & operator=(const etl::wstring_view &view)
Assignment operator.
Definition wstring.h:233
wstring(TIterator first, TIterator last, typename etl::enable_if<!etl::is_integral< TIterator >::value, int >::type=0)
Definition wstring.h:159
wstring()
Constructor.
Definition wstring.h:79
wstring(size_type count, value_type c)
Definition wstring.h:145
wstring(const etl::wstring< MAX_SIZE_ > &other)
Definition wstring.h:89
etl::wstring< MAX_SIZE_ > substr(size_type position=0, size_type length_=npos) const
Definition wstring.h:191
#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