25 #ifndef __PersistSTL__ 26 #define __PersistSTL__ 28 #include "IPMStream.h" 46 template <
typename _T1,
typename _T2>
49 inline static void Read (
IPMStream* stream, std::pair<_T1, _T2>& p)
57 inline static void Write (
IPMStream* stream,
const std::pair<_T1, _T2>& p)
84 stream->
XferByte ((uchar*)buf, size);
98 int32 size = (int32)str.size();
102 const char* buf = &str[0];
103 stream->
XferByte ((uchar*)buf, size);
109 template <
typename T>
112 inline static void Read (
IPMStream* stream, std::vector<T>& v)
122 for (
typename std::vector<T>::iterator i = v.begin(); i != v.end(); ++i)
128 inline static void Write (
IPMStream* stream,
const std::vector<T>& v)
132 const int32 size =
static_cast<int32
>(v.size());
135 for (
typename std::vector<T>::const_iterator i = v.begin(); i != v.end(); ++i)
145 template <
typename _KeyType,
typename _DataType>
148 inline static void Read (
IPMStream* stream, std::map<_KeyType, _DataType>& m)
165 const bool unique = m.insert (std::pair<const _KeyType, _DataType> (key, data)).second;
166 ASSERT_MSG (unique,
"Duplicate key found while deserializing a map.");
170 inline static void Write (
IPMStream* stream,
const std::map<_KeyType, _DataType>& m)
174 const int32 size = (int32)m.size();
177 for (
typename std::map<_KeyType, _DataType>::const_iterator i = m.begin(); i != m.end(); ++i)
179 const _KeyType& key = i->first;
182 const _DataType& data = i->second;