summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorRyan Houdek <Sonicadvance1@gmail.com>2014-07-29 11:34:57 -0500
committerRyan Houdek <Sonicadvance1@gmail.com>2014-08-12 23:45:14 -0500
commit3a657fe33c4d1bb060a3a67e00d2334c40dde541 (patch)
treeb5db1a88889a4430d116dec100cb8d996fb3da42 /Source/Core
parente4e44909d5ffa60abf81d4685a156654c463bbf9 (diff)
Add TryParseVector to StringUtil.
Adds a nice way to have options be in a vector for results
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Common/StringUtil.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/Source/Core/Common/StringUtil.h b/Source/Core/Common/StringUtil.h
index 50d270e732..8e9e9315af 100644
--- a/Source/Core/Common/StringUtil.h
+++ b/Source/Core/Common/StringUtil.h
@@ -75,6 +75,23 @@ static bool TryParse(const std::string &str, N *const output)
return false;
}
+template <typename N>
+bool TryParseVector(const std::string& str, std::vector<N>* output, const char delimiter = ',')
+{
+ output->clear();
+ std::istringstream buffer(str);
+ std::string variable;
+
+ while (std::getline(buffer, variable, delimiter))
+ {
+ N tmp = 0;
+ if (!TryParse(variable, &tmp))
+ return false;
+ output->push_back(tmp);
+ }
+ return true;
+}
+
// TODO: kill this
bool AsciiToHex(const std::string& _szValue, u32& result);