bindings/python/serialization/serializable.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2017-2021 CNRS INRIA
3 //
4 
5 #ifndef __pinocchio_python_serialization_serializable_hpp__
6 #define __pinocchio_python_serialization_serializable_hpp__
7 
8 #include <boost/python.hpp>
9 
10 #include "pinocchio/serialization/serializable.hpp"
12 
13 namespace pinocchio
14 {
15  namespace python
16  {
17 
18  namespace bp = boost::python;
19 
20  template<typename Derived>
22  : public bp::def_visitor< SerializableVisitor<Derived> >
23  {
24 
25  template<class PyClass>
26  void visit(PyClass& cl) const
27  {
28  cl
29  .def("saveToText",&Derived::saveToText,
30  bp::arg("filename"),"Saves *this inside a text file.")
31  .def("loadFromText",&Derived::loadFromText,
32  bp::arg("filename"),"Loads *this from a text file.")
33 
34  .def("saveToString",&Derived::saveToString,
35  bp::arg("self"),
36  "Parses the current object to a string.")
37  .def("loadFromString",&Derived::loadFromString,
38  bp::args("self","string"),
39  "Parses from the input string the content of the current object.")
40 
41  .def("saveToXML",&Derived::saveToXML,
42  bp::args("filename","tag_name"),"Saves *this inside a XML file.")
43  .def("loadFromXML",&Derived::loadFromXML,
44  bp::args("self","filename","tag_name"),"Loads *this from a XML file.")
45 
46  .def("saveToBinary",(void (Derived::*)(const std::string &) const)&Derived::saveToBinary,
47  bp::args("self","filename"),"Saves *this inside a binary file.")
48  .def("loadFromBinary",(void (Derived::*)(const std::string &))&Derived::loadFromBinary,
49  bp::args("self","filename"),"Loads *this from a binary file.")
50 
51  .def("saveToBinary",(void (Derived::*)(boost::asio::streambuf &) const)&Derived::saveToBinary,
52  bp::args("self","buffer"),"Saves *this inside a binary buffer.")
53  .def("loadFromBinary",(void (Derived::*)(boost::asio::streambuf &))&Derived::loadFromBinary,
54  bp::args("self","buffer"),"Loads *this from a binary buffer.")
55 
56  .def("saveToBinary",(void (Derived::*)(serialization::StaticBuffer &) const)&Derived::saveToBinary,
57  bp::args("self","buffer"),"Saves *this inside a static binary buffer.")
58  .def("loadFromBinary",(void (Derived::*)(serialization::StaticBuffer &))&Derived::loadFromBinary,
59  bp::args("self","buffer"),"Loads *this from a static binary buffer.")
60  ;
61 
62  serialize<Derived>();
63  }
64 
65  };
66  }
67 }
68 
69 #endif // ifndef __pinocchio_python_serialization_serializable_hpp__
void loadFromXML(T &object, const std::string &filename, const std::string &tag_name)
Loads an object from a XML file.
Definition: archive.hpp:179
std::string saveToString(const T &object)
Saves an object inside a std::string.
Definition: archive.hpp:162
void saveToText(const T &object, const std::string &filename)
Saves an object inside a TXT file.
Definition: archive.hpp:88
Static buffer with pre-allocated memory.
void loadFromText(T &object, const std::string &filename)
Loads an object from a TXT file.
Definition: archive.hpp:61
void loadFromString(T &object, const std::string &str)
Loads an object from a std::string.
Definition: archive.hpp:145
Main pinocchio namespace.
Definition: timings.cpp:28
void saveToXML(const T &object, const std::string &filename, const std::string &tag_name)
Saves an object inside a XML file.
Definition: archive.hpp:210


pinocchio
Author(s):
autogenerated on Fri Jun 23 2023 02:38:32