Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
BHepRepWriter.h
이 파일의 문서화 페이지로 가기
1 // Copyright FreeHEP, 2005.
2 #ifndef CHEPREP_BHEPREPWRITER_H
3 #define CHEPREP_BHEPREPWRITER_H
4 
5 #include "cheprep/config.h"
6 
7 #include <string>
8 #include <iostream>
9 #include <vector>
10 #include <map>
11 
13 
18 namespace cheprep {
19 
21 
22  public:
23 
24  BHepRepWriter(std::ostream& os);
25  virtual ~BHepRepWriter();
26 
27  void close();
28  void openDoc(std::string version = "BinaryHepRep/1.0", std::string encoding = "UTF-8", bool standalone = false);
29  void closeDoc(bool force = false);
30  void openTag(std::string name);
31  void closeTag();
32  void printTag(std::string name);
33  void setAttribute(std::string name, char* value);
34  void setAttribute(std::string name, std::string value);
35  void setAttribute(std::string name, std::vector<double> value);
36  void setAttribute(std::string name, int64 value);
37  void setAttribute(std::string name, int value);
38  void setAttribute(std::string name, bool value);
39  void setAttribute(std::string name, double value);
40 
41  //
42  // Can be removed when we can properly inherit those (since names are equal to overloaded ones).
43  //
44  void openTag(std::string ns, std::string name) {
45  openTag(ns == defaultNameSpace ? name : ns.append(":").append(name));
46  }
47  void printTag(std::string ns, std::string name) {
48  printTag(ns == defaultNameSpace ? name : ns.append(":").append(name));
49  }
50  void setAttribute(std::string ns, std::string name, std::string value) {
51  setAttribute(ns.append(":").append(name), value);
52  }
53  void setAttribute(std::string ns, std::string name, double value) {
54  setAttribute(ns.append(":").append(name), value);
55  }
56 
57  private:
58  static const unsigned char WBXML_VERSION = 0x03;
59  static const unsigned char UNKNOWN_PID = 0x01;
60  static const unsigned char UTF8 = 0x6a;
61 
62  // standard tags
63  static const unsigned char SWITCH_PAGE = 0x00;
64  static const unsigned char END = 0x01;
65  static const unsigned char ENTITY = 0x02;
66  static const unsigned char STR_I = 0x03;
67  static const unsigned char LITERAL = 0x04;
68 
69  static const unsigned char CONTENT = 0x40;
70  static const unsigned char EXT_I_0 = 0x40;
71  static const unsigned char EXT_I_1 = 0x41;
72  static const unsigned char EXT_I_2 = 0x42;
73  static const unsigned char PI = 0x43;
74  static const unsigned char LITERAL_C = 0x44;
75 
76  static const unsigned char ATTRIBUTE = 0x80;
77  static const unsigned char EXT_T_0 = 0x80;
78  static const unsigned char EXT_T_1 = 0x81;
79  static const unsigned char EXT_T_2 = 0x82;
80  static const unsigned char STR_T = 0x83;
81  static const unsigned char LITERAL_A = 0x84;
82 
83  static const unsigned char EXT_0 = 0xC0;
84  static const unsigned char EXT_1 = 0xC1;
85  static const unsigned char EXT_2 = 0xC2;
86  static const unsigned char OPAQUE = 0xC3;
87  static const unsigned char LITERAL_AC = 0xC4;
88 
89  // our own extensions
90  static const unsigned char STR_D = EXT_I_0;
91  static const unsigned char STR_R = EXT_T_0;
92 
93  // class definitions
94  static std::map<std::string, unsigned char> tags;
95  static std::map<std::string, unsigned char> attributes;
96  static std::map<std::string, unsigned char> values;
97 
98  // outputstream variables
99  std::ostream& os;
102 
103  // document variables
104  std::map<std::string, unsigned int> stringValues;
105 
106  // tag variables
107  std::map<std::string, std::string> stringAttributes;
108  std::map<std::string, std::vector<double> > colorAttributes;
109  std::map<std::string, int64> longAttributes;
110  std::map<std::string, int> intAttributes;
111  std::map<std::string, bool> booleanAttributes;
112  std::map<std::string, double> doubleAttributes;
113 
114  // point array
115  std::vector<double> points;
116 
117  // methods
118  void writeTag(std::string name, bool content = false);
119  void writePoints();
120  void writeStringDefine(std::string s);
121  void writeMultiByteInt(unsigned int ui);
122  void writeReal(double ui);
123  void writeLong(int64 i);
124  void writeInt(int i);
125  void writeByte(unsigned char b);
126  void writeString(std::string s);
127  };
128 
129 } // cheprep
130 
131 #endif // CHEPREP_BHEPREPWRITER_H
static const unsigned char EXT_T_0
Definition: BHepRepWriter.h:77
const XML_Char * name
Definition: expat.h:151
void openTag(std::string ns, std::string name)
Definition: BHepRepWriter.h:44
void closeDoc(bool force=false)
static const unsigned char EXT_T_1
Definition: BHepRepWriter.h:78
void writeMultiByteInt(unsigned int ui)
std::map< std::string, int > intAttributes
std::map< std::string, int64 > longAttributes
std::map< std::string, double > doubleAttributes
static const unsigned char STR_D
Definition: BHepRepWriter.h:90
static const unsigned char STR_I
Definition: BHepRepWriter.h:66
void setAttribute(std::string ns, std::string name, double value)
Definition: BHepRepWriter.h:53
static const unsigned char SWITCH_PAGE
Definition: BHepRepWriter.h:63
static const unsigned char LITERAL_AC
Definition: BHepRepWriter.h:87
void openDoc(std::string version="BinaryHepRep/1.0", std::string encoding="UTF-8", bool standalone=false)
static const unsigned char PI
Definition: BHepRepWriter.h:73
const XML_Char const XML_Char int standalone
Definition: expat.h:187
void setAttribute(std::string name, char *value)
void writeTag(std::string name, bool content=false)
const XML_Char * s
Definition: expat.h:262
static const unsigned char CONTENT
Definition: BHepRepWriter.h:69
static const unsigned char OPAQUE
Definition: BHepRepWriter.h:86
const XML_Char int const XML_Char * value
Definition: expat.h:331
static const unsigned char EXT_I_1
Definition: BHepRepWriter.h:71
long long int64
Definition: config.h:31
void printTag(std::string name)
static const unsigned char EXT_1
Definition: BHepRepWriter.h:84
static const unsigned char EXT_I_0
Definition: BHepRepWriter.h:70
static const unsigned char EXT_T_2
Definition: BHepRepWriter.h:79
static const unsigned char UNKNOWN_PID
Definition: BHepRepWriter.h:59
static const unsigned char LITERAL_C
Definition: BHepRepWriter.h:74
BHepRepWriter(std::ostream &os)
static const unsigned char EXT_2
Definition: BHepRepWriter.h:85
std::map< std::string, std::vector< double > > colorAttributes
const XML_Char * version
Definition: expat.h:187
static std::map< std::string, unsigned char > values
Definition: BHepRepWriter.h:96
std::map< std::string, bool > booleanAttributes
static const unsigned char STR_T
Definition: BHepRepWriter.h:80
static const unsigned char WBXML_VERSION
Definition: BHepRepWriter.h:58
static const unsigned char EXT_0
Definition: BHepRepWriter.h:83
void writeString(std::string s)
static const unsigned char EXT_I_2
Definition: BHepRepWriter.h:72
void writeByte(unsigned char b)
static const unsigned char LITERAL_A
Definition: BHepRepWriter.h:81
static const unsigned char LITERAL
Definition: BHepRepWriter.h:67
static std::map< std::string, unsigned char > tags
Definition: BHepRepWriter.h:94
void printTag(std::string ns, std::string name)
Definition: BHepRepWriter.h:47
static std::map< std::string, unsigned char > attributes
Definition: BHepRepWriter.h:95
static const unsigned char UTF8
Definition: BHepRepWriter.h:60
void setAttribute(std::string ns, std::string name, std::string value)
Definition: BHepRepWriter.h:50
static const unsigned char END
Definition: BHepRepWriter.h:64
std::vector< double > points
std::map< std::string, std::string > stringAttributes
void writeStringDefine(std::string s)
void writeReal(double ui)
std::map< std::string, unsigned int > stringValues
#define ns
Definition: xmlparse.cc:614
static const unsigned char STR_R
Definition: BHepRepWriter.h:91
void openTag(std::string name)