Skip to content
Snippets Groups Projects
Commit 41bcc808 authored by Fabian Tërnava's avatar Fabian Tërnava
Browse files

fixed string templates for to_vec, added str function replace_last

parent 5bf002f7
No related branches found
No related tags found
No related merge requests found
......@@ -68,7 +68,7 @@ namespace simox::alg {
return help::to_<T>(s, help::type<T>{}, locale, trim);
}
template<typename T, typename std::enable_if<!std::is_integral<T>::value>::type* = nullptr>
template<typename T, typename std::enable_if<std::is_fundamental<T>::value>::type* = nullptr>
inline std::vector<T> to_vec(const std::vector<std::string>& vec, std::locale locale = DEFAULT_LOCALE, bool trimElements = false)
{
std::vector<T> res;
......@@ -79,14 +79,14 @@ namespace simox::alg {
return res;
}
template<typename T, typename std::enable_if<!std::is_integral<T>::value>::type* = nullptr>
template<typename T, typename std::enable_if<std::is_fundamental<T>::value>::type* = nullptr>
inline std::vector<T> to_vec(const std::string& str, const std::string& splitBy = "\t ", bool trimElements = true,
bool ignoreEmptyElements = true, std::locale locale = DEFAULT_LOCALE)
{
return to_vec<T>(split(str, splitBy, trimElements, ignoreEmptyElements, locale), locale, false);
}
template<typename T, typename std::enable_if<!std::is_integral<T>::value>::type* = nullptr>
template<typename T, typename std::enable_if<std::is_fundamental<T>::value>::type* = nullptr>
inline std::vector<T> to_vec_check_size(const std::string& str, unsigned int expectedSize, const std::string& splitBy = "\t ",
bool trimElements = true, bool ignoreEmptyElements = true, std::locale locale = DEFAULT_LOCALE)
{
......
......@@ -97,6 +97,11 @@ std::string replace_first(const std::string& input, const std::string& search, c
return boost::algorithm::replace_first_copy(input, search, replace);
}
std::string replace_last(const std::string& input, const std::string& search, const std::string& replace)
{
return boost::algorithm::replace_last_copy(input, search, replace);
}
bool starts_with(const std::string& input, const std::string& search)
{
return boost::starts_with(input, search);
......
......@@ -56,6 +56,8 @@ namespace simox::alg
std::string replace_first(std::string const& input, std::string const& search, std::string const& replace);
std::string replace_last(std::string const& input, std::string const& search, std::string const& replace);
std::string replace_all(std::string const& input, std::string const& search, std::string const& replace);
bool starts_with(std::string const& input, std::string const& search);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment