00001 #ifndef OST_EXPORT_HELPER_VECTOR_HH
00002 #define OST_EXPORT_HELPER_VECTOR_HH
00003
00004 # include <boost/python/def_visitor.hpp>
00005
00006
00007
00008
00009
00010 namespace ost {
00011
00012
00013 template <typename Container>
00014 class VectorAdditions :
00015 public boost::python::def_visitor<VectorAdditions<Container> > {
00016 public:
00017 template <class Class>
00018 void visit(Class& cl) const
00019 {
00020 cl
00021 .def("__str__", &to_string)
00022 ;
00023 }
00024 private:
00025 static std::string to_string(Container& cl)
00026 {
00027 std::stringstream ss;
00028 ss << "[";
00029 bool first=true;
00030 for (typename Container::const_iterator
00031 i=cl.begin(), e=cl.end(); i!=e; ++i) {
00032 if (first) {
00033 first=false;
00034 } else {
00035 ss << ", ";
00036 }
00037 ss << (*i);
00038 }
00039 ss << "]";
00040 return ss.str();
00041 }
00042 };
00043
00044 }
00045
00046 #endif