w, u16 & u32 string utilities added

This commit is contained in:
John Wellbelove 2020-07-16 01:03:41 +01:00
parent 5c9f648cc5
commit 21001d1847
14 changed files with 5862 additions and 16 deletions

View File

@ -305,12 +305,12 @@ namespace etl
do
{
position = s.find(p_old, position);
if (position != etl::istring::npos)
if (position != TIString::npos)
{
s.replace(position, etl::strlen(p_old), p_new, etl::strlen(p_new));
position += etl::strlen(p_new);
}
} while (position != etl::istring::npos);
} while (position != TIString::npos);
++pairsbegin;
}

View File

@ -0,0 +1,508 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2020 John Wellbelove, John Lagerquist
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef ETL_U16STRING_UTILITIES_INCLUDED
#define ETL_U16STRING_UTILITIES_INCLUDED
#include "platform.h"
#include "u16string.h"
#include "string_view.h"
#include "algorithm.h"
#include "private/string_utilities_helper.h"
#include <ctype.h>
namespace etl
{
//***************************************************************************
/// trim_whitespace_left
/// Trim left of whitespace
//***************************************************************************
inline void trim_whitespace_left(etl::iu16string& s)
{
etl::private_string_utilities::trim_from_left<etl::iu16string>(s, u" \t\n\r\f\v");
}
//***************************************************************************
/// trim_whitespace_left
/// View trim left of whitespace
//***************************************************************************
inline etl::u16string_view trim_whitespace_left(const etl::u16string_view& view)
{
return etl::private_string_utilities::view_trim_from_left<etl::u16string_view>(view, u" \t\n\r\f\v");
}
//***************************************************************************
/// trim_from_left
/// Trim left of specified characters
//***************************************************************************
inline void trim_from_left(etl::iu16string& s, etl::iu16string::const_pointer trim_characters)
{
etl::private_string_utilities::trim_from_left<etl::iu16string>(s, trim_characters);
}
//***************************************************************************
/// trim_from_left
/// View trim left of specified characters
//***************************************************************************
inline etl::u16string_view trim_from_left(const etl::u16string_view& view, etl::iu16string::const_pointer trim_characters)
{
return etl::private_string_utilities::view_trim_from_left<etl::u16string_view>(view, trim_characters);
}
//***************************************************************************
/// trim_left
/// Trim left, up to, but not including, delimiters.
//***************************************************************************
inline void trim_left(etl::iu16string& s, etl::iu16string::const_pointer delimiters)
{
etl::private_string_utilities::trim_left_delimiters<etl::iu16string>(s, delimiters);
}
//***************************************************************************
/// trim_left
/// Trim left, up to, but not including, delimiters.
//***************************************************************************
inline etl::u16string_view trim_left(etl::u16string_view& s, etl::u16string_view::const_pointer delimiters)
{
return etl::private_string_utilities::view_trim_left_delimiters<etl::u16string_view>(s, delimiters);
}
//***************************************************************************
/// trim_whitespace_right
/// Trim right of whitespace
//***************************************************************************
inline void trim_whitespace_right(etl::iu16string& s)
{
etl::private_string_utilities::trim_from_right<etl::iu16string>(s, u" \t\n\r\f\v");
}
//***************************************************************************
/// trim_whitespace_right
/// Trim right of whitespace
//***************************************************************************
inline etl::u16string_view trim_whitespace_right(const etl::u16string_view& view)
{
return etl::private_string_utilities::view_trim_from_right<etl::u16string_view>(view, u" \t\n\r\f\v");
}
//***************************************************************************
/// trim_from_right
/// Trim right of specified characters
//***************************************************************************
inline void trim_from_right(etl::iu16string& s, etl::iu16string::const_pointer trim_characters)
{
etl::private_string_utilities::trim_from_right<etl::iu16string>(s, trim_characters);
}
//***************************************************************************
/// trim_from_right
/// Trim right of specified characters
//***************************************************************************
inline etl::u16string_view trim_from_right(const etl::u16string_view& view, etl::iu16string::const_pointer trim_characters)
{
return etl::private_string_utilities::view_trim_from_right<etl::u16string_view>(view, trim_characters);
}
//***************************************************************************
/// trim_right
//***************************************************************************
inline void trim_right(etl::iu16string& s, etl::iu16string::const_pointer delimiters)
{
etl::private_string_utilities::trim_right_delimiters<etl::iu16string>(s, delimiters);
}
//***************************************************************************
/// trim_right
//***************************************************************************
inline etl::u16string_view trim_right(const etl::u16string_view& view, etl::iu16string::const_pointer delimiters)
{
return etl::private_string_utilities::view_trim_right_delimiters<etl::u16string_view>(view, delimiters);
}
//***************************************************************************
/// trim_whitespace
/// Trim both ends of whitespace
//***************************************************************************
inline void trim_whitespace(etl::iu16string& s)
{
etl::private_string_utilities::trim_from<etl::iu16string>(s, u" \t\n\r\f\v");
}
//***************************************************************************
/// trim_whitespace
/// Trim both ends of whitespace
//***************************************************************************
inline etl::u16string_view trim_whitespace(const etl::u16string_view& view)
{
return etl::private_string_utilities::view_trim_from<etl::u16string_view>(view, u" \t\n\r\f\v");
}
//***************************************************************************
/// trim_from
/// Trim right of specified characters
//***************************************************************************
inline void trim_from(etl::iu16string& s, etl::iu16string::const_pointer trim_characters)
{
etl::private_string_utilities::trim_from<etl::iu16string>(s, trim_characters);
}
//***************************************************************************
/// trim_from
/// Trim right of specified characters
//***************************************************************************
inline etl::u16string_view trim_from(const etl::u16string_view& view, etl::iu16string::const_pointer trim_characters)
{
return etl::private_string_utilities::view_trim_from<etl::u16string_view>(view, trim_characters);
}
//***************************************************************************
/// trim
//***************************************************************************
inline void trim(etl::iu16string& s, etl::iu16string::const_pointer delimiters)
{
etl::private_string_utilities::trim_delimiters<etl::iu16string>(s, delimiters);
}
//***************************************************************************
/// trim
//***************************************************************************
inline etl::u16string_view trim(const etl::u16string_view& view, etl::iu16string::const_pointer delimiters)
{
return etl::private_string_utilities::view_trim_delimiters<etl::u16string_view>(view, delimiters);
}
//***************************************************************************
/// reverse
/// Reverse the string
//***************************************************************************
inline void reverse(etl::iu16string& s)
{
etl::private_string_utilities::reverse<etl::iu16string>(s);
}
//***************************************************************************
/// Get up to the first n characters.
//***************************************************************************
inline void left_n(etl::iu16string& s, size_t n)
{
n = (n > s.size()) ? s.size() : n;
s.erase(s.begin() + n, s.end());
}
//***************************************************************************
/// Get a view of up to the first n characters.
//***************************************************************************
inline etl::u16string_view left_n(etl::u16string_view view, size_t n)
{
n = (n > view.size()) ? view.size() : n;
return etl::u16string_view(view.begin(), view.begin() + n);
}
//***************************************************************************
/// Get up to the last n characters.
//***************************************************************************
inline void right_n(etl::iu16string& s, size_t n)
{
n = (n > s.size()) ? s.size() : n;
s.erase(s.begin(), s.end() - n);
}
//***************************************************************************
/// Get a view of up to the last n characters.
//***************************************************************************
inline etl::u16string_view right_n(etl::u16string_view view, size_t n)
{
n = (n > view.size()) ? view.size() : n;
return etl::u16string_view(view.end() - n, view.end());
}
//***************************************************************************
/// pad_left
//***************************************************************************
inline void pad_left(etl::iu16string& s, size_t required_size, etl::iu16string::value_type pad_char)
{
etl::private_string_utilities::pad_left(s, required_size, pad_char);
}
//***************************************************************************
/// pad_right
//***************************************************************************
inline void pad_right(etl::iu16string& s, size_t required_size, etl::iu16string::value_type pad_char)
{
etl::private_string_utilities::pad_right(s, required_size, pad_char);
}
//***************************************************************************
/// pad
//***************************************************************************
void pad(etl::iu16string& s, size_t required_size, string_pad_direction pad_direction, etl::iu16string::value_type pad_char)
{
etl::private_string_utilities::pad(s, required_size, pad_direction, pad_char);
}
//***************************************************************************
/// to_upper_case
//***************************************************************************
inline void to_upper_case(etl::iu16string& s)
{
etl::iu16string::iterator itr = s.begin();
while (itr != s.end())
{
*itr = etl::iu16string::value_type(::toupper(*itr));
++itr;
}
}
//***************************************************************************
/// to_lower_case
//***************************************************************************
inline void to_lower_case(etl::iu16string& s)
{
etl::iu16string::iterator itr = s.begin();
while (itr != s.end())
{
*itr = etl::iu16string::value_type(::tolower(*itr));
++itr;
}
}
//***************************************************************************
/// to_sentence_case
//***************************************************************************
inline void to_sentence_case(etl::iu16string& s)
{
etl::iu16string::iterator itr = s.begin();
*itr = etl::iu16string::value_type(::toupper(*itr));
++itr;
while (itr != s.end())
{
*itr = etl::iu16string::value_type(::tolower(*itr));
}
}
//***************************************************************************
/// transform
//***************************************************************************
inline void transform(etl::iu16string& s,
const etl::pair<etl::iu16string::value_type, etl::iu16string::value_type>* pairsbegin,
const etl::pair<etl::iu16string::value_type, etl::iu16string::value_type>* pairsend)
{
etl::private_string_utilities::transform_characters<etl::iu16string>(s, pairsbegin, pairsend);
}
//***************************************************************************
/// transform
//***************************************************************************
inline void transform(etl::iu16string& s,
const etl::pair<const etl::iu16string::value_type*, const etl::iu16string::value_type*>* pairsbegin,
const etl::pair<const etl::iu16string::value_type*, const etl::iu16string::value_type*>* pairsend)
{
etl::private_string_utilities::transform_strings<etl::iu16string>(s, pairsbegin, pairsend);
}
//***************************************************************************
/// get_token
//***************************************************************************
inline etl::u16string_view get_token(const etl::iu16string& s, etl::iu16string::const_pointer delimiters, const u16string_view& last_view)
{
return etl::private_string_utilities::get_token(s, delimiters, last_view);
}
//*********************************************************************
/// Find first of any of delimiters within the string
//*********************************************************************
inline etl::iu16string::iterator find_first_of(etl::iu16string::iterator first, etl::iu16string::iterator last, etl::iu16string::const_pointer delimiters)
{
return etl::private_string_utilities::find_first_of(first, last, delimiters);
}
//*********************************************************************
/// Find first of any of delimiters within the string
//*********************************************************************
inline etl::iu16string::const_iterator find_first_of(etl::iu16string::const_iterator first, etl::iu16string::const_iterator last, etl::iu16string::const_pointer delimiters)
{
return etl::private_string_utilities::find_first_of(first, last, delimiters);
}
//*********************************************************************
/// Find first of any of delimiters within the string
//*********************************************************************
inline etl::iu16string::iterator find_first_of(etl::iu16string& s, etl::iu16string::const_pointer delimiters)
{
return etl::private_string_utilities::find_first_of(s.begin(), s.end(), delimiters);
}
//*********************************************************************
/// Find first of any of delimiters within the string
//*********************************************************************
inline etl::iu16string::const_iterator find_first_of(const etl::iu16string& s, etl::iu16string::const_pointer delimiters)
{
return etl::private_string_utilities::find_first_of(s.cbegin(), s.cend(), delimiters);
}
//*********************************************************************
/// Find first of any of delimiters within the string
//*********************************************************************
inline etl::iu16string::const_iterator find_first_of(const etl::u16string_view& s, etl::iu16string::const_pointer delimiters)
{
return etl::private_string_utilities::find_first_of(s.cbegin(), s.cend(), delimiters);
}
//*********************************************************************
/// Find first not of delimiters within the string
//*********************************************************************
inline etl::iu16string::iterator find_first_not_of(etl::iu16string::iterator first, etl::iu16string::iterator last, etl::iu16string::const_pointer delimiters)
{
return etl::private_string_utilities::find_first_not_of(first, last, delimiters);
}
//*********************************************************************
/// Find first not of delimiters within the string
//*********************************************************************
inline etl::iu16string::const_iterator find_first_not_of(etl::iu16string::const_iterator first, etl::iu16string::const_iterator last, etl::iu16string::const_pointer delimiters)
{
return etl::private_string_utilities::find_first_not_of(first, last, delimiters);
}
//*********************************************************************
/// Find first not of delimiters within the string
//*********************************************************************
inline etl::iu16string::iterator find_first_not_of(etl::iu16string& s, etl::iu16string::const_pointer delimiters)
{
return etl::private_string_utilities::find_first_not_of(s.begin(), s.end(), delimiters);
}
//*********************************************************************
/// Find first not of delimiters within the string
//*********************************************************************
inline etl::iu16string::const_iterator find_first_not_of(const etl::iu16string& s, etl::iu16string::const_pointer delimiters)
{
return etl::private_string_utilities::find_first_not_of(s.cbegin(), s.cend(), delimiters);
}
//*********************************************************************
/// Find first not of delimiters within the string
//*********************************************************************
inline etl::iu16string::const_iterator find_first_not_of(const etl::u16string_view& view, etl::iu16string::const_pointer delimiters)
{
return etl::private_string_utilities::find_first_not_of(view.cbegin(), view.cend(), delimiters);
}
//*********************************************************************
/// Find last of any of delimiters within the string
//*********************************************************************
inline etl::iu16string::iterator find_last_of(etl::iu16string::iterator first, etl::iu16string::iterator last, etl::iu16string::const_pointer delimiters)
{
return etl::private_string_utilities::find_last_of(first, last, delimiters);
}
//*********************************************************************
/// Find last of any of delimiters within the string
//*********************************************************************
inline etl::iu16string::const_iterator find_last_of(etl::iu16string::const_iterator first, etl::iu16string::const_iterator last, etl::iu16string::const_pointer delimiters)
{
return etl::private_string_utilities::find_last_of(first, last, delimiters);
}
//*********************************************************************
/// Find last of any of delimiters within the string
//*********************************************************************
inline etl::iu16string::iterator find_last_of(etl::iu16string& s, etl::iu16string::const_pointer delimiters)
{
return etl::private_string_utilities::find_last_of(s.begin(), s.end(), delimiters);
}
//*********************************************************************
/// Find last of any of delimiters within the string
//*********************************************************************
inline etl::iu16string::const_iterator find_last_of(const etl::iu16string& s, etl::iu16string::const_pointer delimiters)
{
return etl::private_string_utilities::find_last_of(s.cbegin(), s.cend(), delimiters);
}
//*********************************************************************
/// Find last of any of delimiters within the string
//*********************************************************************
inline etl::iu16string::const_iterator find_last_of(const etl::u16string_view& view, etl::iu16string::const_pointer delimiters)
{
return etl::private_string_utilities::find_last_of(view.cbegin(), view.cend(), delimiters);
}
//*********************************************************************
/// Find last of any of delimiters within the string
//*********************************************************************
inline etl::iu16string::iterator find_last_not_of(etl::iu16string::iterator first, etl::iu16string::iterator last, etl::iu16string::const_pointer delimiters)
{
return etl::private_string_utilities::find_last_not_of(first, last, delimiters);
}
//*********************************************************************
/// Find last of any of delimiters within the string
//*********************************************************************
inline etl::iu16string::const_iterator find_last_not_of(etl::iu16string::const_iterator first, etl::iu16string::const_iterator last, etl::iu16string::const_pointer delimiters)
{
return etl::private_string_utilities::find_last_not_of(first, last, delimiters);
}
//*********************************************************************
/// Find last of any of delimiters within the string
//*********************************************************************
inline etl::iu16string::iterator find_last_not_of(etl::iu16string& s, etl::iu16string::const_pointer delimiters)
{
return etl::private_string_utilities::find_last_not_of(s.begin(), s.end(), delimiters);
}
//*********************************************************************
/// Find last of any of delimiters within the string
//*********************************************************************
inline etl::iu16string::const_iterator find_last_not_of(const etl::iu16string& s, etl::iu16string::const_pointer delimiters)
{
return etl::private_string_utilities::find_last_not_of(s.cbegin(), s.cend(), delimiters);
}
//*********************************************************************
/// Find last of any of delimiters within the string
//*********************************************************************
inline etl::iu16string::const_iterator find_last_not_of(const etl::u16string_view& view, etl::iu16string::const_pointer delimiters)
{
return etl::private_string_utilities::find_last_not_of(view.cbegin(), view.cend(), delimiters);
}
}
#endif

