Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Pimenov <m@maps.me>2016-12-09 19:23:40 +0300
committerMaxim Pimenov <m@maps.me>2016-12-09 19:32:46 +0300
commit7a549c17c184e6d76495aa453c2a4273340c7d3a (patch)
tree6bb94951435bf5a6ed64bd8924f720f0989e274d /pyhelpers
parent018a743312312e0bcce0aaabd9bf7c7331d6af42 (diff)
A cleaner interface for bindings.
Diffstat (limited to 'pyhelpers')
-rw-r--r--pyhelpers/vector_list_conversion.hpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/pyhelpers/vector_list_conversion.hpp b/pyhelpers/vector_list_conversion.hpp
new file mode 100644
index 0000000000..44ecfa24d3
--- /dev/null
+++ b/pyhelpers/vector_list_conversion.hpp
@@ -0,0 +1,24 @@
+#pragma once
+
+#include "std/vector.hpp"
+
+#include <boost/python.hpp>
+
+namespace
+{
+using namespace boost::python;
+
+template <typename T>
+inline vector<T> python_list_to_std_vector(boost::python::object const & iterable)
+{
+ return vector<T>(boost::python::stl_input_iterator<T>(iterable),
+ boost::python::stl_input_iterator<T>());
+}
+
+template <typename T>
+boost::python::list std_vector_to_python_list(vector<T> const & v)
+{
+ boost::python::object get_iter = boost::python::iterator<vector<T>>();
+ return boost::python::list(get_iter(v));
+}
+} // namespace