From: stephan b. <sg...@us...> - 2004-12-27 18:08:13
|
Update of /cvsroot/pclasses/pclasses2/src/s11n/io In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26678/src/s11n/io Modified Files: data_node_format.h Log Message: Moved child_node_simple_formatter into the core algos, as deps allowed me to. Index: data_node_format.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/io/data_node_format.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- data_node_format.h 26 Dec 2004 12:30:06 -0000 1.2 +++ data_node_format.h 27 Dec 2004 18:07:54 -0000 1.3 @@ -199,7 +199,7 @@ ? 0 : this->m_nodestack.back() ); typedef ::P::s11n::node_traits<node_type> NTR; - node_type * newnode = new node_type(); + node_type * newnode = new node_type; if ( m_node ) { // if we're in a node, add new node as a child to that one: NTR::children( *m_node ).push_back( newnode ); @@ -215,6 +215,7 @@ { CERR << "open_node("<<classname<<","<<nodename<<") WARNING: deleting extra root node!\n"; delete( m_node ); + m_node = 0; ret = false; } else @@ -327,6 +328,8 @@ /** Deletes this object's root_node() if auto_delete() is true. + + After calling this, root_node() returns 0. */ void reset() { @@ -342,58 +345,6 @@ node_stack m_nodestack; }; - /** - A helper functor to loop over serializable children - of a node from within a Serializer implementation. - - Designed for use with std::for_each(). - - SerializerT must be compatible with - <code>data_node_serializer<></code>. - - */ - template <typename SerializerT> - struct node_child_simple_formatter - { - typedef SerializerT serializer_type; -// typedef typename SerializerT::node_type node_type; - /** - Preconditions: - - - Ser must be valid references. - - - Both ser and os must outlive this - object. More correctly, this object's - operator() must not be called after either - ser or os are destroyed. - - */ - node_child_simple_formatter( serializer_type & ser, std::ostream & os, - const std::string & prefix = "", const std::string & suffix = "\n" ) - : m_ser(ser), m_os(&os), m_pre(prefix), m_suf(suffix) - { - } - - /** - Serializes src into this object's target - container, using this object's serializer. - */ - template <typename NodeType> - bool operator()( const NodeType * src ) const - { - if( ! src ) return false; - if( ! this->m_pre.empty() ) *(this->m_os) << this->m_pre; - bool b = this->m_ser.serialize( *src, *(this->m_os) ); - if( ! this->m_suf.empty() ) *(this->m_os) << this->m_suf; - return b; - } - - private: - serializer_type & m_ser; - std::ostream * m_os; - std::string m_pre; - std::string m_suf; - }; } // namespace io }} // namespace P::s11n |