00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef XMLWRITER_H
00020 #define XMLWRITER_H
00021
00022 #include <string>
00023 #include <sstream>
00024 #include "attributesimpl.h"
00025 #include "xmlwritingexception.h"
00026
00036 class XMLWriter
00037 {
00038 private:
00040 std::string m_sRootNode;
00041
00043 std::string m_sEncoding;
00044
00046 std::ostringstream m_OutputStream;
00047
00048 public:
00051 XMLWriter(const std::string& sEncoding = DEFAULT_ENCODING);
00052
00054 ~XMLWriter();
00055
00061 void startDocument() throw (XMLWritingException);
00062
00066 void addElement(const std::string& name,const std::string& value);
00067
00072 void addElement(const std::string& name,const std::string& value, const AttributesImpl& atts);
00073
00077 void startElement(const std::string& name, bool bEndLine = true);
00078
00083 void startElement(const std::string& name, const AttributesImpl& atts, bool bEndLine = true);
00084
00087 void endElement(const std::string& name);
00088
00092 void endDocument();
00093
00096 std::string getEncoding() const { return m_sEncoding; }
00097
00100 void setEncoding(const std::string& charset);
00101
00104 void setRootNode(const std::string& sRootNode) { m_sRootNode = sRootNode; }
00105
00108 std::string getRootNode() const { return m_sRootNode; }
00109
00112 std::string getXMLDocument() const { return m_OutputStream.str(); }
00113
00114 public:
00116 static const char* DEFAULT_ENCODING;
00117 };
00118
00119 #endif