Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members  

XMLWriter.h

00001 /*
00002    Copyright (C) 2001 - 2003 the Strongroom project
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    @author Ewald Snel
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     // buffer
00058     char *data;
00059     int offset;
00060     int capacity;
00061 };
00062 
00063 #endif

Generated on Wed Feb 18 13:45:56 2004 for strongroom by doxygen1.2.18