Mbed port of the Simple Plain Xml parser. See http://code.google.com/p/spxml/ for more details. This library uses less memory and is much better suited to streaming data than TinyXML (doesn\'t use as much C++ features, and especially works without streams). See http://mbed.org/users/hlipka/notebook/xml-parsing/ for usage examples.

Dependents:   spxmltest_weather VFD_fontx2_weather weather_LCD_display News_LCD_display ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers spxmlparser.hpp Source File

spxmlparser.hpp

00001 /*
00002  * Copyright 2007 Stephen Liu
00003  * LGPL, see http://code.google.com/p/spxml/
00004  * For license terms, see the file COPYING along with this library.
00005  */
00006 
00007 #ifndef __xmlparser_hpp__
00008 #define __xmlparser_hpp__
00009 
00010 class SP_XmlPullEvent;
00011 class SP_XmlPullEventQueue;
00012 class SP_XmlReader;
00013 class SP_XmlReaderPool;
00014 class SP_XmlArrayList;
00015 
00016 class SP_XmlPullParser {
00017 public:
00018     SP_XmlPullParser();
00019     ~SP_XmlPullParser();
00020 
00021     /// append more input xml source
00022     /// @return how much byte has been consumed
00023     int append( const char * source, int len );
00024 
00025     /// @return NOT NULL : the pull event
00026     /// @return NULL : error or need more input
00027     SP_XmlPullEvent * getNext();    
00028 
00029     /// @return NOT NULL : the detail error message
00030     /// @return NULL : no error
00031     const char * getError();
00032 
00033     int getLevel();
00034 
00035     /// default ignoreWhitespace is true
00036     void setIgnoreWhitespace( int ignoreWhitespace );
00037 
00038     int getIgnoreWhitespace();
00039 
00040     const char * getEncoding();
00041 
00042 protected:
00043     void changeReader( SP_XmlReader * reader );
00044 
00045     SP_XmlReader * getReader( int type );
00046 
00047     void setError( const char * error );
00048 
00049     friend class SP_XmlReader;
00050 
00051 private:
00052     SP_XmlPullEventQueue * mEventQueue;
00053     SP_XmlReader * mReader;
00054     SP_XmlReaderPool * mReaderPool;
00055     SP_XmlArrayList * mTagNameStack;
00056 
00057     enum { eRootNone, eRootStart, eRootEnd };
00058     int mRootTagState;
00059 
00060     int mLevel;
00061 
00062     int mIgnoreWhitespace;
00063 
00064     char * mError;
00065 
00066     char mErrorSegment[ 32 ];
00067     int mErrorIndex;
00068     int mColIndex, mRowIndex;
00069 
00070     char mEncoding[ 32 ];
00071 };
00072 
00073 #endif
00074