diff --git a/cl_parser/include/cpp_tools/cl_parser/tcli.hpp b/cl_parser/include/cpp_tools/cl_parser/tcli.hpp index 1c38f5a61688a9e4f585475ec46348153625fd35..653311fe653c050407f8df32eb0254358b1bbff9 100644 --- a/cl_parser/include/cpp_tools/cl_parser/tcli.hpp +++ b/cl_parser/include/cpp_tools/cl_parser/tcli.hpp @@ -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>