summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/stringutils.cpp11
-rw-r--r--src/utils/stringutils.h3
2 files changed, 14 insertions, 0 deletions
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index ffce9897e..99316ce32 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -364,3 +364,14 @@ std::string normalize(const std::string &name)
std::string normalized = name;
return toLower(trim(normalized));
}
+
+std::set<int> splitToIntSet(const std::string &text, char separator)
+{
+ std::set<int> tokens;
+ std::stringstream ss(text);
+ std::string item;
+ while(std::getline(ss, item, separator))
+ tokens.insert(atoi(item.c_str()));
+
+ return tokens;
+}
diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h
index 15d41380f..934c0f82d 100644
--- a/src/utils/stringutils.h
+++ b/src/utils/stringutils.h
@@ -25,6 +25,7 @@
#include <string>
#include <sstream>
#include <list>
+#include <set>
/**
* Trims spaces off the end and the beginning of the given string.
@@ -164,4 +165,6 @@ void replaceSpecialChars(std::string &text);
*/
std::string normalize(const std::string &name);
+std::set<int> splitToIntSet(const std::string &text, char separator);
+
#endif // UTILS_STRINGUTILS_H