28 #define MRPTSTL_SERIALIZABLE_SEQ_CONTAINER( CONTAINER ) \ 30 template <class T,class _Ax> \ 31 CStream& operator << (mrpt::utils::CStream& out, const CONTAINER<T,_Ax> &obj) \ 33 out << std::string(#CONTAINER) << mrpt::utils::TTypeName<T>::get(); \ 34 out << static_cast<uint32_t>(obj.size()); \ 35 std::for_each( obj.begin(), obj.end(), mrpt::utils::metaprogramming::ObjectWriteToStream(&out) ); \ 39 template <class T,class _Ax> \ 40 CStream& operator >> (mrpt::utils::CStream& in, CONTAINER<T,_Ax> &obj) \ 43 std::string pref,stored_T; \ 45 if (pref!=#CONTAINER) THROW_EXCEPTION_FMT("Error: serialized container %s<%s>'s preambles is wrong: '%s'",#CONTAINER,TTypeName<T>::get().c_str(),pref.c_str() ) \ 47 if (stored_T != mrpt::utils::TTypeName<T>::get() ) THROW_EXCEPTION_FMT("Error: serialized container %s< %s != %s >",#CONTAINER,stored_T.c_str(),TTypeName<T>::get().c_str() ) \ 51 std::for_each( obj.begin(), obj.end(), mrpt::utils::metaprogramming::ObjectReadFromStream(&in) ); \ 56 #define MRPTSTL_SERIALIZABLE_ASSOC_CONTAINER( CONTAINER ) \ 58 template <class K,class V, class _Pr, class _Alloc> \ 59 CStream& operator << (mrpt::utils::CStream& out, const CONTAINER<K,V,_Pr,_Alloc> &obj) \ 61 out << std::string(#CONTAINER) << TTypeName<K>::get() << TTypeName<V>::get(); \ 62 out << static_cast<uint32_t>(obj.size()); \ 63 for (typename CONTAINER<K,V,_Pr,_Alloc>::const_iterator it=obj.begin();it!=obj.end();++it) \ 64 out << it->first << it->second; \ 68 template <class K,class V, class _Pr, class _Alloc> \ 69 CStream& operator >> (mrpt::utils::CStream& in, CONTAINER<K,V,_Pr,_Alloc> &obj) \ 72 std::string pref,stored_K,stored_V; \ 74 if (pref!=#CONTAINER) THROW_EXCEPTION(format("Error: serialized container %s<%s,%s>'s preamble is wrong: '%s'",#CONTAINER, TTypeName<K>::get().c_str(), TTypeName<V>::get().c_str() ,pref.c_str())) \ 76 if (stored_K != TTypeName<K>::get()) THROW_EXCEPTION(format("Error: serialized container %s key type %s != %s",#CONTAINER,stored_K.c_str(), TTypeName<K>::get().c_str())) \ 78 if (stored_V != TTypeName<V>::get()) THROW_EXCEPTION(format("Error: serialized container %s value type %s != %s",#CONTAINER,stored_V.c_str(), TTypeName<V>::get().c_str())) \ 81 for (uint32_t i=0;i<n;i++) \ 86 typename CONTAINER<K,V,_Pr,_Alloc>::iterator it_new = obj.insert(obj.end(), std::make_pair(key_obj, V()) ); \ 87 in >> it_new->second; \ 100 #define MRPTSTL_SERIALIZABLE_SIMPLE_ASSOC_CONTAINER( CONTAINER ) \ 102 template <class K,class _Pr,class _Alloc> \ 103 CStream& operator << (mrpt::utils::CStream& out, const CONTAINER<K,_Pr,_Alloc> &obj) \ 105 out << std::string(#CONTAINER) << TTypeName<K>::get(); \ 106 out << static_cast<uint32_t>(obj.size()); \ 107 for (typename CONTAINER<K,_Pr,_Alloc>::const_iterator it=obj.begin();it!=obj.end();++it) \ 112 template <class K,class _Pr,class _Alloc> \ 113 CStream& operator >> (mrpt::utils::CStream& in, CONTAINER<K,_Pr,_Alloc> &obj) \ 116 std::string pref,stored_K; \ 118 if (pref!=#CONTAINER) THROW_EXCEPTION(format("Error: serialized container %s<%s>'s preamble is wrong: '%s'",#CONTAINER, TTypeName<K>::get().c_str(),pref.c_str())) \ 120 if (stored_K != TTypeName<K>::get()) THROW_EXCEPTION(format("Error: serialized container %s key type %s != %s",#CONTAINER,stored_K.c_str(), TTypeName<K>::get().c_str())) \ 123 for (uint32_t i=0;i<n;i++) \ 127 obj.insert(key_obj); \ 137 template <
class T1,
class T2>
138 CStream& operator << (mrpt::utils::CStream& out, const std::pair<T1,T2> &
obj)
141 out <<
obj.first <<
obj.second;
145 template <
class T1,
class T2>
A template to obtain the type of its argument as a string at compile time.
#define THROW_EXCEPTION(msg)
#define MRPTSTL_SERIALIZABLE_SIMPLE_ASSOC_CONTAINER(CONTAINER)
GLsizei GLsizei GLuint * obj
::mrpt::utils::CStream & operator>>(mrpt::utils::CStream &in, CImagePtr &pObj)
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
GLsizei const GLchar ** string
MRPTSTL_SERIALIZABLE_SEQ_CONTAINER(std::vector) MRPTSTL_SERIALIZABLE_SEQ_CONTAINER(std
Template method to serialize a STL pair.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define MRPTSTL_SERIALIZABLE_ASSOC_CONTAINER(CONTAINER)