View File

@ -0,0 +1,508 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2020 John Wellbelove, John Lagerquist
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef ETL_U32STRING_UTILITIES_INCLUDED
#define ETL_U32STRING_UTILITIES_INCLUDED
#include "platform.h"
#include "u32string.h"
#include "string_view.h"
#include "algorithm.h"
#include "private/string_utilities_helper.h"
#include <ctype.h>
namespace etl
{
//***************************************************************************
/// trim_whitespace_left
/// Trim left of whitespace
//***************************************************************************
inline void trim_whitespace_left(etl::iu32string& s)
{
etl::private_string_utilities::trim_from_left<etl::iu32string>(s, U" \t\n\r\f\v");
}
//***************************************************************************
/// trim_whitespace_left
/// View trim left of whitespace
//***************************************************************************
inline etl::u32string_view trim_whitespace_left(const etl::u32string_view& view)
{
return etl::private_string_utilities::view_trim_from_left<etl::u32string_view>(view, U" \t\n\r\f\v");
}
//***************************************************************************
/// trim_from_left
/// Trim left of specified characters
//***************************************************************************
inline void trim_from_left(etl::iu32string& s, etl::iu32string::const_pointer trim_characters)
{
etl::private_string_utilities::trim_from_left<etl::iu32string>(s, trim_characters);
}
//***************************************************************************
/// trim_from_left
/// View trim left of specified characters
//***************************************************************************
inline etl::u32string_view trim_from_left(const etl::u32string_view& view, etl::iu32string::const_pointer trim_characters)
{
return etl::private_string_utilities::view_trim_from_left<etl::u32string_view>(view, trim_characters);
}
//***************************************************************************
/// trim_left
/// Trim left, up to, but not including, delimiters.
//***************************************************************************
inline void trim_left(etl::iu32string& s, etl::iu32string::const_pointer delimiters)
{
etl::private_string_utilities::trim_left_delimiters<etl::iu32string>(s, delimiters);
}
//***************************************************************************
/// trim_left
/// Trim left, up to, but not including, delimiters.
//***************************************************************************
inline etl::u32string_view trim_left(etl::u32string_view& s, etl::u32string_view::const_pointer delimiters)
{
return etl::private_string_utilities::view_trim_left_delimiters<etl::u32string_view>(s, delimiters);
}
//***************************************************************************
/// trim_whitespace_right
/// Trim right of whitespace
//***************************************************************************
inline void trim_whitespace_right(etl::iu32string& s)
{
etl::private_string_utilities::trim_from_right<etl::iu32string>(s, U" \t\n\r\f\v");
}
//***************************************************************************
/// trim_whitespace_right
/// Trim right of whitespace
//***************************************************************************
inline etl::u32string_view trim_whitespace_right(const etl::u32string_view& view)
{
return etl::private_string_utilities::view_trim_from_right<etl::u32string_view>(view, U" \t\n\r\f\v");
}
//***************************************************************************
/// trim_from_right
/// Trim right of specified characters
//***************************************************************************
inline void trim_from_right(etl::iu32string& s, etl::iu32string::const_pointer trim_characters)
{
etl::private_string_utilities::trim_from_right<etl::iu32string>(s, trim_characters);
}
//***************************************************************************
/// trim_from_right
/// Trim right of specified characters
//***************************************************************************
inline etl::u32string_view trim_from_right(const etl::u32string_view& view, etl::iu32string::const_pointer trim_characters)
{
return etl::private_string_utilities::view_trim_from_right<etl::u32string_view>(view, trim_characters);
}
//***************************************************************************
/// trim_right
//***************************************************************************
inline void trim_right(etl::iu32string& s, etl::iu32string::const_pointer delimiters)
{
etl::private_string_utilities::trim_right_delimiters<etl::iu32string>(s, delimiters);
}
//***************************************************************************
/// trim_right
//***************************************************************************
inline etl::u32string_view trim_right(const etl::u32string_view& view, etl::iu32string::const_pointer delimiters)
{
return etl::private_string_utilities::view_trim_right_delimiters<etl::u32string_view>(view, delimiters);
}
//***************************************************************************
/// trim_whitespace
/// Trim both ends of whitespace
//***************************************************************************
inline void trim_whitespace(etl::iu32string& s)
{
etl::private_string_utilities::trim_from<etl::iu32string>(s, U" \t\n\r\f\v");
}
//***************************************************************************
/// trim_whitespace
/// Trim both ends of whitespace
//***************************************************************************
inline etl::u32string_view trim_whitespace(const etl::u32string_view& view)
{
return etl::private_string_utilities::view_trim_from<etl::u32string_view>(view, U" \t\n\r\f\v");
}
//***************************************************************************
/// trim_from
/// Trim right of specified characters
//***************************************************************************
inline void trim_from(etl::iu32string& s, etl::iu32string::const_pointer trim_characters)
{
etl::private_string_utilities::trim_from<etl::iu32string>(s, trim_characters);
}
//***************************************************************************
/// trim_from
/// Trim right of specified characters
//***************************************************************************
inline etl::u32string_view trim_from(const etl::u32string_view& view, etl::iu32string::const_pointer trim_characters)
{
return etl::private_string_utilities::view_trim_from<etl::u32string_view>(view, trim_characters);
}
//***************************************************************************
/// trim
//***************************************************************************
inline void trim(etl::iu32string& s, etl::iu32string::const_pointer delimiters)
{
etl::private_string_utilities::trim_delimiters<etl::iu32string>(s, delimiters);
}
//***************************************************************************
/// trim
//***************************************************************************
inline etl::u32string_view trim(const etl::u32string_view& view, etl::iu32string::const_pointer delimiters)
{
return etl::private_string_utilities::view_trim_delimiters<etl::u32string_view>(view, delimiters);
}
//***************************************************************************
/// reverse
/// Reverse the string
//***************************************************************************
inline void reverse(etl::iu32string& s)
{
etl::private_string_utilities::reverse<etl::iu32string>(s);
}
//***************************************************************************
/// Get up to the first n characters.
//***************************************************************************
inline void left_n(etl::iu32string& s, size_t n)
{
n = (n > s.size()) ? s.size() : n;
s.erase(s.begin() + n, s.end());
}
//***************************************************************************
/// Get a view of up to the first n characters.
//***************************************************************************
inline etl::u32string_view left_n(etl::u32string_view view, size_t n)
{
n = (n > view.size()) ? view.size() : n;
return etl::u32string_view(view.begin(), view.begin() + n);
}
//***************************************************************************
/// Get up to the last n characters.
//***************************************************************************
inline void right_n(etl::iu32string& s, size_t n)
{
n = (n > s.size()) ? s.size() : n;
s.erase(s.begin(), s.end() - n);
}
//***************************************************************************
/// Get a view of up to the last n characters.
//***************************************************************************
inline etl::u32string_view right_n(etl::u32string_view view, size_t n)
{
n = (n > view.size()) ? view.size() : n;
return etl::u32string_view(view.end() - n, view.end());
}
//***************************************************************************
/// pad_left
//***************************************************************************
inline void pad_left(etl::iu32string& s, size_t required_size, etl::iu32string::value_type pad_char)
{
etl::private_string_utilities::pad_left(s, required_size, pad_char);
}
//***************************************************************************
/// pad_right
//***************************************************************************
inline void pad_right(etl::iu32string& s, size_t required_size, etl::iu32string::value_type pad_char)
{
etl::private_string_utilities::pad_right(s, required_size, pad_char);
}
//***************************************************************************
/// pad
//***************************************************************************
void pad(etl::iu32string& s, size_t required_size, string_pad_direction pad_direction, etl::iu32string::value_type pad_char)
{
etl::private_string_utilities::pad(s, required_size, pad_direction, pad_char);
}
//***************************************************************************
/// to_upper_case
//***************************************************************************
inline void to_upper_case(etl::iu32string& s)
{
etl::iu32string::iterator itr = s.begin();
while (itr != s.end())
{
*itr = etl::iu32string::value_type(::toupper(*itr));
++itr;
}
}
//***************************************************************************
/// to_lower_case
//***************************************************************************
inline void to_lower_case(etl::iu32string& s)
{
etl::iu32string::iterator itr = s.begin();
while (itr != s.end())
{
*itr = etl::iu32string::value_type(::tolower(*itr));
++itr;
}
}
//***************************************************************************
/// to_sentence_case
//***************************************************************************
inline void to_sentence_case(etl::iu32string& s)
{
etl::iu32string::iterator itr = s.begin();
*itr = etl::iu32string::value_type(::toupper(*itr));
++itr;
while (itr != s.end())
{
*itr = etl::iu32string::value_type(::tolower(*itr));
}
}
//***************************************************************************
/// transform
//***************************************************************************
inline void transform(etl::iu32string& s,
const etl::pair<etl::iu32string::value_type, etl::iu32string::value_type>* pairsbegin,
const etl::pair<etl::iu32string::value_type, etl::iu32string::value_type>* pairsend)
{
etl::private_string_utilities::transform_characters<etl::iu32string>(s, pairsbegin, pairsend);
}
//***************************************************************************
/// transform
//***************************************************************************
inline void transform(etl::iu32string& s,
const etl::pair<const etl::iu32string::value_type*, const etl::iu32string::value_type*>* pairsbegin,
const etl::pair<const etl::iu32string::value_type*, const etl::iu32string::value_type*>* pairsend)
{
etl::private_string_utilities::transform_strings<etl::iu32string>(s, pairsbegin, pairsend);
}
//***************************************************************************
/// get_token
//***************************************************************************
inline etl::u32string_view get_token(const etl::iu32string& s, etl::iu32string::const_pointer delimiters, const u32string_view& last_view)
{
return etl::private_string_utilities::get_token(s, delimiters, last_view);
}
//*********************************************************************
/// Find first of any of delimiters within the string
//*********************************************************************
inline etl::iu32string::iterator find_first_of(etl::iu32string::iterator first, etl::iu32string::iterator last, etl::iu32string::const_pointer delimiters)
{
return etl::private_string_utilities::find_first_of(first, last, delimiters);
}
//*********************************************************************
/// Find first of any of delimiters within the string
//*********************************************************************
inline etl::iu32string::const_iterator find_first_of(etl::iu32string::const_iterator first, etl::iu32string::const_iterator last, etl::iu32string::const_pointer delimiters)
{
return etl::private_string_utilities::find_first_of(first, last, delimiters);
}
//*********************************************************************
/// Find first of any of delimiters within the string
//*********************************************************************
inline etl::iu32string::iterator find_first_of(etl::iu32string& s, etl::iu32string::const_pointer delimiters)
{
return etl::private_string_utilities::find_first_of(s.begin(), s.end(), delimiters);
}
//*********************************************************************
/// Find first of any of delimiters within the string
//*********************************************************************
inline etl::iu32string::const_iterator find_first_of(const etl::iu32string& s, etl::iu32string::const_pointer delimiters)
{
return etl::private_string_utilities::find_first_of(s.cbegin(), s.cend(), delimiters);
}
//*********************************************************************
/// Find first of any of delimiters within the string
//*********************************************************************
inline etl::iu32string::const_iterator find_first_of(const etl::u32string_view& s, etl::iu32string::const_pointer delimiters)
{
return etl::private_string_utilities::find_first_of(s.cbegin(), s.cend(), delimiters);
}
//*********************************************************************
/// Find first not of delimiters within the string
//*********************************************************************
inline etl::iu32string::iterator find_first_not_of(etl::iu32string::iterator first, etl::iu32string::iterator last, etl::iu32string::const_pointer delimiters)
{
return etl::private_string_utilities::find_first_not_of(first, last, delimiters);
}
//*********************************************************************
/// Find first not of delimiters within the string
//*********************************************************************
inline etl::iu32string::const_iterator find_first_not_of(etl::iu32string::const_iterator first, etl::iu32string::const_iterator last, etl::iu32string::const_pointer delimiters)
{
return etl::private_string_utilities::find_first_not_of(first, last, delimiters);
}
//*********************************************************************
/// Find first not of delimiters within the string
//*********************************************************************
inline etl::iu32string::iterator find_first_not_of(etl::iu32string& s, etl::iu32string::const_pointer delimiters)
{
return etl::private_string_utilities::find_first_not_of(s.begin(), s.end(), delimiters);
}
//*********************************************************************
/// Find first not of delimiters within the string
//*********************************************************************
inline etl::iu32string::const_iterator find_first_not_of(const etl::iu32string& s, etl::iu32string::const_pointer delimiters)
{
return etl::private_string_utilities::find_first_not_of(s.cbegin(), s.cend(), delimiters);
}
//*********************************************************************
/// Find first not of delimiters within the string
//*********************************************************************
inline etl::iu32string::const_iterator find_first_not_of(const etl::u32string_view& view, etl::iu32string::const_pointer delimiters)
{
return etl::private_string_utilities::find_first_not_of(view.cbegin(), view.cend(), delimiters);
}
//*********************************************************************
/// Find last of any of delimiters within the string
//*********************************************************************
inline etl::iu32string::iterator find_last_of(etl::iu32string::iterator first, etl::iu32string::iterator last, etl::iu32string::const_pointer delimiters)
{
return etl::private_string_utilities::find_last_of(first, last, delimiters);
}
//*********************************************************************
/// Find last of any of delimiters within the string
//*********************************************************************
inline etl::iu32string::const_iterator find_last_of(etl::iu32string::const_iterator first, etl::iu32string::const_iterator last, etl::iu32string::const_pointer delimiters)
{
return etl::private_string_utilities::find_last_of(first, last, delimiters);
}
//*********************************************************************
/// Find last of any of delimiters within the string
//*********************************************************************
inline etl::iu32string::iterator find_last_of(etl::iu32string& s, etl::iu32string::const_pointer delimiters)
{
return etl::private_string_utilities::find_last_of(s.begin(), s.end(), delimiters);
}
//*********************************************************************
/// Find last of any of delimiters within the string
//*********************************************************************
inline etl::iu32string::const_iterator find_last_of(const etl::iu32string& s, etl::iu32string::const_pointer delimiters)
{
return etl::private_string_utilities::find_last_of(s.cbegin(), s.cend(), delimiters);
}
//*********************************************************************
/// Find last of any of delimiters within the string
//*********************************************************************
inline etl::iu32string::const_iterator find_last_of(const etl::u32string_view& view, etl::iu32string::const_pointer delimiters)
{
return etl::private_string_utilities::find_last_of(view.cbegin(), view.cend(), delimiters);
}
//*********************************************************************
/// Find last of any of delimiters within the string
//*********************************************************************
inline etl::iu32string::iterator find_last_not_of(etl::iu32string::iterator first, etl::iu32string::iterator last, etl::iu32string::const_pointer delimiters)
{
return etl::private_string_utilities::find_last_not_of(first, last, delimiters);
}
//*********************************************************************
/// Find last of any of delimiters within the string
//*********************************************************************
inline etl::iu32string::const_iterator find_last_not_of(etl::iu32string::const_iterator first, etl::iu32string::const_iterator last, etl::iu32string::const_pointer delimiters)
{
return etl::private_string_utilities::find_last_not_of(first, last, delimiters);
}
//*********************************************************************
/// Find last of any of delimiters within the string
//*********************************************************************
inline etl::iu32string::iterator find_last_not_of(etl::iu32string& s, etl::iu32string::const_pointer delimiters)
{
return etl::private_string_utilities::find_last_not_of(s.begin(), s.end(), delimiters);
}
//*********************************************************************
/// Find last of any of delimiters within the string
//*********************************************************************
inline etl::iu32string::const_iterator find_last_not_of(const etl::iu32string& s, etl::iu32string::const_pointer delimiters)
{
return etl::private_string_utilities::find_last_not_of(s.cbegin(), s.cend(), delimiters);
}
//*********************************************************************
/// Find last of any of delimiters within the string
//*********************************************************************
inline etl::iu32string::const_iterator find_last_not_of(const etl::u32string_view& view, etl::iu32string::const_pointer delimiters)
{
return etl::private_string_utilities::find_last_not_of(view.cbegin(), view.cend(), delimiters);
}
}
#endif

