Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
XMLWriter.h
Go to the documentation of this file.
1 // Copyright FreeHEP, 2005.
2 #ifndef CHEPREP_XMLWRITER_H
3 #define CHEPREP_XMLWRITER_H 1
4 
5 #include "cheprep/config.h"
6 
7 #include <iostream>
8 #include <map>
9 #include <stack>
10 #include <vector>
11 #include <string>
12 
15 
20 namespace cheprep {
21 
22 class XMLWriter : public AbstractXMLWriter {
23 
24  public:
25  XMLWriter(std::ostream* out, std::string indentString = " ", std::string defaultNameSpace = "");
26  virtual ~XMLWriter();
27  void close();
28  void openDoc(std::string version = "1.0", std::string encoding = "", bool standalone = false);
29  void referToDTD(std::string name, std::string pid, std::string ref);
30  void referToDTD(std::string name, std::string system);
31  void closeDoc(bool force = false);
32  void printComment(std::string comment);
33  void printPlain(std::string text);
34  void print(std::string text);
35  void println(std::string text);
36  void openTag(std::string name);
37  void closeTag();
38  void printTag(std::string name);
39  void setAttribute(std::string name, char* value);
40  void setAttribute(std::string name, std::string value);
41  void setAttribute(std::string name, std::vector<double> value);
42  void setAttribute(std::string name, int64 value);
43  void setAttribute(std::string name, int value);
44  void setAttribute(std::string name, bool value);
45  void setAttribute(std::string name, double value);
46  void printAttributes(int tagLength);
47  std::string normalize(std::string s);
48  std::string normalizeText(std::string s);
49  void checkNameValid(std::string s);
50 
51  //
52  // Can be removed when we can properly inherit those (since names are equal to overloaded ones).
53  //
54  void openTag(std::string ns, std::string name) {
55  openTag(ns == defaultNameSpace ? name : ns.append(":").append(name));
56  }
57  void printTag(std::string ns, std::string name) {
58  printTag(ns == defaultNameSpace ? name : ns.append(":").append(name));
59  }
60  void setAttribute(std::string ns, std::string name, std::string value) {
61  setAttribute(ns.append(":").append(name), value);
62  }
63  void setAttribute(std::string ns, std::string name, double value) {
64  setAttribute(ns.append(":").append(name), value);
65  }
66 
67 
68 
69  protected:
70  bool closed;
72 
73  private:
74  std::string dtdName;
75  std::map<std::string, std::string> attributes;
76  std::stack<std::string> openTags;
77 };
78 
79 } // cheprep
80 
81 #endif
std::string normalizeText(std::string s)
Definition: XMLWriter.cc:247
const XML_Char * name
Definition: expat.h:151
void println(std::string text)
Definition: XMLWriter.cc:102
void printTag(std::string ns, std::string name)
Definition: XMLWriter.h:57
void printTag(std::string name)
Definition: XMLWriter.cc:130
void printComment(std::string comment)
Definition: XMLWriter.cc:87
void closeDoc(bool force=false)
Definition: XMLWriter.cc:70
void printAttributes(int tagLength)
Definition: XMLWriter.cc:176
void referToDTD(std::string name, std::string pid, std::string ref)
Definition: XMLWriter.cc:54
XMLWriter(std::ostream *out, std::string indentString=" ", std::string defaultNameSpace="")
Definition: XMLWriter.cc:18
const XML_Char const XML_Char int standalone
Definition: expat.h:187
void setAttribute(std::string ns, std::string name, std::string value)
Definition: XMLWriter.h:60
const XML_Char * s
Definition: expat.h:262
void openTag(std::string name)
Definition: XMLWriter.cc:107
void print(std::string text)
Definition: XMLWriter.cc:98
void openTag(std::string ns, std::string name)
Definition: XMLWriter.h:54
const XML_Char int const XML_Char * value
Definition: expat.h:331
long long int64
Definition: config.h:31
IndentPrintWriter * writer
Definition: XMLWriter.h:71
std::string normalize(std::string s)
Definition: XMLWriter.cc:201
virtual ~XMLWriter()
Definition: XMLWriter.cc:26
const XML_Char * version
Definition: expat.h:187
void setAttribute(std::string name, char *value)
Definition: XMLWriter.cc:137
void openDoc(std::string version="1.0", std::string encoding="", bool standalone=false)
Definition: XMLWriter.cc:36
void printPlain(std::string text)
Definition: XMLWriter.cc:94
void checkNameValid(std::string s)
Definition: XMLWriter.cc:280
#define ns
Definition: xmlparse.cc:614
void setAttribute(std::string ns, std::string name, double value)
Definition: XMLWriter.h:63