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 __spxmlutils_hpp__
hlipka 0:3fa97f2c0505 8 #define __spxmlutils_hpp__
hlipka 0:3fa97f2c0505 9
hlipka 0:3fa97f2c0505 10 #include <stdio.h>
hlipka 0:3fa97f2c0505 11
hlipka 0:3fa97f2c0505 12 typedef struct tagSP_XmlArrayListNode SP_XmlArrayListNode_t;
hlipka 0:3fa97f2c0505 13
hlipka 0:3fa97f2c0505 14 class SP_XmlArrayList {
hlipka 0:3fa97f2c0505 15 public:
hlipka 0:3fa97f2c0505 16 static const int LAST_INDEX;
hlipka 0:3fa97f2c0505 17
hlipka 0:3fa97f2c0505 18 SP_XmlArrayList( int initCount = 2 );
hlipka 0:3fa97f2c0505 19 virtual ~SP_XmlArrayList();
hlipka 0:3fa97f2c0505 20
hlipka 0:3fa97f2c0505 21 int getCount() const;
hlipka 0:3fa97f2c0505 22 int append( void * value );
hlipka 0:3fa97f2c0505 23 const void * getItem( int index ) const;
hlipka 0:3fa97f2c0505 24 void * takeItem( int index );
hlipka 0:3fa97f2c0505 25 void sort( int ( * cmpFunc )( const void *, const void * ) );
hlipka 0:3fa97f2c0505 26
hlipka 0:3fa97f2c0505 27 private:
hlipka 0:3fa97f2c0505 28 SP_XmlArrayList( SP_XmlArrayList & );
hlipka 0:3fa97f2c0505 29 SP_XmlArrayList & operator=( SP_XmlArrayList & );
hlipka 0:3fa97f2c0505 30
hlipka 0:3fa97f2c0505 31 int mMaxCount;
hlipka 0:3fa97f2c0505 32 int mCount;
hlipka 0:3fa97f2c0505 33 void ** mFirst;
hlipka 0:3fa97f2c0505 34 };
hlipka 0:3fa97f2c0505 35
hlipka 0:3fa97f2c0505 36 class SP_XmlQueue {
hlipka 0:3fa97f2c0505 37 public:
hlipka 0:3fa97f2c0505 38 SP_XmlQueue();
hlipka 0:3fa97f2c0505 39 virtual ~SP_XmlQueue();
hlipka 0:3fa97f2c0505 40
hlipka 0:3fa97f2c0505 41 void push( void * item );
hlipka 0:3fa97f2c0505 42 void * pop();
hlipka 0:3fa97f2c0505 43 void * top();
hlipka 0:3fa97f2c0505 44
hlipka 0:3fa97f2c0505 45 private:
hlipka 0:3fa97f2c0505 46 void ** mEntries;
hlipka 0:3fa97f2c0505 47 unsigned int mHead;
hlipka 0:3fa97f2c0505 48 unsigned int mTail;
hlipka 0:3fa97f2c0505 49 unsigned int mCount;
hlipka 0:3fa97f2c0505 50 unsigned int mMaxCount;
hlipka 0:3fa97f2c0505 51 };
hlipka 0:3fa97f2c0505 52
hlipka 0:3fa97f2c0505 53 class SP_XmlStringBuffer {
hlipka 0:3fa97f2c0505 54 public:
hlipka 0:3fa97f2c0505 55 SP_XmlStringBuffer();
hlipka 0:3fa97f2c0505 56 virtual ~SP_XmlStringBuffer();
hlipka 0:3fa97f2c0505 57 int append( char c );
hlipka 0:3fa97f2c0505 58 int append( const char * value, int size = 0 );
hlipka 0:3fa97f2c0505 59 int getSize() const;
hlipka 0:3fa97f2c0505 60 const char * getBuffer() const;
hlipka 0:3fa97f2c0505 61 char * takeBuffer();
hlipka 0:3fa97f2c0505 62 void clean();
hlipka 0:3fa97f2c0505 63
hlipka 0:3fa97f2c0505 64 private:
hlipka 0:3fa97f2c0505 65 SP_XmlStringBuffer( SP_XmlStringBuffer & );
hlipka 0:3fa97f2c0505 66 SP_XmlStringBuffer & operator=( SP_XmlStringBuffer & );
hlipka 0:3fa97f2c0505 67
hlipka 0:3fa97f2c0505 68 void init();
hlipka 0:3fa97f2c0505 69
hlipka 0:3fa97f2c0505 70 char * mBuffer;
hlipka 0:3fa97f2c0505 71 int mMaxSize;
hlipka 0:3fa97f2c0505 72 int mSize;
hlipka 0:3fa97f2c0505 73 };
hlipka 0:3fa97f2c0505 74
hlipka 0:3fa97f2c0505 75 #ifdef WIN32
hlipka 0:3fa97f2c0505 76
hlipka 0:3fa97f2c0505 77 #define snprintf _snprintf
hlipka 0:3fa97f2c0505 78 #define strncasecmp strnicmp
hlipka 0:3fa97f2c0505 79 #define strcasecmp stricmp
hlipka 0:3fa97f2c0505 80 #endif
hlipka 0:3fa97f2c0505 81
hlipka 0:3fa97f2c0505 82 #endif
hlipka 0:3fa97f2c0505 83