00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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");
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
00087 std::vector<int> nspCounts;
00088
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