namespace mrpt::serialization

Overview

namespace serialization {

// namespaces

namespace mrpt::serialization::detail;
namespace mrpt::serialization::internal;
namespace mrpt::serialization::metaprogramming;

// typedefs

typedef std::disjunction<std::is_same<T, Ts>...> is_any;
typedef is_any<T, bool, uint8_t, int8_t, uint16_t, int16_t, uint32_t, int32_t, uint64_t, int64_t, float, double, long double> is_simple_type;
typedef std::is_same<typename T::value_type, std::pair<const typename T::key_type, typename T::mapped_type>> is_map_like;
typedef std::is_same<T, typename std::map<typename T::key_type, typename T::mapped_type, typename T::key_compare, typename T::allocator_type>> is_map;
typedef std::is_same<T, typename std::multimap<typename T::key_type, typename T::mapped_type, typename T::key_compare, typename T::allocator_type>> is_multimap;

// classes

class CArchive;

template <>
class CArchiveStreamBase<const std::vector<uint8_t>>;

template <class STREAM>
class CArchiveStreamBase;

template <>
class CArchiveStreamBase<std::vector<uint8_t>>;

template <>
class CArchiveStreamBase<std::istream>;

template <>
class CArchiveStreamBase<std::ostream>;

template <>
class CArchiveStreamBase<std::iostream>;

class CExceptionEOF;
class CMessage;

template <typename SCHEME_CAPABLE>
class CSchemeArchive;

class CSchemeArchiveBase;
class CSchemeArchiveBase_impl;
class CSerializable;

// global functions

CArchive& operator >> (
    CArchive& s,
    mrpt::aligned_std_vector<float>& a
    );

CArchive& operator << (
    CArchive& s,
    const mrpt::aligned_std_vector<float>& a
    );

CArchive& operator >> (
    CArchive& s,
    std::vector<float>& a
    );

CArchive& operator << (
    CArchive& s,
    const std::vector<float>& a
    );

template <typename KEY, typename VALUE>
CArchive& operator << (CArchive& out, const mrpt::containers::bimap<KEY, VALUE>& obj);

template <typename KEY, typename VALUE>
CArchive& operator >> (CArchive& in, mrpt::containers::bimap<KEY, VALUE>& obj);

template <typename T, std::enable_if_t<is_simple_type<T>::value, int> = 0>
CArchive& operator << (
    CArchive& out,
    const T& a
    );

template <typename T, std::enable_if_t<is_simple_type<T>::value, int> = 0>
CArchive& operator >> (
    CArchive& in,
    T& a
    );

CArchive& operator << (
    CArchive& out,
    const mrpt::Clock::time_point& a
    );

CArchive& operator >> (
    CArchive& in,
    mrpt::Clock::time_point& a
    );

CArchive& operator << (
    CArchive& s,
    const std::string& str
    );

CArchive& operator << (
    CArchive& s,
    const std::vector<int32_t>& a
    );

CArchive& operator << (
    CArchive& s,
    const std::vector<uint32_t>& a
    );

CArchive& operator << (
    CArchive& s,
    const std::vector<uint16_t>& a
    );

CArchive& operator << (
    CArchive& s,
    const std::vector<int16_t>& a
    );

CArchive& operator << (
    CArchive& s,
    const std::vector<int64_t>& a
    );

CArchive& operator << (
    CArchive& s,
    const std::vector<uint8_t>& a
    );

CArchive& operator << (
    CArchive& s,
    const std::vector<int8_t>& a
    );

CArchive& operator << (
    CArchive& out,
    const std::vector<bool>& a
    );

CArchive& operator << (
    CArchive& s,
    const std::vector<std::string>& vec
    );

CArchive& operator << (
    CArchive& s,
    const std::vector<size_t>& a
    );

CArchive& operator >> (
    CArchive& in,
    std::string& str
    );

CArchive& operator >> (
    CArchive& in,
    std::vector<int32_t>& a
    );

CArchive& operator >> (
    CArchive& in,
    std::vector<uint32_t>& a
    );

CArchive& operator >> (
    CArchive& in,
    std::vector<uint16_t>& a
    );

CArchive& operator >> (
    CArchive& in,
    std::vector<int16_t>& a
    );

CArchive& operator >> (
    CArchive& in,
    std::vector<int64_t>& a
    );

CArchive& operator >> (
    CArchive& in,
    std::vector<uint8_t>& a
    );

CArchive& operator >> (
    CArchive& in,
    std::vector<int8_t>& a
    );

CArchive& operator >> (
    CArchive& in,
    std::vector<bool>& a
    );

CArchive& operator >> (
    CArchive& in,
    std::vector<std::string>& a
    );

CArchive& operator >> (
    CArchive& s,
    std::vector<double>& a
    );

CArchive& operator << (
    CArchive& s,
    const std::vector<double>& a
    );

CArchive& operator >> (
    CArchive& s,
    std::vector<size_t>& a
    );

template <
    typename T,
    std::enable_if_t<std::is_base_of_v<mrpt::serialization::CSerializable, T>>* = nullptr
    >
CArchive& operator >> (
    CArchive& in,
    typename std::shared_ptr<T>& pObj
    );

template <typename... T>
CArchive& operator >> (
    CArchive& in,
    typename std::variant<T...>& pObj
    );

template <typename... T>
CArchive& operator << (
    CArchive& out,
    const typename std::variant<T...>& pObj
    );

template <
    class T,
    std::enable_if_t<!std::is_base_of_v<mrpt::serialization::CSerializable, T>>* = nullptr
    >
CArchive& operator << (
    CArchive& out,
    const std::shared_ptr<T>& pObj
    );

template <class ENUM_TYPE, std::enable_if_t<std::is_enum_v<ENUM_TYPE>>* = nullptr>
CArchive& operator << (
    CArchive& out,
    const ENUM_TYPE& pEnum
    );

template <class ENUM_TYPE, std::enable_if_t<std::is_enum_v<ENUM_TYPE>>* = nullptr>
CArchive& operator >> (
    CArchive& in,
    ENUM_TYPE& pEnum
    );

template <class STREAM>
CArchiveStreamBase<STREAM> archiveFrom(STREAM& s);

template <class STREAM>
CArchive::Ptr archivePtrFrom(STREAM& s);

template <class STREAM>
CArchive::UniquePtr archiveUniquePtrFrom(STREAM& s);

CSchemeArchiveBase archiveJSON();

std::ostream& operator << (
    std::ostream& out,
    const CSchemeArchiveBase& a
    );

std::istream& operator >> (
    std::istream& in,
    CSchemeArchiveBase& a
    );

void ObjectToOctetVector(const CSerializable* o, std::vector<uint8_t>& out_vector);
void OctetVectorToObject(const std::vector<uint8_t>& in_data, CSerializable::Ptr& obj);

template <class T>
CArchive& operator << (CArchive& out, const std::optional<T>& obj);

template <class T>
CArchive& operator >> (CArchive& in, std::optional<T>& obj);

void registerAllClasses_mrpt_serialization();

template <typename T, std::enable_if_t<is_map<T>::value, int> = 0>
std::string containerName();

template <class T, size_t N>
CArchive& operator << (CArchive& out, const std::array<T, N>& obj);

template <class T, size_t N>
CArchive& operator >> (CArchive& in, std::array<T, N>& obj);

template <class T1, class T2>
CArchive& operator << (CArchive& out, const std::pair<T1, T2>& obj);

template <class T1, class T2>
CArchive& operator >> (CArchive& in, std::pair<T1, T2>& obj);

template <typename ZMQ_SOCKET_TYPE>
void mrpt_send_to_zmq(
    ZMQ_SOCKET_TYPE zmq_socket,
    const mrpt::serialization::CSerializable& obj,
    const size_t max_packet_len = 0
    );

template <typename ZMQ_SOCKET_TYPE, typename VECTOR_MSG_T>
bool mrpt_recv_from_zmq_buf(
    ZMQ_SOCKET_TYPE zmq_socket,
    VECTOR_MSG_T& out_lst_msgs,
    mrpt::io::CMemoryStream& target_buf,
    bool dont_wait,
    size_t* rx_obj_length_in_bytes
    );

template <typename ZMQ_SOCKET_TYPE>
mrpt::serialization::CSerializable::Ptr mrpt_recv_from_zmq(
    ZMQ_SOCKET_TYPE zmq_socket,
    bool dont_wait = false,
    size_t* rx_obj_length_in_bytes = nullptr
    );

template <typename ZMQ_SOCKET_TYPE>
bool mrpt_recv_from_zmq_into(
    ZMQ_SOCKET_TYPE zmq_socket,
    mrpt::serialization::CSerializable& target_object,
    bool dont_wait = false,
    size_t* rx_obj_length_in_bytes = nullptr
    );

} // namespace serialization

