VectorConvert.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 #include <istream>
4 #include <ostream>
5 #include <vector>
6 #include <string>
7 #include <coil/stringutil.h>
8 
9 namespace std
10 {
11  template<typename T>
12  std::istream& operator>>(std::istream& is, std::vector<T>& v)
13  {
14  std::string s;
15  std::vector<std::string> sv;
16  is >> s;
17  sv = coil::split(s ,",");
18  v.resize(sv.size());
19  for (int i(0), len(sv.size()); i < len; ++i)
20  {
21  T tv;
22  if (coil::stringTo(tv, sv[i].c_str()))
23  {
24  v[i] = tv;
25  }
26  }
27  return is;
28  }
29 }
30 
bool stringTo(To &val, const char *str)
Convert the given std::string to object.
Definition: stringutil.h:597
std::istream & operator>>(std::istream &is, std::vector< T > &v)
Definition: VectorConvert.h:12
vstring split(const std::string &input, const std::string &delimiter, bool ignore_empty)
Split string by delimiter.
Definition: stringutil.cpp:346


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Mon Feb 28 2022 23:00:45