Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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
16/**
17 * @author Mark Donszelmann
18 */
19namespace cheprep {
20
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
virtual ~XMLWriter()
Definition: XMLWriter.cc:25
void printComment(std::string comment)
Definition: XMLWriter.cc:86
void checkNameValid(std::string s)
Definition: XMLWriter.cc:279
void openTag(std::string name)
Definition: XMLWriter.cc:106
IndentPrintWriter * writer
Definition: XMLWriter.h:70
void print(std::string text)
Definition: XMLWriter.cc:97
void setAttribute(std::string ns, std::string name, std::string value)
Definition: XMLWriter.h:59
void openTag(std::string ns, std::string name)
Definition: XMLWriter.h:53
std::string normalize(std::string s)
Definition: XMLWriter.cc:200
std::string normalizeText(std::string s)
Definition: XMLWriter.cc:246
void setAttribute(std::string ns, std::string name, double value)
Definition: XMLWriter.h:62
void openDoc(std::string version="1.0", std::string encoding="", bool standalone=false)
Definition: XMLWriter.cc:35
void closeDoc(bool force=false)
Definition: XMLWriter.cc:69
void referToDTD(std::string name, std::string pid, std::string ref)
Definition: XMLWriter.cc:53
void printTag(std::string ns, std::string name)
Definition: XMLWriter.h:56
void setAttribute(std::string name, char *value)
Definition: XMLWriter.cc:136
void printAttributes(int tagLength)
Definition: XMLWriter.cc:175
void printTag(std::string name)
Definition: XMLWriter.cc:129
void println(std::string text)
Definition: XMLWriter.cc:101
void printPlain(std::string text)
Definition: XMLWriter.cc:93
long long int64
Definition: config.h:30
#define ns
Definition: xmlparse.cc:614