mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-22 20:17:16 +01:00
Add TryParseVector to StringUtil.
Adds a nice way to have options be in a vector for results
This commit is contained in:
parent
e4e44909d5
commit
3a657fe33c
@ -75,6 +75,23 @@ static bool TryParse(const std::string &str, N *const output)
|
|||||||
return false;
|
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
|
// TODO: kill this
|
||||||
bool AsciiToHex(const std::string& _szValue, u32& result);
|
bool AsciiToHex(const std::string& _szValue, u32& result);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user