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 template<typename T>
10 std::istream& operator>>(std::istream& is, std::vector<T>& v)
11 {
12  std::string s;
13  std::vector<std::string> sv;
14  is >> s;
15  sv = coil::split(s ,",");
16  v.resize(sv.size());
17  for (int i(0), len(sv.size()); i < len; ++i)
18  {
19  T tv;
20  if (coil::stringTo(tv, sv[i].c_str()))
21  {
22  v[i] = tv;
23  }
24  }
25  return is;
26 }
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:10
vstring split(const std::string &input, const std::string &delimiter, bool ignore_empty)
Split string by delimiter.
Definition: stringutil.cpp:341


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Mon Jun 10 2019 14:07:56