Global Functions

template <
    typename T,
    std::enable_if_t<std::is_base_of_v<mrpt::serialization::CSerializable, T>>* = nullptr
    >
CArchive& operator >> (
    CArchive& in,
    typename std::shared_ptr<T>& pObj
    )

Read a smart pointer to a non-CSerializable (POD,…) data type.

template <
    class T,
    std::enable_if_t<!std::is_base_of_v<mrpt::serialization::CSerializable, T>>* = nullptr
    >
CArchive& operator << (
    CArchive& out,
    const std::shared_ptr<T>& pObj
    )

Write a shared_ptr to a non-CSerializable object.

template <class STREAM>
CArchiveStreamBase<STREAM> archiveFrom(STREAM& s)

Helper function to create a templatized wrapper CArchive object for a: MRPT’s CStream, std::istream, std::ostream, std::stringstream.

Use with std::{.*}stream requires including <mrpt/serialization/archiveFrom_std_streams.h> and explicitly specifying the template parameter like: archiveFrom<std::istream> or archiveFrom<std::ostream>.

See also:

[mrpt-serialization], and example serialization_stl/test.cpp

template <class STREAM>
CArchive::Ptr archivePtrFrom(STREAM& s)

Like archiveFrom(), returning a shared_ptr<>.

template <class STREAM>
CArchive::UniquePtr archiveUniquePtrFrom(STREAM& s)

Like archiveFrom(), returning a unique_ptr<>.