View File

@ -0,0 +1,508 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2020 John Wellbelove, John Lagerquist
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef ETL_WSTRING_UTILITIES_INCLUDED
#define ETL_WSTRING_UTILITIES_INCLUDED
#include "platform.h"
#include "wstring.h"
#include "string_view.h"
#include "algorithm.h"
#include "private/string_utilities_helper.h"
#include <ctype.h>
namespace etl
{
//***************************************************************************
/// trim_whitespace_left
/// Trim left of whitespace
//***************************************************************************
inline void trim_whitespace_left(etl::iwstring& s)
{
etl::private_string_utilities::trim_from_left<etl::iwstring>(s, L" \t\n\r\f\v");
}
//***************************************************************************
/// trim_whitespace_left
/// View trim left of whitespace
//***************************************************************************
inline etl::wstring_view trim_whitespace_left(const etl::wstring_view& view)
{
return etl::private_string_utilities::view_trim_from_left<etl::wstring_view>(view, L" \t\n\r\f\v");
}
//***************************************************************************
/// trim_from_left
/// Trim left of specified characters
//***************************************************************************
inline void trim_from_left(etl::iwstring& s, etl::iwstring::const_pointer trim_characters)
{
etl::private_string_utilities::trim_from_left<etl::iwstring>(s, trim_characters);
}
//***************************************************************************
/// trim_from_left
/// View trim left of specified characters
//***************************************************************************
inline etl::wstring_view trim_from_left(const etl::wstring_view& view, etl::iwstring::const_pointer trim_characters)
{
return etl::private_string_utilities::view_trim_from_left<etl::wstring_view>(view, trim_characters);
}
//***************************************************************************
/// trim_left
/// Trim left, up to, but not including, delimiters.
//***************************************************************************
inline void trim_left(etl::iwstring& s, etl::iwstring::const_pointer delimiters)
{
etl::private_string_utilities::trim_left_delimiters<etl::iwstring>(s, delimiters);
}
//***************************************************************************
/// trim_left
/// Trim left, up to, but not including, delimiters.
//***************************************************************************
inline etl::wstring_view trim_left(etl::wstring_view& s, etl::wstring_view::const_pointer delimiters)
{
return etl::private_string_utilities::view_trim_left_delimiters<etl::wstring_view>(s, delimiters);
}
//***************************************************************************
/// trim_whitespace_right
/// Trim right of whitespace
//***************************************************************************
inline void trim_whitespace_right(etl::iwstring& s)
{
etl::private_string_utilities::trim_from_right<etl::iwstring>(s, L" \t\n\r\f\v");
}
//***************************************************************************
/// trim_whitespace_right
/// Trim right of whitespace
//***************************************************************************
inline etl::wstring_view trim_whitespace_right(const etl::wstring_view& view)
{
return etl::private_string_utilities::view_trim_from_right<etl::wstring_view>(view, L" \t\n\r\f\v");
}
//***************************************************************************
/// trim_from_right
/// Trim right of specified characters
//***************************************************************************
inline void trim_from_right(etl::iwstring& s, etl::iwstring::const_pointer trim_characters)
{
etl::private_string_utilities::trim_from_right<etl::iwstring>(s, trim_characters);
}
//***************************************************************************
/// trim_from_right
/// Trim right of specified characters
//***************************************************************************
inline etl::wstring_view trim_from_right(const etl::wstring_view& view, etl::iwstring::const_pointer trim_characters)
{
return etl::private_string_utilities::view_trim_from_right<etl::wstring_view>(view, trim_characters);
}
//***************************************************************************
/// trim_right
//***************************************************************************
inline void trim_right(etl::iwstring& s, etl::iwstring::const_pointer delimiters)
{
etl::private_string_utilities::trim_right_delimiters<etl::iwstring>(s, delimiters);
}
//***************************************************************************
/// trim_right
//***************************************************************************
inline etl::wstring_view trim_right(const etl::wstring_view& view, etl::iwstring::const_pointer delimiters)
{
return etl::private_string_utilities::view_trim_right_delimiters<etl::wstring_view>(view, delimiters);
}
//***************************************************************************
/// trim_whitespace
/// Trim both ends of whitespace
//***************************************************************************
inline void trim_whitespace(etl::iwstring& s)
{
etl::private_string_utilities::trim_from<etl::iwstring>(s, L" \t\n\r\f\v");
}
//***************************************************************************
/// trim_whitespace
/// Trim both ends of whitespace
//***************************************************************************
inline etl::wstring_view trim_whitespace(const etl::wstring_view& view)
{
return etl::private_string_utilities::view_trim_from<etl::wstring_view>(view, L" \t\n\r\f\v");
}
//***************************************************************************
/// trim_from
/// Trim right of specified characters
//***************************************************************************
inline void trim_from(etl::iwstring& s, etl::iwstring::const_pointer trim_characters)
{
etl::private_string_utilities::trim_from<etl::iwstring>(s, trim_characters);
}
//***************************************************************************
/// trim_from
/// Trim right of specified characters
//***************************************************************************
inline etl::wstring_view trim_from(const etl::wstring_view& view, etl::iwstring::const_pointer trim_characters)
{
return etl::private_string_utilities::view_trim_from<etl::wstring_view>(view, trim_characters);
}
//***************************************************************************
/// trim
//***************************************************************************
inline void trim(etl::iwstring& s, etl::iwstring::const_pointer delimiters)
{
etl::private_string_utilities::trim_delimiters<etl::iwstring>(s, delimiters);
}
//***************************************************************************
/// trim
//***************************************************************************
inline etl::wstring_view trim(const etl::wstring_view& view, etl::iwstring::const_pointer delimiters)
{
return etl::private_string_utilities::view_trim_delimiters<etl::wstring_view>(view, delimiters);
}
//***************************************************************************
/// reverse
/// Reverse the string
//***************************************************************************
inline void reverse(etl::iwstring& s)
{
etl::private_string_utilities::reverse<etl::iwstring>(s);
}
//***************************************************************************
/// Get up to the first n characters.
//***************************************************************************
inline void left_n(etl::iwstring& s, size_t n)
{
n = (n > s.size()) ? s.size() : n;
s.erase(s.begin() + n, s.end());
}
//***************************************************************************
/// Get a view of up to the first n characters.
//***************************************************************************
inline etl::wstring_view left_n(etl::wstring_view view, size_t n)
{
n = (n > view.size()) ? view.size() : n;
return etl::wstring_view(view.begin(), view.begin() + n);
}
//***************************************************************************
/// Get up to the last n characters.
//***************************************************************************
inline void right_n(etl::iwstring& s, size_t n)
{
n = (n > s.size()) ? s.size() : n;
s.erase(s.begin(), s.end() - n);
}
//***************************************************************************
/// Get a view of up to the last n characters.
//***************************************************************************
inline etl::wstring_view right_n(etl::wstring_view view, size_t n)
{
n = (n > view.size()) ? view.size() : n;
return etl::wstring_view(view.end() - n, view.end());
}
//***************************************************************************
/// pad_left
//***************************************************************************
inline void pad_left(etl::iwstring& s, size_t required_size, etl::iwstring::value_type pad_char)
{
etl::private_string_utilities::pad_left(s, required_size, pad_char);
}
//***************************************************************************
/// pad_right
//***************************************************************************
inline void pad_right(etl::iwstring& s, size_t required_size, etl::iwstring::value_type pad_char)
{
etl::private_string_utilities::pad_right(s, required_size, pad_char);
}
//***************************************************************************
/// pad
//***************************************************************************
void pad(etl::iwstring& s, size_t required_size, string_pad_direction pad_direction, etl::iwstring::value_type pad_char)
{
etl::private_string_utilities::pad(s, required_size, pad_direction, pad_char);
}
//***************************************************************************
/// to_upper_case
//***************************************************************************
inline void to_upper_case(etl::iwstring& s)
{
etl::iwstring::iterator itr = s.begin();
while (itr != s.end())
{
*itr = etl::iwstring::value_type(::toupper(*itr));
++itr;
}
}
//***************************************************************************
/// to_lower_case
//***************************************************************************
inline void to_lower_case(etl::iwstring& s)
{
etl::iwstring::iterator itr = s.begin();
while (itr != s.end())
{
*itr = etl::iwstring::value_type(::tolower(*itr));
++itr;
}
}
//***************************************************************************
/// to_sentence_case
//***************************************************************************
inline void to_sentence_case(etl::iwstring& s)
{
etl::iwstring::iterator itr = s.begin();
*itr = etl::iwstring::value_type(::toupper(*itr));
++itr;
while (itr != s.end())
{
*itr = etl::iwstring::value_type(::tolower(*itr));
}
}
//***************************************************************************
/// transform
//***************************************************************************
inline void transform(etl::iwstring& s,
const etl::pair<etl::iwstring::value_type, etl::iwstring::value_type>* pairsbegin,
const etl::pair<etl::iwstring::value_type, etl::iwstring::value_type>* pairsend)
{
etl::private_string_utilities::transform_characters<etl::iwstring>(s, pairsbegin, pairsend);
}
//***************************************************************************
/// transform
//***************************************************************************
inline void transform(etl::iwstring& s,
const etl::pair<const etl::iwstring::value_type*, const etl::iwstring::value_type*>* pairsbegin,
const etl::pair<const etl::iwstring::value_type*, const etl::iwstring::value_type*>* pairsend)
{
etl::private_string_utilities::transform_strings<etl::iwstring>(s, pairsbegin, pairsend);
}
//***************************************************************************
/// get_token
//***************************************************************************
inline etl::wstring_view get_token(const etl::iwstring& s, etl::iwstring::const_pointer delimiters, const wstring_view& last_view)
{
return etl::private_string_utilities::get_token(s, delimiters, last_view);
}
//*********************************************************************
/// Find first of any of delimiters within the string
//*********************************************************************
inline etl::iwstring::iterator find_first_of(etl::iwstring::iterator first, etl::iwstring::iterator last, etl::iwstring::const_pointer delimiters)
{
return etl::private_string_utilities::find_first_of(first, last, delimiters);
}
//*********************************************************************
/// Find first of any of delimiters within the string
//*********************************************************************
inline etl::iwstring::const_iterator find_first_of(etl::iwstring::const_iterator first, etl::iwstring::const_iterator last, etl::iwstring::const_pointer delimiters)
{
return etl::private_string_utilities::find_first_of(first, last, delimiters);
}
//*********************************************************************
/// Find first of any of delimiters within the string
//*********************************************************************
inline etl::iwstring::iterator find_first_of(etl::iwstring& s, etl::iwstring::const_pointer delimiters)
{
return etl::private_string_utilities::find_first_of(s.begin(), s.end(), delimiters);
}
//*********************************************************************
/// Find first of any of delimiters within the string
//*********************************************************************
inline etl::iwstring::const_iterator find_first_of(const etl::iwstring& s, etl::iwstring::const_pointer delimiters)
{
return etl::private_string_utilities::find_first_of(s.cbegin(), s.cend(), delimiters);
}
//*********************************************************************
/// Find first of any of delimiters within the string
//*********************************************************************
inline etl::iwstring::const_iterator find_first_of(const etl::wstring_view& s, etl::iwstring::const_pointer delimiters)
{
return etl::private_string_utilities::find_first_of(s.cbegin(), s.cend(), delimiters);
}
//*********************************************************************
/// Find first not of delimiters within the string
//*********************************************************************
inline etl::iwstring::iterator find_first_not_of(etl::iwstring::iterator first, etl::iwstring::iterator last, etl::iwstring::const_pointer delimiters)
{
return etl::private_string_utilities::find_first_not_of(first, last, delimiters);
}
//*********************************************************************
/// Find first not of delimiters within the string
//*********************************************************************
inline etl::iwstring::const_iterator find_first_not_of(etl::iwstring::const_iterator first, etl::iwstring::const_iterator last, etl::iwstring::const_pointer delimiters)
{
return etl::private_string_utilities::find_first_not_of(first, last, delimiters);
}
//*********************************************************************
/// Find first not of delimiters within the string
//*********************************************************************
inline etl::iwstring::iterator find_first_not_of(etl::iwstring& s, etl::iwstring::const_pointer delimiters)
{
return etl::private_string_utilities::find_first_not_of(s.begin(), s.end(), delimiters);
}
//*********************************************************************
/// Find first not of delimiters within the string
//*********************************************************************
inline etl::iwstring::const_iterator find_first_not_of(const etl::iwstring& s, etl::iwstring::const_pointer delimiters)
{
return etl::private_string_utilities::find_first_not_of(s.cbegin(), s.cend(), delimiters);
}
//*********************************************************************
/// Find first not of delimiters within the string
//*********************************************************************
inline etl::iwstring::const_iterator find_first_not_of(const etl::wstring_view& view, etl::iwstring::const_pointer delimiters)
{
return etl::private_string_utilities::find_first_not_of(view.cbegin(), view.cend(), delimiters);
}
//*********************************************************************
/// Find last of any of delimiters within the string
//*********************************************************************
inline etl::iwstring::iterator find_last_of(etl::iwstring::iterator first, etl::iwstring::iterator last, etl::iwstring::const_pointer delimiters)
{
return etl::private_string_utilities::find_last_of(first, last, delimiters);
}
//*********************************************************************
/// Find last of any of delimiters within the string
//*********************************************************************
inline etl::iwstring::const_iterator find_last_of(etl::iwstring::const_iterator first, etl::iwstring::const_iterator last, etl::iwstring::const_pointer delimiters)
{
return etl::private_string_utilities::find_last_of(first, last, delimiters);
}
//*********************************************************************
/// Find last of any of delimiters within the string
//*********************************************************************
inline etl::iwstring::iterator find_last_of(etl::iwstring& s, etl::iwstring::const_pointer delimiters)
{
return etl::private_string_utilities::find_last_of(s.begin(), s.end(), delimiters);
}
//*********************************************************************
/// Find last of any of delimiters within the string
//*********************************************************************
inline etl::iwstring::const_iterator find_last_of(const etl::iwstring& s, etl::iwstring::const_pointer delimiters)
{
return etl::private_string_utilities::find_last_of(s.cbegin(), s.cend(), delimiters);
}
//*********************************************************************
/// Find last of any of delimiters within the string
//*********************************************************************
inline etl::iwstring::const_iterator find_last_of(const etl::wstring_view& view, etl::iwstring::const_pointer delimiters)
{
return etl::private_string_utilities::find_last_of(view.cbegin(), view.cend(), delimiters);
}
//*********************************************************************
/// Find last of any of delimiters within the string
//*********************************************************************
inline etl::iwstring::iterator find_last_not_of(etl::iwstring::iterator first, etl::iwstring::iterator last, etl::iwstring::const_pointer delimiters)
{
return etl::private_string_utilities::find_last_not_of(first, last, delimiters);
}
//*********************************************************************
/// Find last of any of delimiters within the string
//*********************************************************************
inline etl::iwstring::const_iterator find_last_not_of(etl::iwstring::const_iterator first, etl::iwstring::const_iterator last, etl::iwstring::const_pointer delimiters)
{
return etl::private_string_utilities::find_last_not_of(first, last, delimiters);
}
//*********************************************************************
/// Find last of any of delimiters within the string
//*********************************************************************
inline etl::iwstring::iterator find_last_not_of(etl::iwstring& s, etl::iwstring::const_pointer delimiters)
{
return etl::private_string_utilities::find_last_not_of(s.begin(), s.end(), delimiters);
}
//*********************************************************************
/// Find last of any of delimiters within the string
//*********************************************************************
inline etl::iwstring::const_iterator find_last_not_of(const etl::iwstring& s, etl::iwstring::const_pointer delimiters)
{
return etl::private_string_utilities::find_last_not_of(s.cbegin(), s.cend(), delimiters);
}
//*********************************************************************
/// Find last of any of delimiters within the string
//*********************************************************************
inline etl::iwstring::const_iterator find_last_not_of(const etl::wstring_view& view, etl::iwstring::const_pointer delimiters)
{
return etl::private_string_utilities::find_last_not_of(view.cbegin(), view.cend(), delimiters);
}
}
#endif

