Verified Commit c44157e6 authored by Justin Carpentier's avatar Justin Carpentier
Browse files

python: expose new StaticBuffer and related functions

parent 6e9c4c59
Pipeline #14089 passed with stage
in 105 minutes and 10 seconds
......@@ -52,6 +52,11 @@ namespace pinocchio
bp::args("self","buffer"),"Saves *this inside a binary buffer.")
.def("loadFromBinary",(void (Derived::*)(boost::asio::streambuf &))&Derived::loadFromBinary,
bp::args("self","buffer"),"Loads *this from a binary buffer.")
.def("saveToBinary",(void (Derived::*)(serialization::StaticBuffer &) const)&Derived::saveToBinary,
bp::args("self","buffer"),"Saves *this inside a static binary buffer.")
.def("loadFromBinary",(void (Derived::*)(serialization::StaticBuffer &))&Derived::loadFromBinary,
bp::args("self","buffer"),"Loads *this from a static binary buffer.")
;
serialize<Derived>();
......
......@@ -41,6 +41,16 @@ namespace pinocchio
.def("prepare",prepare_proxy,"Reserve data.",bp::return_internal_reference<>())
;
typedef pinocchio::serialization::StaticBuffer StaticBuffer;
bp::class_<StaticBuffer>("StaticBuffer",
"Static buffer to save/load serialized objects in binary mode with pre-allocated memory.",
bp::init<size_t>(bp::args("self","size"),"Default constructor from a given size capacity."))
.def("size",&StaticBuffer::size,bp::arg("self"),
"Get the size of the input sequence.")
.def("reserve",&StaticBuffer::resize,bp::arg("new_size"),
"Increase the capacity of the vector to a value that's greater or equal to new_size.")
;
bp::def("buffer_copy",buffer_copy,
bp::args("dest","source"),
"Copy bytes from a source buffer to a target buffer.");
......
......@@ -25,12 +25,20 @@ namespace pinocchio
bp::scope current_scope = getOrCreatePythonNamespace("serialization");
bp::def("loadFromBinary",(void (*)(T &, boost::asio::streambuf &))pinocchio::serialization::loadFromBinary<T>,
bp::args("object","buffer"),
bp::args("object","stream_buffer"),
"Load an object from a binary buffer.");
bp::def("saveToBinary",(void (*)(const T &, boost::asio::streambuf &))pinocchio::serialization::saveToBinary<T>,
bp::args("object","buffer"),
bp::args("object","stream_buffer"),
"Save an object to a binary buffer.");
bp::def("loadFromBinary",(void (*)(T &, serialization::StaticBuffer &))pinocchio::serialization::loadFromBinary<T>,
bp::args("object","static_buffer"),
"Load an object from a static binary buffer.");
bp::def("saveToBinary",(void (*)(const T &, serialization::StaticBuffer &))pinocchio::serialization::saveToBinary<T>,
bp::args("object","static_buffer"),
"Save an object to a static binary buffer.");
}
} // namespace python
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment