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 <map>
00025 #include <iostream>
00026 #include <sstream>
00027 #include <string>
00028 #include <vector>
00029
00030
00031
00032 class XmlSerializer {
00033
00034 public:
00035 XmlSerializer(std::ostream &os, std::string encoding="utf");
00036 XmlSerializer(std::string encoding="utf");
00037 ~XmlSerializer(void);
00038 void docdecl(std::string dd);
00039 void startDocument(std::string encoding,
00040 bool standalone);
00041 XmlSerializer& startTag(std::string nsp, std::string name);
00042 XmlSerializer& attribute(std::string nsp,
00043 std::string name,
00044 std::string value);
00045 XmlSerializer& endTag(std::string nsp, std::string name);
00046 void endDocument();
00047 void entityRef(std::string name);
00048 bool getFeature(std::string name);
00049 std::string getPrefix(std::string nsp, bool create);
00050 std::string getPrefix(std::string nsp,
00051 bool includeDefault,
00052 bool create);
00053
00054 void ignorableWhitespace(std::string s);
00055 void setFeature(std::string name, bool value);
00056 void setPrefix(std::string prefix, std::string nsp);
00057
00058 void flush();
00059 std::string getNamespace();
00060 std::string getName();
00061 int getDepth();
00062 XmlSerializer& text(std::string txt);
00063 XmlSerializer& text(std::string txt, int start, int len);
00064 void cdsect(std::string data);
00065 void comment(std::string comment);
00066 void processingInstruction(std::string pi);
00067
00068
00069 private:
00070 std::ostream& writer;
00071 bool pending;
00072 int auto_;
00073 int depth;
00074 std::string encoding;
00075 std::vector<std::string> elementStack,nspStack;
00076
00077 std::vector<int> nspCounts;
00078
00079 std::vector<bool> indent;
00080 bool unicode;
00081 void check(bool close);
00082 void writeEscaped(std::string s, int quot);
00083 void exception (std::string desc);
00084 void init();
00085 };
00086
00087 #endif