1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
// file : XSCRT/Parser.ipp
// author : Boris Kolpackov <boris@dre.vanderbilt.edu>
// cvs-id : $Id$
namespace XSCRT
{
/*
//@@ recode to delegate to one function.
//
template<>
inline
std::wstring
parse<std::wstring> (XML::Element const& e, Parser&, std::wstring*)
{
return XML::transcode (e.dom_element ()->getTextContent ());
}
template<>
inline
std::wstring
parse<std::wstring> (XML::Attribute const& a, Parser&, std::wstring*)
{
return a.value ();
}
template<>
inline
XMLSchema::byte
parse<XMLSchema::byte> (XML::Element const& e, Parser& p, XMLSchema::byte*)
{
wchar_t r;
std::wstringstream s;
s << parse<std::wstring> (e, p, 0);
s >> r;
return static_cast<char>(r);
}
template<>
inline
XMLSchema::byte
parse<XMLSchema::byte> (XML::Attribute const& a, Parser&, XMLSchema::byte*)
{
wchar_t r;
std::wstringstream s;
s << a.value ();
s >> r;
return static_cast<char>(r);
}
template<>
inline
XMLSchema::unsignedByte
parse<XMLSchema::unsignedByte> (XML::Element const& e,
Parser& p,
XMLSchema::unsignedByte*)
{
wchar_t r;
std::wstringstream s;
s << parse<std::wstring> (e, p, 0);
s >> r;
return static_cast<unsigned char>(r);
}
template<>
inline
XMLSchema::unsignedByte
parse<XMLSchema::unsignedByte> (XML::Attribute const& a,
Parser&,
XMLSchema::unsignedByte*)
{
wchar_t r;
std::wstringstream s;
s << a.value ();
s >> r;
return static_cast<unsigned char>(r);
}
template<>
inline
XMLSchema::unsignedLong
parse<XMLSchema::unsignedLong> (XML::Element const& e,
Parser& p,
XMLSchema::unsignedLong*)
{
unsigned long r;
std::wstringstream s;
s << parse<std::wstring> (e, p, 0);
s >> r;
return r;
}
template<>
inline
XMLSchema::unsignedLong
parse<XMLSchema::unsignedLong> (XML::Attribute const& a,
Parser&,
XMLSchema::unsignedLong*)
{
unsigned long r;
std::wstringstream s;
s << a.value ();
s >> r;
return r;
}
template<>
inline
XMLSchema::boolean
parse<XMLSchema::boolean> (XML::Element const& e,
Parser& p,
XMLSchema::boolean*)
{
return parse<std::wstring> (e, p, 0) == L"true";
}
template<>
inline
XMLSchema::boolean
parse<XMLSchema::boolean> (XML::Attribute const& a,
Parser&,
XMLSchema::boolean*)
{
return a.value () == L"true";
}
// ID
//
//
template<>
inline
XMLSchema::ID
parse<XMLSchema::ID> (std::wstring const& s, Parser&, XMLSchema::ID*)
{
return XMLSchema::ID (s);
}
template<>
inline
XMLSchema::ID
parse<XMLSchema::ID> (XML::Element const& e, Parser& p, XMLSchema::ID*)
{
return parse<XMLSchema::ID> (parse<std::wstring> (e, p, 0), p, 0);
}
template<>
inline
XMLSchema::ID
parse<XMLSchema::ID> (XML::Attribute const& a, Parser& p, XMLSchema::ID*)
{
return parse<XMLSchema::ID> (a.value (), p, 0);
}
// IDREF
//
//
template<>
inline
XMLSchema::IDREF
parse<XMLSchema::IDREF> (std::wstring const& s, Parser&, XMLSchema::IDREF*)
{
return XMLSchema::IDREF (s);
}
template<>
inline
XMLSchema::IDREF
parse<XMLSchema::IDREF> (XML::Element const& e, Parser& p, XMLSchema::IDREF*)
{
return parse<XMLSchema::IDREF> (parse<std::wstring> (e, p, 0), p, 0);
}
template<>
inline
XMLSchema::IDREF
parse<XMLSchema::IDREF> (XML::Attribute const& a,
Parser& p,
XMLSchema::IDREF*)
{
return parse<XMLSchema::IDREF> (a.value (), p, 0);
}
// string
//
//
template<>
inline
XMLSchema::string
parse<XMLSchema::string> (std::wstring const& s, Parser&, XMLSchema::string*)
{
return s;
}
template<>
inline
XMLSchema::string
parse<XMLSchema::string> (XML::Element const& e,
Parser& p,
XMLSchema::string*)
{
return parse<XMLSchema::string> (parse<std::wstring> (e, p, 0), p, 0);
}
template<>
inline
XMLSchema::string
parse<XMLSchema::string> (XML::Attribute const& a,
Parser& p,
XMLSchema::string*)
{
return parse<XMLSchema::string> (a.value (), p, 0);
}
*/
}
|