31#ifndef ETL_STRING_INCLUDED
32#define ETL_STRING_INCLUDED
47 inline namespace literals
49 inline namespace string_literals
51 constexpr etl::string_view operator ""_sv(
const char* str,
size_t length)
noexcept
66 template <
size_t MAX_SIZE_>
74 typedef istring::value_type value_type;
76 static ETL_CONSTANT
size_t MAX_SIZE = MAX_SIZE_;
82 :
istring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
92 :
istring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
102 :
istring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
114 :
istring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
125 ETL_EXPLICIT_STRING_FROM_CHAR
string(
const value_type* text)
126 :
istring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
136 string(
const value_type* text,
size_t count)
137 :
istring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
139 this->
assign(text, text + count);
148 :
istring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
160 template <
typename TIterator>
162 :
istring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
164 this->
assign(first, last);
167#if ETL_HAS_INITIALIZER_LIST
171 string(std::initializer_list<value_type> init)
172 :
istring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
174 this->
assign(init.begin(), init.end());
183 :
istring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
197 if (position != this->
size())
201 length_ = etl::min(length_, this->
size() - position);
203 new_string.
assign(buffer + position, buffer + position + length_);
250#if ETL_HAS_ISTRING_REPAIR
259 value_type buffer[MAX_SIZE + 1];
262 template <
size_t MAX_SIZE_>
263 ETL_CONSTANT
size_t string<MAX_SIZE_>::MAX_SIZE;
276 typedef istring::value_type value_type;
277 typedef istring::size_type size_type;
283 :
istring(buffer, buffer_size - 1U)
293 :
istring(buffer, buffer_size - 1U)
303 :
istring(buffer, buffer_size - 1U)
315 :
istring(buffer, buffer_size - 1U)
326 string_ext(
const char* text,
char* buffer, size_type buffer_size)
327 :
istring(buffer, buffer_size - 1U)
345 string_ext(
const value_type* text, size_type count, value_type* buffer, size_type buffer_size)
346 :
istring(buffer, buffer_size - 1U)
348 this->
assign(text, text + count);
356 string_ext(size_type count, value_type c, value_type* buffer, size_type buffer_size)
357 :
istring(buffer, buffer_size - 1U)
369 template <
typename TIterator>
371 :
istring(buffer, buffer_size - 1U)
373 this->
assign(first, last);
376#if ETL_HAS_INITIALIZER_LIST
380 string_ext(std::initializer_list<value_type> init, value_type* buffer, size_type buffer_size)
381 :
istring(buffer, buffer_size - 1U)
383 this->
assign(init.begin(), init.end());
392 :
istring(buffer, buffer_size - 1U)
438#if ETL_HAS_ISTRING_REPAIR
455#if ETL_USING_8BIT_TYPES
457 struct hash<
etl::istring>
461 return etl::private_hash::generic_hash<size_t>(
reinterpret_cast<const uint8_t*
>(text.
data()),
462 reinterpret_cast<const uint8_t*
>(text.
data() + text.
size()));
466 template <
size_t SIZE>
467 struct hash<
etl::string<SIZE> >
471 return etl::private_hash::generic_hash<size_t>(
reinterpret_cast<const uint8_t*
>(text.
data()),
472 reinterpret_cast<const uint8_t*
>(text.
data() + text.
size()));
477 struct hash<
etl::string_ext>
481 return etl::private_hash::generic_hash<size_t>(
reinterpret_cast<const uint8_t*
>(text.
data()),
482 reinterpret_cast<const uint8_t*
>(text.
data() + text.
size()));
490 template<
size_t Array_Size>
499 template<
size_t MAX_SIZE,
size_t SIZE>
String view.
Definition: string_view.h:96
ETL_CONSTEXPR const_iterator begin() const
Returns a const iterator to the beginning of the array.
Definition: string_view.h:193
ETL_CONSTEXPR const_iterator end() const
Returns a const iterator to the end of the array.
Definition: string_view.h:209
Definition: basic_string.h:326
void resize(size_type new_size)
Definition: basic_string.h:456
void assign(const etl::ibasic_string< T > &other)
Definition: basic_string.h:626
pointer data()
Definition: basic_string.h:589
void initialise()
Initialise the string.
Definition: basic_string.h:2289
void repair_buffer(T *p_buffer_)
Fix the internal pointers after a low level memory copy.
Definition: basic_string.h:2302
size_type length() const
Definition: basic_string.h:185
size_type current_size
The current number of elements in the string.
Definition: basic_string.h:311
size_type size() const
Definition: basic_string.h:176
string_ext(const etl::istring &other, value_type *buffer, size_type buffer_size, size_type position, size_type length=npos)
Definition: string.h:314
string_ext(value_type *buffer, size_type buffer_size)
Constructor.
Definition: string.h:282
string_ext(const etl::string_ext &other, value_type *buffer, size_type buffer_size)
Definition: string.h:292
string_ext(const etl::string_view &view, value_type *buffer, size_type buffer_size)
Definition: string.h:391
string_ext(const char *text, char *buffer, size_type buffer_size)
Definition: string.h:326
string_ext(size_type count, value_type c, value_type *buffer, size_type buffer_size)
Definition: string.h:356
string_ext(const etl::istring &other, value_type *buffer, size_type buffer_size)
Definition: string.h:302
void repair()
Fix the internal pointers after a low level memory copy.
Definition: string.h:437
string_ext(const value_type *text, size_type count, value_type *buffer, size_type buffer_size)
Definition: string.h:345
string_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: string.h:370
string_ext & operator=(const string_ext &rhs)
Assignment operator.
Definition: string.h:400
Definition: basic_string.h:98
etl::string< MAX_SIZE_ > substr(size_type position=0, size_type length_=npos) const
Definition: string.h:193
void repair()
Fix the internal pointers after a low level memory copy.
Definition: string.h:249
string()
Constructor.
Definition: string.h:81
string(TIterator first, TIterator last, typename etl::enable_if<!etl::is_integral< TIterator >::value, int >::type=0)
Definition: string.h:161
string(const etl::string_view &view)
Definition: string.h:182
string(const etl::string< MAX_SIZE_ > &other)
Definition: string.h:91
string(const etl::istring &other)
Definition: string.h:101
string & operator=(const string &rhs)
Assignment operator.
Definition: string.h:212
string(const etl::istring &other, size_t position, size_t length=npos)
Definition: string.h:113
string(const value_type *text, size_t count)
Definition: string.h:136
string(size_type count, value_type c)
Definition: string.h:147
#define ETL_ASSERT(b, e)
Definition: error_handler.h:316
enable_if
Definition: type_traits_generator.h:1191
is_integral
Definition: type_traits_generator.h:1001
bitset_ext
Definition: absolute.h:38
etl::string< Array_Size - 1U > make_string(const char(&text)[Array_Size])
Hash function.
Definition: string.h:491
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:500
ETL_CONSTEXPR size_t strlen(const T *t)
Alternative strlen for all character types.
Definition: char_traits.h:267
Character traits for any character type.
Definition: char_traits.h:102