@ -20,9 +20,6 @@
@@ -20,9 +20,6 @@
# include <utility>
# include <vector>
# include <boost/tuple/tuple.hpp>
# include <boost/type_traits/is_fundamental.hpp>
class CAutoFile ;
class CDataStream ;
class CScript ;
@ -432,14 +429,15 @@ template<typename Stream, typename C> void Serialize(Stream& os, const std::basi
@@ -432,14 +429,15 @@ template<typename Stream, typename C> void Serialize(Stream& os, const std::basi
template < typename Stream , typename C > void Unserialize ( Stream & is , std : : basic_string < C > & str , int , int = 0 ) ;
// vector
template < typename T , typename A > unsigned int GetSerializeSize_impl ( const std : : vector < T , A > & v , int nType , int nVersion , const boost : : true_type & ) ;
template < typename T , typename A > unsigned int GetSerializeSize_impl ( const std : : vector < T , A > & v , int nType , int nVersion , const boost : : false_type & ) ;
// vectors of unsigned char are a special case and are intended to be serialized as a single opaque blob.
template < typename T , typename A > unsigned int GetSerializeSize_impl ( const std : : vector < T , A > & v , int nType , int nVersion , const unsigned char & ) ;
template < typename T , typename A , typename V > unsigned int GetSerializeSize_impl ( const std : : vector < T , A > & v , int nType , int nVersion , const V & ) ;
template < typename T , typename A > inline unsigned int GetSerializeSize ( const std : : vector < T , A > & v , int nType , int nVersion ) ;
template < typename Stream , typename T , typename A > void Serialize_impl ( Stream & os , const std : : vector < T , A > & v , int nType , int nVersion , const boost : : true_type & ) ;
template < typename Stream , typename T , typename A > void Serialize_impl ( Stream & os , const std : : vector < T , A > & v , int nType , int nVersion , const boost : : false_type & ) ;
template < typename Stream , typename T , typename A > void Serialize_impl ( Stream & os , const std : : vector < T , A > & v , int nType , int nVersion , const unsigned char & ) ;
template < typename Stream , typename T , typename A , typename V > void Serialize_impl ( Stream & os , const std : : vector < T , A > & v , int nType , int nVersion , const V & ) ;
template < typename Stream , typename T , typename A > inline void Serialize ( Stream & os , const std : : vector < T , A > & v , int nType , int nVersion ) ;
template < typename Stream , typename T , typename A > void Unserialize_impl ( Stream & is , std : : vector < T , A > & v , int nType , int nVersion , const boost : : true_type & ) ;
template < typename Stream , typename T , typename A > void Unserialize_impl ( Stream & is , std : : vector < T , A > & v , int nType , int nVersion , const boost : : false_type & ) ;
template < typename Stream , typename T , typename A > void Unserialize_impl ( Stream & is , std : : vector < T , A > & v , int nType , int nVersion , const unsigned char & ) ;
template < typename Stream , typename T , typename A , typename V > void Unserialize_impl ( Stream & is , std : : vector < T , A > & v , int nType , int nVersion , const V & ) ;
template < typename Stream , typename T , typename A > inline void Unserialize ( Stream & is , std : : vector < T , A > & v , int nType , int nVersion ) ;
// others derived from vector
@ -452,16 +450,6 @@ template<typename K, typename T> unsigned int GetSerializeSize(const std::pair<K
@@ -452,16 +450,6 @@ template<typename K, typename T> unsigned int GetSerializeSize(const std::pair<K
template < typename Stream , typename K , typename T > void Serialize ( Stream & os , const std : : pair < K , T > & item , int nType , int nVersion ) ;
template < typename Stream , typename K , typename T > void Unserialize ( Stream & is , std : : pair < K , T > & item , int nType , int nVersion ) ;
// 3 tuple
template < typename T0 , typename T1 , typename T2 > unsigned int GetSerializeSize ( const boost : : tuple < T0 , T1 , T2 > & item , int nType , int nVersion ) ;
template < typename Stream , typename T0 , typename T1 , typename T2 > void Serialize ( Stream & os , const boost : : tuple < T0 , T1 , T2 > & item , int nType , int nVersion ) ;
template < typename Stream , typename T0 , typename T1 , typename T2 > void Unserialize ( Stream & is , boost : : tuple < T0 , T1 , T2 > & item , int nType , int nVersion ) ;
// 4 tuple
template < typename T0 , typename T1 , typename T2 , typename T3 > unsigned int GetSerializeSize ( const boost : : tuple < T0 , T1 , T2 , T3 > & item , int nType , int nVersion ) ;
template < typename Stream , typename T0 , typename T1 , typename T2 , typename T3 > void Serialize ( Stream & os , const boost : : tuple < T0 , T1 , T2 , T3 > & item , int nType , int nVersion ) ;
template < typename Stream , typename T0 , typename T1 , typename T2 , typename T3 > void Unserialize ( Stream & is , boost : : tuple < T0 , T1 , T2 , T3 > & item , int nType , int nVersion ) ;
// map
template < typename K , typename T , typename Pred , typename A > unsigned int GetSerializeSize ( const std : : map < K , T , Pred , A > & m , int nType , int nVersion ) ;
template < typename Stream , typename K , typename T , typename Pred , typename A > void Serialize ( Stream & os , const std : : map < K , T , Pred , A > & m , int nType , int nVersion ) ;
@ -536,13 +524,13 @@ void Unserialize(Stream& is, std::basic_string<C>& str, int, int)
@@ -536,13 +524,13 @@ void Unserialize(Stream& is, std::basic_string<C>& str, int, int)
// vector
//
template < typename T , typename A >
unsigned int GetSerializeSize_impl ( const std : : vector < T , A > & v , int nType , int nVersion , const boost : : true_type & )
unsigned int GetSerializeSize_impl ( const std : : vector < T , A > & v , int nType , int nVersion , const unsigned char & )
{
return ( GetSizeOfCompactSize ( v . size ( ) ) + v . size ( ) * sizeof ( T ) ) ;
}
template < typename T , typename A >
unsigned int GetSerializeSize_impl ( const std : : vector < T , A > & v , int nType , int nVersion , const boost : : false_type & )
template < typename T , typename A , typename V >
unsigned int GetSerializeSize_impl ( const std : : vector < T , A > & v , int nType , int nVersion , const V & )
{
unsigned int nSize = GetSizeOfCompactSize ( v . size ( ) ) ;
for ( typename std : : vector < T , A > : : const_iterator vi = v . begin ( ) ; vi ! = v . end ( ) ; + + vi )
@ -553,20 +541,20 @@ unsigned int GetSerializeSize_impl(const std::vector<T, A>& v, int nType, int nV
@@ -553,20 +541,20 @@ unsigned int GetSerializeSize_impl(const std::vector<T, A>& v, int nType, int nV
template < typename T , typename A >
inline unsigned int GetSerializeSize ( const std : : vector < T , A > & v , int nType , int nVersion )
{
return GetSerializeSize_impl ( v , nType , nVersion , boost : : is_fundamental < T > ( ) ) ;
return GetSerializeSize_impl ( v , nType , nVersion , T ( ) ) ;
}
template < typename Stream , typename T , typename A >
void Serialize_impl ( Stream & os , const std : : vector < T , A > & v , int nType , int nVersion , const boost : : true_type & )
void Serialize_impl ( Stream & os , const std : : vector < T , A > & v , int nType , int nVersion , const unsigned char & )
{
WriteCompactSize ( os , v . size ( ) ) ;
if ( ! v . empty ( ) )
os . write ( ( char * ) & v [ 0 ] , v . size ( ) * sizeof ( T ) ) ;
}
template < typename Stream , typename T , typename A >
void Serialize_impl ( Stream & os , const std : : vector < T , A > & v , int nType , int nVersion , const boost : : false_type & )
template < typename Stream , typename T , typename A , typename V >
void Serialize_impl ( Stream & os , const std : : vector < T , A > & v , int nType , int nVersion , const V & )
{
WriteCompactSize ( os , v . size ( ) ) ;
for ( typename std : : vector < T , A > : : const_iterator vi = v . begin ( ) ; vi ! = v . end ( ) ; + + vi )
@ -576,12 +564,12 @@ void Serialize_impl(Stream& os, const std::vector<T, A>& v, int nType, int nVers
@@ -576,12 +564,12 @@ void Serialize_impl(Stream& os, const std::vector<T, A>& v, int nType, int nVers
template < typename Stream , typename T , typename A >
inline void Serialize ( Stream & os , const std : : vector < T , A > & v , int nType , int nVersion )
{
Serialize_impl ( os , v , nType , nVersion , boost : : is_fundamental < T > ( ) ) ;
Serialize_impl ( os , v , nType , nVersion , T ( ) ) ;
}
template < typename Stream , typename T , typename A >
void Unserialize_impl ( Stream & is , std : : vector < T , A > & v , int nType , int nVersion , const boost : : true_type & )
void Unserialize_impl ( Stream & is , std : : vector < T , A > & v , int nType , int nVersion , const unsigned char & )
{
// Limit size per read so bogus size value won't cause out of memory
v . clear ( ) ;
@ -596,8 +584,8 @@ void Unserialize_impl(Stream& is, std::vector<T, A>& v, int nType, int nVersion,
@@ -596,8 +584,8 @@ void Unserialize_impl(Stream& is, std::vector<T, A>& v, int nType, int nVersion,
}
}
template < typename Stream , typename T , typename A >
void Unserialize_impl ( Stream & is , std : : vector < T , A > & v , int nType , int nVersion , const boost : : false_type & )
template < typename Stream , typename T , typename A , typename V >
void Unserialize_impl ( Stream & is , std : : vector < T , A > & v , int nType , int nVersion , const V & )
{
v . clear ( ) ;
unsigned int nSize = ReadCompactSize ( is ) ;
@ -617,7 +605,7 @@ void Unserialize_impl(Stream& is, std::vector<T, A>& v, int nType, int nVersion,
@@ -617,7 +605,7 @@ void Unserialize_impl(Stream& is, std::vector<T, A>& v, int nType, int nVersion,
template < typename Stream , typename T , typename A >
inline void Unserialize ( Stream & is , std : : vector < T , A > & v , int nType , int nVersion )
{
Unserialize_impl ( is , v , nType , nVersion , boost : : is_fundamental < T > ( ) ) ;
Unserialize_impl ( is , v , nType , nVersion , T ( ) ) ;
}
@ -669,71 +657,6 @@ void Unserialize(Stream& is, std::pair<K, T>& item, int nType, int nVersion)
@@ -669,71 +657,6 @@ void Unserialize(Stream& is, std::pair<K, T>& item, int nType, int nVersion)
//
// 3 tuple
//
template < typename T0 , typename T1 , typename T2 >
unsigned int GetSerializeSize ( const boost : : tuple < T0 , T1 , T2 > & item , int nType , int nVersion )
{
unsigned int nSize = 0 ;
nSize + = GetSerializeSize ( boost : : get < 0 > ( item ) , nType , nVersion ) ;
nSize + = GetSerializeSize ( boost : : get < 1 > ( item ) , nType , nVersion ) ;
nSize + = GetSerializeSize ( boost : : get < 2 > ( item ) , nType , nVersion ) ;
return nSize ;
}
template < typename Stream , typename T0 , typename T1 , typename T2 >
void Serialize ( Stream & os , const boost : : tuple < T0 , T1 , T2 > & item , int nType , int nVersion )
{
Serialize ( os , boost : : get < 0 > ( item ) , nType , nVersion ) ;
Serialize ( os , boost : : get < 1 > ( item ) , nType , nVersion ) ;
Serialize ( os , boost : : get < 2 > ( item ) , nType , nVersion ) ;
}
template < typename Stream , typename T0 , typename T1 , typename T2 >
void Unserialize ( Stream & is , boost : : tuple < T0 , T1 , T2 > & item , int nType , int nVersion )
{
Unserialize ( is , boost : : get < 0 > ( item ) , nType , nVersion ) ;
Unserialize ( is , boost : : get < 1 > ( item ) , nType , nVersion ) ;
Unserialize ( is , boost : : get < 2 > ( item ) , nType , nVersion ) ;
}
//
// 4 tuple
//
template < typename T0 , typename T1 , typename T2 , typename T3 >
unsigned int GetSerializeSize ( const boost : : tuple < T0 , T1 , T2 , T3 > & item , int nType , int nVersion )
{
unsigned int nSize = 0 ;
nSize + = GetSerializeSize ( boost : : get < 0 > ( item ) , nType , nVersion ) ;
nSize + = GetSerializeSize ( boost : : get < 1 > ( item ) , nType , nVersion ) ;
nSize + = GetSerializeSize ( boost : : get < 2 > ( item ) , nType , nVersion ) ;
nSize + = GetSerializeSize ( boost : : get < 3 > ( item ) , nType , nVersion ) ;
return nSize ;
}
template < typename Stream , typename T0 , typename T1 , typename T2 , typename T3 >
void Serialize ( Stream & os , const boost : : tuple < T0 , T1 , T2 , T3 > & item , int nType , int nVersion )
{
Serialize ( os , boost : : get < 0 > ( item ) , nType , nVersion ) ;
Serialize ( os , boost : : get < 1 > ( item ) , nType , nVersion ) ;
Serialize ( os , boost : : get < 2 > ( item ) , nType , nVersion ) ;
Serialize ( os , boost : : get < 3 > ( item ) , nType , nVersion ) ;
}
template < typename Stream , typename T0 , typename T1 , typename T2 , typename T3 >
void Unserialize ( Stream & is , boost : : tuple < T0 , T1 , T2 , T3 > & item , int nType , int nVersion )
{
Unserialize ( is , boost : : get < 0 > ( item ) , nType , nVersion ) ;
Unserialize ( is , boost : : get < 1 > ( item ) , nType , nVersion ) ;
Unserialize ( is , boost : : get < 2 > ( item ) , nType , nVersion ) ;
Unserialize ( is , boost : : get < 3 > ( item ) , nType , nVersion ) ;
}
//
// map
//