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

Committer:
hlipka
Date:
Wed Nov 24 20:52:14 2010 +0000
Revision:
0:3fa97f2c0505
initial revision

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hlipka 0:3fa97f2c0505 1 /*
hlipka 0:3fa97f2c0505 2 * Copyright 2007 Stephen Liu
hlipka 0:3fa97f2c0505 3 * LGPL, see http://code.google.com/p/spxml/
hlipka 0:3fa97f2c0505 4 * For license terms, see the file COPYING along with this library.
hlipka 0:3fa97f2c0505 5 */
hlipka 0:3fa97f2c0505 6
hlipka 0:3fa97f2c0505 7 #ifndef __xmlparser_hpp__
hlipka 0:3fa97f2c0505 8 #define __xmlparser_hpp__
hlipka 0:3fa97f2c0505 9
hlipka 0:3fa97f2c0505 10 class SP_XmlPullEvent;
hlipka 0:3fa97f2c0505 11 class SP_XmlPullEventQueue;
hlipka 0:3fa97f2c0505 12 class SP_XmlReader;
hlipka 0:3fa97f2c0505 13 class SP_XmlReaderPool;
hlipka 0:3fa97f2c0505 14 class SP_XmlArrayList;
hlipka 0:3fa97f2c0505 15
hlipka 0:3fa97f2c0505 16 class SP_XmlPullParser {
hlipka 0:3fa97f2c0505 17 public:
hlipka 0:3fa97f2c0505 18 SP_XmlPullParser();
hlipka 0:3fa97f2c0505 19 ~SP_XmlPullParser();
hlipka 0:3fa97f2c0505 20
hlipka 0:3fa97f2c0505 21 /// append more input xml source
hlipka 0:3fa97f2c0505 22 /// @return how much byte has been consumed
hlipka 0:3fa97f2c0505 23 int append( const char * source, int len );
hlipka 0:3fa97f2c0505 24
hlipka 0:3fa97f2c0505 25 /// @return NOT NULL : the pull event
hlipka 0:3fa97f2c0505 26 /// @return NULL : error or need more input
hlipka 0:3fa97f2c0505 27 SP_XmlPullEvent * getNext();
hlipka 0:3fa97f2c0505 28
hlipka 0:3fa97f2c0505 29 /// @return NOT NULL : the detail error message
hlipka 0:3fa97f2c0505 30 /// @return NULL : no error
hlipka 0:3fa97f2c0505 31 const char * getError();
hlipka 0:3fa97f2c0505 32
hlipka 0:3fa97f2c0505 33 int getLevel();
hlipka 0:3fa97f2c0505 34
hlipka 0:3fa97f2c0505 35 /// default ignoreWhitespace is true
hlipka 0:3fa97f2c0505 36 void setIgnoreWhitespace( int ignoreWhitespace );
hlipka 0:3fa97f2c0505 37
hlipka 0:3fa97f2c0505 38 int getIgnoreWhitespace();
hlipka 0:3fa97f2c0505 39
hlipka 0:3fa97f2c0505 40 const char * getEncoding();
hlipka 0:3fa97f2c0505 41
hlipka 0:3fa97f2c0505 42 protected:
hlipka 0:3fa97f2c0505 43 void changeReader( SP_XmlReader * reader );
hlipka 0:3fa97f2c0505 44
hlipka 0:3fa97f2c0505 45 SP_XmlReader * getReader( int type );
hlipka 0:3fa97f2c0505 46
hlipka 0:3fa97f2c0505 47 void setError( const char * error );
hlipka 0:3fa97f2c0505 48
hlipka 0:3fa97f2c0505 49 friend class SP_XmlReader;
hlipka 0:3fa97f2c0505 50
hlipka 0:3fa97f2c0505 51 private:
hlipka 0:3fa97f2c0505 52 SP_XmlPullEventQueue * mEventQueue;
hlipka 0:3fa97f2c0505 53 SP_XmlReader * mReader;
hlipka 0:3fa97f2c0505 54 SP_XmlReaderPool * mReaderPool;
hlipka 0:3fa97f2c0505 55 SP_XmlArrayList * mTagNameStack;
hlipka 0:3fa97f2c0505 56
hlipka 0:3fa97f2c0505 57 enum { eRootNone, eRootStart, eRootEnd };
hlipka 0:3fa97f2c0505 58 int mRootTagState;
hlipka 0:3fa97f2c0505 59
hlipka 0:3fa97f2c0505 60 int mLevel;
hlipka 0:3fa97f2c0505 61
hlipka 0:3fa97f2c0505 62 int mIgnoreWhitespace;
hlipka 0:3fa97f2c0505 63
hlipka 0:3fa97f2c0505 64 char * mError;
hlipka 0:3fa97f2c0505 65
hlipka 0:3fa97f2c0505 66 char mErrorSegment[ 32 ];
hlipka 0:3fa97f2c0505 67 int mErrorIndex;
hlipka 0:3fa97f2c0505 68 int mColIndex, mRowIndex;
hlipka 0:3fa97f2c0505 69
hlipka 0:3fa97f2c0505 70 char mEncoding[ 32 ];
hlipka 0:3fa97f2c0505 71 };
hlipka 0:3fa97f2c0505 72
hlipka 0:3fa97f2c0505 73 #endif
hlipka 0:3fa97f2c0505 74