Skip to content
Snippets Groups Projects
Commit 9d6b2672 authored by Jorrit Fahlke's avatar Jorrit Fahlke
Browse files

[ConfigParser] Allow get of a std::vector.

[[Imported from SVN: r6029]]
parent 7164aeb5
Branches
Tags
No related merge requests found
......@@ -383,6 +383,30 @@ namespace Dune {
}
};
template<typename T, typename A>
struct ConfigParser::Parser<std::vector<T, A> > {
static std::vector<T, A>
parse(const std::string& str) {
std::vector<T, A> vec;
std::istringstream s(str);
while(true) {
T val;
s >> val;
if(s.fail()) {
if(s.eof())
// extraction failed because of EOF, that OK
break;
// otherwise, it failed because of something else
DUNE_THROW(RangeError, "Cannot parse value \"" << str << "\" as a "
"std::vector<" << typeid(T).name() << ", " <<
typeid(A).name() << ">");
}
vec.push_back(val);
}
return vec;
}
};
} // end namespace Dune
#endif // DUNE_CONFIGPARSER_HH
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment