Geant4 9.6.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 * @version $Id: XMLWriter.h,v 1.3 2005-06-02 21:28:45 duns Exp $
19 */
20namespace cheprep {
21
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
virtual ~XMLWriter()
Definition: XMLWriter.cc:26
void printComment(std::string comment)
Definition: XMLWriter.cc:87
void checkNameValid(std::string s)
Definition: XMLWriter.cc:280
void openTag(std::string name)
Definition: XMLWriter.cc:107
IndentPrintWriter * writer
Definition: XMLWriter.h:71
void print(std::string text)
Definition: XMLWriter.cc:98
void setAttribute(std::string ns, std::string name, std::string value)
Definition: XMLWriter.h:60
void openTag(std::string ns, std::string name)
Definition: XMLWriter.h:54
std::string normalize(std::string s)
Definition: XMLWriter.cc:201
std::string normalizeText(std::string s)
Definition: XMLWriter.cc:247
void setAttribute(std::string ns, std::string name, double value)
Definition: XMLWriter.h:63
void openDoc(std::string version="1.0", std::string encoding="", bool standalone=false)
Definition: XMLWriter.cc:36
void closeDoc(bool force=false)
Definition: XMLWriter.cc:70
void referToDTD(std::string name, std::string pid, std::string ref)
Definition: XMLWriter.cc:54
void printTag(std::string ns, std::string name)
Definition: XMLWriter.h:57
void setAttribute(std::string name, char *value)
Definition: XMLWriter.cc:137
void printAttributes(int tagLength)
Definition: XMLWriter.cc:176
void printTag(std::string name)
Definition: XMLWriter.cc:130
void println(std::string text)
Definition: XMLWriter.cc:102
void printPlain(std::string text)
Definition: XMLWriter.cc:94
long long int64
Definition: config.h:31
#define ns
Definition: xmlparse.cc:597