29 namespace jmmcg {
namespace LIBJMMCG_VER_NAMESPACE {
namespace NTUtils {
namespace XML {
33 static const tchar *
const node_types_names[]={
39 return doc->createNode(node_types_names[type],node_name,xml_ns);
44 return node->appendChild(CreateNode(type,node_name,doc,xml_ns));
49 const MSXML2::IXMLDOMNodePtr comment_node(CreateNode(element,node_name,doc,xml_ns,node));
50 const MSXML2::IXMLDOMTextPtr text(CreateNode(text,node_name,doc,xml_ns,comment_node));
51 text->nodeValue=comment;
57 return tstring(
static_cast<
const tchar *>(doc->parseError->reason));
62 inline void __fastcall
63 ToXML(
const MSXML2::IXMLDOMDocumentPtr &doc,
const MSXML2::IXMLDOMNodePtr &n,
const POINT &pt,
const tchar *xml_ns) {
65 const MSXML2::IXMLDOMElementPtr node(CreateNode(element,_T(
"point"),doc,xml_ns,n));
66 node->setAttribute(_T(
"x"),pt.x);
67 node->setAttribute(_T(
"y"),pt.y);
68 }
catch (
const _com_error &err) {
69 info::function info(__LINE__,
__PRETTY_FUNCTION__,
typeid(
void),info::function::argument(_T(
"const MSXML2::IXMLDOMDocumentPtr &"),tostring(doc)));
70 info.add_arg(_T(
"const MSXML2::IXMLDOMNodePtr &"),tostring(n));
71 info.add_arg(_T(
"const POINT *"),tostring(&pt));
72 info.add_arg(_T(
"const tchar *"),xml_ns);
73 throw exception(err.ErrorMessage(),info,JMMCG_REVISION_HDR(_T(LIBJMMCG_VERSION_NUMBER)));
77 inline void __fastcall
78 FromXML(
const MSXML2::IXMLDOMNodePtr &n,POINT &pt) {
80 const MSXML2::IXMLDOMNamedNodeMapPtr attribs(n->selectSingleNode(_T(
"point"))->attributes);
81 fromstring(
static_cast<
const tchar *>(attribs->getNamedItem(_T(
"x"))->text),pt.x);
82 fromstring(
static_cast<
const tchar *>(attribs->getNamedItem(_T(
"y"))->text),pt.y);
83 }
catch (
const _com_error &err) {
84 info::function info(__LINE__,
__PRETTY_FUNCTION__,
typeid(
void),info::function::argument(_T(
"const MSXML2::IXMLDOMNodePtr &"),tostring(n)));
85 info.add_arg(_T(
"const POINT *"),tostring(&pt));
86 throw exception(err.ErrorMessage(),info,JMMCG_REVISION_HDR(_T(LIBJMMCG_VERSION_NUMBER)));
90 inline void __fastcall
91 ToXML(
const MSXML2::IXMLDOMDocumentPtr &doc,
const MSXML2::IXMLDOMNodePtr &n,
const RECT &rect,
const tchar *xml_ns) {
93 const MSXML2::IXMLDOMElementPtr node(CreateNode(element,_T(
"rectangle"),doc,xml_ns,n));
94 node->setAttribute(_T(
"top"),rect.top);
95 node->setAttribute(_T(
"left"),rect.left);
96 node->setAttribute(_T(
"bottom"),rect.bottom);
97 node->setAttribute(_T(
"right"),rect.right);
98 }
catch (
const _com_error &err) {
99 info::function info(__LINE__,
__PRETTY_FUNCTION__,
typeid(
void),info::function::argument(_T(
"const MSXML2::IXMLDOMDocumentPtr &"),tostring(doc)));
100 info.add_arg(_T(
"const MSXML2::IXMLDOMNodePtr &"),tostring(n));
101 info.add_arg(_T(
"const RECT *"),tostring(&rect));
102 info.add_arg(_T(
"const tchar *"),xml_ns);
103 throw exception(err.ErrorMessage(),info,JMMCG_REVISION_HDR(_T(LIBJMMCG_VERSION_NUMBER)));
107 inline void __fastcall
108 FromXML(
const MSXML2::IXMLDOMNodePtr &n,RECT &rect) {
110 const MSXML2::IXMLDOMNamedNodeMapPtr attribs(n->selectSingleNode(_T(
"rectangle"))->attributes);
111 fromstring(
static_cast<
const tchar *>(attribs->getNamedItem(_T(
"top"))->text),rect.top);
112 fromstring(
static_cast<
const tchar *>(attribs->getNamedItem(_T(
"left"))->text),rect.left);
113 fromstring(
static_cast<
const tchar *>(attribs->getNamedItem(_T(
"bottom"))->text),rect.bottom);
114 fromstring(
static_cast<
const tchar *>(attribs->getNamedItem(_T(
"right"))->text),rect.right);
115 }
catch (
const _com_error &err) {
116 info::function info(__LINE__,
__PRETTY_FUNCTION__,
typeid(
void),info::function::argument(_T(
"const MSXML2::IXMLDOMNodePtr &"),tostring(n)));
117 info.add_arg(_T(
"const RECT *"),tostring(&rect));
118 throw exception(err.ErrorMessage(),info,JMMCG_REVISION_HDR(_T(LIBJMMCG_VERSION_NUMBER)));
122 template<
typename Value>
inline void __fastcall
123 ToXML(
const MSXML2::IXMLDOMDocumentPtr &doc,
const MSXML2::IXMLDOMNodePtr &n,
const tchar *colln_name,
const std::vector<Value> &colln,
const tchar *xml_ns) {
125 const MSXML2::IXMLDOMNodePtr colln_node(CreateNode(element,colln_name,doc,xml_ns,n));
126 for (std::vector<Value>::const_iterator i(colln.begin());i!=colln.end();++i) {
127 const MSXML2::IXMLDOMNodePtr node(CreateNode(element,_T(
"node"),doc,xml_ns,colln_node));
130 }
catch (
const _com_error &err) {
131 info::function info(__LINE__,
__PRETTY_FUNCTION__,
typeid(
void),info::function::argument(_T(
"const MSXML2::IXMLDOMDocumentPtr &"),tostring(doc)));
132 info.add_arg(_T(
"const MSXML2::IXMLDOMNodePtr &"),tostring(n));
133 info.add_arg(_T(
"const tchar *"),colln_name);
134 info.add_arg(_T(
"const std::vector<Value> *"),tostring(&colln));
135 info.add_arg(_T(
"const tchar *"),xml_ns);
136 throw exception(err.ErrorMessage(),info,JMMCG_REVISION_HDR(_T(LIBJMMCG_VERSION_NUMBER)));
140 template<>
inline void __fastcall
141 ToXML(
const MSXML2::IXMLDOMDocumentPtr &doc,
const MSXML2::IXMLDOMNodePtr &n,
const tchar *colln_name,
const std::vector<
double> &colln,
const tchar *xml_ns) {
143 const MSXML2::IXMLDOMNodePtr colln_node(CreateNode(element,colln_name,doc,xml_ns,n));
144 for (std::vector<
double>::const_iterator i(colln.begin());i!=colln.end();++i) {
145 const MSXML2::IXMLDOMElementPtr node(CreateNode(element,_T(
"node"),doc,xml_ns,colln_node));
146 node->setAttribute(_T(
"value"),*i);
148 }
catch (
const _com_error &err) {
149 info::function info(__LINE__,
__PRETTY_FUNCTION__,
typeid(
void),info::function::argument(_T(
"const MSXML2::IXMLDOMDocumentPtr &"),tostring(doc)));
150 info.add_arg(_T(
"const MSXML2::IXMLDOMNodePtr &"),tostring(n));
151 info.add_arg(_T(
"const tchar *"),colln_name);
152 info.add_arg(_T(
"const std::vector<double> *"),tostring(&colln));
153 info.add_arg(_T(
"const tchar *"),xml_ns);
154 throw exception(err.ErrorMessage(),info,JMMCG_REVISION_HDR(_T(LIBJMMCG_VERSION_NUMBER)));
158 template<>
inline void __fastcall
159 ToXML(
const MSXML2::IXMLDOMDocumentPtr &doc,
const MSXML2::IXMLDOMNodePtr &n,
const tchar *colln_name,
const std::vector<
unsigned long> &colln,
const tchar *xml_ns) {
161 const MSXML2::IXMLDOMNodePtr colln_node(CreateNode(element,colln_name,doc,xml_ns,n));
162 for (std::vector<
unsigned long>::const_iterator i(colln.begin());i!=colln.end();++i) {
163 const MSXML2::IXMLDOMElementPtr node(CreateNode(element,_T(
"node"),doc,xml_ns,colln_node));
164 node->setAttribute(_T(
"value"),
static_cast<
long>(*i));
166 }
catch (
const _com_error &err) {
167 info::function info(__LINE__,
__PRETTY_FUNCTION__,
typeid(
void),info::function::argument(_T(
"const MSXML2::IXMLDOMDocumentPtr &"),tostring(doc)));
168 info.add_arg(_T(
"const MSXML2::IXMLDOMNodePtr &"),tostring(n));
169 info.add_arg(_T(
"const tchar *"),colln_name);
170 info.add_arg(_T(
"const std::vector<unsigned long> *"),tostring(&colln));
171 info.add_arg(_T(
"const tchar *"),xml_ns);
172 throw exception(err.ErrorMessage(),info,JMMCG_REVISION_HDR(_T(LIBJMMCG_VERSION_NUMBER)));
176 template<>
inline void __fastcall
177 ToXML(
const MSXML2::IXMLDOMDocumentPtr &doc,
const MSXML2::IXMLDOMNodePtr &n,
const tchar *colln_name,
const std::vector<CPoint> &colln,
const tchar *xml_ns) {
179 const MSXML2::IXMLDOMNodePtr colln_node(CreateNode(element,colln_name,doc,xml_ns,n));
180 for (std::vector<CPoint>::const_iterator i(colln.begin());i!=colln.end();++i) {
181 const MSXML2::IXMLDOMNodePtr node(CreateNode(element,_T(
"node"),doc,xml_ns,colln_node));
182 ToXML(doc,node,*i,xml_ns);
184 }
catch (
const _com_error &err) {
185 info::function info(__LINE__,
__PRETTY_FUNCTION__,
typeid(
void),info::function::argument(_T(
"const MSXML2::IXMLDOMDocumentPtr &"),tostring(doc)));
186 info.add_arg(_T(
"const MSXML2::IXMLDOMNodePtr &"),tostring(n));
187 info.add_arg(_T(
"const tchar *"),colln_name);
188 info.add_arg(_T(
"const std::vector<CPoint> *"),tostring(&colln));
189 info.add_arg(_T(
"const tchar *"),xml_ns);
190 throw exception(err.ErrorMessage(),info,JMMCG_REVISION_HDR(_T(LIBJMMCG_VERSION_NUMBER)));
194 template<
typename Value>
inline void __fastcall
195 FromXML(
const MSXML2::IXMLDOMNodePtr &n,
const tstring &colln_name,std::vector<Value> &colln) {
197 assert(colln.empty());
198 const MSXML2::IXMLDOMNodeListPtr nodes(n->selectNodes((colln_name+_T(
"/*")).c_str()));
199 for (
long i=0;i<nodes->length;++i) {
200 colln.push_back(Value::FromXML(nodes->item[i]));
202 }
catch (
const _com_error &err) {
203 info::function info(__LINE__,
__PRETTY_FUNCTION__,
typeid(
void),info::function::argument(_T(
"const MSXML2::IXMLDOMNodePtr &"),tostring(n)));
204 info.add_arg(_T(
"const tchar *"),colln_name);
205 info.add_arg(_T(
"const std::vector<Value> *"),tostring(&colln));
206 throw exception(err.ErrorMessage(),info,JMMCG_REVISION_HDR(_T(LIBJMMCG_VERSION_NUMBER)));
210 template<>
inline void __fastcall
211 FromXML(
const MSXML2::IXMLDOMNodePtr &n,
const tstring &colln_name,std::vector<
double> &colln) {
213 assert(colln.empty());
214 const MSXML2::IXMLDOMNodeListPtr nodes(n->selectNodes((colln_name+_T(
"/node/@value")).c_str()));
215 for (
long i=0;i<nodes->length;++i) {
217 fromstring(
static_cast<
const tchar *>(nodes->item[i]->text),tmp);
218 colln.push_back(tmp);
220 }
catch (
const _com_error &err) {
221 info::function info(__LINE__,
__PRETTY_FUNCTION__,
typeid(
void),info::function::argument(_T(
"const MSXML2::IXMLDOMNodePtr &"),tostring(n)));
222 info.add_arg(_T(
"const tchar *"),colln_name);
223 info.add_arg(_T(
"const std::vector<double> *"),tostring(&colln));
224 throw exception(err.ErrorMessage(),info,JMMCG_REVISION_HDR(_T(LIBJMMCG_VERSION_NUMBER)));
228 template<>
inline void __fastcall
229 FromXML(
const MSXML2::IXMLDOMNodePtr &n,
const tstring &colln_name,std::vector<
unsigned long> &colln) {
231 assert(colln.empty());
232 const MSXML2::IXMLDOMNodeListPtr nodes(n->selectNodes((colln_name+_T(
"/node/@value")).c_str()));
233 for (
long i=0;i<nodes->length;++i) {
235 fromstring(
static_cast<
const tchar *>(nodes->item[i]->text),tmp);
236 colln.push_back(tmp);
238 }
catch (
const _com_error &err) {
239 info::function info(__LINE__,
__PRETTY_FUNCTION__,
typeid(
void),info::function::argument(_T(
"const MSXML2::IXMLDOMNodePtr &"),tostring(n)));
240 info.add_arg(_T(
"const tchar *"),colln_name);
241 info.add_arg(_T(
"const std::vector<unsigned long> *"),tostring(&colln));
242 throw exception(err.ErrorMessage(),info,JMMCG_REVISION_HDR(_T(LIBJMMCG_VERSION_NUMBER)));
246 template<>
inline void __fastcall
247 FromXML(
const MSXML2::IXMLDOMNodePtr &n,
const tstring &colln_name,std::vector<CPoint> &colln) {
249 assert(colln.empty());
250 const MSXML2::IXMLDOMNodeListPtr nodes(n->selectNodes((colln_name+_T(
"/*")).c_str()));
251 for (
long i=0;i<nodes->length;++i) {
253 FromXML(nodes->item[i],val);
254 colln.push_back(val);
256 }
catch (
const _com_error &err) {
257 info::function info(__LINE__,
__PRETTY_FUNCTION__,
typeid(
void),info::function::argument(_T(
"const MSXML2::IXMLDOMNodePtr &"),tostring(n)));
258 info.add_arg(_T(
"const tchar *"),colln_name);
259 info.add_arg(_T(
"const std::vector<CPoint> *"),tostring(&colln));
260 throw exception(err.ErrorMessage(),info,JMMCG_REVISION_HDR(_T(LIBJMMCG_VERSION_NUMBER)));
289 inline void __fastcall
300 inline void __fastcall
311 inline void __fastcall
324 inline void __fastcall