IBR-DTNSuite  0.8
ibrcommon/ibrcommon/xml/XMLStreamWriter.h
Go to the documentation of this file.
00001 /*
00002  * XMLStreamWriter.h
00003  *
00004  *  Created on: 01.06.2011
00005  *      Author: morgenro
00006  */
00007 
00008 #ifndef XMLSTREAMWRITER_H_
00009 #define XMLSTREAMWRITER_H_
00010 
00011 #include <libxml/xmlwriter.h>
00012 #include <iostream>
00013 
00014 namespace ibrcommon
00015 {
00016         class XMLStreamWriter
00017         {
00018         public:
00019                 static int __write_callback(void * context, const char * buffer, int len);
00020                 static int __close_callback(void * context);
00021 
00022                 XMLStreamWriter(std::ostream &stream);
00023                 virtual ~XMLStreamWriter();
00024 
00025                 void startDocument(const char *encoding);
00026 
00027                 void endDocument();
00028 
00029                 void startElement(const std::string &name);
00030 
00031                 void addAttribute(const std::string &name, const std::string &value);
00032 
00033                 void addComment(const std::string &comment);
00034 
00035                 void endElement();
00036 
00037                 void addData(const std::string &data);
00038 
00039                 void addData(const char *data, const size_t len);
00040 
00041         private:
00042                 std::ostream &_stream;
00043                 xmlOutputBufferPtr _out_buf;
00044                 xmlTextWriterPtr _writer;
00045         };
00046 }
00047 
00048 #endif /* XMLSTREAMWRITER_H_ */