|
From: stephan b. <sg...@us...> - 2004-12-28 04:18:10
|
Update of /cvsroot/pclasses/pclasses2/src/s11n In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15336/src/s11n Modified Files: data_node_serialize.h Log Message: Moved s11n_api_marshaller from P:: anon namespace to s11n:: anon namespace. Index: data_node_serialize.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/data_node_serialize.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- data_node_serialize.h 27 Dec 2004 18:24:30 -0000 1.3 +++ data_node_serialize.h 28 Dec 2004 04:18:01 -0000 1.4 @@ -30,102 +30,12 @@ #define NODEERR if(0) CERR // ^^^ a debugging macro -namespace P { -namespace { // anon namespace important for linking reasons, to avoid ODR violations. - - /*** - s11n_api_marshaler is OBSOLETED (as of version 0.9.3) by - s11n_traits. It is implemented in terms of s11n_traits for - backwards compatibility, but it will be phased out at some - point. - - For the default implementation s11n_traits<SerializableT> - is used to marshal the de/serialize() calls. - */ - template <typename SerializableT> - struct s11n_api_marshaler - { - /** - Same as SerializableT. - */ - typedef SerializableT serializable_type; - - /** - Returns s11n_traits<serializable_type>::serialize_functor()( dest, src ). - - It also sets dest's class_name() to ::classname<serializable_type>(), - but this is only suitable for monomorphic serializable_types. - */ - template <typename NodeType> - static bool serialize( NodeType &dest, const serializable_type & src ) - { - typedef s11n::node_traits<NodeType> NTR; - typedef s11n::s11n_traits<serializable_type> STR; - NTR::class_name( dest, ::classname<serializable_type>() ); // only good for monomorphs - return STR::serialize_functor()( dest, src ); - } - - /** - Returns s11n_traits<SerializableT>::deserialize_functor()( src, dest ). - */ - template <typename NodeType> - static bool deserialize( const NodeType & src, serializable_type & dest ) - { - typedef s11n::s11n_traits<serializable_type> STR; - return STR::deserialize_functor()( src, dest ); - } - }; - - /** - A specialization to handle pointer types the same as - reference/value types. It simply translates the pointers - into references. - */ - template <typename SerializableT> - struct s11n_api_marshaler<SerializableT *> - { - /** - The SerializableT templatized type, minus any - pointer part. - */ - typedef SerializableT serializable_type; - - /** - Convenience typedef: this class' parent type. - */ - typedef s11n_api_marshaler<serializable_type> parent_type; - - /** - Returns parent_type::serialize( dest, *src ); - - src must be a valid pointer. - */ - template <typename NodeType> - static bool serialize( NodeType &dest, const serializable_type * src ) - { - if( ! src ) return false; - return parent_type::serialize( dest, *src ); - } - - /** - Returns parent_type::deserialize( src, *dest ); - - dest must be a valid pointer. - */ - template <typename NodeType> - static bool deserialize( const NodeType & src, serializable_type * dest ) - { - if( ! dest ) return false; - return parent_type::deserialize( src, *dest ); - } - }; - -} // anon namespace +namespace P { /********************************************************************** -General Conventions: +s11n general conventions: NodeType should conform to the conventions laid out by s11n::data_node. @@ -159,12 +69,99 @@ These signatures apply for all functors designed to work as de/serializers. +**********************************************************************/ +namespace s11n { -**********************************************************************/ + namespace { // anon namespace important for linking reasons, to avoid ODR violations. + /*** + s11n_api_marshaler is an internal API marshaller for s11n. + See the lib manual for full details. + + For the default implementation s11n_traits<SerializableT> + is used to marshal the de/serialize() calls. + */ + template <typename SerializableT> + struct s11n_api_marshaler + { + /** + Same as SerializableT. + */ + typedef SerializableT serializable_type; + + /** + Returns s11n_traits<serializable_type>::serialize_functor()( dest, src ). + + It also sets dest's class_name() to ::classname<serializable_type>(), + but this is only suitable for monomorphic serializable_types. + */ + template <typename NodeType> + static bool serialize( NodeType &dest, const serializable_type & src ) + { + typedef s11n::node_traits<NodeType> NTR; + typedef s11n::s11n_traits<serializable_type> STR; + NTR::class_name( dest, ::classname<serializable_type>() ); // only good for monomorphs + return STR::serialize_functor()( dest, src ); + } + + /** + Returns s11n_traits<SerializableT>::deserialize_functor()( src, dest ). + */ + template <typename NodeType> + static bool deserialize( const NodeType & src, serializable_type & dest ) + { + typedef s11n::s11n_traits<serializable_type> STR; + return STR::deserialize_functor()( src, dest ); + } + }; + + /** + A specialization to handle pointer types the same as + reference/value types. It simply translates the pointers + into references. + */ + template <typename SerializableT> + struct s11n_api_marshaler<SerializableT *> + { + /** + The SerializableT templatized type, minus any + pointer part. + */ + typedef SerializableT serializable_type; + + /** + Convenience typedef: this class' parent type. + */ + typedef s11n_api_marshaler<serializable_type> parent_type; + + /** + Returns parent_type::serialize( dest, *src ); + + src must be a valid pointer. + */ + template <typename NodeType> + static bool serialize( NodeType &dest, const serializable_type * src ) + { + if( ! src ) return false; + return parent_type::serialize( dest, *src ); + } + + /** + Returns parent_type::deserialize( src, *dest ); + + dest must be a valid pointer. + */ + template <typename NodeType> + static bool deserialize( const NodeType & src, serializable_type * dest ) + { + if( ! dest ) return false; + return parent_type::deserialize( src, *dest ); + } + }; + + } // anon namespace -namespace s11n { /** @@ -176,9 +173,6 @@ { try { -// typedef typename s11n_traits<SerializableT>::serialize_functor Proxy; -// return serialize<DataNodeType,SerializableT,Proxy>( target, src, Proxy() ); -// return Proxy()( target, src ); return s11n_api_marshaler<SerializableT>::serialize( target, src ); } catch(...) @@ -197,9 +191,6 @@ { try { -// typedef typename s11n_traits<DeserializableT>::deserialize_functor Proxy; -// return deserialize<DataNodeType,DeserializableT,Proxy>( src, target, Proxy() ); -// return Proxy()( src, target ); return s11n_api_marshaler<DeserializableT>::deserialize( src, target ); } catch(...) |