From c17c4ebbab022de80a9f893115f2fd41e6a07c44 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 8 May 2007 06:31:33 +0000 Subject: Added the TAF format structures and XML format structures, I'm making up TAF (textual archive format), but named it wrong, this seemed easier than redoing it all. --- src/xmlreader.cpp | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 src/xmlreader.cpp (limited to 'src/xmlreader.cpp') diff --git a/src/xmlreader.cpp b/src/xmlreader.cpp new file mode 100644 index 0000000..432ecc1 --- /dev/null +++ b/src/xmlreader.cpp @@ -0,0 +1,108 @@ +#include "xmlreader.h" + +Bu::XmlReader::XmlReader( Bu::Stream &sIn ) : + sIn( sIn ) +{ +} + +Bu::XmlReader::~XmlReader() +{ +} + +const char *Bu::XmlReader::lookahead( int nAmnt ) +{ + if( sBuf.getSize() >= nAmnt ) + return sBuf.getStr(); + + int nNew = nAmnt - sBuf.getSize(); + char *buf = new char[nNew]; + sIn.read( buf, nNew ); + sBuf.append( buf ); + + return sBuf.getStr(); +} + +void Bu::XmlReader::burn( int nAmnt ) +{ + if( sBuf.getSize() < nAmnt ) + { + lookahead( nAmnt ); + } + + sBuf.remove( nAmnt ); +} + +void Bu::XmlNode::checkString( const char *str, int nLen ) +{ + if( !strncmp( str, lookahead( nLen ), nLen ) ) + { + burn( nLen ); + return; + } + + throw Bu::ExceptionBase("Expected string '%s'", str ); +} + +Bu::XmlNode *Bu::XmlReader::read() +{ + prolog(); +} + +void Bu::XmlReader::prolog() +{ + XMLDecl(); + Misc(); +} + +void Bu::XmlReader::XMLDecl() +{ + checkString("