Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

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 
00032 
00033 #ifndef WSDLPULL_EXPORT
00034 #if (defined _MSC_VER) && (defined _MT)
00035 #define WSDLPULL_EXPORT __declspec (dllimport)
00036 #else
00037 #define WSDLPULL_EXPORT 
00038 #endif
00039 #endif
00040 
00041 
00042 class WSDLPULL_EXPORT XmlSerializer {
00043  
00044  public:
00045   XmlSerializer(std::ostream &os, std::string encoding="utf");
00046   XmlSerializer(std::string encoding="utf");//standard output
00047   ~XmlSerializer(void);
00048   void docdecl(std::string dd);
00049   void startDocument(std::string encoding,
00050                      bool standalone);
00051   XmlSerializer& startTag(std::string nsp, std::string name);
00052   XmlSerializer& attribute(std::string nsp,
00053                            std::string name,
00054                            std::string value);
00055   XmlSerializer& endTag(std::string nsp, std::string name);
00056   void endDocument();
00057   void entityRef(std::string name);
00058   bool getFeature(std::string name);
00059   std::string getPrefix(std::string nsp, bool create);
00060   std::string getPrefix(std::string nsp,
00061                         bool includeDefault,
00062                         bool create);
00063 
00064   void ignorableWhitespace(std::string s);
00065   void setFeature(std::string name, bool value);
00066   void setPrefix(std::string prefix, std::string nsp);
00067 
00068   void flush();
00069   std::string getNamespace();
00070   std::string getName();
00071   int getDepth();
00072   XmlSerializer& text(std::string txt);
00073   XmlSerializer& text(std::string txt, int start, int len);
00074   void cdsect(std::string data);
00075   void comment(std::string comment);
00076   void processingInstruction(std::string pi);
00077 
00078   
00079  private:
00080   std::ostream& writer;
00081   bool pending;
00082   int auto_;
00083   int depth;
00084   std::string encoding;
00085   std::vector<std::string> elementStack,nspStack;
00086   //nsp/prefix/name
00087   std::vector<int> nspCounts;
00088   //prefix/nsp; both empty are ""
00089   std::vector<bool> indent;
00090   bool unicode;
00091   void check(bool close);
00092   void writeEscaped(std::string s, int quot);
00093   void exception (std::string desc);
00094   void init();
00095 };
00096 
00097 #endif

Generated on Mon Feb 6 23:02:42 2006 for wsdlpull by  doxygen 1.3.9.1