Go to the documentation of this file.
24 namespace serialization
29 #define MRPTSTL_SERIALIZABLE_SEQ_CONTAINER(CONTAINER) \
31 template <class T, class _Ax> \
32 CArchive& operator<<(CArchive& out, const CONTAINER<T, _Ax>& obj) \
34 out << std::string(#CONTAINER) << mrpt::typemeta::TTypeName<T>::get(); \
35 out << static_cast<uint32_t>(obj.size()); \
37 obj.begin(), obj.end(), \
38 metaprogramming::ObjectWriteToStream(&out)); \
42 template <class T, class _Ax> \
43 CArchive& operator>>(CArchive& in, CONTAINER<T, _Ax>& obj) \
46 std::string pref, stored_T; \
48 if (pref != #CONTAINER) \
49 THROW_EXCEPTION_FMT( \
50 "Error: serialized container %s<%s>'s preambles is wrong: " \
52 #CONTAINER, mrpt::typemeta::TTypeName<T>::get().c_str(), \
56 std::string(mrpt::typemeta::TTypeName<T>::get().c_str())) \
57 THROW_EXCEPTION_FMT( \
58 "Error: serialized container %s< %s != %s >", #CONTAINER, \
59 stored_T.c_str(), mrpt::typemeta::TTypeName<T>::get().c_str()) \
64 obj.begin(), obj.end(), \
65 metaprogramming::ObjectReadFromStream(&in)); \
69 #define MRPTSTL_SERIALIZABLE_ASSOC_CONTAINER(CONTAINER) \
71 template <class K, class V, class _Pr, class _Alloc> \
72 CArchive& operator<<( \
73 CArchive& out, const CONTAINER<K, V, _Pr, _Alloc>& obj) \
75 out << std::string(#CONTAINER) << mrpt::typemeta::TTypeName<K>::get() \
76 << mrpt::typemeta::TTypeName<V>::get(); \
77 out << static_cast<uint32_t>(obj.size()); \
78 for (typename CONTAINER<K, V, _Pr, _Alloc>::const_iterator it = \
80 it != obj.end(); ++it) \
81 out << it->first << it->second; \
85 template <class K, class V, class _Pr, class _Alloc> \
86 CArchive& operator>>(CArchive& in, CONTAINER<K, V, _Pr, _Alloc>& obj) \
89 std::string pref, stored_K, stored_V; \
91 if (pref != #CONTAINER) \
94 "Error: serialized container %s<%s,%s>'s preamble is " \
96 #CONTAINER, mrpt::typemeta::TTypeName<K>::get().c_str(), \
97 mrpt::typemeta::TTypeName<V>::get().c_str(), \
101 std::string(mrpt::typemeta::TTypeName<K>::get().c_str())) \
104 "Error: serialized container %s key type %s != %s", \
105 #CONTAINER, stored_K.c_str(), \
106 mrpt::typemeta::TTypeName<K>::get().c_str())) \
109 std::string(mrpt::typemeta::TTypeName<V>::get().c_str())) \
112 "Error: serialized container %s value type %s != %s", \
113 #CONTAINER, stored_V.c_str(), \
114 mrpt::typemeta::TTypeName<V>::get().c_str())) \
117 for (uint32_t i = 0; i < n; i++) \
123 typename CONTAINER<K, V, _Pr, _Alloc>::iterator it_new = \
124 obj.insert(obj.end(), std::make_pair(key_obj, V())); \
125 in >> it_new->second; \
130 #define MRPTSTL_SERIALIZABLE_SIMPLE_ASSOC_CONTAINER(CONTAINER) \
132 template <class K, class _Pr, class _Alloc> \
133 CArchive& operator<<(CArchive& out, const CONTAINER<K, _Pr, _Alloc>& obj) \
135 out << std::string(#CONTAINER) << mrpt::typemeta::TTypeName<K>::get(); \
136 out << static_cast<uint32_t>(obj.size()); \
137 for (typename CONTAINER<K, _Pr, _Alloc>::const_iterator it = \
139 it != obj.end(); ++it) \
144 template <class K, class _Pr, class _Alloc> \
145 CArchive& operator>>(CArchive& in, CONTAINER<K, _Pr, _Alloc>& obj) \
148 std::string pref, stored_K; \
150 if (pref != #CONTAINER) \
153 "Error: serialized container %s<%s>'s preamble is wrong: " \
155 #CONTAINER, mrpt::typemeta::TTypeName<K>::get().c_str(), \
159 std::string(mrpt::typemeta::TTypeName<K>::get().c_str())) \
162 "Error: serialized container %s key type %s != %s", \
163 #CONTAINER, stored_K.c_str(), \
164 mrpt::typemeta::TTypeName<K>::get().c_str())) \
167 for (uint32_t i = 0; i < n; i++) \
171 obj.insert(key_obj); \
187 template <class T,
size_t N>
198 template <
class T,
size_t N>
203 in >> pref >> stored_N;
204 if (pref !=
"std::array" || stored_N != N)
206 "Error: serialized container %s's preambles is wrong: "
213 "Error: serialized container std::array< %s != %s >",
221 template <
class T1,
class T2>
226 out <<
obj.first <<
obj.second;
230 template <
class T1,
class T2>
235 if (pref !=
"std::pair")
238 "Error: serialized std::pair<%s,%s>'s preamble is wrong: '%s'",
245 "Error: serialized std::pair first type %s != %s",
251 "Error: serialized std::pair second type %s != %s",
#define MRPTSTL_SERIALIZABLE_ASSOC_CONTAINER(CONTAINER)
#define MRPTSTL_SERIALIZABLE_SIMPLE_ASSOC_CONTAINER(CONTAINER)
GLsizei GLsizei GLuint * obj
#define MRPTSTL_SERIALIZABLE_SEQ_CONTAINER(CONTAINER)
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
CArchive & operator>>(CArchive &s, mrpt::aligned_std_vector< float > &a)
#define THROW_EXCEPTION(msg)
Virtual base class for "archives": classes abstracting I/O streams.
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
CArchive & operator<<(CArchive &s, const mrpt::aligned_std_vector< float > &a)
GLsizei const GLchar ** string
unsigned __int32 uint32_t
Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST | |