XmlSerializer.h

Go to the documentation of this file.
00001 /* Copyright (c) 2005,2007 Vivek Krishna
00002  *  Based on kxml2 by Stefan Haustein, Oberhausen, Rhld., Germany
00003  * Permission is hereby granted, free of charge, to any person obtaining a copy
00004  * of this software and associated documentation files (the "Software"), to deal
00005  * in the Software without restriction, including without limitation the rights
00006  * to use, copy, modify, merge, publish, distribute, sublicense, and/or
00007  * sell copies of the Software, and to permit persons to whom the Software is
00008  * furnished to do so, subject to the following conditions:
00009  *
00010  * The  above copyright notice and this permission notice shall be included in
00011  * all copies or substantial portions of the Software.
00012  *
00013  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00014  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00015  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00016  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00017  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00018  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
00019  * IN THE SOFTWARE. */
00020  
00021 #ifndef _XMLSERIALIZERH
00022 #define _XMLSERIALIZERH
00023 
00024 #include <iostream>
00025 #include <sstream>
00026 #include <string>
00027 #include <vector>
00028 #ifdef HAVE_CONFIG_H //
00029 #include <config.h>
00030 #endif 
00031 #include "wsdlpull_export.h"
00032 
00033 class WSDLPULL_EXPORT XmlSerializer {
00034  
00035  public:
00036   XmlSerializer(std::ostream &os, std::string encoding="utf");
00037   XmlSerializer(std::string encoding="utf");//standard output
00038   ~XmlSerializer(void);
00039   void docdecl(std::string dd);
00040   void startDocument(std::string encoding,
00041                      bool standalone);
00042   XmlSerializer& startTag(std::string nsp, std::string name);
00043   XmlSerializer& attribute(std::string nsp,
00044                            std::string name,
00045                            std::string value);
00046   XmlSerializer& endTag(std::string nsp, std::string name);
00047   void endDocument();
00048   void entityRef(std::string name);
00049   bool getFeature(std::string name);
00050   std::string getPrefix(std::string nsp, bool create);
00051   std::string getPrefix(std::string nsp,
00052                         bool includeDefault,
00053                         bool create);
00054 
00055   void ignorableWhitespace(std::string s);
00056   void setFeature(std::string name, bool value);
00057   void setPrefix(std::string prefix, std::string nsp);
00058 
00059   void flush();
00060   std::string getNamespace();
00061   std::string getName();
00062   int getDepth();
00063   XmlSerializer& text(std::string txt);
00064   XmlSerializer& text(std::string txt, int start, int len);
00065   void cdsect(std::string data);
00066   void comment(std::string comment);
00067   void processingInstruction(std::string pi);
00068 
00069   
00070  private:
00071   std::ostream& writer;
00072   bool pending;
00073   int auto_;
00074   int depth;
00075   std::string encoding;
00076   std::vector<std::string> elementStack,nspStack;
00077   //nsp/prefix/name
00078   std::vector<int> nspCounts;
00079   //prefix/nsp; both empty are ""
00080   std::vector<bool> indent;
00081   bool unicode;
00082   void check(bool close);
00083   void writeEscaped(std::string s, int quot);
00084   void exception (std::string desc);
00085   void init();
00086 };
00087 
00088 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by  doxygen 1.6.2