Vegastrike 0.5.1 rc1
1.0
Original sources for Vegastrike Evolved
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
xml_serializer.h
Go to the documentation of this file.
1
#ifndef _XML_SERIALIZER_H_
2
#define _XML_SERIALIZER_H_
3
#include "
xml_support.h
"
4
#include <vector>
5
#include <string>
6
#include "
vsfilesystem.h
"
7
using
std::string;
8
using
std::vector;
9
struct
XMLType
10
{
11
union
wordlength
12
{
13
int
*
i
;
14
unsigned
int
*
ui
;
15
float
*
f
;
16
void
*
p
;
17
char
*
c
;
18
//short * s;
19
bool
*
b
;
20
double
*
d
;
21
//unsigned short * us;
22
unsigned
char
*
uc
;
23
int
hardint
;
24
float
hardfloat
;
25
}
26
w
;
27
std::string
str
;
28
XMLType
(
bool
*mybool )
29
{
30
w
.
b
= mybool;
31
}
32
XMLType
(
double
*mydouble )
33
{
34
w
.
d
= mydouble;
35
}
36
XMLType
(
int
*myint )
37
{
38
w
.
i
= myint;
39
}
40
XMLType
(
unsigned
int
*myuint )
41
{
42
w
.
ui
= myuint;
43
}
44
XMLType
(
int
myhardint )
45
{
46
w
.
hardint
= myhardint;
47
}
48
XMLType
(
float
myhardfloat )
49
{
50
w
.
hardfloat
= myhardfloat;
51
}
52
XMLType
(
float
*myfloat )
53
{
54
w
.
f
= myfloat;
55
}
56
XMLType
(
void
*myvoid )
57
{
58
w
.
p
= myvoid;
59
}
60
XMLType
(
char
*mychar )
61
{
62
w
.
c
= mychar;
63
}
64
//XMLType (short * mychar) {w.s=mychar;} // removing useless shorts - use integers instead
65
//XMLType (unsigned short * mychar) {w.us=mychar;} // removing useless shorts - use integers instead
66
XMLType
(
unsigned
char
*mychar )
67
{
68
w
.
uc
= mychar;
69
}
70
XMLType
(
const
std::string &s ) :
str
( s )
71
{
72
w
.
p
= &this->
str
;
73
}
74
XMLType
(
const
std::string &s,
void
*
v
) :
str
( s )
75
{
76
w
.
p
=
v
;
77
}
78
XMLType
(
const
std::string &s,
int
myhardint ) :
str
( s )
79
{
80
w
.
hardint
= myhardint;
81
}
82
XMLType
(
const
std::string &s,
float
*f ) :
str
( s )
83
{
84
w
.
f
= f;
85
}
86
};
87
typedef
std::string (
XMLHandler
)(
const
XMLType
&input,
void
*mythis );
88
XMLHandler
intHandler
;
89
XMLHandler
floatHandler
;
90
XMLHandler
intStarHandler
;
91
//XMLHandler shortStarHandler;
92
//XMLHandler shortToFloatHandler;
93
//XMLHandler ushortStarHandler;
94
XMLHandler
intToFloatHandler
;
95
XMLHandler
uintStarHandler
;
96
XMLHandler
charStarHandler
;
97
XMLHandler
boolStarHandler
;
98
XMLHandler
doubleStarHandler
;
99
XMLHandler
ucharStarHandler
;
100
XMLHandler
negationCharStarHandler
;
101
XMLHandler
floatStarHandler
;
102
XMLHandler
fabsFloatStarHandler
;
103
//XMLHandler absShortStarHandler;
104
XMLHandler
absIntStarHandler
;
105
106
XMLHandler
speedStarHandler
;
107
XMLHandler
accelStarHandler
;
108
109
XMLHandler
scaledFloatStarHandler
;
110
XMLHandler
angleStarHandler
;
111
XMLHandler
negationFloatStarHandler
;
112
XMLHandler
negationIntStarHandler
;
113
XMLHandler
stringStarHandler
;
114
XMLHandler
stringHandler
;
115
XMLHandler
lessNeg1Handler
;
116
XMLHandler
cloakHandler
;
117
118
struct
XMLElement
119
{
120
std::string
elem
;
121
XMLType
value
;
122
XMLHandler
*
handler
;
123
XMLElement
(
const
std::string &ele,
const
XMLType
&val,
XMLHandler
*hand ) :
value
( val )
124
{
125
elem
= ele;
126
handler
= hand;
127
}
128
void
Write
(
VSFileSystem::VSFile
&f,
void
*mythis );
129
string
WriteString
(
void
*mythis );
130
};
131
struct
XMLnode
132
{
133
XMLnode
*
up
;
134
std::string
val
;
135
vector< XMLElement >
elements
;
136
vector< XMLnode >
subnodes
;
137
XMLnode
()
138
{
139
up
= NULL;
140
}
141
XMLnode
(
const
std::string &
val
,
XMLnode
*newup )
142
{
143
this->val =
val
;
144
up
= newup;
145
}
146
void
Write
(
VSFileSystem::VSFile
&f,
void
*mythis,
int
tablevel );
147
string
WriteString
(
void
*mythis,
int
tablevel );
148
};
149
class
XMLSerializer
150
{
151
std::string filename;
152
std::string savedir;
153
void
*mythis;
154
XMLnode
topnode;
155
XMLnode
*curnode;
156
public
:
157
std::string
randomdata
[1];
158
XMLSerializer
(
const
char
*filename,
const
char
*modificationname,
void
*mythis );
159
void
AddTag
(
const
std::string &tag );
160
void
AddElement
(
const
std::string &element,
XMLHandler
*handler,
const
XMLType
&input );
161
void
Write
(
const
char
*modificationname =
""
);
162
string
WriteString
();
163
void
EndTag
(
const
std::string endname =
string
(
""
) );
164
std::string
getName
()
165
{
166
return
filename;
167
}
168
void
setName
(
const
std::string &fil )
169
{
170
this->filename = fil;
171
}
172
};
173
#endif
174
src
xml_serializer.h
Generated on Fri May 29 2015 23:07:40 for Vegastrike 0.5.1 rc1 by
1.8.4