From 4cb166570a8e2e97216bf6c7aeb99b971ff58ad7 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 12 Jun 2007 01:28:27 +0000 Subject: Moved out the xml system again. I think that if I am going to do it again, I'm going to do it over from scratch, that was just painful. Also, started in again on the server system, it's looking pretty good, already got connections working, next up is managing data flow through clients and protocols! --- src/xmlwriter.cpp | 167 ------------------------------------------------------ 1 file changed, 167 deletions(-) delete mode 100644 src/xmlwriter.cpp (limited to 'src/xmlwriter.cpp') diff --git a/src/xmlwriter.cpp b/src/xmlwriter.cpp deleted file mode 100644 index 7dc6ca9..0000000 --- a/src/xmlwriter.cpp +++ /dev/null @@ -1,167 +0,0 @@ -#include -#include -#include "xmlwriter.h" - -XmlWriter::XmlWriter( const Bu::FString &sIndent, XmlNode *pRoot ) : - XmlDocument( pRoot ), - sIndent( sIndent ) -{ -} - -XmlWriter::~XmlWriter() -{ -} - -void XmlWriter::write() -{ - write( getRoot(), sIndent.c_str() ); -} - -void XmlWriter::write( XmlNode *pRoot, const Bu::FString &sIndent ) -{ - writeNode( pRoot, 0, sIndent ); -} - -void XmlWriter::closeNode() -{ - XmlDocument::closeNode(); - - if( isCompleted() ) - { - write( getRoot(), sIndent.c_str() ); - } -} - -void XmlWriter::writeIndent( int nIndent, const Bu::FString &sIndent ) -{ - if( sIndent == NULL ) return; - for( int j = 0; j < nIndent; j++ ) - { - writeString( sIndent ); - } -} - -Bu::FString XmlWriter::escape( const Bu::FString &sIn ) -{ - Bu::FString sOut; - - int nMax = sIn.getSize(); - for( int j = 0; j < nMax; j++ ) - { - char c = sIn[j]; - if( ((c >= ' ' && c <= '9') || - (c >= 'a' && c <= 'z') || - (c >= 'A' && c <= 'Z') ) && - (c != '\"' && c != '\'' && c != '&') - ) - { - sOut += c; - } - else - { - sOut += "&#"; - char buf[4]; - sprintf( buf, "%u", (unsigned char)c ); - sOut += buf; - sOut += ';'; - } - } - - return sOut; -} - -void XmlWriter::writeNodeProps( XmlNode *pNode, int nIndent, const Bu::FString &sIndent ) -{ - for( int j = 0; j < pNode->getNumProperties(); j++ ) - { - writeString(" "); - //writeString( pNode->getPropertyName( j ) ); - writeString("=\""); - //writeString( escape( pNode->getProperty( j ) ).c_str() ); - writeString("\""); - } -} - -void XmlWriter::writeNode( XmlNode *pNode, int nIndent, const Bu::FString &sIndent ) -{ - if( pNode->hasChildren() ) - { - writeIndent( nIndent, sIndent ); - writeString("<"); - writeString( pNode->getName() ); - writeNodeProps( pNode, nIndent, sIndent ); - if( sIndent != "" ) - writeString(">\n"); - else - writeString(">"); -/* - if( pNode->getContent( 0 ) ) - { - writeIndent( nIndent+1, sIndent ); - if( sIndent != "" ) - { - writeString( pNode->getContent( 0 ) ); - writeString("\n"); - } - else - writeString( pNode->getContent( 0 ) ); - } - - int nNumChildren = pNode->getNumChildren(); - for( int j = 0; j < nNumChildren; j++ ) - { - writeNode( pNode->getChild( j ), nIndent+1, sIndent ); - if( pNode->getContent( j+1 ) ) - { - writeIndent( nIndent+1, sIndent ); - if( sIndent ) - { - writeString( pNode->getContent( j+1 ) ); - writeString("\n"); - } - else - writeString( pNode->getContent( j+1 ) ); - } - } -*/ - writeIndent( nIndent, sIndent ); - if( sIndent != "" ) - { - writeString("getName() ); - writeString(">\n"); - } - else - { - writeString("getName() ); - writeString(">"); - } - }/* - else if( pNode->getContent() ) - { - writeIndent( nIndent, sIndent ); - writeString("<"); - writeString( pNode->getName() ); - writeNodeProps( pNode, nIndent, sIndent ); - writeString(">"); - writeString( pNode->getContent() ); - writeString("getName() ); - writeString(">"); - if( sIndent ) - writeString("\n"); - }*/ - else - { - writeIndent( nIndent, sIndent ); - writeString("<"); - writeString( pNode->getName() ); - writeNodeProps( pNode, nIndent, sIndent ); - if( sIndent != "" ) - writeString("/>\n"); - else - writeString("/>"); - } -} - -- cgit v1.2.3