wsdlpull 1.23
XmlSerializer.h
Go to the documentation of this file.
1/* Copyright (c) 2005,2007 Vivek Krishna
2 * Based on kxml2 by Stefan Haustein, Oberhausen, Rhld., Germany
3 * Permission is hereby granted, free of charge, to any person obtaining a copy
4 * of this software and associated documentation files (the "Software"), to deal
5 * in the Software without restriction, including without limitation the rights
6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or
7 * sell copies of the Software, and to permit persons to whom the Software is
8 * furnished to do so, subject to the following conditions:
9 *
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19 * IN THE SOFTWARE. */
20
21#ifndef _XMLSERIALIZERH
22#define _XMLSERIALIZERH
23
24#include <iostream>
25#include <sstream>
26#include <string>
27#include <vector>
28#ifdef HAVE_CONFIG_H //
29#include <config.h>
30#endif
31#include "wsdlpull_export.h"
32
34
35 public:
36 XmlSerializer(std::ostream &os, std::string encoding="utf");
37 XmlSerializer(std::string encoding="utf");//standard output
38 ~XmlSerializer(void);
39 void docdecl(std::string dd);
40 void startDocument(std::string encoding,
41 bool standalone);
42 XmlSerializer& startTag(std::string nsp, std::string name);
43 XmlSerializer& attribute(std::string nsp,
44 std::string name,
45 std::string value);
46 XmlSerializer& endTag(std::string nsp, std::string name);
47 void endDocument();
48 void entityRef(std::string name);
49 bool getFeature(std::string name);
50 std::string getPrefix(std::string nsp, bool create);
51 std::string getPrefix(std::string nsp,
52 bool includeDefault,
53 bool create);
54
55 void ignorableWhitespace(std::string s);
56 void setFeature(std::string name, bool value);
57 void setPrefix(std::string prefix, std::string nsp);
58
59 void flush();
60 std::string getNamespace();
61 std::string getName();
62 int getDepth();
63 XmlSerializer& text(std::string txt);
64 XmlSerializer& text(std::string txt, int start, int len);
65 void cdsect(std::string data);
66 void comment(std::string comment);
67 void processingInstruction(std::string pi);
68
69
70 private:
71 std::ostream& writer;
72 bool pending;
73 int auto_;
74 int depth;
75 std::string encoding;
76 std::vector<std::string> elementStack,nspStack;
77 //nsp/prefix/name
78 std::vector<int> nspCounts;
79 //prefix/nsp; both empty are ""
80 std::vector<bool> indent;
81 bool unicode;
82 void check(bool close);
83 void writeEscaped(std::string s, int quot);
84 void exception (std::string desc);
85 void init();
86};
87
88#endif
#define WSDLPULL_EXPORT