Commit 8e1b595a authored by ESTERIE Pierre's avatar ESTERIE Pierre
Browse files

Add support for vector of strings

parent ac32a6e8
......@@ -24,20 +24,44 @@ namespace cpp_tools::cl_parser
template <typename ValueType>
std::istream &operator>>(std::istream &is, std::vector<ValueType> &t)
{
bool first = true;
double val;
char delimiter;
while (!is.eof())
bool first = true;
ValueType val;
char delimiter;
while(!is.eof())
{
// The first object is not delimited
first ? (first = false) : ((is >> delimiter), true);
// Get the value
is >> val;
t.emplace_back(val);
}
return is;
}
inline std::istream& operator>>(std::istream& is, std::vector<std::string>& t)
{
char val{'\0'};
std::string s;
char delimiter{','};
while(!is.eof())
{
// Get the value
is >> val;
s.push_back(val);
if(val == delimiter)
{
// The first object is not delimited
first ? (first = false) : ((is >> delimiter), true);
// Get the value
is >> val;
t.emplace_back(val);
s.erase(s.size()-1);
t.emplace_back(s);
s.clear();
}
return is;
}
/**
if(!s.empty())
{
t.emplace_back(s);
}
return is;
}
/**
>>>>>>> 105ed9b (Add support for vector of strings)
* \brief Get container size
*/
template <class C>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment