21#ifndef mia_core_svector_hh
22#define mia_core_svector_hh
40std::ostream&
operator << (std::ostream& os,
const std::vector<T>& v)
56 static bool apply(
const std::string& str, T& v)
59 std::istringstream s(str);
65 while (!s.eof() && s.peek() ==
' ')
74 static bool apply(
const std::string& s, std::string& str)
83std::istream&
operator >> (std::istream& is, std::vector<T>& v)
85 std::vector<T> values;
89 while (std::getline(is, token,
',')) {
91 values.push_back(val);
93 throw create_exception<std::invalid_argument>(
"Reading vector: value, '", token,
94 "' could not be translate to ",
95 mia::__type_descr<T>::value);
99 if (!v.empty() && v.size() != values.size()) {
100 throw create_exception<std::invalid_argument>(
"Reading vector: expected ",
101 v.size(),
" values, but got ", values.size());
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
#define NS_MIA_END
conveniance define to end the mia namespace
std::ostream & operator<<(std::ostream &os, const std::vector< T > &v)
implements the direct streaming of std::vectors.
static bool apply(const std::string &s, std::string &str)
static bool apply(const std::string &str, T &v)
std::istream & operator>>(std::istream &is, std::vector< T > &v)