View File

@ -448,14 +448,15 @@
<Unit filename="../../include/etl/type_def.h" />
<Unit filename="../../include/etl/type_lookup.h" />
<Unit filename="../../include/etl/type_select.h" />
<Unit filename="../../include/etl/type_traits - Copy.h" />
<Unit filename="../../include/etl/type_traits.h" />
<Unit filename="../../include/etl/u16format_spec.h" />
<Unit filename="../../include/etl/u16string.h" />
<Unit filename="../../include/etl/u16string_stream.h" />
<Unit filename="../../include/etl/u16string_utilities.h" />
<Unit filename="../../include/etl/u32format_spec.h" />
<Unit filename="../../include/etl/u32string.h" />
<Unit filename="../../include/etl/u32string_stream.h" />
<Unit filename="../../include/etl/u32string_utilities.h" />
<Unit filename="../../include/etl/unordered_map.h" />
<Unit filename="../../include/etl/unordered_multimap.h" />
<Unit filename="../../include/etl/unordered_multiset.h" />
@ -470,6 +471,7 @@
<Unit filename="../../include/etl/wformat_spec.h" />
<Unit filename="../../include/etl/wstring.h" />
<Unit filename="../../include/etl/wstring_stream.h" />
<Unit filename="../../include/etl/wstring_utilities.h" />
<Unit filename="../ExtraCheckMacros.h" />
<Unit filename="../data.h" />
<Unit filename="../etl_profile.h" />
@ -578,9 +580,15 @@
<Unit filename="../test_state_chart.cpp" />
<Unit filename="../test_string_char.cpp" />
<Unit filename="../test_string_stream.cpp" />
<Unit filename="../test_string_stream_u16.cpp" />
<Unit filename="../test_string_stream_u32.cpp" />
<Unit filename="../test_string_stream_wchar_t.cpp" />
<Unit filename="../test_string_u16.cpp" />
<Unit filename="../test_string_u32.cpp" />
<Unit filename="../test_string_utilities_char.cpp" />
<Unit filename="../test_string_utilities.cpp" />
<Unit filename="../test_string_utilities_u16.cpp" />
<Unit filename="../test_string_utilities_u32.cpp" />
<Unit filename="../test_string_utilities_wchar_t.cpp" />
<Unit filename="../test_string_view.cpp" />
<Unit filename="../test_string_wchar_t.cpp" />
<Unit filename="../test_task_scheduler.cpp" />
@ -592,8 +600,6 @@
<Unit filename="../test_type_lookup.cpp" />
<Unit filename="../test_type_select.cpp" />
<Unit filename="../test_type_traits.cpp" />
<Unit filename="../test_u16string_stream.cpp" />
<Unit filename="../test_u32string_stream.cpp" />
<Unit filename="../test_unordered_map.cpp" />
<Unit filename="../test_unordered_multimap.cpp" />
<Unit filename="../test_unordered_multiset.cpp" />
@ -608,7 +614,6 @@
<Unit filename="../test_vector_pointer.cpp" />
<Unit filename="../test_vector_pointer_external_buffer.cpp" />
<Unit filename="../test_visitor.cpp" />
<Unit filename="../test_wstring_stream.cpp" />
<Unit filename="../test_xor_checksum.cpp" />
<Unit filename="../test_xor_rotate_checksum.cpp" />
<Extensions>

