common/str_list: get_str_set(), add second param for template

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
This commit is contained in:
Yehuda Sadeh 2018-07-31 17:44:47 -07:00
parent 4f47d987cd
commit 72e8e1c76e
2 changed files with 12 additions and 10 deletions

View File

@ -75,10 +75,3 @@ void get_str_set(const string& str, set<string>& str_set)
const char *delims = ";,= \t";
get_str_set(str, delims, str_set);
}
set<string> get_str_set(const string& str, const char *delims)
{
set<string> result;
get_str_set(str, delims, result);
return result;
}

View File

@ -86,13 +86,22 @@ extern void get_str_set(const std::string& str,
* @param [in] delims characters used to split **str**
* @param [out] str_list Set modified containing str after it has been split
**/
extern void get_str_set(const std::string& str,
const char *delims,
std::set<std::string>& str_list);
template<class Compare = std::less<std::string> >
void get_str_set(const std::string& str,
const char *delims,
std::set<std::string, Compare>& str_list)
{
str_list.clear();
for_each_substr(str, delims, [&str_list] (auto token) {
str_list.emplace(token.begin(), token.end());
});
}
std::set<std::string> get_str_set(const std::string& str,
const char *delims = ";,= \t");
/**
* Return a String containing the vector **v** joined with **sep**
*