diff --git a/include/utils/string.hpp b/include/utils/string.hpp index abcceb9f..4b1e5737 100644 --- a/include/utils/string.hpp +++ b/include/utils/string.hpp @@ -13,19 +13,19 @@ namespace string std::string replace(std::string haystack, std::string needle, std::string replacement); std::string replace_all(std::string haystack, std::string needle, std::string replacement); - std::string squeeze(std::string haystack, const char &needle); + std::string squeeze(std::string haystack, char needle); - // std::string strip(std::string haystack, const char &needle); + // std::string strip(std::string haystack, char needle); std::string strip_trailing_newline(std::string s); - std::string trim(std::string haystack, const char &needle); - std::string ltrim(std::string haystack, const char &needle); - std::string rtrim(std::string haystack, const char &needle); + std::string trim(std::string haystack, char needle); + std::string ltrim(std::string haystack, char needle); + std::string rtrim(std::string haystack, char needle); - std::string join(const std::vector &strs, std::string delim); + std::string join(std::vector strs, std::string delim); - std::vector split(std::string s, const char &delim); - std::vector &split_into(std::string s, const char &delim, std::vector &elems); + std::vector split(std::string s, char delim); + std::vector &split_into(std::string s, char delim, std::vector &elems); std::size_t find_nth(std::string haystack, std::size_t pos, std::string needle, std::size_t nth); } diff --git a/src/utils/string.cpp b/src/utils/string.cpp index fce66eb9..aa7d9d02 100644 --- a/src/utils/string.cpp +++ b/src/utils/string.cpp @@ -37,11 +37,11 @@ namespace string return boost::replace_all_copy(haystack, needle, replacement); } - std::string squeeze(std::string haystack, const char &needle) { + std::string squeeze(std::string haystack, char needle) { return replace_all(haystack, {needle, needle}, {needle}); } - // std::string strip(std::string haystack, const char &needle) + // std::string strip(std::string haystack, char needle) // { // std::string str(haystack); // std::string::size_type pos; @@ -58,11 +58,11 @@ namespace string return str; } - std::string trim(std::string haystack, const char &needle) { + std::string trim(std::string haystack, char needle) { return rtrim(ltrim(haystack, needle), needle); } - std::string ltrim(std::string haystack, const char &needle) + std::string ltrim(std::string haystack, char needle) { std::string str(haystack); while (str[0] == needle) @@ -70,7 +70,7 @@ namespace string return str; } - std::string rtrim(std::string haystack, const char &needle) + std::string rtrim(std::string haystack, char needle) { std::string str(haystack); while (str[str.length()-1] == needle) @@ -78,7 +78,7 @@ namespace string return str; } - std::string join(const std::vector &strs, std::string delim) + std::string join(std::vector strs, std::string delim) { std::string str; for (auto &s : strs) @@ -86,13 +86,13 @@ namespace string return str; } - std::vector split(std::string s, const char &delim) + std::vector split(std::string s, char delim) { std::vector vec; return split_into(s, delim, vec); } - std::vector &split_into(std::string s, const char &delim, std::vector &container) + std::vector &split_into(std::string s, char delim, std::vector &container) { std::string str; std::stringstream buffer(s);