View File

@ -263,7 +263,7 @@ namespace
TEST(test_view_trim_left_string_delimiters)
{
String text(STR("qztfpHello Worldqztfp"));
String expected("Hello Worldqztfp");
String expected(STR("Hello Worldqztfp"));
StringView textview(text);
StringView expectedview(expected);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1136,8 +1136,10 @@
<ClInclude Include="..\..\include\etl\type_select.h" />
<ClInclude Include="..\..\include\etl\u16format_spec.h" />
<ClInclude Include="..\..\include\etl\u16string_stream.h" />
<ClInclude Include="..\..\include\etl\u16string_utilities.h" />
<ClInclude Include="..\..\include\etl\u32format_spec.h" />
<ClInclude Include="..\..\include\etl\u32string_stream.h" />
<ClInclude Include="..\..\include\etl\u32string_utilities.h" />
<ClInclude Include="..\..\include\etl\variant_pool.h" />
<ClInclude Include="..\..\include\etl\version.h" />
<ClInclude Include="..\..\include\etl\algorithm.h" />
@ -1235,6 +1237,7 @@
<ClInclude Include="..\..\include\etl\wformat_spec.h" />
<ClInclude Include="..\..\include\etl\wstring.h" />
<ClInclude Include="..\..\include\etl\wstring_stream.h" />
<ClInclude Include="..\..\include\etl\wstring_utilities.h" />
<ClInclude Include="..\data.h" />
<ClInclude Include="..\etl_profile.h" />
<ClInclude Include="..\murmurhash3.h" />
@ -1630,7 +1633,10 @@
<ClCompile Include="..\test_string_u16_external_buffer.cpp" />
<ClCompile Include="..\test_string_u32.cpp" />
<ClCompile Include="..\test_string_u32_external_buffer.cpp" />
<ClCompile Include="..\test_string_utilities_char.cpp" />
<ClCompile Include="..\test_string_utilities.cpp" />
<ClCompile Include="..\test_string_utilities_u16.cpp" />
<ClCompile Include="..\test_string_utilities_u32.cpp" />
<ClCompile Include="..\test_string_utilities_wchar_t.cpp" />
<ClCompile Include="..\test_string_view.cpp" />
<ClCompile Include="..\test_string_wchar_t.cpp" />
<ClCompile Include="..\test_string_wchar_t_external_buffer.cpp" />
@ -1643,8 +1649,8 @@
<ClCompile Include="..\test_type_lookup.cpp" />
<ClCompile Include="..\test_type_select.cpp" />
<ClCompile Include="..\test_type_traits.cpp" />
<ClCompile Include="..\test_u16string_stream.cpp" />
<ClCompile Include="..\test_u32string_stream.cpp" />
<ClCompile Include="..\test_string_stream_u16.cpp" />
<ClCompile Include="..\test_string_stream_u32.cpp" />
<ClCompile Include="..\test_unordered_map.cpp" />
<ClCompile Include="..\test_unordered_multimap.cpp" />
<ClCompile Include="..\test_unordered_multiset.cpp" />
@ -1659,7 +1665,7 @@
<ClCompile Include="..\test_vector_pointer.cpp" />
<ClCompile Include="..\test_vector_pointer_external_buffer.cpp" />
<ClCompile Include="..\test_visitor.cpp" />
<ClCompile Include="..\test_wstring_stream.cpp" />
<ClCompile Include="..\test_string_stream_wchar_t.cpp" />
<ClCompile Include="..\test_xor_checksum.cpp" />
<ClCompile Include="..\test_xor_rotate_checksum.cpp" />
</ItemGroup>

View File

@ -876,6 +876,15 @@
<ClInclude Include="..\..\include\etl\private\string_utilities_helper.h">
<Filter>ETL\Private</Filter>
</ClInclude>
<ClInclude Include="..\..\include\etl\wstring_utilities.h">
<Filter>ETL\Strings</Filter>
</ClInclude>
<ClInclude Include="..\..\include\etl\u16string_utilities.h">
<Filter>ETL\Strings</Filter>
</ClInclude>
<ClInclude Include="..\..\include\etl\u32string_utilities.h">
<Filter>ETL\Strings</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\main.cpp">
@ -1355,16 +1364,25 @@
<ClCompile Include="..\test_string_stream.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\test_wstring_stream.cpp">
<ClCompile Include="..\test_string_stream_u16.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\test_u16string_stream.cpp">
<ClCompile Include="..\test_string_stream_u32.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\test_u32string_stream.cpp">
<ClCompile Include="..\test_string_stream_wchar_t.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\test_string_utilities_char.cpp">
<ClCompile Include="..\test_string_utilities.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\test_string_utilities_wchar_t.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\test_string_utilities_u16.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\test_string_utilities_u32.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>