mirror of
https://github.com/ETLCPP/etl.git
synced 2026-10-28 18:07:10 +08:00
string_ext
This commit is contained in:
parent
8e838a67d3
commit
bb21758cb6
@ -261,12 +261,10 @@ namespace etl
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
/// A string implementation that uses a fixed size buffer.
|
||||
/// A specialisation that requires an external buffer to be specified.
|
||||
/// A string implementation that uses a fixed size external buffer.
|
||||
///\ingroup string
|
||||
//***************************************************************************
|
||||
template <>
|
||||
class string<0U> : public istring
|
||||
class string_ext : public istring
|
||||
{
|
||||
public:
|
||||
|
||||
@ -279,7 +277,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Constructor.
|
||||
//*************************************************************************
|
||||
string(value_type* buffer, size_type buffer_size)
|
||||
string_ext(value_type* buffer, size_type buffer_size)
|
||||
: istring(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->initialise();
|
||||
@ -287,9 +285,9 @@ namespace etl
|
||||
|
||||
//*************************************************************************
|
||||
/// Copy constructor.
|
||||
///\param other The other string.
|
||||
///\param other The other string_ext.
|
||||
//*************************************************************************
|
||||
string(const etl::string<0U>& other, value_type* buffer, size_type buffer_size)
|
||||
string_ext(const etl::string_ext& other, value_type* buffer, size_type buffer_size)
|
||||
: istring(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->assign(other);
|
||||
@ -299,19 +297,19 @@ namespace etl
|
||||
/// From other istring.
|
||||
///\param other The other istring.
|
||||
//*************************************************************************
|
||||
string(const etl::istring& other, value_type* buffer, size_type buffer_size)
|
||||
string_ext(const etl::istring& other, value_type* buffer, size_type buffer_size)
|
||||
: istring(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->assign(other);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// From other string, position, length.
|
||||
///\param other The other string.
|
||||
/// From other string_ext, position, length.
|
||||
///\param other The other string_ext.
|
||||
///\param position The position of the first character.
|
||||
///\param length The number of characters. Default = npos.
|
||||
//*************************************************************************
|
||||
string(const etl::istring& other, value_type* buffer, size_type buffer_size, size_type position, size_type length_ = npos)
|
||||
string_ext(const etl::istring& other, value_type* buffer, size_type buffer_size, size_type position, size_type length_ = npos)
|
||||
: istring(buffer, buffer_size - 1U)
|
||||
{
|
||||
ETL_ASSERT(position < other.size(), ETL_ERROR(string_out_of_bounds));
|
||||
@ -332,9 +330,9 @@ namespace etl
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructor, from null terminated text.
|
||||
///\param text The initial text of the string.
|
||||
///\param text The initial text of the string_ext.
|
||||
//*************************************************************************
|
||||
string(const char* text, char* buffer, size_type buffer_size)
|
||||
string_ext(const char* text, char* buffer, size_type buffer_size)
|
||||
: istring(buffer, buffer_size - 1U)
|
||||
{
|
||||
// Is the initial text at the same address as the buffer?
|
||||
@ -350,10 +348,10 @@ namespace etl
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructor, from null terminated text and count.
|
||||
///\param text The initial text of the string.
|
||||
///\param text The initial text of the string_ext.
|
||||
///\param count The number of characters to copy.
|
||||
//*************************************************************************
|
||||
string(const value_type* text, size_type count, value_type* buffer, size_type buffer_size)
|
||||
string_ext(const value_type* text, size_type count, value_type* buffer, size_type buffer_size)
|
||||
: istring(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->assign(text, text + count);
|
||||
@ -361,10 +359,10 @@ namespace etl
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructor, from initial size and value.
|
||||
///\param initialSize The initial size of the string.
|
||||
///\param value The value to fill the string with.
|
||||
///\param initialSize The initial size of the string_ext.
|
||||
///\param value The value to fill the string_ext with.
|
||||
//*************************************************************************
|
||||
string(size_type count, value_type c, value_type* buffer, size_type buffer_size)
|
||||
string_ext(size_type count, value_type c, value_type* buffer, size_type buffer_size)
|
||||
: istring(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->initialise();
|
||||
@ -378,7 +376,7 @@ namespace etl
|
||||
///\param last The iterator to the last element + 1.
|
||||
//*************************************************************************
|
||||
template <typename TIterator>
|
||||
string(TIterator first, TIterator last, value_type* buffer, size_type buffer_size)
|
||||
string_ext(TIterator first, TIterator last, value_type* buffer, size_type buffer_size)
|
||||
: istring(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->assign(first, last);
|
||||
@ -388,7 +386,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Construct from initializer_list.
|
||||
//*************************************************************************
|
||||
string(std::initializer_list<value_type> init, value_type* buffer, size_type buffer_size)
|
||||
string_ext(std::initializer_list<value_type> init, value_type* buffer, size_type buffer_size)
|
||||
: istring(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->assign(init.begin(), init.end());
|
||||
@ -399,7 +397,7 @@ namespace etl
|
||||
/// From string_view.
|
||||
///\param view The string_view.
|
||||
//*************************************************************************
|
||||
explicit string(const etl::string_view& view, value_type* buffer, size_type buffer_size)
|
||||
explicit string_ext(const etl::string_view& view, value_type* buffer, size_type buffer_size)
|
||||
: istring(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->assign(view.begin(), view.end());
|
||||
@ -408,7 +406,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
string& operator = (const string& rhs)
|
||||
string_ext& operator = (const string_ext& rhs)
|
||||
{
|
||||
if (&rhs != this)
|
||||
{
|
||||
@ -422,7 +420,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
string& operator = (const istring& rhs)
|
||||
string_ext& operator = (const istring& rhs)
|
||||
{
|
||||
if (&rhs != this)
|
||||
{
|
||||
@ -435,7 +433,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
string& operator = (const value_type* text)
|
||||
string_ext& operator = (const value_type* text)
|
||||
{
|
||||
this->assign(text);
|
||||
|
||||
@ -457,7 +455,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Deleted.
|
||||
//*************************************************************************
|
||||
string(const string& other) ETL_DELETE;
|
||||
string_ext(const string_ext& other) ETL_DELETE;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
@ -483,15 +481,25 @@ namespace etl
|
||||
reinterpret_cast<const uint8_t*>(&text[text.size()]));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct hash<etl::string_ext>
|
||||
{
|
||||
size_t operator()(const etl::string_ext& text) const
|
||||
{
|
||||
return etl::private_hash::generic_hash<size_t>(reinterpret_cast<const uint8_t*>(&text[0]),
|
||||
reinterpret_cast<const uint8_t*>(&text[text.size()]));
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Make string from string literal or array
|
||||
//***************************************************************************
|
||||
template<size_t ARRAY_SIZE>
|
||||
etl::string<ARRAY_SIZE == 1 ? 1 : ARRAY_SIZE - 1> make_string(const char(&text)[ARRAY_SIZE])
|
||||
etl::string<ARRAY_SIZE - 1> make_string(const char(&text)[ARRAY_SIZE])
|
||||
{
|
||||
return etl::string<ARRAY_SIZE == 1 ? 1 : ARRAY_SIZE - 1>(text, ARRAY_SIZE - 1);
|
||||
return etl::string<ARRAY_SIZE - 1>(text, ARRAY_SIZE - 1);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
|
||||
@ -245,12 +245,10 @@ namespace etl
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
/// A u16string implementation that uses a fixed size buffer.
|
||||
/// A specialisation that requires an external buffer to be specified.
|
||||
/// A u16string_ex implementation that uses a fixed external buffer.
|
||||
///\ingroup u16string
|
||||
//***************************************************************************
|
||||
template <>
|
||||
class u16string<0U> : public iu16string
|
||||
class u16string_ext : public iu16string
|
||||
{
|
||||
public:
|
||||
|
||||
@ -262,7 +260,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Constructor.
|
||||
//*************************************************************************
|
||||
u16string(value_type* buffer, size_type buffer_size)
|
||||
u16string_ext(value_type* buffer, size_type buffer_size)
|
||||
: iu16string(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->initialise();
|
||||
@ -270,9 +268,9 @@ namespace etl
|
||||
|
||||
//*************************************************************************
|
||||
/// Copy constructor.
|
||||
///\param other The other u16string.
|
||||
///\param other The other u16string_ext.
|
||||
//*************************************************************************
|
||||
u16string(const etl::u16string<0U>& other, value_type* buffer, size_type buffer_size)
|
||||
u16string_ext(const etl::u16string_ext& other, value_type* buffer, size_type buffer_size)
|
||||
: iu16string(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->assign(other);
|
||||
@ -282,19 +280,19 @@ namespace etl
|
||||
/// From other iu16string.
|
||||
///\param other The other iu16string.
|
||||
//*************************************************************************
|
||||
u16string(const etl::iu16string& other, value_type* buffer, size_type buffer_size)
|
||||
u16string_ext(const etl::iu16string& other, value_type* buffer, size_type buffer_size)
|
||||
: iu16string(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->assign(other);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// From other u16string, position, length.
|
||||
///\param other The other u16string.
|
||||
/// From other u16string_ext, position, length.
|
||||
///\param other The other u16string_ext.
|
||||
///\param position The position of the first character.
|
||||
///\param length The number of characters. Default = npos.
|
||||
//*************************************************************************
|
||||
u16string(const etl::iu16string& other, value_type* buffer, size_type buffer_size, size_type position, size_type length_ = npos)
|
||||
u16string_ext(const etl::iu16string& other, value_type* buffer, size_type buffer_size, size_type position, size_type length_ = npos)
|
||||
: iu16string(buffer, buffer_size - 1U)
|
||||
{
|
||||
ETL_ASSERT(position < other.size(), ETL_ERROR(string_out_of_bounds));
|
||||
@ -315,9 +313,9 @@ namespace etl
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructor, from null terminated text.
|
||||
///\param text The initial text of the u16string.
|
||||
///\param text The initial text of the u16string_ext.
|
||||
//*************************************************************************
|
||||
u16string(const value_type* text, value_type* buffer, size_type buffer_size)
|
||||
u16string_ext(const value_type* text, value_type* buffer, size_type buffer_size)
|
||||
: iu16string(buffer, buffer_size - 1U)
|
||||
{
|
||||
// Is the initial text at the same address as the buffer?
|
||||
@ -333,10 +331,10 @@ namespace etl
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructor, from null terminated text and count.
|
||||
///\param text The initial text of the u16string.
|
||||
///\param text The initial text of the u16string_ext.
|
||||
///\param count The number of characters to copy.
|
||||
//*************************************************************************
|
||||
u16string(const value_type* text, size_type count, value_type* buffer, size_type buffer_size)
|
||||
u16string_ext(const value_type* text, size_type count, value_type* buffer, size_type buffer_size)
|
||||
: iu16string(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->assign(text, text + count);
|
||||
@ -344,10 +342,10 @@ namespace etl
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructor, from initial size and value.
|
||||
///\param initialSize The initial size of the u16string.
|
||||
///\param value The value to fill the u16string with.
|
||||
///\param initialSize The initial size of the u16string_ext.
|
||||
///\param value The value to fill the u16string_ext with.
|
||||
//*************************************************************************
|
||||
u16string(size_type count, value_type c, value_type* buffer, size_type buffer_size)
|
||||
u16string_ext(size_type count, value_type c, value_type* buffer, size_type buffer_size)
|
||||
: iu16string(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->initialise();
|
||||
@ -361,7 +359,7 @@ namespace etl
|
||||
///\param last The iterator to the last element + 1.
|
||||
//*************************************************************************
|
||||
template <typename TIterator>
|
||||
u16string(TIterator first, TIterator last, value_type* buffer, size_type buffer_size)
|
||||
u16string_ext(TIterator first, TIterator last, value_type* buffer, size_type buffer_size)
|
||||
: iu16string(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->assign(first, last);
|
||||
@ -371,7 +369,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Construct from initializer_list.
|
||||
//*************************************************************************
|
||||
u16string(std::initializer_list<value_type> init, value_type* buffer, size_type buffer_size)
|
||||
u16string_ext(std::initializer_list<value_type> init, value_type* buffer, size_type buffer_size)
|
||||
: iu16string(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->assign(init.begin(), init.end());
|
||||
@ -382,7 +380,7 @@ namespace etl
|
||||
/// From u16string_view.
|
||||
///\param view The u16string_view.
|
||||
//*************************************************************************
|
||||
explicit u16string(const etl::u16string_view& view, value_type* buffer, size_type buffer_size)
|
||||
explicit u16string_ext(const etl::u16string_view& view, value_type* buffer, size_type buffer_size)
|
||||
: iu16string(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->assign(view.begin(), view.end());
|
||||
@ -391,7 +389,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
u16string& operator = (const u16string& rhs)
|
||||
u16string_ext& operator = (const u16string_ext& rhs)
|
||||
{
|
||||
if (&rhs != this)
|
||||
{
|
||||
@ -405,7 +403,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
u16string& operator = (const iu16string& rhs)
|
||||
u16string_ext& operator = (const iu16string& rhs)
|
||||
{
|
||||
if (&rhs != this)
|
||||
{
|
||||
@ -418,7 +416,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
u16string& operator = (const value_type* text)
|
||||
u16string_ext& operator = (const value_type* text)
|
||||
{
|
||||
this->assign(text);
|
||||
|
||||
@ -440,7 +438,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Deleted.
|
||||
//*************************************************************************
|
||||
u16string(const u16string& other) ETL_DELETE;
|
||||
u16string_ext(const u16string_ext& other) ETL_DELETE;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
@ -466,6 +464,16 @@ namespace etl
|
||||
reinterpret_cast<const uint8_t*>(&text[text.size()]));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct hash<etl::u16string_ext >
|
||||
{
|
||||
size_t operator()(const etl::u16string_ext& text) const
|
||||
{
|
||||
return etl::private_hash::generic_hash<size_t>(reinterpret_cast<const uint8_t*>(&text[0]),
|
||||
reinterpret_cast<const uint8_t*>(&text[text.size()]));
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
|
||||
@ -245,12 +245,10 @@ namespace etl
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
/// A u32string implementation that uses a fixed size buffer.
|
||||
/// A specialisation that requires an external buffer to be specified.
|
||||
/// A u32string implementation that uses a fixed size external buffer.
|
||||
///\ingroup u32string
|
||||
//***************************************************************************
|
||||
template <>
|
||||
class u32string<0U> : public iu32string
|
||||
class u32string_ext : public iu32string
|
||||
{
|
||||
public:
|
||||
|
||||
@ -262,7 +260,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Constructor.
|
||||
//*************************************************************************
|
||||
u32string(value_type* buffer, size_type buffer_size)
|
||||
u32string_ext(value_type* buffer, size_type buffer_size)
|
||||
: iu32string(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->initialise();
|
||||
@ -270,9 +268,9 @@ namespace etl
|
||||
|
||||
//*************************************************************************
|
||||
/// Copy constructor.
|
||||
///\param other The other u32string.
|
||||
///\param other The other u32string_ext.
|
||||
//*************************************************************************
|
||||
u32string(const etl::u32string<0U>& other, value_type* buffer, size_type buffer_size)
|
||||
u32string_ext(const etl::u32string_ext& other, value_type* buffer, size_type buffer_size)
|
||||
: iu32string(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->assign(other);
|
||||
@ -282,19 +280,19 @@ namespace etl
|
||||
/// From other iu32string.
|
||||
///\param other The other iu32string.
|
||||
//*************************************************************************
|
||||
u32string(const etl::iu32string& other, value_type* buffer, size_type buffer_size)
|
||||
u32string_ext(const etl::iu32string& other, value_type* buffer, size_type buffer_size)
|
||||
: iu32string(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->assign(other);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// From other u32string, position, length.
|
||||
///\param other The other u32string.
|
||||
/// From other u32string_ext, position, length.
|
||||
///\param other The other u32string_ext.
|
||||
///\param position The position of the first character.
|
||||
///\param length The number of characters. Default = npos.
|
||||
//*************************************************************************
|
||||
u32string(const etl::iu32string& other, value_type* buffer, size_type buffer_size, size_type position, size_type length_ = npos)
|
||||
u32string_ext(const etl::iu32string& other, value_type* buffer, size_type buffer_size, size_type position, size_type length_ = npos)
|
||||
: iu32string(buffer, buffer_size - 1U)
|
||||
{
|
||||
ETL_ASSERT(position < other.size(), ETL_ERROR(string_out_of_bounds));
|
||||
@ -315,9 +313,9 @@ namespace etl
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructor, from null terminated text.
|
||||
///\param text The initial text of the u32string.
|
||||
///\param text The initial text of the u32string_ext.
|
||||
//*************************************************************************
|
||||
ETL_EXPLICIT_STRING_FROM_CHAR u32string(const value_type* text, value_type* buffer, size_type buffer_size)
|
||||
ETL_EXPLICIT_STRING_FROM_CHAR u32string_ext(const value_type* text, value_type* buffer, size_type buffer_size)
|
||||
: iu32string(buffer, buffer_size - 1U)
|
||||
{
|
||||
// Is the initial text at the same address as the buffer?
|
||||
@ -333,10 +331,10 @@ namespace etl
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructor, from null terminated text and count.
|
||||
///\param text The initial text of the u32string.
|
||||
///\param text The initial text of the u32string_ext.
|
||||
///\param count The number of characters to copy.
|
||||
//*************************************************************************
|
||||
u32string(const value_type* text, size_type count, value_type* buffer, size_type buffer_size)
|
||||
u32string_ext(const value_type* text, size_type count, value_type* buffer, size_type buffer_size)
|
||||
: iu32string(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->assign(text, text + count);
|
||||
@ -344,10 +342,10 @@ namespace etl
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructor, from initial size and value.
|
||||
///\param initialSize The initial size of the u32string.
|
||||
///\param value The value to fill the u32string with.
|
||||
///\param initialSize The initial size of the u32string_ext.
|
||||
///\param value The value to fill the u32string_ext with.
|
||||
//*************************************************************************
|
||||
u32string(size_type count, value_type c, value_type* buffer, size_type buffer_size)
|
||||
u32string_ext(size_type count, value_type c, value_type* buffer, size_type buffer_size)
|
||||
: iu32string(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->initialise();
|
||||
@ -361,7 +359,7 @@ namespace etl
|
||||
///\param last The iterator to the last element + 1.
|
||||
//*************************************************************************
|
||||
template <typename TIterator>
|
||||
u32string(TIterator first, TIterator last, value_type* buffer, size_type buffer_size)
|
||||
u32string_ext(TIterator first, TIterator last, value_type* buffer, size_type buffer_size)
|
||||
: iu32string(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->assign(first, last);
|
||||
@ -371,7 +369,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Construct from initializer_list.
|
||||
//*************************************************************************
|
||||
u32string(std::initializer_list<value_type> init, value_type* buffer, size_type buffer_size)
|
||||
u32string_ext(std::initializer_list<value_type> init, value_type* buffer, size_type buffer_size)
|
||||
: iu32string(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->assign(init.begin(), init.end());
|
||||
@ -382,7 +380,7 @@ namespace etl
|
||||
/// From u32string_view.
|
||||
///\param view The u32string_view.
|
||||
//*************************************************************************
|
||||
explicit u32string(const etl::u32string_view& view, value_type* buffer, size_type buffer_size)
|
||||
explicit u32string_ext(const etl::u32string_view& view, value_type* buffer, size_type buffer_size)
|
||||
: iu32string(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->assign(view.begin(), view.end());
|
||||
@ -391,7 +389,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
u32string& operator = (const u32string& rhs)
|
||||
u32string_ext& operator = (const u32string_ext& rhs)
|
||||
{
|
||||
if (&rhs != this)
|
||||
{
|
||||
@ -405,7 +403,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
u32string& operator = (const iu32string& rhs)
|
||||
u32string_ext& operator = (const iu32string& rhs)
|
||||
{
|
||||
if (&rhs != this)
|
||||
{
|
||||
@ -418,7 +416,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
u32string& operator = (const value_type* text)
|
||||
u32string_ext& operator = (const value_type* text)
|
||||
{
|
||||
this->assign(text);
|
||||
|
||||
@ -440,7 +438,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Deleted.
|
||||
//*************************************************************************
|
||||
u32string(const u32string& other) ETL_DELETE;
|
||||
u32string_ext(const u32string_ext& other) ETL_DELETE;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
@ -466,6 +464,16 @@ namespace etl
|
||||
reinterpret_cast<const uint8_t*>(&text[text.size()]));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct hash<etl::u32string_ext >
|
||||
{
|
||||
size_t operator()(const etl::u32string_ext& text) const
|
||||
{
|
||||
return etl::private_hash::generic_hash<size_t>(reinterpret_cast<const uint8_t*>(&text[0]),
|
||||
reinterpret_cast<const uint8_t*>(&text[text.size()]));
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
|
||||
@ -245,12 +245,10 @@ namespace etl
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
/// A wstring implementation that uses a fixed size buffer.
|
||||
/// A specialisation that requires an external buffer to be specified.
|
||||
/// A wstring implementation that uses a fixed size external buffer.
|
||||
///\ingroup wstring
|
||||
//***************************************************************************
|
||||
template <>
|
||||
class wstring<0U> : public iwstring
|
||||
class wstring_ext : public iwstring
|
||||
{
|
||||
public:
|
||||
|
||||
@ -262,7 +260,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Constructor.
|
||||
//*************************************************************************
|
||||
wstring(value_type* buffer, size_type buffer_size)
|
||||
wstring_ext(value_type* buffer, size_type buffer_size)
|
||||
: iwstring(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->initialise();
|
||||
@ -270,9 +268,9 @@ namespace etl
|
||||
|
||||
//*************************************************************************
|
||||
/// Copy constructor.
|
||||
///\param other The other wstring.
|
||||
///\param other The other wstring_ext.
|
||||
//*************************************************************************
|
||||
wstring(const etl::wstring<0U>& other, value_type* buffer, size_type buffer_size)
|
||||
wstring_ext(const etl::wstring_ext& other, value_type* buffer, size_type buffer_size)
|
||||
: iwstring(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->assign(other);
|
||||
@ -282,19 +280,19 @@ namespace etl
|
||||
/// From other iwstring.
|
||||
///\param other The other iwstring.
|
||||
//*************************************************************************
|
||||
wstring(const etl::iwstring& other, value_type* buffer, size_type buffer_size)
|
||||
wstring_ext(const etl::iwstring& other, value_type* buffer, size_type buffer_size)
|
||||
: iwstring(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->assign(other);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// From other wstring, position, length.
|
||||
///\param other The other wstring.
|
||||
/// From other wstring_ext, position, length.
|
||||
///\param other The other wstring_ext.
|
||||
///\param position The position of the first character.
|
||||
///\param length The number of characters. Default = npos.
|
||||
//*************************************************************************
|
||||
wstring(const etl::iwstring& other, value_type* buffer, size_type buffer_size, size_type position, size_type length_ = npos)
|
||||
wstring_ext(const etl::iwstring& other, value_type* buffer, size_type buffer_size, size_type position, size_type length_ = npos)
|
||||
: iwstring(buffer, buffer_size - 1U)
|
||||
{
|
||||
ETL_ASSERT(position < other.size(), ETL_ERROR(string_out_of_bounds));
|
||||
@ -315,9 +313,9 @@ namespace etl
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructor, from null terminated text.
|
||||
///\param text The initial text of the wstring.
|
||||
///\param text The initial text of the wstring_ext.
|
||||
//*************************************************************************
|
||||
wstring(const value_type* text, value_type* buffer, size_type buffer_size)
|
||||
wstring_ext(const value_type* text, value_type* buffer, size_type buffer_size)
|
||||
: iwstring(buffer, buffer_size - 1U)
|
||||
{
|
||||
// Is the initial text at the same address as the buffer?
|
||||
@ -333,10 +331,10 @@ namespace etl
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructor, from null terminated text and count.
|
||||
///\param text The initial text of the wstring.
|
||||
///\param text The initial text of the wstring_ext.
|
||||
///\param count The number of characters to copy.
|
||||
//*************************************************************************
|
||||
wstring(const value_type* text, size_type count, value_type* buffer, size_type buffer_size)
|
||||
wstring_ext(const value_type* text, size_type count, value_type* buffer, size_type buffer_size)
|
||||
: iwstring(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->assign(text, text + count);
|
||||
@ -344,10 +342,10 @@ namespace etl
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructor, from initial size and value.
|
||||
///\param initialSize The initial size of the wstring.
|
||||
///\param value The value to fill the wstring with.
|
||||
///\param initialSize The initial size of the wstring_ext.
|
||||
///\param value The value to fill the wstring_ext with.
|
||||
//*************************************************************************
|
||||
wstring(size_type count, value_type c, value_type* buffer, size_type buffer_size)
|
||||
wstring_ext(size_type count, value_type c, value_type* buffer, size_type buffer_size)
|
||||
: iwstring(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->initialise();
|
||||
@ -361,7 +359,7 @@ namespace etl
|
||||
///\param last The iterator to the last element + 1.
|
||||
//*************************************************************************
|
||||
template <typename TIterator>
|
||||
wstring(TIterator first, TIterator last, value_type* buffer, size_type buffer_size)
|
||||
wstring_ext(TIterator first, TIterator last, value_type* buffer, size_type buffer_size)
|
||||
: iwstring(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->assign(first, last);
|
||||
@ -371,7 +369,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Construct from initializer_list.
|
||||
//*************************************************************************
|
||||
wstring(std::initializer_list<value_type> init, value_type* buffer, size_type buffer_size)
|
||||
wstring_ext(std::initializer_list<value_type> init, value_type* buffer, size_type buffer_size)
|
||||
: iwstring(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->assign(init.begin(), init.end());
|
||||
@ -382,7 +380,7 @@ namespace etl
|
||||
/// From wstring_view.
|
||||
///\param view The wstring_view.
|
||||
//*************************************************************************
|
||||
explicit wstring(const etl::wstring_view& view, value_type* buffer, size_type buffer_size)
|
||||
explicit wstring_ext(const etl::wstring_view& view, value_type* buffer, size_type buffer_size)
|
||||
: iwstring(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->assign(view.begin(), view.end());
|
||||
@ -391,7 +389,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
wstring& operator = (const wstring& rhs)
|
||||
wstring_ext& operator = (const wstring_ext& rhs)
|
||||
{
|
||||
if (&rhs != this)
|
||||
{
|
||||
@ -405,7 +403,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
wstring& operator = (const iwstring& rhs)
|
||||
wstring_ext& operator = (const iwstring& rhs)
|
||||
{
|
||||
if (&rhs != this)
|
||||
{
|
||||
@ -418,7 +416,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
wstring& operator = (const value_type* text)
|
||||
wstring_ext& operator = (const value_type* text)
|
||||
{
|
||||
this->assign(text);
|
||||
|
||||
@ -440,7 +438,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Deleted.
|
||||
//*************************************************************************
|
||||
wstring(const wstring& other) ETL_DELETE;
|
||||
wstring_ext(const wstring_ext& other) ETL_DELETE;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
@ -466,6 +464,16 @@ namespace etl
|
||||
reinterpret_cast<const uint8_t*>(&text[text.size()]));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct hash<etl::wstring_ext>
|
||||
{
|
||||
size_t operator()(const etl::wstring_ext& text) const
|
||||
{
|
||||
return etl::private_hash::generic_hash<size_t>(reinterpret_cast<const uint8_t*>(&text[0]),
|
||||
reinterpret_cast<const uint8_t*>(&text[text.size()]));
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
|
||||
@ -58,8 +58,8 @@ namespace
|
||||
{
|
||||
size_t length = strlen("");
|
||||
|
||||
auto ctext = etl::make_string("");
|
||||
auto wtext = etl::make_string(L"");
|
||||
auto ctext = etl::make_string("");
|
||||
auto wtext = etl::make_string(L"");
|
||||
auto u16text = etl::make_string(u"");
|
||||
auto u32text = etl::make_string(U"");
|
||||
|
||||
|
||||
@ -53,7 +53,7 @@ namespace
|
||||
static constexpr size_t SIZE_L = 52;
|
||||
static constexpr size_t SIZE_S = 4;
|
||||
|
||||
using Text = etl::string<0>;
|
||||
using Text = etl::string_ext;
|
||||
using IText = etl::istring;
|
||||
using TextT = etl::string<SIZE>;
|
||||
using Compare_Text = std::string;
|
||||
|
||||
@ -53,7 +53,7 @@ namespace
|
||||
static constexpr size_t SIZE_L = 52;
|
||||
static constexpr size_t SIZE_S = 4;
|
||||
|
||||
using Text = etl::u16string<0>;
|
||||
using Text = etl::u16string_ext;
|
||||
using IText = etl::iu16string;
|
||||
using TextT = etl::u16string<SIZE>;
|
||||
using Compare_Text = std::u16string;
|
||||
|
||||
@ -53,7 +53,7 @@ namespace
|
||||
static constexpr size_t SIZE_L = 52;
|
||||
static constexpr size_t SIZE_S = 4;
|
||||
|
||||
using Text = etl::u32string<0>;
|
||||
using Text = etl::u32string_ext;
|
||||
using IText = etl::iu32string;
|
||||
using TextT = etl::u32string<SIZE>;
|
||||
using Compare_Text = std::u32string;
|
||||
|
||||
@ -53,7 +53,7 @@ namespace
|
||||
static constexpr size_t SIZE_L = 52;
|
||||
static constexpr size_t SIZE_S = 4;
|
||||
|
||||
using Text = etl::wstring<0>;
|
||||
using Text = etl::wstring_ext;
|
||||
using IText = etl::iwstring;
|
||||
using TextT = etl::wstring<SIZE>;
|
||||
using Compare_Text = std::wstring;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user