ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
XMLWriter.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file XMLWriter.h
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 
19 namespace cheprep {
20 
21 class XMLWriter : public AbstractXMLWriter {
22 
23  public:
24  XMLWriter(std::ostream* out, std::string indentString = " ", std::string defaultNameSpace = "");
25  virtual ~XMLWriter();
26  void close();
27  void openDoc(std::string version = "1.0", std::string encoding = "", bool standalone = false);
28  void referToDTD(std::string name, std::string pid, std::string ref);
29  void referToDTD(std::string name, std::string system);
30  void closeDoc(bool force = false);
31  void printComment(std::string comment);
32  void printPlain(std::string text);
33  void print(std::string text);
34  void println(std::string text);
35  void openTag(std::string name);
36  void closeTag();
37  void printTag(std::string name);
38  void setAttribute(std::string name, char* value);
39  void setAttribute(std::string name, std::string value);
40  void setAttribute(std::string name, std::vector<double> value);
41  void setAttribute(std::string name, int64 value);
42  void setAttribute(std::string name, int value);
43  void setAttribute(std::string name, bool value);
44  void setAttribute(std::string name, double value);
45  void printAttributes(int tagLength);
46  std::string normalize(std::string s);
47  std::string normalizeText(std::string s);
48  void checkNameValid(std::string s);
49 
50  //
51  // Can be removed when we can properly inherit those (since names are equal to overloaded ones).
52  //
53  void openTag(std::string ns, std::string name) {
54  openTag(ns == defaultNameSpace ? name : ns.append(":").append(name));
55  }
56  void printTag(std::string ns, std::string name) {
57  printTag(ns == defaultNameSpace ? name : ns.append(":").append(name));
58  }
59  void setAttribute(std::string ns, std::string name, std::string value) {
60  setAttribute(ns.append(":").append(name), value);
61  }
62  void setAttribute(std::string ns, std::string name, double value) {
63  setAttribute(ns.append(":").append(name), value);
64  }
65 
66 
67 
68  protected:
69  bool closed;
71 
72  private:
73  std::string dtdName;
74  std::map<std::string, std::string> attributes;
75  std::stack<std::string> openTags;
76 };
77 
78 } // cheprep
79 
80 #endif