mirror of
https://github.com/ETLCPP/etl.git
synced 2026-04-30 19:09:10 +08:00
Renamed string utility etl::transform to etl::replace
This commit is contained in:
parent
0a1b49c8f8
commit
26c595edc8
@ -273,12 +273,12 @@ namespace etl
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// transform_characters
|
||||
/// replace_characters
|
||||
//***************************************************************************
|
||||
template <typename TIString>
|
||||
void transform_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)
|
||||
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)
|
||||
{
|
||||
@ -288,12 +288,12 @@ namespace etl
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// transform_strings
|
||||
/// replace_strings
|
||||
//***************************************************************************
|
||||
template <typename TIString>
|
||||
void transform_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)
|
||||
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)
|
||||
{
|
||||
|
||||
@ -317,23 +317,23 @@ namespace etl
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// transform
|
||||
/// replace
|
||||
//***************************************************************************
|
||||
inline void transform(etl::istring& s,
|
||||
const etl::pair<etl::istring::value_type, etl::istring::value_type>* pairsbegin,
|
||||
const etl::pair<etl::istring::value_type, etl::istring::value_type>* pairsend)
|
||||
inline void replace(etl::istring& s,
|
||||
const etl::pair<etl::istring::value_type, etl::istring::value_type>* pairsbegin,
|
||||
const etl::pair<etl::istring::value_type, etl::istring::value_type>* pairsend)
|
||||
{
|
||||
etl::private_string_utilities::transform_characters<etl::istring>(s, pairsbegin, pairsend);
|
||||
etl::private_string_utilities::replace_characters<etl::istring>(s, pairsbegin, pairsend);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// transform
|
||||
/// replace
|
||||
//***************************************************************************
|
||||
inline void transform(etl::istring& s,
|
||||
const etl::pair<const etl::istring::value_type*, const etl::istring::value_type*>* pairsbegin,
|
||||
const etl::pair<const etl::istring::value_type*, const etl::istring::value_type*>* pairsend)
|
||||
inline void replace(etl::istring& s,
|
||||
const etl::pair<const etl::istring::value_type*, const etl::istring::value_type*>* pairsbegin,
|
||||
const etl::pair<const etl::istring::value_type*, const etl::istring::value_type*>* pairsend)
|
||||
{
|
||||
etl::private_string_utilities::transform_strings<etl::istring>(s, pairsbegin, pairsend);
|
||||
etl::private_string_utilities::replace_strings<etl::istring>(s, pairsbegin, pairsend);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
|
||||
@ -273,23 +273,23 @@ namespace etl
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// transform
|
||||
/// replace
|
||||
//***************************************************************************
|
||||
inline void transform(etl::iu16string& s,
|
||||
const etl::pair<etl::iu16string::value_type, etl::iu16string::value_type>* pairsbegin,
|
||||
const etl::pair<etl::iu16string::value_type, etl::iu16string::value_type>* pairsend)
|
||||
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::transform_characters<etl::iu16string>(s, pairsbegin, pairsend);
|
||||
etl::private_string_utilities::replace_characters<etl::iu16string>(s, pairsbegin, pairsend);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// transform
|
||||
/// replace
|
||||
//***************************************************************************
|
||||
inline void transform(etl::iu16string& s,
|
||||
const etl::pair<const etl::iu16string::value_type*, const etl::iu16string::value_type*>* pairsbegin,
|
||||
const etl::pair<const etl::iu16string::value_type*, const etl::iu16string::value_type*>* pairsend)
|
||||
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::transform_strings<etl::iu16string>(s, pairsbegin, pairsend);
|
||||
etl::private_string_utilities::replace_strings<etl::iu16string>(s, pairsbegin, pairsend);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
|
||||
@ -273,23 +273,23 @@ namespace etl
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// transform
|
||||
/// replace
|
||||
//***************************************************************************
|
||||
inline void transform(etl::iu32string& s,
|
||||
const etl::pair<etl::iu32string::value_type, etl::iu32string::value_type>* pairsbegin,
|
||||
const etl::pair<etl::iu32string::value_type, etl::iu32string::value_type>* pairsend)
|
||||
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::transform_characters<etl::iu32string>(s, pairsbegin, pairsend);
|
||||
etl::private_string_utilities::replace_characters<etl::iu32string>(s, pairsbegin, pairsend);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// transform
|
||||
/// replace
|
||||
//***************************************************************************
|
||||
inline void transform(etl::iu32string& s,
|
||||
const etl::pair<const etl::iu32string::value_type*, const etl::iu32string::value_type*>* pairsbegin,
|
||||
const etl::pair<const etl::iu32string::value_type*, const etl::iu32string::value_type*>* pairsend)
|
||||
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::transform_strings<etl::iu32string>(s, pairsbegin, pairsend);
|
||||
etl::private_string_utilities::replace_strings<etl::iu32string>(s, pairsbegin, pairsend);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
|
||||
@ -273,23 +273,23 @@ namespace etl
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// transform
|
||||
/// replace
|
||||
//***************************************************************************
|
||||
inline void transform(etl::iwstring& s,
|
||||
const etl::pair<etl::iwstring::value_type, etl::iwstring::value_type>* pairsbegin,
|
||||
const etl::pair<etl::iwstring::value_type, etl::iwstring::value_type>* pairsend)
|
||||
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::transform_characters<etl::iwstring>(s, pairsbegin, pairsend);
|
||||
etl::private_string_utilities::replace_characters<etl::iwstring>(s, pairsbegin, pairsend);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// transform
|
||||
/// replace
|
||||
//***************************************************************************
|
||||
inline void transform(etl::iwstring& s,
|
||||
const etl::pair<const etl::iwstring::value_type*, const etl::iwstring::value_type*>* pairsbegin,
|
||||
const etl::pair<const etl::iwstring::value_type*, const etl::iwstring::value_type*>* pairsend)
|
||||
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::transform_strings<etl::iwstring>(s, pairsbegin, pairsend);
|
||||
etl::private_string_utilities::replace_strings<etl::iwstring>(s, pairsbegin, pairsend);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
|
||||
@ -785,7 +785,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_transform_characters)
|
||||
TEST(test_replace_characters)
|
||||
{
|
||||
String text(STR("This+++is a *file//name:"));
|
||||
String expected(STR("This---is_a__-file__name_"));
|
||||
@ -799,13 +799,13 @@ namespace
|
||||
{ STR(':'), STR('_') }
|
||||
};
|
||||
|
||||
etl::transform(text, etl::begin(lookup), etl::end(lookup));
|
||||
etl::replace(text, etl::begin(lookup), etl::end(lookup));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_transform_characters_empty_string)
|
||||
TEST(test_replace_characters_empty_string)
|
||||
{
|
||||
String text(STR(""));
|
||||
String expected(STR(""));
|
||||
@ -819,13 +819,13 @@ namespace
|
||||
{ STR(':'), STR('_') }
|
||||
};
|
||||
|
||||
etl::transform(text, etl::begin(lookup), etl::end(lookup));
|
||||
etl::replace(text, etl::begin(lookup), etl::end(lookup));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_transform_strings)
|
||||
TEST(test_replace_strings)
|
||||
{
|
||||
String text(STR("This+++is a *file//name:"));
|
||||
String expected(STR("Thisxyis%20a%20%20-file_name.txt"));
|
||||
@ -839,13 +839,13 @@ namespace
|
||||
{ STR(":"), STR(".txt") }
|
||||
};
|
||||
|
||||
etl::transform(text, etl::begin(lookup), etl::end(lookup));
|
||||
etl::replace(text, etl::begin(lookup), etl::end(lookup));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_transform_strings_empty_strings)
|
||||
TEST(test_replace_strings_empty_strings)
|
||||
{
|
||||
String text(STR(""));
|
||||
String expected(STR(""));
|
||||
@ -859,7 +859,7 @@ namespace
|
||||
{ STR(":"), STR(".txt") }
|
||||
};
|
||||
|
||||
etl::transform(text, etl::begin(lookup), etl::end(lookup));
|
||||
etl::replace(text, etl::begin(lookup), etl::end(lookup));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
|
||||
@ -785,7 +785,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_transform_characters)
|
||||
TEST(test_replace_characters)
|
||||
{
|
||||
String text(STR("This+++is a *file//name:"));
|
||||
String expected(STR("This---is_a__-file__name_"));
|
||||
@ -799,13 +799,13 @@ namespace
|
||||
{ STR(':'), STR('_') }
|
||||
};
|
||||
|
||||
etl::transform(text, etl::begin(lookup), etl::end(lookup));
|
||||
etl::replace(text, etl::begin(lookup), etl::end(lookup));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_transform_characters_empty_string)
|
||||
TEST(test_replace_characters_empty_string)
|
||||
{
|
||||
String text(STR(""));
|
||||
String expected(STR(""));
|
||||
@ -819,13 +819,13 @@ namespace
|
||||
{ STR(':'), STR('_') }
|
||||
};
|
||||
|
||||
etl::transform(text, etl::begin(lookup), etl::end(lookup));
|
||||
etl::replace(text, etl::begin(lookup), etl::end(lookup));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_transform_strings)
|
||||
TEST(test_replace_strings)
|
||||
{
|
||||
String text(STR("This+++is a *file//name:"));
|
||||
String expected(STR("Thisxyis%20a%20%20-file_name.txt"));
|
||||
@ -839,13 +839,13 @@ namespace
|
||||
{ STR(":"), STR(".txt") }
|
||||
};
|
||||
|
||||
etl::transform(text, etl::begin(lookup), etl::end(lookup));
|
||||
etl::replace(text, etl::begin(lookup), etl::end(lookup));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_transform_strings_empty_strings)
|
||||
TEST(test_replace_strings_empty_strings)
|
||||
{
|
||||
String text(STR(""));
|
||||
String expected(STR(""));
|
||||
@ -859,7 +859,7 @@ namespace
|
||||
{ STR(":"), STR(".txt") }
|
||||
};
|
||||
|
||||
etl::transform(text, etl::begin(lookup), etl::end(lookup));
|
||||
etl::replace(text, etl::begin(lookup), etl::end(lookup));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
|
||||
@ -785,7 +785,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_transform_characters)
|
||||
TEST(test_replace_characters)
|
||||
{
|
||||
String text(STR("This+++is a *file//name:"));
|
||||
String expected(STR("This---is_a__-file__name_"));
|
||||
@ -799,13 +799,13 @@ namespace
|
||||
{ STR(':'), STR('_') }
|
||||
};
|
||||
|
||||
etl::transform(text, etl::begin(lookup), etl::end(lookup));
|
||||
etl::replace(text, etl::begin(lookup), etl::end(lookup));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_transform_characters_empty_string)
|
||||
TEST(test_replace_characters_empty_string)
|
||||
{
|
||||
String text(STR(""));
|
||||
String expected(STR(""));
|
||||
@ -819,13 +819,13 @@ namespace
|
||||
{ STR(':'), STR('_') }
|
||||
};
|
||||
|
||||
etl::transform(text, etl::begin(lookup), etl::end(lookup));
|
||||
etl::replace(text, etl::begin(lookup), etl::end(lookup));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_transform_strings)
|
||||
TEST(test_replace_strings)
|
||||
{
|
||||
String text(STR("This+++is a *file//name:"));
|
||||
String expected(STR("Thisxyis%20a%20%20-file_name.txt"));
|
||||
@ -839,13 +839,13 @@ namespace
|
||||
{ STR(":"), STR(".txt") }
|
||||
};
|
||||
|
||||
etl::transform(text, etl::begin(lookup), etl::end(lookup));
|
||||
etl::replace(text, etl::begin(lookup), etl::end(lookup));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_transform_strings_empty_strings)
|
||||
TEST(test_replace_strings_empty_strings)
|
||||
{
|
||||
String text(STR(""));
|
||||
String expected(STR(""));
|
||||
@ -859,7 +859,7 @@ namespace
|
||||
{ STR(":"), STR(".txt") }
|
||||
};
|
||||
|
||||
etl::transform(text, etl::begin(lookup), etl::end(lookup));
|
||||
etl::replace(text, etl::begin(lookup), etl::end(lookup));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
|
||||
@ -785,7 +785,7 @@ namespace
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_transform_characters)
|
||||
TEST(test_replace_characters)
|
||||
{
|
||||
String text(STR("This+++is a *file//name:"));
|
||||
String expected(STR("This---is_a__-file__name_"));
|
||||
@ -799,13 +799,13 @@ namespace
|
||||
{ STR(':'), STR('_') }
|
||||
};
|
||||
|
||||
etl::transform(text, etl::begin(lookup), etl::end(lookup));
|
||||
etl::replace(text, etl::begin(lookup), etl::end(lookup));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_transform_characters_empty_string)
|
||||
TEST(test_replace_characters_empty_string)
|
||||
{
|
||||
String text(STR(""));
|
||||
String expected(STR(""));
|
||||
@ -819,13 +819,13 @@ namespace
|
||||
{ STR(':'), STR('_') }
|
||||
};
|
||||
|
||||
etl::transform(text, etl::begin(lookup), etl::end(lookup));
|
||||
etl::replace(text, etl::begin(lookup), etl::end(lookup));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_transform_strings)
|
||||
TEST(test_replace_strings)
|
||||
{
|
||||
String text(STR("This+++is a *file//name:"));
|
||||
String expected(STR("Thisxyis%20a%20%20-file_name.txt"));
|
||||
@ -839,13 +839,13 @@ namespace
|
||||
{ STR(":"), STR(".txt") }
|
||||
};
|
||||
|
||||
etl::transform(text, etl::begin(lookup), etl::end(lookup));
|
||||
etl::replace(text, etl::begin(lookup), etl::end(lookup));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_transform_strings_empty_strings)
|
||||
TEST(test_replace_strings_empty_strings)
|
||||
{
|
||||
String text(STR(""));
|
||||
String expected(STR(""));
|
||||
@ -859,7 +859,7 @@ namespace
|
||||
{ STR(":"), STR(".txt") }
|
||||
};
|
||||
|
||||
etl::transform(text, etl::begin(lookup), etl::end(lookup));
|
||||
etl::replace(text, etl::begin(lookup), etl::end(lookup));
|
||||
|
||||
CHECK(expected == text);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user