27 #define MRPTSTL_SERIALIZABLE_SEQ_CONTAINER(CONTAINER)                          \    29     template <class T, class _Ax>                                              \    30     CArchive& operator<<(CArchive& out, const CONTAINER<T, _Ax>& obj)          \    32         out << std::string(#CONTAINER) << mrpt::typemeta::TTypeName<T>::get(); \    33         out.WriteAs<uint32_t>(obj.size());                                     \    35             obj.begin(), obj.end(),                                            \    36             metaprogramming::ObjectWriteToStream(&out));                       \    40     template <class T, class _Ax>                                              \    41     CArchive& operator>>(CArchive& in, CONTAINER<T, _Ax>& obj)                 \    44         std::string pref, stored_T;                                            \    46         if (pref != #CONTAINER)                                                \    47             THROW_EXCEPTION_FMT(                                               \    48                 "Error: serialized container %s<%s>'s preambles is wrong: "    \    50                 #CONTAINER, mrpt::typemeta::TTypeName<T>::get().c_str(),       \    54             std::string(mrpt::typemeta::TTypeName<T>::get().c_str()))          \    55             THROW_EXCEPTION_FMT(                                               \    56                 "Error: serialized container %s< %s != %s >", #CONTAINER,      \    58                 mrpt::typemeta::TTypeName<T>::get().c_str());                  \    59         const uint32_t n = in.ReadAs<uint32_t>();                              \    62             obj.begin(), obj.end(),                                            \    63             metaprogramming::ObjectReadFromStream(&in));                       \    69     typename T::value_type,
    70     std::pair<const typename T::key_type, typename T::mapped_type>>;
    73 using is_map = std::is_same<
    75            typename T::key_type, 
typename T::mapped_type,
    76            typename T::key_compare, 
typename T::allocator_type>>;
    80     T, 
typename std::multimap<
    81            typename T::key_type, 
typename T::mapped_type,
    82            typename T::key_compare, 
typename T::allocator_type>>;
    84 template <typename T, std::enable_if_t<is_map<T>::value, 
int> = 0>
    89 template <typename T, std::enable_if_t<is_multimap<T>::value, 
int> = 0>
    92     return "std::multimap";
    96 template <class T, std::enable_if_t<is_map_like<T>::value, 
int> = 0>
    99     out << containerName<T>()
   102                std::decay_t<typename T::mapped_type>>::get();
   103     out.WriteAs<uint32_t>(obj.size());
   104     for (
typename T::const_iterator it = obj.begin(); it != obj.end(); ++it)
   105         out << it->first << it->second;
   109 template <class T, std::enable_if_t<is_map_like<T>::value, 
int> = 0>
   113     std::string pref, stored_K, stored_V;
   115     if (pref != containerName<T>())
   117             "Error: serialized container %s<%s,%s>'s preamble is "   119             containerName<T>().c_str(),
   128             "Error: serialized container %s key type %s != %s",
   129             containerName<T>().c_str(), stored_K.c_str(),
   136             "Error: serialized container %s value type %s != %s",
   137             containerName<T>().c_str(), stored_V.c_str(),
   139     const uint32_t n = in.ReadAs<uint32_t>();
   140     for (uint32_t i = 0; i < n; i++)
   142         typename T::key_type key_obj;
   146         typename T::iterator it_new = obj.insert(
   147             obj.end(), std::make_pair(key_obj, 
typename T::mapped_type()));
   148         in >> it_new->second;
   153 #define MRPTSTL_SERIALIZABLE_SIMPLE_ASSOC_CONTAINER(CONTAINER)                 \   155     template <class K, class _Pr, class _Alloc>                                \   156     CArchive& operator<<(CArchive& out, const CONTAINER<K, _Pr, _Alloc>& obj)  \   158         out << std::string(#CONTAINER) << mrpt::typemeta::TTypeName<K>::get(); \   159         out.WriteAs<uint32_t>(obj.size());                                     \   160         for (typename CONTAINER<K, _Pr, _Alloc>::const_iterator it =           \   162              it != obj.end(); ++it)                                            \   167     template <class K, class _Pr, class _Alloc>                                \   168     CArchive& operator>>(CArchive& in, CONTAINER<K, _Pr, _Alloc>& obj)         \   171         std::string pref, stored_K;                                            \   173         if (pref != #CONTAINER)                                                \   174             THROW_EXCEPTION(format(                                            \   175                 "Error: serialized container %s<%s>'s preamble is wrong: "     \   177                 #CONTAINER, mrpt::typemeta::TTypeName<K>::get().c_str(),       \   181             std::string(mrpt::typemeta::TTypeName<K>::get().c_str()))          \   182             THROW_EXCEPTION(format(                                            \   183                 "Error: serialized container %s key type %s != %s",            \   184                 #CONTAINER, stored_K.c_str(),                                  \   185                 mrpt::typemeta::TTypeName<K>::get().c_str()));                 \   186         const uint32_t n = in.ReadAs<uint32_t>();                              \   187         for (uint32_t i = 0; i < n; i++)                                       \   191             obj.insert(key_obj);                                               \   204 template <
class T, 
size_t N>
   205 CArchive& operator<<(CArchive& out, const std::array<T, N>& obj)
   207     out << std::string(
"std::array") << 
static_cast<uint32_t
>(N)
   215 template <
class T, 
size_t N>
   218     std::string pref, stored_T;
   220     in >> pref >> stored_N;
   221     if (pref != 
"std::array" || stored_N != N)
   223             "Error: serialized container %s's preambles is wrong: "   230             "Error: serialized container std::array< %s != %s >",
   238 template <
class T1, 
class T2>
   239 CArchive& operator<<(CArchive& out, const std::pair<T1, T2>& obj)
   243     out << obj.first << obj.second;
   247 template <
class T1, 
class T2>
   250     std::string pref, stored_K, stored_V;
   252     if (pref != 
"std::pair")
   254             "Error: serialized std::pair<%s,%s>'s preamble is wrong: '%s'",
   260             "Error: serialized std::pair first type %s != %s", stored_K.c_str(),
   265             "Error: serialized std::pair second type %s != %s",
   267     in >> obj.first >> obj.second;
 std::string containerName()
 
#define THROW_EXCEPTION(msg)
 
std::string std::string format(std::string_view fmt, ARGS &&... args)
 
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
 
std::is_same< typename T::value_type, std::pair< const typename T::key_type, typename T::mapped_type > > is_map_like
 
#define MRPTSTL_SERIALIZABLE_SEQ_CONTAINER(CONTAINER)
 
CArchive & operator>>(CArchive &s, mrpt::aligned_std_vector< float > &a)
 
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
 
Virtual base class for "archives": classes abstracting I/O streams. 
 
mrpt::vision::TStereoCalibResults out
 
CArchive & operator<<(CArchive &s, const mrpt::aligned_std_vector< float > &a)
 
#define MRPTSTL_SERIALIZABLE_SIMPLE_ASSOC_CONTAINER(CONTAINER)
 
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)