From: stephan b. <sg...@us...> - 2004-12-28 22:04:34
|
Update of /cvsroot/pclasses/pclasses2/src/s11n In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15792/src/s11n Modified Files: S11nNode.h Log Message: Extended interface to include de/serialize() functions. Serializer-related funcs (load/save()) are not here, because that requires circular deps on the Serializers and S11nNode. Index: S11nNode.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/S11nNode.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- S11nNode.h 28 Dec 2004 16:05:15 -0000 1.2 +++ S11nNode.h 28 Dec 2004 22:04:23 -0000 1.3 @@ -5,6 +5,7 @@ #include <string> #include <pclasses/Util/SimplePropertyStore.h> #include <pclasses/s11n/traits.h> +#include <pclasses/s11n/data_node_serialize.h> namespace P { namespace SIO { @@ -25,19 +26,30 @@ use in s11n are defined in the s11n library manual (http://s11n.net/download/). + Maintainer reminder: don't just go changing this API + unless you also implement or change the node_traits + type to accomodate it. + */ class S11nNode : public ::P::Util::SimplePropertyStore { public: + typedef ::P::s11n::node_traits<S11nNode> traits_type; typedef ::P::Util::SimplePropertyStore ParentType; + /** Expected by s11n algos.*/ typedef ParentType::map_type map_type; + /** Expected by s11n algos.*/ typedef map_type::key_type key; + /** Expected by s11n algos.*/ typedef map_type::value_type value; + /** Expected by s11n algos.*/ typedef map_type::mapped_type mapped; + /** Expected by s11n algos.*/ typedef map_type::iterator iterator; + /** Expected by s11n algos.*/ typedef map_type::const_iterator const_iterator; - + /** Expected by s11n algos.*/ typedef std::list<S11nNode *> child_list_type; @@ -65,6 +77,45 @@ iterator S11nNode::end(); const_iterator S11nNode::end() const; + + template <typename SerializableT> + bool serialize( const SerializableT & src ) + { + return ::P::s11n::serialize<S11nNode,SerializableT>( *this, src ); + } + + template <typename SerializableType> + SerializableType * deserialize() const + { + return ::P::s11n::deserialize<S11nNode,SerializableType>( *this ); + } + + template <typename DeserializableT> + bool deserialize( DeserializableT & target ) const + { + return ::P::s11n::deserialize<S11nNode,DeserializableT>( *this, target ); + } + + template <typename SerializableType> + bool serializeSubnode( const std::string & subnodename, + const SerializableType & src ) + { + return ::P::s11n::serialize_subnode<S11nNode,SerializableType>( *this, subnodename, src ); + } + + template <typename DeserializableT> + DeserializableT * deserializeSubnode( const std::string & subnodename ) const + { + return ::P::s11n::deserialize_subnode<S11nNode,DeserializableT>( *this, subnodename ); + } + + template <typename DeserializableT> + bool deserializeSubnode(const std::string & subnodename, + DeserializableT & target ) const + { + return ::P::s11n::deserialize_subnode<S11nNode,DeserializableT>( *this, subnodename, target ); + } + protected: void copy( const S11nNode & rhs ); void clear_properties(); |