[Xmlstorage-commits] SF.net SVN: xmlstorage: [88] trunk/c++
Brought to you by:
martinfuchs
From: <mar...@us...> - 2008-02-07 22:19:39
|
Revision: 88 http://xmlstorage.svn.sourceforge.net/xmlstorage/?rev=88&view=rev Author: martinfuchs Date: 2008-02-07 14:19:43 -0800 (Thu, 07 Feb 2008) Log Message: ----------- move implementation code into xmlstorage.cpp Modified Paths: -------------- trunk/c++/xmlstorage.cpp trunk/c++/xmlstorage.h Modified: trunk/c++/xmlstorage.cpp =================================================================== --- trunk/c++/xmlstorage.cpp 2008-02-07 21:56:14 UTC (rev 87) +++ trunk/c++/xmlstorage.cpp 2008-02-07 22:19:43 UTC (rev 88) @@ -923,5 +923,91 @@ XS_String XMLWriter::s_empty_attr; +void XMLWriter::create(const XS_String& name) +{ + if (!_stack.empty()) { + StackEntry& last = _stack.top(); + if (last._state < PRE_CLOSED) { + write_attributes(last); + close_pre(last); + } + + ++last._children; + } + + StackEntry entry; + entry._node_name = name; + _stack.push(entry); + + write_pre(entry); +} + +bool XMLWriter::back() +{ + if (!_stack.empty()) { + write_post(_stack.top()); + + _stack.pop(); + return true; + } else + return false; +} + +void XMLWriter::close_pre(StackEntry& entry) +{ + _out << '>'; + + entry._state = PRE_CLOSED; +} + +void XMLWriter::write_pre(StackEntry& entry) +{ + if (_format._pretty >= PRETTY_LINEFEED) + _out << _format._endl; + + if (_format._pretty == PRETTY_INDENT) + for(size_t i=_stack.size(); --i>0; ) + _out << XML_INDENT_SPACE; + + _out << '<' << EncodeXMLString(entry._node_name); + //entry._state = PRE; +} + +void XMLWriter::write_attributes(StackEntry& entry) +{ + for(AttrMap::const_iterator it=entry._attributes.begin(); it!=entry._attributes.end(); ++it) + _out << ' ' << EncodeXMLString(it->first) << "=\"" << EncodeXMLString(it->second) << "\""; + + entry._state = ATTRIBUTES; +} + +void XMLWriter::write_post(StackEntry& entry) +{ + if (entry._state < ATTRIBUTES) + write_attributes(entry); + + if (entry._children || !entry._content.empty()) { + if (entry._state < PRE_CLOSED) + close_pre(entry); + + _out << entry._content; + //entry._state = CONTENT; + + if (_format._pretty>=PRETTY_LINEFEED && entry._content.empty()) + _out << _format._endl; + + if (_format._pretty==PRETTY_INDENT && entry._content.empty()) + for(size_t i=_stack.size(); --i>0; ) + _out << XML_INDENT_SPACE; + + _out << "</" << EncodeXMLString(entry._node_name) << ">"; + } else { + _out << "/>"; + } + + entry._state = POST; +} + + } // namespace XMLStorage Modified: trunk/c++/xmlstorage.h =================================================================== --- trunk/c++/xmlstorage.h 2008-02-07 21:56:14 UTC (rev 87) +++ trunk/c++/xmlstorage.h 2008-02-07 22:19:43 UTC (rev 88) @@ -2818,38 +2818,11 @@ } /// create node and move to it - void create(const XS_String& name) - { - if (!_stack.empty()) { - StackEntry& last = _stack.top(); + void create(const XS_String& name); - if (last._state < PRE_CLOSED) { - write_attributes(last); - close_pre(last); - } - - ++last._children; - } - - StackEntry entry; - entry._node_name = name; - _stack.push(entry); - - write_pre(entry); - } - /// go back to previous position - bool back() - { - if (!_stack.empty()) { - write_post(_stack.top()); + bool back(); - _stack.pop(); - return true; - } else - return false; - } - /// attribute setting void put(const XS_String& attr_name, const XS_String& value) { @@ -2899,60 +2872,10 @@ static XS_String s_empty_attr; - void close_pre(StackEntry& entry) - { - _out << '>'; - - entry._state = PRE_CLOSED; - } - - void write_pre(StackEntry& entry) - { - if (_format._pretty >= PRETTY_LINEFEED) - _out << _format._endl; - - if (_format._pretty == PRETTY_INDENT) - for(size_t i=_stack.size(); --i>0; ) - _out << XML_INDENT_SPACE; - - _out << '<' << EncodeXMLString(entry._node_name); - //entry._state = PRE; - } - - void write_attributes(StackEntry& entry) - { - for(AttrMap::const_iterator it=entry._attributes.begin(); it!=entry._attributes.end(); ++it) - _out << ' ' << EncodeXMLString(it->first) << "=\"" << EncodeXMLString(it->second) << "\""; - - entry._state = ATTRIBUTES; - } - - void write_post(StackEntry& entry) - { - if (entry._state < ATTRIBUTES) - write_attributes(entry); - - if (entry._children || !entry._content.empty()) { - if (entry._state < PRE_CLOSED) - close_pre(entry); - - _out << entry._content; - //entry._state = CONTENT; - - if (_format._pretty>=PRETTY_LINEFEED && entry._content.empty()) - _out << _format._endl; - - if (_format._pretty==PRETTY_INDENT && entry._content.empty()) - for(size_t i=_stack.size(); --i>0; ) - _out << XML_INDENT_SPACE; - - _out << "</" << EncodeXMLString(entry._node_name) << ">"; - } else { - _out << "/>"; - } - - entry._state = POST; - } + void close_pre(StackEntry& entry); + void write_pre(StackEntry& entry); + void write_attributes(StackEntry& entry); + void write_post(StackEntry& entry); }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |