xmlwriter.h

00001 /***************************************************************************
00002                           xmlwriter.h  -  description
00003                              -------------------
00004     begin                : mar avr 11 2006
00005     copyright            : (C) 2006 by 
00006                    - Sylvain Archenault <sylvain.archenault@laposte.net>
00007                    - Yves Houpert <yves.houpert@insa-rouen.fr>
00008  ***************************************************************************/
00009 
00010 /***************************************************************************
00011  *                                                                         *
00012  *   This program is free software; you can redistribute it and/or modify  *
00013  *   it under the terms of the GNU General Public License as published by  *
00014  *   the Free Software Foundation; either version 2 of the License, or     *
00015  *   (at your option) any later version.                                   *
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: //private members
00040   std::string m_sRootNode;
00041 
00043   std::string m_sEncoding;
00044 
00046   std::ostringstream m_OutputStream;
00047 
00048 public: //public methods.
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: //public members
00116   static const char* DEFAULT_ENCODING;
00117 };
00118 
00119 #endif

Generated on Fri May 19 12:15:54 2006 for Bamboo Ch@t by  doxygen 1.4.6