00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef __XMLWRITER_H
00013 #define __XMLWRITER_H
00014
00015 #ifdef HAVE_CONFIG_H
00016 #include <config.h>
00017 #endif
00018
00019 #include <stdint.h>
00020 #include <string>
00021
00022
00023 using namespace std;
00024
00028 class XMLWriter
00029 {
00030 public:
00031 XMLWriter();
00032 ~XMLWriter();
00033
00034 void addChild( const char *name );
00035 void addTextChild( const char *text );
00036 void setAttribute( const char *name, const char *value );
00037 void setAttribute( const char *name, int value );
00038 void setAttribute( const char *name, int64_t value );
00039 void setAttributeNS( const char *prefix, const char *url );
00040 void closeNode( const char *name );
00041
00042 string toString();
00043
00044 protected:
00045 void close( bool newLine );
00046 void reserve( int size );
00047 void write( int ch );
00048 void write( const char *text );
00049 void write( const char *text, int length );
00050 void writeEscaped( const char *text );
00051
00052 private:
00053 int indentation;
00054 bool hasChildren;
00055 bool hasAttributes;
00056
00057
00058 char *data;
00059 int offset;
00060 int capacity;
00061 };
00062
00063 #endif