/* -*-c++-*- osgPython - Copyright (C) 2006 Miguel Escriva Gregori * * This library is open source and may be redistributed and/or modified under * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or * (at your option) any later version. The full license is in LICENSE file * included with this distribution, and on the openscenegraph.org website. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * OpenSceneGraph Public License for more details. */ #ifndef OSGPYTHON_UTILITY #define OSGPYTHON_UTILITY 1 #include #include namespace osgPython { template struct std_vector_to_list { static PyObject* convert(std::vector const& p) { typename std::vector::const_iterator it; boost::python::list l = boost::python::list(); for (it=p.begin(); it != p.end(); ++it){ l.append(*it); } return boost::python::incref(l.ptr()); } }; template struct std_vector_to_python_converter { std_vector_to_python_converter() { boost::python::to_python_converter< std::vector, std_vector_to_list >(); } }; template struct std_vector_abstract_to_list { static PyObject* convert(std::vector const& p) { typename std::vector::const_iterator it; boost::python::list l = boost::python::list(); for (it=p.begin(); it != p.end(); ++it){ l.append(T2(*it)); } return boost::python::incref(l.ptr()); } }; template struct std_vector_abstract_to_python_converter { std_vector_abstract_to_python_converter() { boost::python::to_python_converter< std::vector, std_vector_abstract_to_list >(); } }; template struct std_pair_to_tuple { static PyObject* convert(std::pair const& p) { return boost::python::incref(boost::python::make_tuple(p.first, p.second).ptr()); } }; template struct std_pair_to_python_converter { std_pair_to_python_converter() { boost::python::to_python_converter< std::pair, std_pair_to_tuple >(); } }; } //end of osgPython namespace #endif