14 #ifndef ESYS_LSM_BPULISTCONVERTER_H
15 #define ESYS_LSM_BPULISTCONVERTER_H
17 #include <boost/python.hpp>
29 template <
typename TmplValueType>
35 value_type
operator()(
const boost::python::object &pyObject)
const
37 return boost::python::extract<value_type>(pyObject);
41 template<
typename TmplValue>
42 std::vector<TmplValue>
listToVector(
const boost::python::list &pythonList)
45 std::vector<TmplValue> vec;
47 vec.reserve(numElements);
48 for (
int i = 0; i < numElements; i++)
50 vec.push_back(extractor(pythonList[i]));
55 template<
typename TmplValue>
56 std::vector<TmplValue>
tupleToVector(
const boost::python::tuple &pythonTulple)
59 std::vector<TmplValue> vec;
61 vec.reserve(numElements);
62 for (
int i = 0; i < numElements; i++)
64 vec.push_back(extractor(pythonTulple[i]));
69 template<
typename TmplValue,
typename TmplExtractor>
70 std::vector<TmplValue>
listToVector(
const boost::python::list &pythonList, TmplExtractor extractor=TmplExtractor())
72 std::vector<TmplValue> vec;
74 vec.reserve(numElements);
75 for (
int i = 0; i < numElements; i++)
77 vec.push_back(extractor(pythonList[i]));
82 template <
typename TmplVector>
85 boost::python::list pythonList;
87 typename TmplVector::const_iterator it = vec.begin();
92 pythonList.append(*it);
std::vector< TmplValue > listToVector(const boost::python::list &pythonList)
Definition: ListConverter.h:42
Definition: CheckPointable.cpp:16
boost::python::list vectorToList(const TmplVector &vec)
Definition: ListConverter.h:83
std::vector< TmplValue > tupleToVector(const boost::python::tuple &pythonTulple)
Definition: ListConverter.h:56
int len(const boost::python::object &pyOb)
Definition: Util.h:30