mirror of
https://github.com/ETLCPP/etl.git
synced 2026-04-30 19:09:10 +08:00
Re-coded string utilities to allow any string-like container to use it.
This commit is contained in:
parent
476576bca9
commit
2cf00a0ba4
@ -84,7 +84,7 @@ SOFTWARE.
|
||||
//*****************************************************************************
|
||||
#define ETL_DECLARE_ENUM_TYPE(TypeName, ValueType) \
|
||||
typedef ValueType value_type; \
|
||||
TypeName() {} \
|
||||
TypeName() : value(static_cast<enum_type>(value_type())) {} \
|
||||
TypeName(const TypeName &other) : value(other.value) {} \
|
||||
TypeName(enum_type value_) : value(value_) {} \
|
||||
TypeName& operator=(const TypeName &other) {value = other.value; return *this;} \
|
||||
|
||||
@ -1,540 +0,0 @@
|
||||
///\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_STRING_UTILITIES_HELPER_INCLUDED
|
||||
#define ETL_STRING_UTILITIES_HELPER_INCLUDED
|
||||
|
||||
#include "../platform.h"
|
||||
#include "../basic_string.h"
|
||||
#include "../string_view.h"
|
||||
#include "../algorithm.h"
|
||||
#include "../utility.h"
|
||||
#include "../enum_type.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace etl
|
||||
{
|
||||
struct string_pad_direction
|
||||
{
|
||||
enum enum_type
|
||||
{
|
||||
LEFT,
|
||||
RIGHT,
|
||||
};
|
||||
|
||||
ETL_DECLARE_ENUM_TYPE(string_pad_direction, int)
|
||||
ETL_ENUM_TYPE(LEFT, "left")
|
||||
ETL_ENUM_TYPE(RIGHT, "right")
|
||||
ETL_END_ENUM_TYPE
|
||||
};
|
||||
|
||||
namespace private_string_utilities
|
||||
{
|
||||
//***************************************************************************
|
||||
/// trim_from_left
|
||||
/// Trim left of trim_characters
|
||||
//***************************************************************************
|
||||
template <typename TIString>
|
||||
void trim_from_left(TIString& s, typename TIString::const_pointer trim_characters)
|
||||
{
|
||||
size_t position = s.find_first_not_of(trim_characters);
|
||||
s.erase(0U, position);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// view_trim_left_of
|
||||
/// Trim left of whitespace
|
||||
//***************************************************************************
|
||||
template <typename TStringView>
|
||||
TStringView view_trim_from_left(const TStringView& view, typename TStringView::const_pointer trim_characters)
|
||||
{
|
||||
size_t first = view.find_first_not_of(trim_characters);
|
||||
|
||||
typename TStringView::const_pointer pbegin = view.end();
|
||||
|
||||
if (first != TStringView::npos)
|
||||
{
|
||||
pbegin = view.begin() + first;
|
||||
}
|
||||
|
||||
return TStringView(pbegin, view.end());
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// trim_left_delimiters
|
||||
/// Trim left, up to, but not including, delimiters.
|
||||
//***************************************************************************
|
||||
template <typename TIString>
|
||||
void trim_left_delimiters(TIString& s, typename TIString::const_pointer delimiters)
|
||||
{
|
||||
size_t p = s.find_first_of(delimiters);
|
||||
|
||||
if (p != TIString::npos)
|
||||
{
|
||||
s.erase(0, p);
|
||||
}
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// view_trim_left_delimiters
|
||||
/// View trim left, up to, but not including, delimiters.
|
||||
//***************************************************************************
|
||||
template <typename TStringView>
|
||||
TStringView view_trim_left_delimiters(const TStringView& view, typename TStringView::const_pointer delimiters)
|
||||
{
|
||||
size_t first = view.find_first_of(delimiters);
|
||||
|
||||
typename TStringView::const_pointer pbegin = view.end();
|
||||
|
||||
if (first != TStringView::npos)
|
||||
{
|
||||
pbegin = view.begin() + first;
|
||||
}
|
||||
|
||||
return TStringView(pbegin, view.end());
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// trim_from_right
|
||||
/// Trim right of trim_characters
|
||||
//***************************************************************************
|
||||
template <typename TIString>
|
||||
void trim_from_right(TIString& s, typename TIString::const_pointer trim_characters)
|
||||
{
|
||||
s.erase(s.find_last_not_of(trim_characters) + 1);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// view_trim_from_right
|
||||
/// Trim right of trim_characters
|
||||
//***************************************************************************
|
||||
template <typename TStringView>
|
||||
TStringView view_trim_from_right(const TStringView& view, typename TStringView::const_pointer trim_characters)
|
||||
{
|
||||
size_t last = view.find_last_not_of(trim_characters) + 1;
|
||||
|
||||
typename TStringView::const_pointer pend = view.begin();
|
||||
|
||||
if (last != TStringView::npos)
|
||||
{
|
||||
pend += last;
|
||||
}
|
||||
|
||||
return TStringView(view.begin(), pend);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// trim_right_delimiters
|
||||
//***************************************************************************
|
||||
template <typename TIString>
|
||||
void trim_right_delimiters(TIString& s, typename TIString::const_pointer delimiters)
|
||||
{
|
||||
size_t p = s.find_last_of(delimiters);
|
||||
|
||||
if (p != TIString::npos)
|
||||
{
|
||||
++p;
|
||||
|
||||
if (p != s.size())
|
||||
{
|
||||
s.erase(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// view_trim_right_delimiters
|
||||
//***************************************************************************
|
||||
template <typename TStringView>
|
||||
TStringView view_trim_right_delimiters(const TStringView& view, typename TStringView::const_pointer delimiters)
|
||||
{
|
||||
size_t last = view.find_last_of(delimiters) + 1;
|
||||
|
||||
typename TStringView::const_pointer pend = view.begin();
|
||||
|
||||
if (last != TStringView::npos)
|
||||
{
|
||||
pend += last;
|
||||
}
|
||||
|
||||
return TStringView(view.begin(), pend);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// trim_from
|
||||
/// Trim left and right of trim_characters
|
||||
//***************************************************************************
|
||||
template <typename TIString>
|
||||
void trim_from(TIString& s, typename TIString::const_pointer trim_characters)
|
||||
{
|
||||
trim_from_left(s, trim_characters);
|
||||
trim_from_right(s, trim_characters);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// trim_from
|
||||
/// Trim left and right of trim_characters
|
||||
//***************************************************************************
|
||||
template <typename TStringView>
|
||||
TStringView view_trim_from(const TStringView& view, typename TStringView::const_pointer trim_characters)
|
||||
{
|
||||
size_t first = view.find_first_not_of(trim_characters);
|
||||
size_t last = view.find_last_not_of(trim_characters) + 1;
|
||||
|
||||
typename TStringView::const_pointer pbegin = view.begin();
|
||||
typename TStringView::const_pointer pend = view.begin();
|
||||
|
||||
if (first != TStringView::npos)
|
||||
{
|
||||
pbegin += first;
|
||||
}
|
||||
|
||||
if (last != TStringView::npos)
|
||||
{
|
||||
pend += last;
|
||||
}
|
||||
|
||||
return TStringView(pbegin, pend);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// trim_delimiters
|
||||
/// Trim left and right of trim_characters
|
||||
//***************************************************************************
|
||||
template <typename TIString>
|
||||
void trim_delimiters(TIString& s, typename TIString::const_pointer delimiters)
|
||||
{
|
||||
trim_left_delimiters(s, delimiters);
|
||||
trim_right_delimiters(s, delimiters);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// trim_delimiters
|
||||
/// Trim left and right of trim_characters
|
||||
//***************************************************************************
|
||||
template <typename TStringView>
|
||||
TStringView view_trim_delimiters(const TStringView& view, typename TStringView::const_pointer delimiters)
|
||||
{
|
||||
size_t first = view.find_first_of(delimiters);
|
||||
size_t last = view.find_last_of(delimiters) + 1;
|
||||
|
||||
typename TStringView::const_pointer pbegin = view.begin();
|
||||
typename TStringView::const_pointer pend = view.begin();
|
||||
|
||||
if (first != TStringView::npos)
|
||||
{
|
||||
pbegin += first;
|
||||
}
|
||||
|
||||
if (last != TStringView::npos)
|
||||
{
|
||||
pend += last;
|
||||
}
|
||||
|
||||
return TStringView(pbegin, pend);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// reverse
|
||||
/// Reverse a string
|
||||
//***************************************************************************
|
||||
template <typename TIString>
|
||||
void reverse(TIString& s)
|
||||
{
|
||||
etl::reverse(s.begin(), s.end());
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// replace_characters
|
||||
//***************************************************************************
|
||||
template <typename TIString>
|
||||
void replace_characters(TIString& s,
|
||||
const etl::pair<typename TIString::value_type, typename TIString::value_type>* pairsbegin,
|
||||
const etl::pair<typename TIString::value_type, typename TIString::value_type>* pairsend)
|
||||
{
|
||||
while (pairsbegin != pairsend)
|
||||
{
|
||||
etl::replace(s.begin(), s.end(), pairsbegin->first, pairsbegin->second);
|
||||
++pairsbegin;
|
||||
}
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// replace_strings
|
||||
//***************************************************************************
|
||||
template <typename TIString>
|
||||
void replace_strings(TIString& s,
|
||||
const etl::pair<const typename TIString::value_type*, const typename TIString::value_type*>* pairsbegin,
|
||||
const etl::pair<const typename TIString::value_type*, const typename TIString::value_type*>* pairsend)
|
||||
{
|
||||
while (pairsbegin != pairsend)
|
||||
{
|
||||
const typename TIString::value_type* p_old = pairsbegin->first;
|
||||
const typename TIString::value_type* p_new = pairsbegin->second;
|
||||
|
||||
size_t position = 0U;
|
||||
|
||||
do
|
||||
{
|
||||
position = s.find(p_old, position);
|
||||
if (position != TIString::npos)
|
||||
{
|
||||
s.replace(position, etl::strlen(p_old), p_new, etl::strlen(p_new));
|
||||
position += etl::strlen(p_new);
|
||||
}
|
||||
} while (position != TIString::npos);
|
||||
|
||||
++pairsbegin;
|
||||
}
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Find first of any of delimiters within the string
|
||||
//*********************************************************************
|
||||
template <typename TIterator, typename TPointer>
|
||||
TIterator find_first_of(TIterator first, TIterator last, TPointer delimiters)
|
||||
{
|
||||
TIterator itr(first);
|
||||
|
||||
while (itr != last)
|
||||
{
|
||||
TPointer pd = delimiters;
|
||||
|
||||
while (*pd != 0)
|
||||
{
|
||||
if (*itr == *pd)
|
||||
{
|
||||
return itr;
|
||||
}
|
||||
|
||||
++pd;
|
||||
}
|
||||
|
||||
++itr;
|
||||
}
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Find first not of any of delimiters within the string
|
||||
//*********************************************************************
|
||||
template <typename TIterator, typename TPointer>
|
||||
TIterator find_first_not_of(TIterator first, TIterator last, TPointer delimiters)
|
||||
{
|
||||
TIterator itr(first);
|
||||
|
||||
while (itr != last)
|
||||
{
|
||||
TPointer pd = delimiters;
|
||||
|
||||
bool found = false;
|
||||
|
||||
while (*pd != 0)
|
||||
{
|
||||
if (*itr == *pd)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
||||
++pd;
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
return itr;
|
||||
}
|
||||
|
||||
++itr;
|
||||
}
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Find last of any of delimiters within the string
|
||||
//*********************************************************************
|
||||
template <typename TIterator, typename TPointer>
|
||||
TIterator find_last_of(TIterator first, TIterator last, TPointer delimiters)
|
||||
{
|
||||
if (first == last)
|
||||
{
|
||||
return last;
|
||||
}
|
||||
|
||||
TIterator itr(last - 1);
|
||||
TIterator end(first - 1);
|
||||
|
||||
while (itr != end)
|
||||
{
|
||||
TPointer pd = delimiters;
|
||||
|
||||
while (*pd != 0)
|
||||
{
|
||||
if (*itr == *pd)
|
||||
{
|
||||
return itr;
|
||||
}
|
||||
|
||||
++pd;
|
||||
}
|
||||
|
||||
--itr;
|
||||
}
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Find last not of any of delimiters within the string
|
||||
//*********************************************************************
|
||||
template <typename TIterator, typename TPointer>
|
||||
TIterator find_last_not_of(TIterator first, TIterator last, TPointer delimiters)
|
||||
{
|
||||
if (first == last)
|
||||
{
|
||||
return last;
|
||||
}
|
||||
|
||||
TIterator itr(last - 1);
|
||||
TIterator end(first - 1);
|
||||
|
||||
while (itr != end)
|
||||
{
|
||||
TPointer pd = delimiters;
|
||||
|
||||
bool found = false;
|
||||
|
||||
while (*pd != 0)
|
||||
{
|
||||
if (*itr == *pd)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
||||
++pd;
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
return itr;
|
||||
}
|
||||
|
||||
--itr;
|
||||
}
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// get_token
|
||||
//***************************************************************************
|
||||
template <typename TStringView, typename TIString>
|
||||
TStringView get_token(const TIString& s, typename TIString::const_pointer delimiters, const TStringView& last_view)
|
||||
{
|
||||
typename TIString::const_iterator first = last_view.end();
|
||||
typename TIString::const_iterator last = last_view.end();
|
||||
|
||||
// If the last view was default constructed then we must be looking for the first token.
|
||||
if (last_view.data() == ETL_NULLPTR)
|
||||
{
|
||||
first = s.begin();
|
||||
}
|
||||
|
||||
// Look for the start of the next token.
|
||||
first = find_first_not_of(first, s.end(), delimiters);
|
||||
last = find_first_of(first, s.end(), delimiters);
|
||||
|
||||
return TStringView(first, last);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// pad_left
|
||||
//***************************************************************************
|
||||
template <typename TIString>
|
||||
void pad_left(TIString& s, size_t required_size, typename TIString::value_type pad_char)
|
||||
{
|
||||
required_size = etl::min(required_size, s.capacity());
|
||||
|
||||
if (required_size > s.size())
|
||||
{
|
||||
required_size -= s.size();
|
||||
s.insert(0U, required_size, pad_char);
|
||||
}
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// pad_right
|
||||
//***************************************************************************
|
||||
template <typename TIString>
|
||||
void pad_right(TIString& s, size_t required_size, typename TIString::value_type pad_char)
|
||||
{
|
||||
required_size = etl::min(required_size, s.capacity());
|
||||
|
||||
if (required_size > s.size())
|
||||
{
|
||||
required_size -= s.size();
|
||||
s.insert(s.size(), required_size, pad_char);
|
||||
}
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// pad
|
||||
//***************************************************************************
|
||||
template <typename TIString>
|
||||
void pad(TIString& s, size_t required_size, string_pad_direction pad_direction, typename TIString::value_type pad_char)
|
||||
{
|
||||
switch (int(pad_direction))
|
||||
{
|
||||
case string_pad_direction::LEFT:
|
||||
{
|
||||
pad_left(s, required_size, pad_char);
|
||||
break;
|
||||
}
|
||||
|
||||
case string_pad_direction::RIGHT:
|
||||
{
|
||||
pad_right(s, required_size, pad_char);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -1,514 +0,0 @@
|
||||
///\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_STD_STRING_UTILITIES_INCLUDED
|
||||
#define ETL_STD_STRING_UTILITIES_INCLUDED
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
#if ETL_USING_STL
|
||||
|
||||
#include "algorithm.h"
|
||||
#include "private/string_utilities_helper.h"
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
namespace etl
|
||||
{
|
||||
//***************************************************************************
|
||||
/// trim_whitespace_left
|
||||
/// Trim left of whitespace
|
||||
//***************************************************************************
|
||||
inline void trim_whitespace_left(std::string& s)
|
||||
{
|
||||
etl::private_string_utilities::trim_from_left<std::string>(s, " \t\n\r\f\v");
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// trim_whitespace_left
|
||||
/// View trim left of whitespace
|
||||
//***************************************************************************
|
||||
inline std::string_view trim_whitespace_left(const std::string_view& view)
|
||||
{
|
||||
return etl::private_string_utilities::view_trim_from_left<std::string_view>(view, " \t\n\r\f\v");
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// trim_from_left
|
||||
/// Trim left of specified characters
|
||||
//***************************************************************************
|
||||
inline void trim_from_left(std::string& s, std::string::const_pointer trim_characters)
|
||||
{
|
||||
etl::private_string_utilities::trim_from_left<std::string>(s, trim_characters);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// trim_from_left
|
||||
/// View trim left of specified characters
|
||||
//***************************************************************************
|
||||
inline std::string_view trim_from_left(const std::string_view& view, std::string::const_pointer trim_characters)
|
||||
{
|
||||
return etl::private_string_utilities::view_trim_from_left<std::string_view>(view, trim_characters);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// trim_left
|
||||
/// Trim left, up to, but not including, delimiters.
|
||||
//***************************************************************************
|
||||
inline void trim_left(std::string& s, std::string::const_pointer delimiters)
|
||||
{
|
||||
etl::private_string_utilities::trim_left_delimiters<std::string>(s, delimiters);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// trim_left
|
||||
/// Trim left, up to, but not including, delimiters.
|
||||
//***************************************************************************
|
||||
inline std::string_view trim_left(std::string_view& s, std::string_view::const_pointer delimiters)
|
||||
{
|
||||
return etl::private_string_utilities::view_trim_left_delimiters<std::string_view>(s, delimiters);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// trim_whitespace_right
|
||||
/// Trim right of whitespace
|
||||
//***************************************************************************
|
||||
inline void trim_whitespace_right(std::string& s)
|
||||
{
|
||||
etl::private_string_utilities::trim_from_right<std::string>(s, " \t\n\r\f\v");
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// trim_whitespace_right
|
||||
/// Trim right of whitespace
|
||||
//***************************************************************************
|
||||
inline std::string_view trim_whitespace_right(const std::string_view& view)
|
||||
{
|
||||
return etl::private_string_utilities::view_trim_from_right<std::string_view>(view, " \t\n\r\f\v");
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// trim_from_right
|
||||
/// Trim right of specified characters
|
||||
//***************************************************************************
|
||||
inline void trim_from_right(std::string& s, std::string::const_pointer trim_characters)
|
||||
{
|
||||
etl::private_string_utilities::trim_from_right<std::string>(s, trim_characters);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// trim_from_right
|
||||
/// Trim right of specified characters
|
||||
//***************************************************************************
|
||||
inline std::string_view trim_from_right(const std::string_view& view, std::string::const_pointer trim_characters)
|
||||
{
|
||||
return etl::private_string_utilities::view_trim_from_right<std::string_view>(view, trim_characters);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// trim_right
|
||||
//***************************************************************************
|
||||
inline void trim_right(std::string& s, std::string::const_pointer delimiters)
|
||||
{
|
||||
etl::private_string_utilities::trim_right_delimiters<std::string>(s, delimiters);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// trim_right
|
||||
//***************************************************************************
|
||||
inline std::string_view trim_right(const std::string_view& view, std::string::const_pointer delimiters)
|
||||
{
|
||||
return etl::private_string_utilities::view_trim_right_delimiters<std::string_view>(view, delimiters);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// trim_whitespace
|
||||
/// Trim both ends of whitespace
|
||||
//***************************************************************************
|
||||
inline void trim_whitespace(std::string& s)
|
||||
{
|
||||
etl::private_string_utilities::trim_from<std::string>(s, " \t\n\r\f\v");
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// trim_whitespace
|
||||
/// Trim both ends of whitespace
|
||||
//***************************************************************************
|
||||
inline std::string_view trim_whitespace(const std::string_view& view)
|
||||
{
|
||||
return etl::private_string_utilities::view_trim_from<std::string_view>(view, " \t\n\r\f\v");
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// trim_from
|
||||
/// Trim right of specified characters
|
||||
//***************************************************************************
|
||||
inline void trim_from(std::string& s, std::string::const_pointer trim_characters)
|
||||
{
|
||||
etl::private_string_utilities::trim_from<std::string>(s, trim_characters);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// trim_from
|
||||
/// Trim right of specified characters
|
||||
//***************************************************************************
|
||||
inline std::string_view trim_from(const std::string_view& view, std::string::const_pointer trim_characters)
|
||||
{
|
||||
return etl::private_string_utilities::view_trim_from<std::string_view>(view, trim_characters);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// trim
|
||||
//***************************************************************************
|
||||
inline void trim(std::string& s, std::string::const_pointer delimiters)
|
||||
{
|
||||
etl::private_string_utilities::trim_delimiters<std::string>(s, delimiters);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// trim
|
||||
//***************************************************************************
|
||||
inline std::string_view trim(const std::string_view& view, std::string::const_pointer delimiters)
|
||||
{
|
||||
return etl::private_string_utilities::view_trim_delimiters<std::string_view>(view, delimiters);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// reverse
|
||||
/// Reverse the string
|
||||
//***************************************************************************
|
||||
inline void reverse(std::string& s)
|
||||
{
|
||||
etl::private_string_utilities::reverse<std::string>(s);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Get up to the first n characters.
|
||||
//***************************************************************************
|
||||
inline void left_n(std::string& 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 std::string_view left_n(std::string_view view, size_t n)
|
||||
{
|
||||
n = (n > view.size()) ? view.size() : n;
|
||||
|
||||
return std::string_view(view.data(), n);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Get up to the last n characters.
|
||||
//***************************************************************************
|
||||
inline void right_n(std::string& 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 std::string_view right_n(std::string_view view, size_t n)
|
||||
{
|
||||
n = (n > view.size()) ? view.size() : n;
|
||||
|
||||
return std::string_view(view.data() + view.size() - n, n);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// pad_left
|
||||
//***************************************************************************
|
||||
inline void pad_left(std::string& s, size_t required_size, std::string::value_type pad_char)
|
||||
{
|
||||
etl::private_string_utilities::pad_left(s, required_size, pad_char);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// pad_right
|
||||
//***************************************************************************
|
||||
inline void pad_right(std::string& s, size_t required_size, std::string::value_type pad_char)
|
||||
{
|
||||
etl::private_string_utilities::pad_right(s, required_size, pad_char);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// pad
|
||||
//***************************************************************************
|
||||
void pad(std::string& s, size_t required_size, string_pad_direction pad_direction, std::string::value_type pad_char)
|
||||
{
|
||||
etl::private_string_utilities::pad(s, required_size, pad_direction, pad_char);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// to_upper_case
|
||||
//***************************************************************************
|
||||
inline void to_upper_case(std::string& s)
|
||||
{
|
||||
std::string::iterator itr = s.begin();
|
||||
|
||||
while (itr != s.end())
|
||||
{
|
||||
*itr = std::string::value_type(::toupper(*itr));
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// to_lower_case
|
||||
//***************************************************************************
|
||||
inline void to_lower_case(std::string& s)
|
||||
{
|
||||
std::string::iterator itr = s.begin();
|
||||
|
||||
while (itr != s.end())
|
||||
{
|
||||
*itr = std::string::value_type(::tolower(*itr));
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// to_sentence_case
|
||||
//***************************************************************************
|
||||
inline void to_sentence_case(std::string& s)
|
||||
{
|
||||
std::string::iterator itr = s.begin();
|
||||
|
||||
*itr = std::string::value_type(::toupper(*itr));
|
||||
++itr;
|
||||
|
||||
while (itr != s.end())
|
||||
{
|
||||
*itr = std::string::value_type(::tolower(*itr));
|
||||
}
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// replace
|
||||
//***************************************************************************
|
||||
inline void replace(std::string& s,
|
||||
const std::pair<std::string::value_type, std::string::value_type>* pairsbegin,
|
||||
const std::pair<std::string::value_type, std::string::value_type>* pairsend)
|
||||
{
|
||||
etl::private_string_utilities::replace_characters<std::string>(s, pairsbegin, pairsend);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// replace
|
||||
//***************************************************************************
|
||||
inline void replace(std::string& s,
|
||||
const std::pair<const std::string::value_type*, const std::string::value_type*>* pairsbegin,
|
||||
const std::pair<const std::string::value_type*, const std::string::value_type*>* pairsend)
|
||||
{
|
||||
etl::private_string_utilities::replace_strings<std::string>(s, pairsbegin, pairsend);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// get_token
|
||||
//***************************************************************************
|
||||
inline std::string_view get_token(const std::string& s, std::string::const_pointer delimiters, const std::string_view& last_view)
|
||||
{
|
||||
return etl::private_string_utilities::get_token(s, delimiters, last_view);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Find first of any of delimiters within the string
|
||||
//*********************************************************************
|
||||
inline std::string::iterator find_first_of(std::string::iterator first, std::string::iterator last, std::string::const_pointer delimiters)
|
||||
{
|
||||
return etl::private_string_utilities::find_first_of(first, last, delimiters);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Find first of any of delimiters within the string
|
||||
//*********************************************************************
|
||||
inline std::string::const_iterator find_first_of(std::string::const_iterator first, std::string::const_iterator last, std::string::const_pointer delimiters)
|
||||
{
|
||||
return etl::private_string_utilities::find_first_of(first, last, delimiters);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Find first of any of delimiters within the string
|
||||
//*********************************************************************
|
||||
inline std::string::iterator find_first_of(std::string& s, std::string::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 std::string::const_iterator find_first_of(const std::string& s, std::string::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 std::string_view::const_iterator find_first_of(const std::string_view& s, std::string_view::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 std::string::iterator find_first_not_of(std::string::iterator first, std::string::iterator last, std::string::const_pointer delimiters)
|
||||
{
|
||||
return etl::private_string_utilities::find_first_not_of(first, last, delimiters);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Find first not of delimiters within the string
|
||||
//*********************************************************************
|
||||
inline std::string::const_iterator find_first_not_of(std::string::const_iterator first, std::string::const_iterator last, std::string::const_pointer delimiters)
|
||||
{
|
||||
return etl::private_string_utilities::find_first_not_of(first, last, delimiters);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Find first not of delimiters within the string
|
||||
//*********************************************************************
|
||||
inline std::string::iterator find_first_not_of(std::string& s, std::string::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 std::string::const_iterator find_first_not_of(const std::string& s, std::string::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 std::string_view::const_iterator find_first_not_of(const std::string_view& view, std::string::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 std::string::iterator find_last_of(std::string::iterator first, std::string::iterator last, std::string::const_pointer delimiters)
|
||||
{
|
||||
return etl::private_string_utilities::find_last_of(first, last, delimiters);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Find last of any of delimiters within the string
|
||||
//*********************************************************************
|
||||
inline std::string::const_iterator find_last_of(std::string::const_iterator first, std::string::const_iterator last, std::string::const_pointer delimiters)
|
||||
{
|
||||
return etl::private_string_utilities::find_last_of(first, last, delimiters);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Find last of any of delimiters within the string
|
||||
//*********************************************************************
|
||||
inline std::string::iterator find_last_of(std::string& s, std::string::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 std::string::const_iterator find_last_of(const std::string& s, std::string::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 std::string_view::const_iterator find_last_of(const std::string_view& view, std::string::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 std::string::iterator find_last_not_of(std::string::iterator first, std::string::iterator last, std::string::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 std::string::const_iterator find_last_not_of(std::string::const_iterator first, std::string::const_iterator last, std::string::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 std::string::iterator find_last_not_of(std::string& s, std::string::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 std::string::const_iterator find_last_not_of(const std::string& s, std::string::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 std::string_view::const_iterator find_last_not_of(const std::string_view& view, std::string::const_pointer delimiters)
|
||||
{
|
||||
return etl::private_string_utilities::find_last_not_of(view.cbegin(), view.cend(), delimiters);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@ -154,7 +154,7 @@ namespace etl
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Construct from iterator/size.
|
||||
/// Construct from pointer/size.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR17 basic_string_view(const T* begin_, size_t size_)
|
||||
: mbegin(begin_)
|
||||
|
||||
@ -1,464 +0,0 @@
|
||||
///\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);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// replace
|
||||
//***************************************************************************
|
||||
inline void replace(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::replace_characters<etl::iu16string>(s, pairsbegin, pairsend);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// replace
|
||||
//***************************************************************************
|
||||
inline void replace(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::replace_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
|
||||
@ -1,464 +0,0 @@
|
||||
///\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);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// replace
|
||||
//***************************************************************************
|
||||
inline void replace(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::replace_characters<etl::iu32string>(s, pairsbegin, pairsend);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// replace
|
||||
//***************************************************************************
|
||||
inline void replace(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::replace_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
|
||||
@ -38,8 +38,8 @@ SOFTWARE.
|
||||
///\ingroup utilities
|
||||
|
||||
#define ETL_VERSION_MAJOR 18
|
||||
#define ETL_VERSION_MINOR 7
|
||||
#define ETL_VERSION_PATCH 1
|
||||
#define ETL_VERSION_MINOR 8
|
||||
#define ETL_VERSION_PATCH 0
|
||||
#define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) "." ETL_STRINGIFY(ETL_VERSION_MINOR) "." ETL_STRINGIFY(ETL_VERSION_PATCH)
|
||||
#define ETL_VERSION_W ETL_STRINGIFY(ETL_VERSION_MAJOR) L"." ETL_STRINGIFY(ETL_VERSION_MINOR) L"." ETL_STRINGIFY(ETL_VERSION_PATCH)
|
||||
#define ETL_VERSION_U16 ETL_STRINGIFY(ETL_VERSION_MAJOR) u"." ETL_STRINGIFY(ETL_VERSION_MINOR) u"." ETL_STRINGIFY(ETL_VERSION_PATCH)
|
||||
|
||||
@ -1,464 +0,0 @@
|
||||
///\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);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// replace
|
||||
//***************************************************************************
|
||||
inline void replace(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::replace_characters<etl::iwstring>(s, pairsbegin, pairsend);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// replace
|
||||
//***************************************************************************
|
||||
inline void replace(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::replace_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
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Embedded Template Library",
|
||||
"version": "18.7.1",
|
||||
"version": "18.8.0",
|
||||
"authors": {
|
||||
"name": "John Wellbelove",
|
||||
"email": "john.wellbelove@etlcpp.com"
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
name=Embedded Template Library
|
||||
version=18.7.1
|
||||
version=18.8.0
|
||||
author= John Wellbelove <john.wellbelove@etlcpp.com>
|
||||
maintainer=John Wellbelove <john.wellbelove@etlcpp.com>
|
||||
license=MIT
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
===============================================================================
|
||||
18.8.0
|
||||
Re-coded string utilities to allow any string-like container to use it.
|
||||
|
||||
===============================================================================
|
||||
18.7.1
|
||||
Removed to_upper_case, to_lower_case & to_sentence_case from
|
||||
|
||||
@ -373,7 +373,6 @@
|
||||
<Unit filename="../../include/etl/private/minmax_push.h" />
|
||||
<Unit filename="../../include/etl/private/move.h" />
|
||||
<Unit filename="../../include/etl/private/pvoidvector.h" />
|
||||
<Unit filename="../../include/etl/private/string_utilities_helper.h" />
|
||||
<Unit filename="../../include/etl/private/swap.h" />
|
||||
<Unit filename="../../include/etl/private/to_string_helper.h" />
|
||||
<Unit filename="../../include/etl/private/vector_base.h" />
|
||||
@ -452,7 +451,6 @@
|
||||
<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" />
|
||||
@ -586,6 +584,10 @@
|
||||
<Unit filename="../test_string_u16.cpp" />
|
||||
<Unit filename="../test_string_u32.cpp" />
|
||||
<Unit filename="../test_string_utilities.cpp" />
|
||||
<Unit filename="../test_string_utilities_std.cpp" />
|
||||
<Unit filename="../test_string_utilities_std_u16.cpp" />
|
||||
<Unit filename="../test_string_utilities_std_u32.cpp" />
|
||||
<Unit filename="../test_string_utilities_std_wchar_t.cpp" />
|
||||
<Unit filename="../test_string_utilities_u16.cpp" />
|
||||
<Unit filename="../test_string_utilities_u32.cpp" />
|
||||
<Unit filename="../test_string_utilities_wchar_t.cpp" />
|
||||
|
||||
@ -42,11 +42,11 @@ namespace
|
||||
{
|
||||
static const size_t SIZE = 50;
|
||||
|
||||
typedef etl::string<SIZE> String;
|
||||
typedef etl::istring IString;
|
||||
typedef etl::string_view StringView;
|
||||
typedef etl::istring::value_type Char;
|
||||
typedef etl::vector<String, 10> Vector;
|
||||
using String = etl::string<SIZE>;
|
||||
using IString = etl::istring;
|
||||
using StringView = etl::string_view;
|
||||
using Char = etl::istring::value_type;
|
||||
using Vector = etl::vector<String, 10>;
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_whitespace_left_empty)
|
||||
@ -60,7 +60,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_whitespace_left_empty)
|
||||
TEST(test_trim_view_whitespace_left_empty)
|
||||
{
|
||||
String text(STR(""));
|
||||
String expected(STR(""));
|
||||
@ -68,9 +68,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_whitespace_left(textview);
|
||||
StringView view = etl::trim_view_whitespace_left(textview);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -85,7 +86,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_whitespace_left)
|
||||
TEST(test_trim_view_whitespace_left)
|
||||
{
|
||||
String text(STR(" \t\n\r\f\vHello World\t\n\r\f\v "));
|
||||
String expected(STR("Hello World\t\n\r\f\v "));
|
||||
@ -93,9 +94,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_whitespace_left(textview);
|
||||
StringView view = etl::trim_view_whitespace_left(textview);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -110,7 +112,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_whitespace_left_nothing_to_trim)
|
||||
TEST(test_trim_view_whitespace_left_nothing_to_trim)
|
||||
{
|
||||
String text(STR("Hello World\t\n\r\f\v "));
|
||||
String expected(STR("Hello World\t\n\r\f\v "));
|
||||
@ -118,9 +120,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_whitespace_left(textview);
|
||||
StringView view = etl::trim_view_whitespace_left(textview);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -135,7 +138,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_from_left_pointer_empty)
|
||||
TEST(test_trim_from_view_left_pointer_empty)
|
||||
{
|
||||
String text(STR(""));
|
||||
String expected(STR(""));
|
||||
@ -143,9 +146,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_from_left(textview, STR(" \t\n\r\f\v"));
|
||||
StringView view = etl::trim_from_view_left(textview, STR(" \t\n\r\f\v"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -160,7 +164,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_from_left_pointer)
|
||||
TEST(test_trim_from_view_left_pointer)
|
||||
{
|
||||
String text(STR(" \t\n\r\f\vHello World\t\n\r\f\v "));
|
||||
String expected(STR("Hello World\t\n\r\f\v "));
|
||||
@ -168,9 +172,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_from_left(textview, STR(" \t\n\r\f\v"));
|
||||
StringView view = etl::trim_from_view_left(textview, STR(" \t\n\r\f\v"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -185,7 +190,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_from_left_pointer_nothing_to_trim)
|
||||
TEST(test_trim_from_view_left_pointer_nothing_to_trim)
|
||||
{
|
||||
String text(STR("Hello World\t\n\r\f\v "));
|
||||
String expected(STR("Hello World\t\n\r\f\v "));
|
||||
@ -193,11 +198,12 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_from_left(textview, STR(" \t\n\r\f\v"));
|
||||
StringView view = etl::trim_from_view_left(textview, STR(" \t\n\r\f\v"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_from_left_pointer_length_empty)
|
||||
{
|
||||
@ -210,7 +216,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_left_pointer_delimiters)
|
||||
TEST(test_trim_left_delimiters)
|
||||
{
|
||||
String text(STR("qztfpHello Worldqztfp"));
|
||||
String expected(STR("Hello Worldqztfp"));
|
||||
@ -221,7 +227,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_left_pointer_delimiters)
|
||||
TEST(test_trim_view_left_delimiters)
|
||||
{
|
||||
String text(STR("qztfpHello Worldqztfp"));
|
||||
String expected(STR("Hello Worldqztfp"));
|
||||
@ -229,13 +235,14 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_left(textview, STR("Hel"));
|
||||
StringView view = etl::trim_view_left(textview, STR("Hel"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_left_pointer_delimiters_nothing_to_trim)
|
||||
TEST(test_trim_left_delimiters_nothing_to_trim)
|
||||
{
|
||||
String text(STR("Hello Worldqztfp"));
|
||||
String expected(STR("Hello Worldqztfp"));
|
||||
@ -246,7 +253,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_left_pointer_delimiters_nothing_to_trim)
|
||||
TEST(test_trim_view_left_delimiters_nothing_to_trim)
|
||||
{
|
||||
String text(STR("Hello Worldqztfp"));
|
||||
String expected(STR("Hello Worldqztfp"));
|
||||
@ -254,13 +261,40 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_left(textview, STR("Hel"));
|
||||
StringView view = etl::trim_view_left(textview, STR("Hel"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_left_string_delimiters)
|
||||
TEST(test_trim_left_delimiters_no_delimiters)
|
||||
{
|
||||
String text(STR("Hello Worldqztfp"));
|
||||
String expected(STR(""));
|
||||
|
||||
etl::trim_left(text, STR("XYZ"));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_view_left_delimiters_no_delimiters)
|
||||
{
|
||||
String text(STR("Hello Worldqztfp"));
|
||||
String expected(STR(""));
|
||||
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_view_left(textview, STR("XYZ"));
|
||||
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_view_left_string_delimiters)
|
||||
{
|
||||
String text(STR("qztfpHello Worldqztfp"));
|
||||
String expected(STR("Hello Worldqztfp"));
|
||||
@ -268,9 +302,11 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_left(textview, STR("Hel"));
|
||||
StringView view = etl::trim_view_left(textview, STR("Hel"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -285,7 +321,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_whitespace_right_empty)
|
||||
TEST(test_trim_view_whitespace_right_empty)
|
||||
{
|
||||
String text(STR(""));
|
||||
String expected(STR(""));
|
||||
@ -293,9 +329,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_whitespace_right(textview);
|
||||
StringView view = etl::trim_view_whitespace_right(textview);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -310,7 +347,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_whitespace_right)
|
||||
TEST(test_trim_view_whitespace_right)
|
||||
{
|
||||
String text(STR(" \t\n\r\f\vHello World\t\n\r\f\v "));
|
||||
String expected(STR(" \t\n\r\f\vHello World"));
|
||||
@ -318,9 +355,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_whitespace_right(textview);
|
||||
StringView view = etl::trim_view_whitespace_right(textview);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -335,7 +373,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_whitespace_right_nothing_to_trim)
|
||||
TEST(test_trim_view_whitespace_right_nothing_to_trim)
|
||||
{
|
||||
String text(STR(" \t\n\r\f\vHello World"));
|
||||
String expected(STR(" \t\n\r\f\vHello World"));
|
||||
@ -343,9 +381,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_whitespace_right(textview);
|
||||
StringView view = etl::trim_view_whitespace_right(textview);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -360,7 +399,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_from_right_pointer_empty)
|
||||
TEST(test_trim_from_view_right_pointer_empty)
|
||||
{
|
||||
String text(STR(""));
|
||||
String expected(STR(""));
|
||||
@ -368,9 +407,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_from_right(textview, STR(" \t\n\r\f\v"));
|
||||
StringView view = etl::trim_from_view_right(textview, STR(" \t\n\r\f\v"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -385,7 +425,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_from_right_pointer)
|
||||
TEST(test_trim_from_view_right_pointer)
|
||||
{
|
||||
String text(STR(" \t\n\r\f\vHello World\t\n\r\f\v "));
|
||||
String expected(STR(" \t\n\r\f\vHello World"));
|
||||
@ -393,9 +433,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_from_right(textview, STR(" \t\n\r\f\v"));
|
||||
StringView view = etl::trim_from_view_right(textview, STR(" \t\n\r\f\v"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -410,7 +451,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_from_right_pointer_nothing_to_trim)
|
||||
TEST(test_trim_from_view_right_pointer_nothing_to_trim)
|
||||
{
|
||||
String text(STR(" \t\n\r\f\vHello World"));
|
||||
String expected(STR(" \t\n\r\f\vHello World"));
|
||||
@ -418,13 +459,14 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_from_right(textview, STR(" \t\n\r\f\v"));
|
||||
StringView view = etl::trim_from_view_right(textview, STR(" \t\n\r\f\v"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_right_pointer_delimiters)
|
||||
TEST(test_trim_right_delimiters)
|
||||
{
|
||||
String text(STR("qztfpHello Worldqztfp"));
|
||||
String expected(STR("qztfpHello World"));
|
||||
@ -435,7 +477,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_right_pointer_delimiters)
|
||||
TEST(test_trim_view_right_delimiters)
|
||||
{
|
||||
String text(STR("qztfpHello Worldqztfp"));
|
||||
String expected(STR("qztfpHello World"));
|
||||
@ -443,13 +485,14 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_right(textview, STR("rld"));
|
||||
StringView view = etl::trim_view_right(textview, STR("rld"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_right_pointer_delimiters_nothing_to_trim)
|
||||
TEST(test_trim_right_delimiters_nothing_to_trim)
|
||||
{
|
||||
String text(STR("qztfpHello World"));
|
||||
String expected(STR("qztfpHello World"));
|
||||
@ -460,7 +503,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_right_pointer_delimiters_nothing_to_trim)
|
||||
TEST(test_trim_view_right_delimiters_nothing_to_trim)
|
||||
{
|
||||
String text(STR("qztfpHello World"));
|
||||
String expected(STR("qztfpHello World"));
|
||||
@ -468,9 +511,36 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_right(textview, STR("rld"));
|
||||
StringView view = etl::trim_view_right(textview, STR("rld"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_right_delimiters_no_delimiters)
|
||||
{
|
||||
String text(STR("qztfpHello World"));
|
||||
String expected(STR(""));
|
||||
|
||||
etl::trim_right(text, STR("XYZ"));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_view_right_delimiters_no_delimiters)
|
||||
{
|
||||
String text(STR("qztfpHello World"));
|
||||
String expected(STR(""));
|
||||
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_view_right(textview, STR("XYZ"));
|
||||
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -485,7 +555,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_whitespace_empty)
|
||||
TEST(test_trim_view_whitespace_empty)
|
||||
{
|
||||
String text(STR(""));
|
||||
String expected(STR(""));
|
||||
@ -493,9 +563,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_whitespace(textview);
|
||||
StringView view = etl::trim_view_whitespace(textview);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -510,7 +581,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_whitespace)
|
||||
TEST(test_trim_view_whitespace)
|
||||
{
|
||||
String text(STR(" \t\n\r\f\vHello World\t\n\r\f\v "));
|
||||
String expected(STR("Hello World"));
|
||||
@ -518,9 +589,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_whitespace(textview);
|
||||
StringView view = etl::trim_view_whitespace(textview);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -535,7 +607,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_whitespace_nothing_to_trim)
|
||||
TEST(test_trim_view_whitespace_nothing_to_trim)
|
||||
{
|
||||
String text(STR("Hello World"));
|
||||
String expected(STR("Hello World"));
|
||||
@ -543,9 +615,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_whitespace(textview);
|
||||
StringView view = etl::trim_view_whitespace(textview);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -560,7 +633,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_from_empty)
|
||||
TEST(test_trim_from_view_empty)
|
||||
{
|
||||
String text(STR(""));
|
||||
String expected(STR(""));
|
||||
@ -568,9 +641,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_from(textview, STR(" \t\n\r\f\v"));
|
||||
StringView view = etl::trim_from_view(textview, STR(" \t\n\r\f\v"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -585,7 +659,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_from)
|
||||
TEST(test_trim_from_view)
|
||||
{
|
||||
String text(STR(" \t\n\r\f\vHello World\t\n\r\f\v "));
|
||||
String expected(STR("Hello World"));
|
||||
@ -593,9 +667,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_from(textview, STR(" \t\n\r\f\v"));
|
||||
StringView view = etl::trim_from_view(textview, STR(" \t\n\r\f\v"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -610,7 +685,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_from_nothing_to_trim)
|
||||
TEST(test_trim_from_view_nothing_to_trim)
|
||||
{
|
||||
String text(STR("Hello World"));
|
||||
String expected(STR("Hello World"));
|
||||
@ -618,13 +693,14 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_from(textview, STR(" \t\n\r\f\v"));
|
||||
StringView view = etl::trim_from_view(textview, STR(" \t\n\r\f\v"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_pointer_delimiters)
|
||||
TEST(test_trim_delimiters)
|
||||
{
|
||||
String text(STR("qztfpHello Worldqztfp"));
|
||||
String expected(STR("Hello World"));
|
||||
@ -635,7 +711,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_pointer_delimiters)
|
||||
TEST(test_trim_view_delimiters)
|
||||
{
|
||||
String text(STR("qztfpHello Worldqztfp"));
|
||||
String expected(STR("Hello World"));
|
||||
@ -643,13 +719,14 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim(textview, STR("Hd"));
|
||||
StringView view = etl::trim_view(textview, STR("Hd"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_pointer_delimiters_nothing_to_trim)
|
||||
TEST(test_trim_delimiters_nothing_to_trim)
|
||||
{
|
||||
String text(STR("Hello World"));
|
||||
String expected(STR("Hello World"));
|
||||
@ -660,7 +737,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_pointer_delimiters_nothing_to_trim)
|
||||
TEST(test_trim_view_delimiters_nothing_to_trim)
|
||||
{
|
||||
String text(STR("Hello World"));
|
||||
String expected(STR("Hello World"));
|
||||
@ -668,9 +745,36 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim(textview, STR("Hd"));
|
||||
StringView view = etl::trim_view(textview, STR("Hd"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_delimiters_no_delimiters)
|
||||
{
|
||||
String text(STR("Hello World"));
|
||||
String expected(STR(""));
|
||||
|
||||
etl::trim(text, STR("XYZ"));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_view_delimiters_no_delimiters)
|
||||
{
|
||||
String text(STR("Hello World"));
|
||||
String expected(STR(""));
|
||||
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_view(textview, STR("XYZ"));
|
||||
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -693,9 +797,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::right_n(textview, expected.size());
|
||||
StringView view = etl::right_n_view(textview, expected.size());
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -707,9 +812,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::right_n(textview, text.size() * 2U);
|
||||
StringView view = etl::right_n_view(textview, text.size() * 2U);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -743,9 +849,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::left_n(textview, expected.size());
|
||||
StringView view = etl::left_n_view(textview, expected.size());
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -757,9 +864,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::left_n(textview, text.size() * 2U);
|
||||
StringView view = etl::left_n_view(textview, text.size() * 2U);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -799,7 +907,7 @@ namespace
|
||||
{ STR(':'), STR('_') }
|
||||
};
|
||||
|
||||
etl::replace(text, etl::begin(lookup), etl::end(lookup));
|
||||
etl::replace_characters(text, etl::begin(lookup), etl::end(lookup));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
@ -819,7 +927,7 @@ namespace
|
||||
{ STR(':'), STR('_') }
|
||||
};
|
||||
|
||||
etl::replace(text, etl::begin(lookup), etl::end(lookup));
|
||||
etl::replace_characters(text, etl::begin(lookup), etl::end(lookup));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
@ -839,7 +947,7 @@ namespace
|
||||
{ STR(":"), STR(".txt") }
|
||||
};
|
||||
|
||||
etl::replace(text, etl::begin(lookup), etl::end(lookup));
|
||||
etl::replace_strings(text, etl::begin(lookup), etl::end(lookup));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
@ -859,32 +967,99 @@ namespace
|
||||
{ STR(":"), STR(".txt") }
|
||||
};
|
||||
|
||||
etl::replace(text, etl::begin(lookup), etl::end(lookup));
|
||||
etl::replace_strings(text, etl::begin(lookup), etl::end(lookup));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_get_token_pointer_delimiters)
|
||||
TEST(test_get_token_delimiters)
|
||||
{
|
||||
String text(STR(" The cat.sat, on;the:mat .,;:"));
|
||||
Vector tokens;
|
||||
|
||||
StringView textview(text);
|
||||
StringView token;
|
||||
|
||||
while (token.end() != text.end())
|
||||
{
|
||||
|
||||
do
|
||||
{
|
||||
token = etl::get_token(text, STR(" .,;:"), token);
|
||||
|
||||
if (!token.empty())
|
||||
{
|
||||
tokens.emplace_back(token.begin(), token.end());
|
||||
}
|
||||
}
|
||||
} while (!token.empty());
|
||||
|
||||
CHECK_EQUAL(6U, tokens.size());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_get_token_delimiters_nothing_to_do)
|
||||
{
|
||||
String text(STR(""));
|
||||
Vector tokens;
|
||||
|
||||
StringView textview(text);
|
||||
StringView token;
|
||||
|
||||
do
|
||||
{
|
||||
token = etl::get_token(text, STR(" .,;:"), token);
|
||||
|
||||
if (!token.empty())
|
||||
{
|
||||
tokens.emplace_back(token.begin(), token.end());
|
||||
}
|
||||
} while (!token.empty());
|
||||
|
||||
CHECK_EQUAL(0U, tokens.size());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_get_token_delimiters_no_tokens)
|
||||
{
|
||||
String text(STR(" ., ;: .,;:"));
|
||||
Vector tokens;
|
||||
|
||||
StringView textview(text);
|
||||
StringView token;
|
||||
|
||||
do
|
||||
{
|
||||
token = etl::get_token(text, STR(" .,;:"), token);
|
||||
|
||||
if (!token.empty())
|
||||
{
|
||||
tokens.emplace_back(token.begin(), token.end());
|
||||
}
|
||||
} while (!token.empty());
|
||||
|
||||
CHECK_EQUAL(0U, tokens.size());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_get_token_delimiters_no_delimiters)
|
||||
{
|
||||
String text(STR("The cat sat on the mat"));
|
||||
Vector tokens;
|
||||
|
||||
StringView textview(text);
|
||||
StringView token;
|
||||
|
||||
do
|
||||
{
|
||||
token = etl::get_token(text, STR(".,;:"), token);
|
||||
|
||||
if (!token.empty())
|
||||
{
|
||||
tokens.emplace_back(token.begin(), token.end());
|
||||
}
|
||||
} while (!token.empty());
|
||||
|
||||
CHECK_EQUAL(1U, tokens.size());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_pad_left)
|
||||
{
|
||||
@ -1107,7 +1282,7 @@ namespace
|
||||
const String text(STR("abcHello Worldabc"));
|
||||
StringView textview(text);
|
||||
|
||||
String::const_iterator itr = etl::find_first_of(textview, STR("Hel"));
|
||||
StringView::const_iterator itr = etl::find_first_of(textview, STR("Hel"));
|
||||
|
||||
CHECK_EQUAL(STR('H'), *itr);
|
||||
}
|
||||
@ -1118,9 +1293,9 @@ namespace
|
||||
const String text(STR("abcHello Worldabc"));
|
||||
StringView textview(text);
|
||||
|
||||
String::const_iterator itr = etl::find_first_of(textview, STR("xyz"));
|
||||
StringView::const_iterator itr = etl::find_first_of(textview, STR("xyz"));
|
||||
|
||||
CHECK(text.end() == itr);
|
||||
CHECK(textview.end() == itr);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -1208,7 +1383,7 @@ namespace
|
||||
const String text(STR("abcHello Worldabc"));
|
||||
StringView textview(text);
|
||||
|
||||
String::const_iterator itr = etl::find_first_not_of(textview, STR("abc"));
|
||||
StringView::const_iterator itr = etl::find_first_not_of(textview, STR("abc"));
|
||||
|
||||
CHECK_EQUAL(STR('H'), *itr);
|
||||
}
|
||||
@ -1219,9 +1394,9 @@ namespace
|
||||
const String text(STR("abcHello Worldabc"));
|
||||
StringView textview(text);
|
||||
|
||||
String::const_iterator itr = etl::find_first_not_of(textview, STR("abcHello World"));
|
||||
StringView::const_iterator itr = etl::find_first_not_of(textview, STR("abcHello World"));
|
||||
|
||||
CHECK(text.end() == itr);
|
||||
CHECK(textview.end() == itr);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -1310,7 +1485,7 @@ namespace
|
||||
String text(STR("abcHello Worldabc"));
|
||||
StringView textview(text);
|
||||
|
||||
String::const_iterator itr = etl::find_last_of(textview, STR("rld"));
|
||||
StringView::const_iterator itr = etl::find_last_of(textview, STR("rld"));
|
||||
|
||||
CHECK_EQUAL(STR('d'), *itr);
|
||||
}
|
||||
@ -1321,9 +1496,9 @@ namespace
|
||||
String text(STR("abcHello Worldabc"));
|
||||
StringView textview(text);
|
||||
|
||||
String::const_iterator itr = etl::find_last_of(textview, STR("xyz"));
|
||||
StringView::const_iterator itr = etl::find_last_of(textview, STR("xyz"));
|
||||
|
||||
CHECK(text.end() == itr);
|
||||
CHECK(textview.end() == itr);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -1412,7 +1587,7 @@ namespace
|
||||
String text(STR("abcHello Worldabc"));
|
||||
StringView textview(text);
|
||||
|
||||
String::const_iterator itr = etl::find_last_not_of(textview, STR("abc"));
|
||||
StringView::const_iterator itr = etl::find_last_not_of(textview, STR("abc"));
|
||||
|
||||
CHECK_EQUAL(STR('d'), *itr);
|
||||
}
|
||||
@ -1423,9 +1598,9 @@ namespace
|
||||
String text(STR("abcHello Worldabc"));
|
||||
StringView textview(text);
|
||||
|
||||
String::const_iterator itr = etl::find_last_not_of(textview, STR("abcHello World"));
|
||||
StringView::const_iterator itr = etl::find_last_not_of(textview, STR("abcHello World"));
|
||||
|
||||
CHECK(text.end() == itr);
|
||||
CHECK(textview.end() == itr);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ SOFTWARE.
|
||||
|
||||
#include "etl/u16string.h"
|
||||
#include "etl/string_view.h"
|
||||
#include "etl/u16string_utilities.h"
|
||||
#include "etl/string_utilities.h"
|
||||
#include "etl/vector.h"
|
||||
|
||||
#undef STR
|
||||
@ -38,15 +38,15 @@ SOFTWARE.
|
||||
|
||||
namespace
|
||||
{
|
||||
SUITE(test_wstring_utilities_char)
|
||||
SUITE(test_string_utilities_u16)
|
||||
{
|
||||
static const size_t SIZE = 50;
|
||||
|
||||
typedef etl::u16string<SIZE> String;
|
||||
typedef etl::iu16string IString;
|
||||
typedef etl::u16string_view StringView;
|
||||
typedef etl::iu16string::value_type Char;
|
||||
typedef etl::vector<String, 10> Vector;
|
||||
using String = etl::u16string<SIZE>;
|
||||
using IString = etl::iu16string;
|
||||
using StringView = etl::u16string_view;
|
||||
using Char = etl::iu16string::value_type;
|
||||
using Vector = etl::vector<String, 10>;
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_whitespace_left_empty)
|
||||
@ -60,7 +60,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_whitespace_left_empty)
|
||||
TEST(test_trim_view_whitespace_left_empty)
|
||||
{
|
||||
String text(STR(""));
|
||||
String expected(STR(""));
|
||||
@ -68,9 +68,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_whitespace_left(textview);
|
||||
StringView view = etl::trim_view_whitespace_left(textview);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -85,7 +86,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_whitespace_left)
|
||||
TEST(test_trim_view_whitespace_left)
|
||||
{
|
||||
String text(STR(" \t\n\r\f\vHello World\t\n\r\f\v "));
|
||||
String expected(STR("Hello World\t\n\r\f\v "));
|
||||
@ -93,9 +94,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_whitespace_left(textview);
|
||||
StringView view = etl::trim_view_whitespace_left(textview);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -110,7 +112,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_whitespace_left_nothing_to_trim)
|
||||
TEST(test_trim_view_whitespace_left_nothing_to_trim)
|
||||
{
|
||||
String text(STR("Hello World\t\n\r\f\v "));
|
||||
String expected(STR("Hello World\t\n\r\f\v "));
|
||||
@ -118,9 +120,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_whitespace_left(textview);
|
||||
StringView view = etl::trim_view_whitespace_left(textview);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -135,7 +138,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_from_left_pointer_empty)
|
||||
TEST(test_trim_from_view_left_pointer_empty)
|
||||
{
|
||||
String text(STR(""));
|
||||
String expected(STR(""));
|
||||
@ -143,9 +146,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_from_left(textview, STR(" \t\n\r\f\v"));
|
||||
StringView view = etl::trim_from_view_left(textview, STR(" \t\n\r\f\v"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -160,7 +164,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_from_left_pointer)
|
||||
TEST(test_trim_from_view_left_pointer)
|
||||
{
|
||||
String text(STR(" \t\n\r\f\vHello World\t\n\r\f\v "));
|
||||
String expected(STR("Hello World\t\n\r\f\v "));
|
||||
@ -168,9 +172,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_from_left(textview, STR(" \t\n\r\f\v"));
|
||||
StringView view = etl::trim_from_view_left(textview, STR(" \t\n\r\f\v"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -185,7 +190,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_from_left_pointer_nothing_to_trim)
|
||||
TEST(test_trim_from_view_left_pointer_nothing_to_trim)
|
||||
{
|
||||
String text(STR("Hello World\t\n\r\f\v "));
|
||||
String expected(STR("Hello World\t\n\r\f\v "));
|
||||
@ -193,11 +198,12 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_from_left(textview, STR(" \t\n\r\f\v"));
|
||||
StringView view = etl::trim_from_view_left(textview, STR(" \t\n\r\f\v"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_from_left_pointer_length_empty)
|
||||
{
|
||||
@ -210,7 +216,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_left_pointer_delimiters)
|
||||
TEST(test_trim_left_delimiters)
|
||||
{
|
||||
String text(STR("qztfpHello Worldqztfp"));
|
||||
String expected(STR("Hello Worldqztfp"));
|
||||
@ -221,7 +227,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_left_pointer_delimiters)
|
||||
TEST(test_trim_view_left_delimiters)
|
||||
{
|
||||
String text(STR("qztfpHello Worldqztfp"));
|
||||
String expected(STR("Hello Worldqztfp"));
|
||||
@ -229,13 +235,14 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_left(textview, STR("Hel"));
|
||||
StringView view = etl::trim_view_left(textview, STR("Hel"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_left_pointer_delimiters_nothing_to_trim)
|
||||
TEST(test_trim_left_delimiters_nothing_to_trim)
|
||||
{
|
||||
String text(STR("Hello Worldqztfp"));
|
||||
String expected(STR("Hello Worldqztfp"));
|
||||
@ -246,7 +253,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_left_pointer_delimiters_nothing_to_trim)
|
||||
TEST(test_trim_view_left_delimiters_nothing_to_trim)
|
||||
{
|
||||
String text(STR("Hello Worldqztfp"));
|
||||
String expected(STR("Hello Worldqztfp"));
|
||||
@ -254,13 +261,40 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_left(textview, STR("Hel"));
|
||||
StringView view = etl::trim_view_left(textview, STR("Hel"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_left_string_delimiters)
|
||||
TEST(test_trim_left_delimiters_no_delimiters)
|
||||
{
|
||||
String text(STR("Hello Worldqztfp"));
|
||||
String expected(STR(""));
|
||||
|
||||
etl::trim_left(text, STR("XYZ"));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_view_left_delimiters_no_delimiters)
|
||||
{
|
||||
String text(STR("Hello Worldqztfp"));
|
||||
String expected(STR(""));
|
||||
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_view_left(textview, STR("XYZ"));
|
||||
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_view_left_string_delimiters)
|
||||
{
|
||||
String text(STR("qztfpHello Worldqztfp"));
|
||||
String expected(STR("Hello Worldqztfp"));
|
||||
@ -268,9 +302,11 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_left(textview, STR("Hel"));
|
||||
StringView view = etl::trim_view_left(textview, STR("Hel"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -285,7 +321,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_whitespace_right_empty)
|
||||
TEST(test_trim_view_whitespace_right_empty)
|
||||
{
|
||||
String text(STR(""));
|
||||
String expected(STR(""));
|
||||
@ -293,9 +329,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_whitespace_right(textview);
|
||||
StringView view = etl::trim_view_whitespace_right(textview);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -310,7 +347,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_whitespace_right)
|
||||
TEST(test_trim_view_whitespace_right)
|
||||
{
|
||||
String text(STR(" \t\n\r\f\vHello World\t\n\r\f\v "));
|
||||
String expected(STR(" \t\n\r\f\vHello World"));
|
||||
@ -318,9 +355,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_whitespace_right(textview);
|
||||
StringView view = etl::trim_view_whitespace_right(textview);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -335,7 +373,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_whitespace_right_nothing_to_trim)
|
||||
TEST(test_trim_view_whitespace_right_nothing_to_trim)
|
||||
{
|
||||
String text(STR(" \t\n\r\f\vHello World"));
|
||||
String expected(STR(" \t\n\r\f\vHello World"));
|
||||
@ -343,9 +381,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_whitespace_right(textview);
|
||||
StringView view = etl::trim_view_whitespace_right(textview);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -360,7 +399,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_from_right_pointer_empty)
|
||||
TEST(test_trim_from_view_right_pointer_empty)
|
||||
{
|
||||
String text(STR(""));
|
||||
String expected(STR(""));
|
||||
@ -368,9 +407,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_from_right(textview, STR(" \t\n\r\f\v"));
|
||||
StringView view = etl::trim_from_view_right(textview, STR(" \t\n\r\f\v"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -385,7 +425,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_from_right_pointer)
|
||||
TEST(test_trim_from_view_right_pointer)
|
||||
{
|
||||
String text(STR(" \t\n\r\f\vHello World\t\n\r\f\v "));
|
||||
String expected(STR(" \t\n\r\f\vHello World"));
|
||||
@ -393,9 +433,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_from_right(textview, STR(" \t\n\r\f\v"));
|
||||
StringView view = etl::trim_from_view_right(textview, STR(" \t\n\r\f\v"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -410,7 +451,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_from_right_pointer_nothing_to_trim)
|
||||
TEST(test_trim_from_view_right_pointer_nothing_to_trim)
|
||||
{
|
||||
String text(STR(" \t\n\r\f\vHello World"));
|
||||
String expected(STR(" \t\n\r\f\vHello World"));
|
||||
@ -418,13 +459,14 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_from_right(textview, STR(" \t\n\r\f\v"));
|
||||
StringView view = etl::trim_from_view_right(textview, STR(" \t\n\r\f\v"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_right_pointer_delimiters)
|
||||
TEST(test_trim_right_delimiters)
|
||||
{
|
||||
String text(STR("qztfpHello Worldqztfp"));
|
||||
String expected(STR("qztfpHello World"));
|
||||
@ -435,7 +477,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_right_pointer_delimiters)
|
||||
TEST(test_trim_view_right_delimiters)
|
||||
{
|
||||
String text(STR("qztfpHello Worldqztfp"));
|
||||
String expected(STR("qztfpHello World"));
|
||||
@ -443,13 +485,14 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_right(textview, STR("rld"));
|
||||
StringView view = etl::trim_view_right(textview, STR("rld"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_right_pointer_delimiters_nothing_to_trim)
|
||||
TEST(test_trim_right_delimiters_nothing_to_trim)
|
||||
{
|
||||
String text(STR("qztfpHello World"));
|
||||
String expected(STR("qztfpHello World"));
|
||||
@ -460,7 +503,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_right_pointer_delimiters_nothing_to_trim)
|
||||
TEST(test_trim_view_right_delimiters_nothing_to_trim)
|
||||
{
|
||||
String text(STR("qztfpHello World"));
|
||||
String expected(STR("qztfpHello World"));
|
||||
@ -468,9 +511,36 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_right(textview, STR("rld"));
|
||||
StringView view = etl::trim_view_right(textview, STR("rld"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_right_delimiters_no_delimiters)
|
||||
{
|
||||
String text(STR("qztfpHello World"));
|
||||
String expected(STR(""));
|
||||
|
||||
etl::trim_right(text, STR("XYZ"));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_view_right_delimiters_no_delimiters)
|
||||
{
|
||||
String text(STR("qztfpHello World"));
|
||||
String expected(STR(""));
|
||||
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_view_right(textview, STR("XYZ"));
|
||||
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -485,7 +555,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_whitespace_empty)
|
||||
TEST(test_trim_view_whitespace_empty)
|
||||
{
|
||||
String text(STR(""));
|
||||
String expected(STR(""));
|
||||
@ -493,9 +563,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_whitespace(textview);
|
||||
StringView view = etl::trim_view_whitespace(textview);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -510,7 +581,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_whitespace)
|
||||
TEST(test_trim_view_whitespace)
|
||||
{
|
||||
String text(STR(" \t\n\r\f\vHello World\t\n\r\f\v "));
|
||||
String expected(STR("Hello World"));
|
||||
@ -518,9 +589,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_whitespace(textview);
|
||||
StringView view = etl::trim_view_whitespace(textview);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -535,7 +607,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_whitespace_nothing_to_trim)
|
||||
TEST(test_trim_view_whitespace_nothing_to_trim)
|
||||
{
|
||||
String text(STR("Hello World"));
|
||||
String expected(STR("Hello World"));
|
||||
@ -543,9 +615,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_whitespace(textview);
|
||||
StringView view = etl::trim_view_whitespace(textview);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -560,7 +633,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_from_empty)
|
||||
TEST(test_trim_from_view_empty)
|
||||
{
|
||||
String text(STR(""));
|
||||
String expected(STR(""));
|
||||
@ -568,9 +641,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_from(textview, STR(" \t\n\r\f\v"));
|
||||
StringView view = etl::trim_from_view(textview, STR(" \t\n\r\f\v"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -585,7 +659,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_from)
|
||||
TEST(test_trim_from_view)
|
||||
{
|
||||
String text(STR(" \t\n\r\f\vHello World\t\n\r\f\v "));
|
||||
String expected(STR("Hello World"));
|
||||
@ -593,9 +667,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_from(textview, STR(" \t\n\r\f\v"));
|
||||
StringView view = etl::trim_from_view(textview, STR(" \t\n\r\f\v"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -610,7 +685,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_from_nothing_to_trim)
|
||||
TEST(test_trim_from_view_nothing_to_trim)
|
||||
{
|
||||
String text(STR("Hello World"));
|
||||
String expected(STR("Hello World"));
|
||||
@ -618,13 +693,14 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_from(textview, STR(" \t\n\r\f\v"));
|
||||
StringView view = etl::trim_from_view(textview, STR(" \t\n\r\f\v"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_pointer_delimiters)
|
||||
TEST(test_trim_delimiters)
|
||||
{
|
||||
String text(STR("qztfpHello Worldqztfp"));
|
||||
String expected(STR("Hello World"));
|
||||
@ -635,7 +711,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_pointer_delimiters)
|
||||
TEST(test_trim_view_delimiters)
|
||||
{
|
||||
String text(STR("qztfpHello Worldqztfp"));
|
||||
String expected(STR("Hello World"));
|
||||
@ -643,13 +719,14 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim(textview, STR("Hd"));
|
||||
StringView view = etl::trim_view(textview, STR("Hd"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_pointer_delimiters_nothing_to_trim)
|
||||
TEST(test_trim_delimiters_nothing_to_trim)
|
||||
{
|
||||
String text(STR("Hello World"));
|
||||
String expected(STR("Hello World"));
|
||||
@ -660,7 +737,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_pointer_delimiters_nothing_to_trim)
|
||||
TEST(test_trim_view_delimiters_nothing_to_trim)
|
||||
{
|
||||
String text(STR("Hello World"));
|
||||
String expected(STR("Hello World"));
|
||||
@ -668,9 +745,36 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim(textview, STR("Hd"));
|
||||
StringView view = etl::trim_view(textview, STR("Hd"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_delimiters_no_delimiters)
|
||||
{
|
||||
String text(STR("Hello World"));
|
||||
String expected(STR(""));
|
||||
|
||||
etl::trim(text, STR("XYZ"));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_view_delimiters_no_delimiters)
|
||||
{
|
||||
String text(STR("Hello World"));
|
||||
String expected(STR(""));
|
||||
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_view(textview, STR("XYZ"));
|
||||
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -693,9 +797,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::right_n(textview, expected.size());
|
||||
StringView view = etl::right_n_view(textview, expected.size());
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -707,9 +812,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::right_n(textview, text.size() * 2U);
|
||||
StringView view = etl::right_n_view(textview, text.size() * 2U);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -743,9 +849,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::left_n(textview, expected.size());
|
||||
StringView view = etl::left_n_view(textview, expected.size());
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -757,9 +864,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::left_n(textview, text.size() * 2U);
|
||||
StringView view = etl::left_n_view(textview, text.size() * 2U);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -799,7 +907,7 @@ namespace
|
||||
{ STR(':'), STR('_') }
|
||||
};
|
||||
|
||||
etl::replace(text, etl::begin(lookup), etl::end(lookup));
|
||||
etl::replace_characters(text, etl::begin(lookup), etl::end(lookup));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
@ -819,7 +927,7 @@ namespace
|
||||
{ STR(':'), STR('_') }
|
||||
};
|
||||
|
||||
etl::replace(text, etl::begin(lookup), etl::end(lookup));
|
||||
etl::replace_characters(text, etl::begin(lookup), etl::end(lookup));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
@ -839,7 +947,7 @@ namespace
|
||||
{ STR(":"), STR(".txt") }
|
||||
};
|
||||
|
||||
etl::replace(text, etl::begin(lookup), etl::end(lookup));
|
||||
etl::replace_strings(text, etl::begin(lookup), etl::end(lookup));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
@ -859,32 +967,99 @@ namespace
|
||||
{ STR(":"), STR(".txt") }
|
||||
};
|
||||
|
||||
etl::replace(text, etl::begin(lookup), etl::end(lookup));
|
||||
etl::replace_strings(text, etl::begin(lookup), etl::end(lookup));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_get_token_pointer_delimiters)
|
||||
TEST(test_get_token_delimiters)
|
||||
{
|
||||
String text(STR(" The cat.sat, on;the:mat .,;:"));
|
||||
Vector tokens;
|
||||
|
||||
StringView textview(text);
|
||||
StringView token;
|
||||
|
||||
while (token.end() != text.end())
|
||||
{
|
||||
|
||||
do
|
||||
{
|
||||
token = etl::get_token(text, STR(" .,;:"), token);
|
||||
|
||||
if (!token.empty())
|
||||
{
|
||||
tokens.emplace_back(token.begin(), token.end());
|
||||
}
|
||||
}
|
||||
} while (!token.empty());
|
||||
|
||||
CHECK_EQUAL(6U, tokens.size());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_get_token_delimiters_nothing_to_do)
|
||||
{
|
||||
String text(STR(""));
|
||||
Vector tokens;
|
||||
|
||||
StringView textview(text);
|
||||
StringView token;
|
||||
|
||||
do
|
||||
{
|
||||
token = etl::get_token(text, STR(" .,;:"), token);
|
||||
|
||||
if (!token.empty())
|
||||
{
|
||||
tokens.emplace_back(token.begin(), token.end());
|
||||
}
|
||||
} while (!token.empty());
|
||||
|
||||
CHECK_EQUAL(0U, tokens.size());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_get_token_delimiters_no_tokens)
|
||||
{
|
||||
String text(STR(" ., ;: .,;:"));
|
||||
Vector tokens;
|
||||
|
||||
StringView textview(text);
|
||||
StringView token;
|
||||
|
||||
do
|
||||
{
|
||||
token = etl::get_token(text, STR(" .,;:"), token);
|
||||
|
||||
if (!token.empty())
|
||||
{
|
||||
tokens.emplace_back(token.begin(), token.end());
|
||||
}
|
||||
} while (!token.empty());
|
||||
|
||||
CHECK_EQUAL(0U, tokens.size());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_get_token_delimiters_no_delimiters)
|
||||
{
|
||||
String text(STR("The cat sat on the mat"));
|
||||
Vector tokens;
|
||||
|
||||
StringView textview(text);
|
||||
StringView token;
|
||||
|
||||
do
|
||||
{
|
||||
token = etl::get_token(text, STR(".,;:"), token);
|
||||
|
||||
if (!token.empty())
|
||||
{
|
||||
tokens.emplace_back(token.begin(), token.end());
|
||||
}
|
||||
} while (!token.empty());
|
||||
|
||||
CHECK_EQUAL(1U, tokens.size());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_pad_left)
|
||||
{
|
||||
@ -1107,7 +1282,7 @@ namespace
|
||||
const String text(STR("abcHello Worldabc"));
|
||||
StringView textview(text);
|
||||
|
||||
String::const_iterator itr = etl::find_first_of(textview, STR("Hel"));
|
||||
StringView::const_iterator itr = etl::find_first_of(textview, STR("Hel"));
|
||||
|
||||
CHECK_EQUAL(STR('H'), *itr);
|
||||
}
|
||||
@ -1118,9 +1293,9 @@ namespace
|
||||
const String text(STR("abcHello Worldabc"));
|
||||
StringView textview(text);
|
||||
|
||||
String::const_iterator itr = etl::find_first_of(textview, STR("xyz"));
|
||||
StringView::const_iterator itr = etl::find_first_of(textview, STR("xyz"));
|
||||
|
||||
CHECK(text.end() == itr);
|
||||
CHECK(textview.end() == itr);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -1208,7 +1383,7 @@ namespace
|
||||
const String text(STR("abcHello Worldabc"));
|
||||
StringView textview(text);
|
||||
|
||||
String::const_iterator itr = etl::find_first_not_of(textview, STR("abc"));
|
||||
StringView::const_iterator itr = etl::find_first_not_of(textview, STR("abc"));
|
||||
|
||||
CHECK_EQUAL(STR('H'), *itr);
|
||||
}
|
||||
@ -1219,9 +1394,9 @@ namespace
|
||||
const String text(STR("abcHello Worldabc"));
|
||||
StringView textview(text);
|
||||
|
||||
String::const_iterator itr = etl::find_first_not_of(textview, STR("abcHello World"));
|
||||
StringView::const_iterator itr = etl::find_first_not_of(textview, STR("abcHello World"));
|
||||
|
||||
CHECK(text.end() == itr);
|
||||
CHECK(textview.end() == itr);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -1310,7 +1485,7 @@ namespace
|
||||
String text(STR("abcHello Worldabc"));
|
||||
StringView textview(text);
|
||||
|
||||
String::const_iterator itr = etl::find_last_of(textview, STR("rld"));
|
||||
StringView::const_iterator itr = etl::find_last_of(textview, STR("rld"));
|
||||
|
||||
CHECK_EQUAL(STR('d'), *itr);
|
||||
}
|
||||
@ -1321,9 +1496,9 @@ namespace
|
||||
String text(STR("abcHello Worldabc"));
|
||||
StringView textview(text);
|
||||
|
||||
String::const_iterator itr = etl::find_last_of(textview, STR("xyz"));
|
||||
StringView::const_iterator itr = etl::find_last_of(textview, STR("xyz"));
|
||||
|
||||
CHECK(text.end() == itr);
|
||||
CHECK(textview.end() == itr);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -1412,7 +1587,7 @@ namespace
|
||||
String text(STR("abcHello Worldabc"));
|
||||
StringView textview(text);
|
||||
|
||||
String::const_iterator itr = etl::find_last_not_of(textview, STR("abc"));
|
||||
StringView::const_iterator itr = etl::find_last_not_of(textview, STR("abc"));
|
||||
|
||||
CHECK_EQUAL(STR('d'), *itr);
|
||||
}
|
||||
@ -1423,9 +1598,9 @@ namespace
|
||||
String text(STR("abcHello Worldabc"));
|
||||
StringView textview(text);
|
||||
|
||||
String::const_iterator itr = etl::find_last_not_of(textview, STR("abcHello World"));
|
||||
StringView::const_iterator itr = etl::find_last_not_of(textview, STR("abcHello World"));
|
||||
|
||||
CHECK(text.end() == itr);
|
||||
CHECK(textview.end() == itr);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ SOFTWARE.
|
||||
|
||||
#include "etl/u32string.h"
|
||||
#include "etl/string_view.h"
|
||||
#include "etl/u32string_utilities.h"
|
||||
#include "etl/string_utilities.h"
|
||||
#include "etl/vector.h"
|
||||
|
||||
#undef STR
|
||||
@ -38,15 +38,15 @@ SOFTWARE.
|
||||
|
||||
namespace
|
||||
{
|
||||
SUITE(test_wstring_utilities_char)
|
||||
SUITE(test_string_utilities_u32)
|
||||
{
|
||||
static const size_t SIZE = 50;
|
||||
|
||||
typedef etl::u32string<SIZE> String;
|
||||
typedef etl::iu32string IString;
|
||||
typedef etl::u32string_view StringView;
|
||||
typedef etl::iu32string::value_type Char;
|
||||
typedef etl::vector<String, 10> Vector;
|
||||
using String = etl::u32string<SIZE>;
|
||||
using IString = etl::iu32string;
|
||||
using StringView = etl::u32string_view;
|
||||
using Char = etl::iu32string::value_type;
|
||||
using Vector = etl::vector<String, 10>;
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_whitespace_left_empty)
|
||||
@ -60,7 +60,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_whitespace_left_empty)
|
||||
TEST(test_trim_view_whitespace_left_empty)
|
||||
{
|
||||
String text(STR(""));
|
||||
String expected(STR(""));
|
||||
@ -68,9 +68,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_whitespace_left(textview);
|
||||
StringView view = etl::trim_view_whitespace_left(textview);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -85,7 +86,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_whitespace_left)
|
||||
TEST(test_trim_view_whitespace_left)
|
||||
{
|
||||
String text(STR(" \t\n\r\f\vHello World\t\n\r\f\v "));
|
||||
String expected(STR("Hello World\t\n\r\f\v "));
|
||||
@ -93,9 +94,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_whitespace_left(textview);
|
||||
StringView view = etl::trim_view_whitespace_left(textview);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -110,7 +112,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_whitespace_left_nothing_to_trim)
|
||||
TEST(test_trim_view_whitespace_left_nothing_to_trim)
|
||||
{
|
||||
String text(STR("Hello World\t\n\r\f\v "));
|
||||
String expected(STR("Hello World\t\n\r\f\v "));
|
||||
@ -118,9 +120,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_whitespace_left(textview);
|
||||
StringView view = etl::trim_view_whitespace_left(textview);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -135,7 +138,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_from_left_pointer_empty)
|
||||
TEST(test_trim_from_view_left_pointer_empty)
|
||||
{
|
||||
String text(STR(""));
|
||||
String expected(STR(""));
|
||||
@ -143,9 +146,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_from_left(textview, STR(" \t\n\r\f\v"));
|
||||
StringView view = etl::trim_from_view_left(textview, STR(" \t\n\r\f\v"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -160,7 +164,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_from_left_pointer)
|
||||
TEST(test_trim_from_view_left_pointer)
|
||||
{
|
||||
String text(STR(" \t\n\r\f\vHello World\t\n\r\f\v "));
|
||||
String expected(STR("Hello World\t\n\r\f\v "));
|
||||
@ -168,9 +172,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_from_left(textview, STR(" \t\n\r\f\v"));
|
||||
StringView view = etl::trim_from_view_left(textview, STR(" \t\n\r\f\v"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -185,7 +190,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_from_left_pointer_nothing_to_trim)
|
||||
TEST(test_trim_from_view_left_pointer_nothing_to_trim)
|
||||
{
|
||||
String text(STR("Hello World\t\n\r\f\v "));
|
||||
String expected(STR("Hello World\t\n\r\f\v "));
|
||||
@ -193,11 +198,12 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_from_left(textview, STR(" \t\n\r\f\v"));
|
||||
StringView view = etl::trim_from_view_left(textview, STR(" \t\n\r\f\v"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_from_left_pointer_length_empty)
|
||||
{
|
||||
@ -210,7 +216,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_left_pointer_delimiters)
|
||||
TEST(test_trim_left_delimiters)
|
||||
{
|
||||
String text(STR("qztfpHello Worldqztfp"));
|
||||
String expected(STR("Hello Worldqztfp"));
|
||||
@ -221,7 +227,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_left_pointer_delimiters)
|
||||
TEST(test_trim_view_left_delimiters)
|
||||
{
|
||||
String text(STR("qztfpHello Worldqztfp"));
|
||||
String expected(STR("Hello Worldqztfp"));
|
||||
@ -229,13 +235,14 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_left(textview, STR("Hel"));
|
||||
StringView view = etl::trim_view_left(textview, STR("Hel"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_left_pointer_delimiters_nothing_to_trim)
|
||||
TEST(test_trim_left_delimiters_nothing_to_trim)
|
||||
{
|
||||
String text(STR("Hello Worldqztfp"));
|
||||
String expected(STR("Hello Worldqztfp"));
|
||||
@ -246,7 +253,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_left_pointer_delimiters_nothing_to_trim)
|
||||
TEST(test_trim_view_left_delimiters_nothing_to_trim)
|
||||
{
|
||||
String text(STR("Hello Worldqztfp"));
|
||||
String expected(STR("Hello Worldqztfp"));
|
||||
@ -254,13 +261,40 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_left(textview, STR("Hel"));
|
||||
StringView view = etl::trim_view_left(textview, STR("Hel"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_left_string_delimiters)
|
||||
TEST(test_trim_left_delimiters_no_delimiters)
|
||||
{
|
||||
String text(STR("Hello Worldqztfp"));
|
||||
String expected(STR(""));
|
||||
|
||||
etl::trim_left(text, STR("XYZ"));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_view_left_delimiters_no_delimiters)
|
||||
{
|
||||
String text(STR("Hello Worldqztfp"));
|
||||
String expected(STR(""));
|
||||
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_view_left(textview, STR("XYZ"));
|
||||
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_view_left_string_delimiters)
|
||||
{
|
||||
String text(STR("qztfpHello Worldqztfp"));
|
||||
String expected(STR("Hello Worldqztfp"));
|
||||
@ -268,9 +302,11 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_left(textview, STR("Hel"));
|
||||
StringView view = etl::trim_view_left(textview, STR("Hel"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -285,7 +321,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_whitespace_right_empty)
|
||||
TEST(test_trim_view_whitespace_right_empty)
|
||||
{
|
||||
String text(STR(""));
|
||||
String expected(STR(""));
|
||||
@ -293,9 +329,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_whitespace_right(textview);
|
||||
StringView view = etl::trim_view_whitespace_right(textview);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -310,7 +347,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_whitespace_right)
|
||||
TEST(test_trim_view_whitespace_right)
|
||||
{
|
||||
String text(STR(" \t\n\r\f\vHello World\t\n\r\f\v "));
|
||||
String expected(STR(" \t\n\r\f\vHello World"));
|
||||
@ -318,9 +355,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_whitespace_right(textview);
|
||||
StringView view = etl::trim_view_whitespace_right(textview);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -335,7 +373,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_whitespace_right_nothing_to_trim)
|
||||
TEST(test_trim_view_whitespace_right_nothing_to_trim)
|
||||
{
|
||||
String text(STR(" \t\n\r\f\vHello World"));
|
||||
String expected(STR(" \t\n\r\f\vHello World"));
|
||||
@ -343,9 +381,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_whitespace_right(textview);
|
||||
StringView view = etl::trim_view_whitespace_right(textview);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -360,7 +399,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_from_right_pointer_empty)
|
||||
TEST(test_trim_from_view_right_pointer_empty)
|
||||
{
|
||||
String text(STR(""));
|
||||
String expected(STR(""));
|
||||
@ -368,9 +407,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_from_right(textview, STR(" \t\n\r\f\v"));
|
||||
StringView view = etl::trim_from_view_right(textview, STR(" \t\n\r\f\v"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -385,7 +425,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_from_right_pointer)
|
||||
TEST(test_trim_from_view_right_pointer)
|
||||
{
|
||||
String text(STR(" \t\n\r\f\vHello World\t\n\r\f\v "));
|
||||
String expected(STR(" \t\n\r\f\vHello World"));
|
||||
@ -393,9 +433,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_from_right(textview, STR(" \t\n\r\f\v"));
|
||||
StringView view = etl::trim_from_view_right(textview, STR(" \t\n\r\f\v"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -410,7 +451,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_from_right_pointer_nothing_to_trim)
|
||||
TEST(test_trim_from_view_right_pointer_nothing_to_trim)
|
||||
{
|
||||
String text(STR(" \t\n\r\f\vHello World"));
|
||||
String expected(STR(" \t\n\r\f\vHello World"));
|
||||
@ -418,13 +459,14 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_from_right(textview, STR(" \t\n\r\f\v"));
|
||||
StringView view = etl::trim_from_view_right(textview, STR(" \t\n\r\f\v"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_right_pointer_delimiters)
|
||||
TEST(test_trim_right_delimiters)
|
||||
{
|
||||
String text(STR("qztfpHello Worldqztfp"));
|
||||
String expected(STR("qztfpHello World"));
|
||||
@ -435,7 +477,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_right_pointer_delimiters)
|
||||
TEST(test_trim_view_right_delimiters)
|
||||
{
|
||||
String text(STR("qztfpHello Worldqztfp"));
|
||||
String expected(STR("qztfpHello World"));
|
||||
@ -443,13 +485,14 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_right(textview, STR("rld"));
|
||||
StringView view = etl::trim_view_right(textview, STR("rld"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_right_pointer_delimiters_nothing_to_trim)
|
||||
TEST(test_trim_right_delimiters_nothing_to_trim)
|
||||
{
|
||||
String text(STR("qztfpHello World"));
|
||||
String expected(STR("qztfpHello World"));
|
||||
@ -460,7 +503,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_right_pointer_delimiters_nothing_to_trim)
|
||||
TEST(test_trim_view_right_delimiters_nothing_to_trim)
|
||||
{
|
||||
String text(STR("qztfpHello World"));
|
||||
String expected(STR("qztfpHello World"));
|
||||
@ -468,9 +511,36 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_right(textview, STR("rld"));
|
||||
StringView view = etl::trim_view_right(textview, STR("rld"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_right_delimiters_no_delimiters)
|
||||
{
|
||||
String text(STR("qztfpHello World"));
|
||||
String expected(STR(""));
|
||||
|
||||
etl::trim_right(text, STR("XYZ"));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_view_right_delimiters_no_delimiters)
|
||||
{
|
||||
String text(STR("qztfpHello World"));
|
||||
String expected(STR(""));
|
||||
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_view_right(textview, STR("XYZ"));
|
||||
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -485,7 +555,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_whitespace_empty)
|
||||
TEST(test_trim_view_whitespace_empty)
|
||||
{
|
||||
String text(STR(""));
|
||||
String expected(STR(""));
|
||||
@ -493,9 +563,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_whitespace(textview);
|
||||
StringView view = etl::trim_view_whitespace(textview);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -510,7 +581,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_whitespace)
|
||||
TEST(test_trim_view_whitespace)
|
||||
{
|
||||
String text(STR(" \t\n\r\f\vHello World\t\n\r\f\v "));
|
||||
String expected(STR("Hello World"));
|
||||
@ -518,9 +589,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_whitespace(textview);
|
||||
StringView view = etl::trim_view_whitespace(textview);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -535,7 +607,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_whitespace_nothing_to_trim)
|
||||
TEST(test_trim_view_whitespace_nothing_to_trim)
|
||||
{
|
||||
String text(STR("Hello World"));
|
||||
String expected(STR("Hello World"));
|
||||
@ -543,9 +615,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_whitespace(textview);
|
||||
StringView view = etl::trim_view_whitespace(textview);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -560,7 +633,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_from_empty)
|
||||
TEST(test_trim_from_view_empty)
|
||||
{
|
||||
String text(STR(""));
|
||||
String expected(STR(""));
|
||||
@ -568,9 +641,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_from(textview, STR(" \t\n\r\f\v"));
|
||||
StringView view = etl::trim_from_view(textview, STR(" \t\n\r\f\v"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -585,7 +659,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_from)
|
||||
TEST(test_trim_from_view)
|
||||
{
|
||||
String text(STR(" \t\n\r\f\vHello World\t\n\r\f\v "));
|
||||
String expected(STR("Hello World"));
|
||||
@ -593,9 +667,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_from(textview, STR(" \t\n\r\f\v"));
|
||||
StringView view = etl::trim_from_view(textview, STR(" \t\n\r\f\v"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -610,7 +685,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_from_nothing_to_trim)
|
||||
TEST(test_trim_from_view_nothing_to_trim)
|
||||
{
|
||||
String text(STR("Hello World"));
|
||||
String expected(STR("Hello World"));
|
||||
@ -618,13 +693,14 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_from(textview, STR(" \t\n\r\f\v"));
|
||||
StringView view = etl::trim_from_view(textview, STR(" \t\n\r\f\v"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_pointer_delimiters)
|
||||
TEST(test_trim_delimiters)
|
||||
{
|
||||
String text(STR("qztfpHello Worldqztfp"));
|
||||
String expected(STR("Hello World"));
|
||||
@ -635,7 +711,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_pointer_delimiters)
|
||||
TEST(test_trim_view_delimiters)
|
||||
{
|
||||
String text(STR("qztfpHello Worldqztfp"));
|
||||
String expected(STR("Hello World"));
|
||||
@ -643,13 +719,14 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim(textview, STR("Hd"));
|
||||
StringView view = etl::trim_view(textview, STR("Hd"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_pointer_delimiters_nothing_to_trim)
|
||||
TEST(test_trim_delimiters_nothing_to_trim)
|
||||
{
|
||||
String text(STR("Hello World"));
|
||||
String expected(STR("Hello World"));
|
||||
@ -660,7 +737,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_pointer_delimiters_nothing_to_trim)
|
||||
TEST(test_trim_view_delimiters_nothing_to_trim)
|
||||
{
|
||||
String text(STR("Hello World"));
|
||||
String expected(STR("Hello World"));
|
||||
@ -668,9 +745,36 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim(textview, STR("Hd"));
|
||||
StringView view = etl::trim_view(textview, STR("Hd"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_delimiters_no_delimiters)
|
||||
{
|
||||
String text(STR("Hello World"));
|
||||
String expected(STR(""));
|
||||
|
||||
etl::trim(text, STR("XYZ"));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_view_delimiters_no_delimiters)
|
||||
{
|
||||
String text(STR("Hello World"));
|
||||
String expected(STR(""));
|
||||
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_view(textview, STR("XYZ"));
|
||||
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -693,9 +797,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::right_n(textview, expected.size());
|
||||
StringView view = etl::right_n_view(textview, expected.size());
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -707,9 +812,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::right_n(textview, text.size() * 2U);
|
||||
StringView view = etl::right_n_view(textview, text.size() * 2U);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -743,9 +849,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::left_n(textview, expected.size());
|
||||
StringView view = etl::left_n_view(textview, expected.size());
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -757,9 +864,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::left_n(textview, text.size() * 2U);
|
||||
StringView view = etl::left_n_view(textview, text.size() * 2U);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -799,7 +907,7 @@ namespace
|
||||
{ STR(':'), STR('_') }
|
||||
};
|
||||
|
||||
etl::replace(text, etl::begin(lookup), etl::end(lookup));
|
||||
etl::replace_characters(text, etl::begin(lookup), etl::end(lookup));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
@ -819,7 +927,7 @@ namespace
|
||||
{ STR(':'), STR('_') }
|
||||
};
|
||||
|
||||
etl::replace(text, etl::begin(lookup), etl::end(lookup));
|
||||
etl::replace_characters(text, etl::begin(lookup), etl::end(lookup));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
@ -839,7 +947,7 @@ namespace
|
||||
{ STR(":"), STR(".txt") }
|
||||
};
|
||||
|
||||
etl::replace(text, etl::begin(lookup), etl::end(lookup));
|
||||
etl::replace_strings(text, etl::begin(lookup), etl::end(lookup));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
@ -859,32 +967,99 @@ namespace
|
||||
{ STR(":"), STR(".txt") }
|
||||
};
|
||||
|
||||
etl::replace(text, etl::begin(lookup), etl::end(lookup));
|
||||
etl::replace_strings(text, etl::begin(lookup), etl::end(lookup));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_get_token_pointer_delimiters)
|
||||
TEST(test_get_token_delimiters)
|
||||
{
|
||||
String text(STR(" The cat.sat, on;the:mat .,;:"));
|
||||
Vector tokens;
|
||||
|
||||
StringView textview(text);
|
||||
StringView token;
|
||||
|
||||
while (token.end() != text.end())
|
||||
{
|
||||
|
||||
do
|
||||
{
|
||||
token = etl::get_token(text, STR(" .,;:"), token);
|
||||
|
||||
if (!token.empty())
|
||||
{
|
||||
tokens.emplace_back(token.begin(), token.end());
|
||||
}
|
||||
}
|
||||
} while (!token.empty());
|
||||
|
||||
CHECK_EQUAL(6U, tokens.size());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_get_token_delimiters_nothing_to_do)
|
||||
{
|
||||
String text(STR(""));
|
||||
Vector tokens;
|
||||
|
||||
StringView textview(text);
|
||||
StringView token;
|
||||
|
||||
do
|
||||
{
|
||||
token = etl::get_token(text, STR(" .,;:"), token);
|
||||
|
||||
if (!token.empty())
|
||||
{
|
||||
tokens.emplace_back(token.begin(), token.end());
|
||||
}
|
||||
} while (!token.empty());
|
||||
|
||||
CHECK_EQUAL(0U, tokens.size());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_get_token_delimiters_no_tokens)
|
||||
{
|
||||
String text(STR(" ., ;: .,;:"));
|
||||
Vector tokens;
|
||||
|
||||
StringView textview(text);
|
||||
StringView token;
|
||||
|
||||
do
|
||||
{
|
||||
token = etl::get_token(text, STR(" .,;:"), token);
|
||||
|
||||
if (!token.empty())
|
||||
{
|
||||
tokens.emplace_back(token.begin(), token.end());
|
||||
}
|
||||
} while (!token.empty());
|
||||
|
||||
CHECK_EQUAL(0U, tokens.size());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_get_token_delimiters_no_delimiters)
|
||||
{
|
||||
String text(STR("The cat sat on the mat"));
|
||||
Vector tokens;
|
||||
|
||||
StringView textview(text);
|
||||
StringView token;
|
||||
|
||||
do
|
||||
{
|
||||
token = etl::get_token(text, STR(".,;:"), token);
|
||||
|
||||
if (!token.empty())
|
||||
{
|
||||
tokens.emplace_back(token.begin(), token.end());
|
||||
}
|
||||
} while (!token.empty());
|
||||
|
||||
CHECK_EQUAL(1U, tokens.size());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_pad_left)
|
||||
{
|
||||
@ -1107,7 +1282,7 @@ namespace
|
||||
const String text(STR("abcHello Worldabc"));
|
||||
StringView textview(text);
|
||||
|
||||
String::const_iterator itr = etl::find_first_of(textview, STR("Hel"));
|
||||
StringView::const_iterator itr = etl::find_first_of(textview, STR("Hel"));
|
||||
|
||||
CHECK_EQUAL(STR('H'), *itr);
|
||||
}
|
||||
@ -1118,9 +1293,9 @@ namespace
|
||||
const String text(STR("abcHello Worldabc"));
|
||||
StringView textview(text);
|
||||
|
||||
String::const_iterator itr = etl::find_first_of(textview, STR("xyz"));
|
||||
StringView::const_iterator itr = etl::find_first_of(textview, STR("xyz"));
|
||||
|
||||
CHECK(text.end() == itr);
|
||||
CHECK(textview.end() == itr);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -1208,7 +1383,7 @@ namespace
|
||||
const String text(STR("abcHello Worldabc"));
|
||||
StringView textview(text);
|
||||
|
||||
String::const_iterator itr = etl::find_first_not_of(textview, STR("abc"));
|
||||
StringView::const_iterator itr = etl::find_first_not_of(textview, STR("abc"));
|
||||
|
||||
CHECK_EQUAL(STR('H'), *itr);
|
||||
}
|
||||
@ -1219,9 +1394,9 @@ namespace
|
||||
const String text(STR("abcHello Worldabc"));
|
||||
StringView textview(text);
|
||||
|
||||
String::const_iterator itr = etl::find_first_not_of(textview, STR("abcHello World"));
|
||||
StringView::const_iterator itr = etl::find_first_not_of(textview, STR("abcHello World"));
|
||||
|
||||
CHECK(text.end() == itr);
|
||||
CHECK(textview.end() == itr);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -1310,7 +1485,7 @@ namespace
|
||||
String text(STR("abcHello Worldabc"));
|
||||
StringView textview(text);
|
||||
|
||||
String::const_iterator itr = etl::find_last_of(textview, STR("rld"));
|
||||
StringView::const_iterator itr = etl::find_last_of(textview, STR("rld"));
|
||||
|
||||
CHECK_EQUAL(STR('d'), *itr);
|
||||
}
|
||||
@ -1321,9 +1496,9 @@ namespace
|
||||
String text(STR("abcHello Worldabc"));
|
||||
StringView textview(text);
|
||||
|
||||
String::const_iterator itr = etl::find_last_of(textview, STR("xyz"));
|
||||
StringView::const_iterator itr = etl::find_last_of(textview, STR("xyz"));
|
||||
|
||||
CHECK(text.end() == itr);
|
||||
CHECK(textview.end() == itr);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -1412,7 +1587,7 @@ namespace
|
||||
String text(STR("abcHello Worldabc"));
|
||||
StringView textview(text);
|
||||
|
||||
String::const_iterator itr = etl::find_last_not_of(textview, STR("abc"));
|
||||
StringView::const_iterator itr = etl::find_last_not_of(textview, STR("abc"));
|
||||
|
||||
CHECK_EQUAL(STR('d'), *itr);
|
||||
}
|
||||
@ -1423,9 +1598,9 @@ namespace
|
||||
String text(STR("abcHello Worldabc"));
|
||||
StringView textview(text);
|
||||
|
||||
String::const_iterator itr = etl::find_last_not_of(textview, STR("abcHello World"));
|
||||
StringView::const_iterator itr = etl::find_last_not_of(textview, STR("abcHello World"));
|
||||
|
||||
CHECK(text.end() == itr);
|
||||
CHECK(textview.end() == itr);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ SOFTWARE.
|
||||
|
||||
#include "etl/wstring.h"
|
||||
#include "etl/string_view.h"
|
||||
#include "etl/wstring_utilities.h"
|
||||
#include "etl/string_utilities.h"
|
||||
#include "etl/vector.h"
|
||||
|
||||
#undef STR
|
||||
@ -38,15 +38,15 @@ SOFTWARE.
|
||||
|
||||
namespace
|
||||
{
|
||||
SUITE(test_wstring_utilities_char)
|
||||
SUITE(test_string_utilities_wchar_t)
|
||||
{
|
||||
static const size_t SIZE = 50;
|
||||
|
||||
typedef etl::wstring<SIZE> String;
|
||||
typedef etl::iwstring IString;
|
||||
typedef etl::wstring_view StringView;
|
||||
typedef etl::iwstring::value_type Char;
|
||||
typedef etl::vector<String, 10> Vector;
|
||||
using String = etl::wstring<SIZE>;
|
||||
using IString = etl::iwstring;
|
||||
using StringView = etl::wstring_view;
|
||||
using Char = etl::iwstring::value_type;
|
||||
using Vector = etl::vector<String, 10>;
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_whitespace_left_empty)
|
||||
@ -60,7 +60,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_whitespace_left_empty)
|
||||
TEST(test_trim_view_whitespace_left_empty)
|
||||
{
|
||||
String text(STR(""));
|
||||
String expected(STR(""));
|
||||
@ -68,9 +68,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_whitespace_left(textview);
|
||||
StringView view = etl::trim_view_whitespace_left(textview);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -85,7 +86,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_whitespace_left)
|
||||
TEST(test_trim_view_whitespace_left)
|
||||
{
|
||||
String text(STR(" \t\n\r\f\vHello World\t\n\r\f\v "));
|
||||
String expected(STR("Hello World\t\n\r\f\v "));
|
||||
@ -93,9 +94,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_whitespace_left(textview);
|
||||
StringView view = etl::trim_view_whitespace_left(textview);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -110,7 +112,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_whitespace_left_nothing_to_trim)
|
||||
TEST(test_trim_view_whitespace_left_nothing_to_trim)
|
||||
{
|
||||
String text(STR("Hello World\t\n\r\f\v "));
|
||||
String expected(STR("Hello World\t\n\r\f\v "));
|
||||
@ -118,9 +120,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_whitespace_left(textview);
|
||||
StringView view = etl::trim_view_whitespace_left(textview);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -135,7 +138,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_from_left_pointer_empty)
|
||||
TEST(test_trim_from_view_left_pointer_empty)
|
||||
{
|
||||
String text(STR(""));
|
||||
String expected(STR(""));
|
||||
@ -143,9 +146,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_from_left(textview, STR(" \t\n\r\f\v"));
|
||||
StringView view = etl::trim_from_view_left(textview, STR(" \t\n\r\f\v"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -160,7 +164,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_from_left_pointer)
|
||||
TEST(test_trim_from_view_left_pointer)
|
||||
{
|
||||
String text(STR(" \t\n\r\f\vHello World\t\n\r\f\v "));
|
||||
String expected(STR("Hello World\t\n\r\f\v "));
|
||||
@ -168,9 +172,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_from_left(textview, STR(" \t\n\r\f\v"));
|
||||
StringView view = etl::trim_from_view_left(textview, STR(" \t\n\r\f\v"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -185,7 +190,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_from_left_pointer_nothing_to_trim)
|
||||
TEST(test_trim_from_view_left_pointer_nothing_to_trim)
|
||||
{
|
||||
String text(STR("Hello World\t\n\r\f\v "));
|
||||
String expected(STR("Hello World\t\n\r\f\v "));
|
||||
@ -193,11 +198,12 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_from_left(textview, STR(" \t\n\r\f\v"));
|
||||
StringView view = etl::trim_from_view_left(textview, STR(" \t\n\r\f\v"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_from_left_pointer_length_empty)
|
||||
{
|
||||
@ -210,7 +216,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_left_pointer_delimiters)
|
||||
TEST(test_trim_left_delimiters)
|
||||
{
|
||||
String text(STR("qztfpHello Worldqztfp"));
|
||||
String expected(STR("Hello Worldqztfp"));
|
||||
@ -221,7 +227,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_left_pointer_delimiters)
|
||||
TEST(test_trim_view_left_delimiters)
|
||||
{
|
||||
String text(STR("qztfpHello Worldqztfp"));
|
||||
String expected(STR("Hello Worldqztfp"));
|
||||
@ -229,13 +235,14 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_left(textview, STR("Hel"));
|
||||
StringView view = etl::trim_view_left(textview, STR("Hel"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_left_pointer_delimiters_nothing_to_trim)
|
||||
TEST(test_trim_left_delimiters_nothing_to_trim)
|
||||
{
|
||||
String text(STR("Hello Worldqztfp"));
|
||||
String expected(STR("Hello Worldqztfp"));
|
||||
@ -246,7 +253,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_left_pointer_delimiters_nothing_to_trim)
|
||||
TEST(test_trim_view_left_delimiters_nothing_to_trim)
|
||||
{
|
||||
String text(STR("Hello Worldqztfp"));
|
||||
String expected(STR("Hello Worldqztfp"));
|
||||
@ -254,13 +261,40 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_left(textview, STR("Hel"));
|
||||
StringView view = etl::trim_view_left(textview, STR("Hel"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_left_string_delimiters)
|
||||
TEST(test_trim_left_delimiters_no_delimiters)
|
||||
{
|
||||
String text(STR("Hello Worldqztfp"));
|
||||
String expected(STR(""));
|
||||
|
||||
etl::trim_left(text, STR("XYZ"));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_view_left_delimiters_no_delimiters)
|
||||
{
|
||||
String text(STR("Hello Worldqztfp"));
|
||||
String expected(STR(""));
|
||||
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_view_left(textview, STR("XYZ"));
|
||||
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_view_left_string_delimiters)
|
||||
{
|
||||
String text(STR("qztfpHello Worldqztfp"));
|
||||
String expected(STR("Hello Worldqztfp"));
|
||||
@ -268,9 +302,11 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_left(textview, STR("Hel"));
|
||||
StringView view = etl::trim_view_left(textview, STR("Hel"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -285,7 +321,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_whitespace_right_empty)
|
||||
TEST(test_trim_view_whitespace_right_empty)
|
||||
{
|
||||
String text(STR(""));
|
||||
String expected(STR(""));
|
||||
@ -293,9 +329,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_whitespace_right(textview);
|
||||
StringView view = etl::trim_view_whitespace_right(textview);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -310,7 +347,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_whitespace_right)
|
||||
TEST(test_trim_view_whitespace_right)
|
||||
{
|
||||
String text(STR(" \t\n\r\f\vHello World\t\n\r\f\v "));
|
||||
String expected(STR(" \t\n\r\f\vHello World"));
|
||||
@ -318,9 +355,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_whitespace_right(textview);
|
||||
StringView view = etl::trim_view_whitespace_right(textview);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -335,7 +373,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_whitespace_right_nothing_to_trim)
|
||||
TEST(test_trim_view_whitespace_right_nothing_to_trim)
|
||||
{
|
||||
String text(STR(" \t\n\r\f\vHello World"));
|
||||
String expected(STR(" \t\n\r\f\vHello World"));
|
||||
@ -343,9 +381,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_whitespace_right(textview);
|
||||
StringView view = etl::trim_view_whitespace_right(textview);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -360,7 +399,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_from_right_pointer_empty)
|
||||
TEST(test_trim_from_view_right_pointer_empty)
|
||||
{
|
||||
String text(STR(""));
|
||||
String expected(STR(""));
|
||||
@ -368,9 +407,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_from_right(textview, STR(" \t\n\r\f\v"));
|
||||
StringView view = etl::trim_from_view_right(textview, STR(" \t\n\r\f\v"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -385,7 +425,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_from_right_pointer)
|
||||
TEST(test_trim_from_view_right_pointer)
|
||||
{
|
||||
String text(STR(" \t\n\r\f\vHello World\t\n\r\f\v "));
|
||||
String expected(STR(" \t\n\r\f\vHello World"));
|
||||
@ -393,9 +433,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_from_right(textview, STR(" \t\n\r\f\v"));
|
||||
StringView view = etl::trim_from_view_right(textview, STR(" \t\n\r\f\v"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -410,7 +451,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_from_right_pointer_nothing_to_trim)
|
||||
TEST(test_trim_from_view_right_pointer_nothing_to_trim)
|
||||
{
|
||||
String text(STR(" \t\n\r\f\vHello World"));
|
||||
String expected(STR(" \t\n\r\f\vHello World"));
|
||||
@ -418,13 +459,14 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_from_right(textview, STR(" \t\n\r\f\v"));
|
||||
StringView view = etl::trim_from_view_right(textview, STR(" \t\n\r\f\v"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_right_pointer_delimiters)
|
||||
TEST(test_trim_right_delimiters)
|
||||
{
|
||||
String text(STR("qztfpHello Worldqztfp"));
|
||||
String expected(STR("qztfpHello World"));
|
||||
@ -435,7 +477,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_right_pointer_delimiters)
|
||||
TEST(test_trim_view_right_delimiters)
|
||||
{
|
||||
String text(STR("qztfpHello Worldqztfp"));
|
||||
String expected(STR("qztfpHello World"));
|
||||
@ -443,13 +485,14 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_right(textview, STR("rld"));
|
||||
StringView view = etl::trim_view_right(textview, STR("rld"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_right_pointer_delimiters_nothing_to_trim)
|
||||
TEST(test_trim_right_delimiters_nothing_to_trim)
|
||||
{
|
||||
String text(STR("qztfpHello World"));
|
||||
String expected(STR("qztfpHello World"));
|
||||
@ -460,7 +503,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_right_pointer_delimiters_nothing_to_trim)
|
||||
TEST(test_trim_view_right_delimiters_nothing_to_trim)
|
||||
{
|
||||
String text(STR("qztfpHello World"));
|
||||
String expected(STR("qztfpHello World"));
|
||||
@ -468,9 +511,36 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_right(textview, STR("rld"));
|
||||
StringView view = etl::trim_view_right(textview, STR("rld"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_right_delimiters_no_delimiters)
|
||||
{
|
||||
String text(STR("qztfpHello World"));
|
||||
String expected(STR(""));
|
||||
|
||||
etl::trim_right(text, STR("XYZ"));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_view_right_delimiters_no_delimiters)
|
||||
{
|
||||
String text(STR("qztfpHello World"));
|
||||
String expected(STR(""));
|
||||
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_view_right(textview, STR("XYZ"));
|
||||
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -485,7 +555,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_whitespace_empty)
|
||||
TEST(test_trim_view_whitespace_empty)
|
||||
{
|
||||
String text(STR(""));
|
||||
String expected(STR(""));
|
||||
@ -493,9 +563,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_whitespace(textview);
|
||||
StringView view = etl::trim_view_whitespace(textview);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -510,7 +581,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_whitespace)
|
||||
TEST(test_trim_view_whitespace)
|
||||
{
|
||||
String text(STR(" \t\n\r\f\vHello World\t\n\r\f\v "));
|
||||
String expected(STR("Hello World"));
|
||||
@ -518,9 +589,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_whitespace(textview);
|
||||
StringView view = etl::trim_view_whitespace(textview);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -535,7 +607,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_whitespace_nothing_to_trim)
|
||||
TEST(test_trim_view_whitespace_nothing_to_trim)
|
||||
{
|
||||
String text(STR("Hello World"));
|
||||
String expected(STR("Hello World"));
|
||||
@ -543,9 +615,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_whitespace(textview);
|
||||
StringView view = etl::trim_view_whitespace(textview);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -560,7 +633,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_from_empty)
|
||||
TEST(test_trim_from_view_empty)
|
||||
{
|
||||
String text(STR(""));
|
||||
String expected(STR(""));
|
||||
@ -568,9 +641,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_from(textview, STR(" \t\n\r\f\v"));
|
||||
StringView view = etl::trim_from_view(textview, STR(" \t\n\r\f\v"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -585,7 +659,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_from)
|
||||
TEST(test_trim_from_view)
|
||||
{
|
||||
String text(STR(" \t\n\r\f\vHello World\t\n\r\f\v "));
|
||||
String expected(STR("Hello World"));
|
||||
@ -593,9 +667,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_from(textview, STR(" \t\n\r\f\v"));
|
||||
StringView view = etl::trim_from_view(textview, STR(" \t\n\r\f\v"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -610,7 +685,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_from_nothing_to_trim)
|
||||
TEST(test_trim_from_view_nothing_to_trim)
|
||||
{
|
||||
String text(STR("Hello World"));
|
||||
String expected(STR("Hello World"));
|
||||
@ -618,13 +693,14 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_from(textview, STR(" \t\n\r\f\v"));
|
||||
StringView view = etl::trim_from_view(textview, STR(" \t\n\r\f\v"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_pointer_delimiters)
|
||||
TEST(test_trim_delimiters)
|
||||
{
|
||||
String text(STR("qztfpHello Worldqztfp"));
|
||||
String expected(STR("Hello World"));
|
||||
@ -635,7 +711,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_pointer_delimiters)
|
||||
TEST(test_trim_view_delimiters)
|
||||
{
|
||||
String text(STR("qztfpHello Worldqztfp"));
|
||||
String expected(STR("Hello World"));
|
||||
@ -643,13 +719,14 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim(textview, STR("Hd"));
|
||||
StringView view = etl::trim_view(textview, STR("Hd"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_pointer_delimiters_nothing_to_trim)
|
||||
TEST(test_trim_delimiters_nothing_to_trim)
|
||||
{
|
||||
String text(STR("Hello World"));
|
||||
String expected(STR("Hello World"));
|
||||
@ -660,7 +737,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_view_trim_pointer_delimiters_nothing_to_trim)
|
||||
TEST(test_trim_view_delimiters_nothing_to_trim)
|
||||
{
|
||||
String text(STR("Hello World"));
|
||||
String expected(STR("Hello World"));
|
||||
@ -668,9 +745,36 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim(textview, STR("Hd"));
|
||||
StringView view = etl::trim_view(textview, STR("Hd"));
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_delimiters_no_delimiters)
|
||||
{
|
||||
String text(STR("Hello World"));
|
||||
String expected(STR(""));
|
||||
|
||||
etl::trim(text, STR("XYZ"));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_trim_view_delimiters_no_delimiters)
|
||||
{
|
||||
String text(STR("Hello World"));
|
||||
String expected(STR(""));
|
||||
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::trim_view(textview, STR("XYZ"));
|
||||
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -693,9 +797,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::right_n(textview, expected.size());
|
||||
StringView view = etl::right_n_view(textview, expected.size());
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -707,9 +812,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::right_n(textview, text.size() * 2U);
|
||||
StringView view = etl::right_n_view(textview, text.size() * 2U);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -743,9 +849,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::left_n(textview, expected.size());
|
||||
StringView view = etl::left_n_view(textview, expected.size());
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -757,9 +864,10 @@ namespace
|
||||
StringView textview(text);
|
||||
StringView expectedview(expected);
|
||||
|
||||
StringView view = etl::left_n(textview, text.size() * 2U);
|
||||
StringView view = etl::left_n_view(textview, text.size() * 2U);
|
||||
|
||||
CHECK(expectedview == view);
|
||||
CHECK_EQUAL(expectedview.size(), view.size());
|
||||
CHECK(std::equal(expectedview.begin(), expectedview.end(), view.begin()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -799,7 +907,7 @@ namespace
|
||||
{ STR(':'), STR('_') }
|
||||
};
|
||||
|
||||
etl::replace(text, etl::begin(lookup), etl::end(lookup));
|
||||
etl::replace_characters(text, etl::begin(lookup), etl::end(lookup));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
@ -819,7 +927,7 @@ namespace
|
||||
{ STR(':'), STR('_') }
|
||||
};
|
||||
|
||||
etl::replace(text, etl::begin(lookup), etl::end(lookup));
|
||||
etl::replace_characters(text, etl::begin(lookup), etl::end(lookup));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
@ -839,7 +947,7 @@ namespace
|
||||
{ STR(":"), STR(".txt") }
|
||||
};
|
||||
|
||||
etl::replace(text, etl::begin(lookup), etl::end(lookup));
|
||||
etl::replace_strings(text, etl::begin(lookup), etl::end(lookup));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
@ -859,32 +967,99 @@ namespace
|
||||
{ STR(":"), STR(".txt") }
|
||||
};
|
||||
|
||||
etl::replace(text, etl::begin(lookup), etl::end(lookup));
|
||||
etl::replace_strings(text, etl::begin(lookup), etl::end(lookup));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_get_token_pointer_delimiters)
|
||||
TEST(test_get_token_delimiters)
|
||||
{
|
||||
String text(STR(" The cat.sat, on;the:mat .,;:"));
|
||||
Vector tokens;
|
||||
|
||||
StringView textview(text);
|
||||
StringView token;
|
||||
|
||||
while (token.end() != text.end())
|
||||
{
|
||||
|
||||
do
|
||||
{
|
||||
token = etl::get_token(text, STR(" .,;:"), token);
|
||||
|
||||
if (!token.empty())
|
||||
{
|
||||
tokens.emplace_back(token.begin(), token.end());
|
||||
}
|
||||
}
|
||||
} while (!token.empty());
|
||||
|
||||
CHECK_EQUAL(6U, tokens.size());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_get_token_delimiters_nothing_to_do)
|
||||
{
|
||||
String text(STR(""));
|
||||
Vector tokens;
|
||||
|
||||
StringView textview(text);
|
||||
StringView token;
|
||||
|
||||
do
|
||||
{
|
||||
token = etl::get_token(text, STR(" .,;:"), token);
|
||||
|
||||
if (!token.empty())
|
||||
{
|
||||
tokens.emplace_back(token.begin(), token.end());
|
||||
}
|
||||
} while (!token.empty());
|
||||
|
||||
CHECK_EQUAL(0U, tokens.size());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_get_token_delimiters_no_tokens)
|
||||
{
|
||||
String text(STR(" ., ;: .,;:"));
|
||||
Vector tokens;
|
||||
|
||||
StringView textview(text);
|
||||
StringView token;
|
||||
|
||||
do
|
||||
{
|
||||
token = etl::get_token(text, STR(" .,;:"), token);
|
||||
|
||||
if (!token.empty())
|
||||
{
|
||||
tokens.emplace_back(token.begin(), token.end());
|
||||
}
|
||||
} while (!token.empty());
|
||||
|
||||
CHECK_EQUAL(0U, tokens.size());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_get_token_delimiters_no_delimiters)
|
||||
{
|
||||
String text(STR("The cat sat on the mat"));
|
||||
Vector tokens;
|
||||
|
||||
StringView textview(text);
|
||||
StringView token;
|
||||
|
||||
do
|
||||
{
|
||||
token = etl::get_token(text, STR(".,;:"), token);
|
||||
|
||||
if (!token.empty())
|
||||
{
|
||||
tokens.emplace_back(token.begin(), token.end());
|
||||
}
|
||||
} while (!token.empty());
|
||||
|
||||
CHECK_EQUAL(1U, tokens.size());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_pad_left)
|
||||
{
|
||||
@ -1107,7 +1282,7 @@ namespace
|
||||
const String text(STR("abcHello Worldabc"));
|
||||
StringView textview(text);
|
||||
|
||||
String::const_iterator itr = etl::find_first_of(textview, STR("Hel"));
|
||||
StringView::const_iterator itr = etl::find_first_of(textview, STR("Hel"));
|
||||
|
||||
CHECK_EQUAL(STR('H'), *itr);
|
||||
}
|
||||
@ -1118,9 +1293,9 @@ namespace
|
||||
const String text(STR("abcHello Worldabc"));
|
||||
StringView textview(text);
|
||||
|
||||
String::const_iterator itr = etl::find_first_of(textview, STR("xyz"));
|
||||
StringView::const_iterator itr = etl::find_first_of(textview, STR("xyz"));
|
||||
|
||||
CHECK(text.end() == itr);
|
||||
CHECK(textview.end() == itr);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -1208,7 +1383,7 @@ namespace
|
||||
const String text(STR("abcHello Worldabc"));
|
||||
StringView textview(text);
|
||||
|
||||
String::const_iterator itr = etl::find_first_not_of(textview, STR("abc"));
|
||||
StringView::const_iterator itr = etl::find_first_not_of(textview, STR("abc"));
|
||||
|
||||
CHECK_EQUAL(STR('H'), *itr);
|
||||
}
|
||||
@ -1219,9 +1394,9 @@ namespace
|
||||
const String text(STR("abcHello Worldabc"));
|
||||
StringView textview(text);
|
||||
|
||||
String::const_iterator itr = etl::find_first_not_of(textview, STR("abcHello World"));
|
||||
StringView::const_iterator itr = etl::find_first_not_of(textview, STR("abcHello World"));
|
||||
|
||||
CHECK(text.end() == itr);
|
||||
CHECK(textview.end() == itr);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -1310,7 +1485,7 @@ namespace
|
||||
String text(STR("abcHello Worldabc"));
|
||||
StringView textview(text);
|
||||
|
||||
String::const_iterator itr = etl::find_last_of(textview, STR("rld"));
|
||||
StringView::const_iterator itr = etl::find_last_of(textview, STR("rld"));
|
||||
|
||||
CHECK_EQUAL(STR('d'), *itr);
|
||||
}
|
||||
@ -1321,9 +1496,9 @@ namespace
|
||||
String text(STR("abcHello Worldabc"));
|
||||
StringView textview(text);
|
||||
|
||||
String::const_iterator itr = etl::find_last_of(textview, STR("xyz"));
|
||||
StringView::const_iterator itr = etl::find_last_of(textview, STR("xyz"));
|
||||
|
||||
CHECK(text.end() == itr);
|
||||
CHECK(textview.end() == itr);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -1412,7 +1587,7 @@ namespace
|
||||
String text(STR("abcHello Worldabc"));
|
||||
StringView textview(text);
|
||||
|
||||
String::const_iterator itr = etl::find_last_not_of(textview, STR("abc"));
|
||||
StringView::const_iterator itr = etl::find_last_not_of(textview, STR("abc"));
|
||||
|
||||
CHECK_EQUAL(STR('d'), *itr);
|
||||
}
|
||||
@ -1423,9 +1598,9 @@ namespace
|
||||
String text(STR("abcHello Worldabc"));
|
||||
StringView textview(text);
|
||||
|
||||
String::const_iterator itr = etl::find_last_not_of(textview, STR("abcHello World"));
|
||||
StringView::const_iterator itr = etl::find_last_not_of(textview, STR("abcHello World"));
|
||||
|
||||
CHECK(text.end() == itr);
|
||||
CHECK(textview.end() == itr);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -1063,7 +1063,6 @@
|
||||
<ClInclude Include="..\..\include\etl\private\crc32_poly_0x1edc6f41.h" />
|
||||
<ClInclude Include="..\..\include\etl\private\crc64_poly_0x42f0e1eba9ea3693.h" />
|
||||
<ClInclude Include="..\..\include\etl\private\crc8_poly_0x07.h" />
|
||||
<ClInclude Include="..\..\include\etl\private\string_utilities_helper.h" />
|
||||
<ClInclude Include="..\..\include\etl\private\to_string_helper.h" />
|
||||
<ClInclude Include="..\..\include\etl\profiles\armv7.h" />
|
||||
<ClInclude Include="..\..\include\etl\profiles\armv7_no_stl.h" />
|
||||
@ -1136,10 +1135,8 @@
|
||||
<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" />
|
||||
@ -1237,7 +1234,6 @@
|
||||
<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" />
|
||||
@ -1626,6 +1622,7 @@
|
||||
<ClCompile Include="..\test_state_chart.cpp" />
|
||||
<ClCompile Include="..\test_smallest.cpp" />
|
||||
<ClCompile Include="..\test_stack.cpp" />
|
||||
<ClCompile Include="..\test_string_utilities_std.cpp" />
|
||||
<ClCompile Include="..\test_string_char.cpp" />
|
||||
<ClCompile Include="..\test_string_char_external_buffer.cpp" />
|
||||
<ClCompile Include="..\test_string_stream.cpp" />
|
||||
@ -1634,6 +1631,9 @@
|
||||
<ClCompile Include="..\test_string_u32.cpp" />
|
||||
<ClCompile Include="..\test_string_u32_external_buffer.cpp" />
|
||||
<ClCompile Include="..\test_string_utilities.cpp" />
|
||||
<ClCompile Include="..\test_string_utilities_std_u16.cpp" />
|
||||
<ClCompile Include="..\test_string_utilities_std_u32.cpp" />
|
||||
<ClCompile Include="..\test_string_utilities_std_wchar_t.cpp" />
|
||||
<ClCompile Include="..\test_string_utilities_u16.cpp" />
|
||||
<ClCompile Include="..\test_string_utilities_u32.cpp" />
|
||||
<ClCompile Include="..\test_string_utilities_wchar_t.cpp" />
|
||||
|
||||
@ -873,18 +873,6 @@
|
||||
<ClInclude Include="..\..\include\etl\string_utilities.h">
|
||||
<Filter>ETL\Strings</Filter>
|
||||
</ClInclude>
|
||||
<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">
|
||||
@ -1385,6 +1373,18 @@
|
||||
<ClCompile Include="..\test_string_utilities_u32.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\test_string_utilities_std.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\test_string_utilities_std_wchar_t.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\test_string_utilities_std_u16.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\test_string_utilities_std_u32.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\library.properties">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user