21 #ifndef mia_core_svector_hh 22 #define mia_core_svector_hh 36 std::ostream& operator << (std::ostream& os, const std::vector<T>& v)
45 static bool apply(
const std::string& str, T& v){
47 std::istringstream s(str);
49 while (!s.eof() && s.peek() ==
' ')
57 static bool apply(
const std::string& s, std::string& str){
65 std::istream&
operator >> (std::istream& is, std::vector<T>& v)
67 std::vector<T> values;
71 while(std::getline(is, token,
',')) {
73 values.push_back(val);
75 throw create_exception<std::invalid_argument>(
"Reading vector: value, '", token,
76 "' could not be translate to ",
77 mia::__type_descr<T>::value);
81 if (!v.empty() && v.size() != values.size()) {
82 throw create_exception<std::invalid_argument>(
"Reading vector: expected ",
83 v.size(),
" values, but got ", values.size());
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
std::istream & operator>>(std::istream &is, std::vector< T > &v)
static bool apply(const std::string &str, T &v)
static bool apply(const std::string &s, std::string &str)
#define NS_MIA_END
conveniance define to end the mia namespace