MRPT
1.9.9
|
Serialization (marshalling) portable library for C++ objects persistence.
[New in MRPT 2.0.0]
This library is part of MRPT and can be installed in Debian-based systems with:
sudo apt install libmrpt-serialization-dev
See: Using MRPT from your CMake project
Main classes and concepts associated with this library:
Serialization happens via archive << object
operators in all cases but, underneath, two mechanisms are provided:
<<
/>>
operators for mrpt::serialization::CArchive objects.Support for STL containers is provided via this "direct mechanism" for the container structure itself, but contained elements can use any of the serialization mechanisms.
Serializing shared_ptr<T>
is supported for any arbitrary type T
. It is legal to serialize an empty (nullptr
) smart pointer; an empty pointer will be read back. Polymorphic classes can be also writen and read, although reading a smart pointer to a polymorphic base class is only supported for classes derived from MRPT's CSerializable, since that operation requires registering types in a class factory (see mrpt_rtti_grp and mrpt::serialization::CSerializable).
See: serialization_stl/test.cpp
Output:
See: serialization_stl/test.cpp
Output:
Write me!
Write me!
An alternative mechanism to serialize objects is based on mrpt::serialization::CSchemeArchive and allow objects to be (de)serialized in plain text formats like XML, JSON, YAML, etc. For now (Aug 2018) only JSON is implemented.
This method only requires having MRPT built against jsoncpp, but does not enforce the user to also depend on that library.
See: serialization_json_example/test.cpp
Output:
If you want to have full control on the JSON formatting and other details, you may directly depend on jsoncpp and use the following, template-based access to MRPT serialization:
See: serialization_json_example/test.cpp
Classes | |
class | mrpt::serialization::CArchive |
Virtual base class for "archives": classes abstracting I/O streams. More... | |
class | mrpt::serialization::CMessage |
A class that contain generic messages, that can be sent and received from a "CClientTCPSocket" object. More... | |
class | mrpt::serialization::CSchemeArchive< SCHEME_CAPABLE > |
Base template class for schema-capable "archives", e.g. More... | |
class | mrpt::serialization::CSchemeArchiveBase_impl |
Pure virtual class carrying the implementation of CSchemeArchiveBase as per the PIMPL idiom. More... | |
class | mrpt::serialization::CSchemeArchiveBase |
Virtual base class for "schematic archives" (JSON, XML,...) More... | |
class | mrpt::serialization::CSerializable |
The virtual base class which provides a unified interface for all persistent objects in MRPT. More... | |
Modules | |
Non-CStream serialization functions (in | |
#include <mrpt/serializatin/CSerializable.h>) | |
Functions | |
CSchemeArchiveBase | mrpt::serialization::archiveJSON () |
Returns an archive for reading/writing in JSON format. More... | |
CSchemeArchiveBase mrpt::serialization::archiveJSON | ( | ) |
Returns an archive for reading/writing in JSON format.
This feature requires compiling MRPT with jsoncpp support. See [mrpt-serialization] for examples of use.
Definition at line 23 of file CSchemeArchive.cpp.
References THROW_EXCEPTION.
Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: c7a3bec24 Sun Mar 29 18:33:13 2020 +0200 at dom mar 29 18:50:38 CEST 2020 |