39 #include <boost/python.hpp>
40 #include <boost/python/stl_iterator.hpp>
47 namespace py_bindings_tools
50 std::vector<T>
typeFromList(
const boost::python::object& values)
52 boost::python::stl_input_iterator<T> begin(values), end;
59 boost::python::list
listFromType(
const std::vector<T>& v)
61 boost::python::list l;
62 for (std::size_t i = 0; i <
v.size(); ++i)
68 boost::python::dict
dictFromType(
const std::map<std::string, T>& v)
70 boost::python::dict
d;
71 for (
typename std::map<std::string, T>::const_iterator it =
v.begin(); it !=
v.end(); ++it)
72 d[it->first] = it->second;
76 std::vector<double>
doubleFromList(
const boost::python::object& values)
78 return typeFromList<double>(values);
81 std::vector<std::string>
stringFromList(
const boost::python::object& values)
83 return typeFromList<std::string>(values);
88 return listFromType<double>(v);
91 boost::python::list
listFromString(
const std::vector<std::string>& v)
93 return listFromType<std::string>(v);