soui 5.0.0.1
Soui5 Doc
 
Loading...
Searching...
No Matches
SXml.cpp
1#include <xml/SXml.h>
2#include <pugixml/pugixml.hpp>
3#include <string/sstringw.h>
4#include <string/strcpcvt.h>
5SNSBEGIN
6
7
8SXmlAttr::SXmlAttr(LPVOID pData):_attr((pugi::xml_attribute_struct*)pData)
9{
10}
11
12SXmlAttr::SXmlAttr(const IXmlAttr * src):_attr((pugi::xml_attribute_struct*)src->GetPrivPtr())
13{
14}
15
16SXmlAttr::SXmlAttr(pugi::xml_attribute attr):_attr(attr)
17{
18
19}
20
21SXmlAttr::SXmlAttr(const SXmlAttr& src):_attr(src._attr)
22{
23
24}
25
26IXmlAttr * SXmlAttr::toIXmlAttr(pugi::xml_attribute attr)
27{
28 if(!attr) return NULL;
29 SXmlDoc *pDoc = (SXmlDoc*)attr.get_doc_extra_data();
30 return pDoc->toIXmlAttr(attr.internal_object());
31}
32
33LPVOID SXmlAttr::GetPrivPtr(THIS) SCONST
34{
35 return _attr.internal_object();
36}
37
38BOOL SXmlAttr::Empty(THIS) SCONST
39{
40 return _attr.empty();
41}
42
43const wchar_t * SXmlAttr::Name(THIS) SCONST
44{
45 return _attr.name();
46}
47
48const wchar_t * SXmlAttr::Value(THIS) SCONST
49{
50 return _attr.value();
51}
52
53BOOL SXmlAttr::set_userdata(THIS_ int data)
54{
55 return _attr.set_userdata(data);
56}
57
58int SXmlAttr::get_userdata(THIS) SCONST
59{
60 return _attr.get_userdata();
61}
62
64{
65 pugi::xml_attribute attr = _attr.next_attribute();
66 return toIXmlAttr(attr);
67}
68
70{
71 pugi::xml_attribute attr = _attr.previous_attribute();
72 return toIXmlAttr(attr);
73}
74
75SXmlAttr::operator bool() const
76{
77 return !_attr.empty();
78}
79
80bool SXmlAttr::empty() const
81{
82 return _attr.empty();
83}
84
85const wchar_t* SXmlAttr::name() const
86{
87 return _attr.name();
88}
89
90const wchar_t* SXmlAttr::value() const
91{
92 return _attr.value();
93}
94
95const wchar_t* SXmlAttr::as_string(const wchar_t* def /*= L""*/) const
96{
97 return _attr.as_string(def);
98}
99
100int SXmlAttr::as_int(int def /*= 0*/) const
101{
102 return _attr.as_int(def);
103}
104
105unsigned int SXmlAttr::as_uint(unsigned int def /*= 0*/) const
106{
107 return _attr.as_uint(def);
108}
109
110double SXmlAttr::as_double(double def /*= 0*/) const
111{
112 return _attr.as_double(def);
113}
114
115float SXmlAttr::as_float(float def /*= 0*/) const
116{
117 return _attr.as_float(def);
118}
119
120bool SXmlAttr::as_bool(bool def /*= false*/) const
121{
122 return _attr.as_bool(def);
123}
124
125bool SXmlAttr::set_name(const wchar_t* rhs)
126{
127 return _attr.set_name(rhs);
128}
129
130bool SXmlAttr::set_value(const wchar_t* rhs)
131{
132 return _attr.set_value(rhs);
133}
134
136{
137 return _attr.set_value(rhs);
138}
139
140bool SXmlAttr::set_value(unsigned int rhs)
141{
142 return _attr.set_value(rhs);
143}
144
146{
147 return _attr.set_value(rhs);
148}
149
150bool SXmlAttr::set_value(unsigned long rhs)
151{
152 return _attr.set_value(rhs);
153}
154
155bool SXmlAttr::set_value(double rhs)
156{
157 return _attr.set_value(rhs);
158}
159
160bool SXmlAttr::set_value(double rhs, int precision)
161{
162 return _attr.set_value(rhs,precision);
163}
164
165bool SXmlAttr::set_value(float rhs)
166{
167 return _attr.set_value(rhs);
168}
169
170bool SXmlAttr::set_value(float rhs, int precision)
171{
172 return _attr.set_value(rhs,precision);
173}
174
176{
177 return _attr.set_value(rhs);
178}
179
181{
182 return _attr.next_attribute();
183}
184
186{
187 return _attr.previous_attribute();
188}
189
190int SXmlAttr::AsInt(THIS_ int def)
191{
192 return as_int(def);
193}
194
195unsigned int SXmlAttr::AsUint(THIS_ int def)
196{
197 return as_uint(def);
198}
199
200float SXmlAttr::AsFloat(THIS_ float def)
201{
202 return as_float(def);
203}
204
205double SXmlAttr::AsDouble(THIS_ double def)
206{
207 return as_double(def);
208}
209
210BOOL SXmlAttr::AsBool(THIS_ BOOL def)
211{
212 return !!as_bool(!!def);
213}
214
215//////////////////////////////////////////////////////////////////////////
216
217SXmlNode::SXmlNode(LPVOID pData):_node((pugi::xml_node_struct*)pData)
218{
219
220}
221
222SXmlNode::SXmlNode(const IXmlNode * src):_node(src?(pugi::xml_node_struct*)src->GetPrivPtr():NULL)
223{
224
225}
226
227SXmlNode::SXmlNode(pugi::xml_node node):_node(node)
228{
229
230}
231
232SXmlNode::SXmlNode(const SXmlNode& src):_node(src._node)
233{
234
235}
236
237
238void SXmlNode::ToString(THIS_ IStringW *out) SCONST
239{
240 pugi::xml_writer_buff writer;
241 _node.print(writer, L"\t", pugi::format_default, sizeof(wchar_t) == 2 ? pugi::encoding_utf16 : pugi::encoding_utf32);
242 out->Assign2(writer.buffer(), writer.size());
243}
244
245LPVOID SXmlNode::GetPrivPtr(THIS) SCONST
246{
247 return _node.internal_object();
248}
249
250BOOL SXmlNode::Empty(THIS) SCONST
251{
252 return _node.empty();
253}
254
255const wchar_t * SXmlNode::Name(THIS) SCONST
256{
257 return _node.name();
258}
259
260const wchar_t * SXmlNode::Value(THIS) SCONST
261{
262 return _node.value();
263}
264
265const wchar_t * SXmlNode::Text(THIS) SCONST
266{
267 return _node.text().get();
268}
269
270BOOL SXmlNode::set_userdata(THIS_ int data)
271{
272 return _node.set_userdata(data);
273}
274
276{
277 return _node.get_userdata();
278}
279
280IXmlAttr * SXmlNode::Attribute(THIS_ const wchar_t* name,BOOL bCaseSensitive) SCONST
281{
282 pugi::xml_attribute attr = _node.attribute(name,!!bCaseSensitive);
283 return SXmlAttr::toIXmlAttr(attr);
284}
285
287{
288 pugi::xml_attribute attr = _node.first_attribute();
289 return SXmlAttr::toIXmlAttr(attr);
290}
291
293{
294 pugi::xml_attribute attr = _node.last_attribute();
295 return SXmlAttr::toIXmlAttr(attr);
296}
297
298IXmlNode *SXmlNode::Child(THIS_ const wchar_t* name,BOOL bCaseSensitive) SCONST
299{
300 pugi::xml_node node = _node.child(name,!!bCaseSensitive);
301 return toIXmlNode(node);
302}
303
305{
306 pugi::xml_node node = _node.first_child();
307 return toIXmlNode(node);
308}
309
311{
312 pugi::xml_node node = _node.last_child();
313 return toIXmlNode(node);
314}
315
317{
318 pugi::xml_node node = _node.next_sibling();
319 return toIXmlNode(node);
320}
321
323{
324 pugi::xml_node node = _node.previous_sibling();
325 return toIXmlNode(node);
326}
327
328IXmlNode *SXmlNode::NextSibling2(THIS_ const wchar_t* name,BOOL bCaseSensitive) SCONST
329{
330 pugi::xml_node node = _node.next_sibling(name,!!bCaseSensitive);
331 return toIXmlNode(node);
332}
333
334IXmlNode *SXmlNode::PrevSibling2(THIS_ const wchar_t* name,BOOL bCaseSensitive) SCONST
335{
336 pugi::xml_node node = _node.previous_sibling(name,!!bCaseSensitive);
337 return toIXmlNode(node);
338}
339
340IXmlNode * SXmlNode::toIXmlNode(pugi::xml_node node)
341{
342 if(!node) return NULL;
343 SXmlDoc *pDoc = (SXmlDoc*)node.get_doc_extra_data();
344 return pDoc->toIXmlNode(node.internal_object());
345}
346
347
348SXmlNode::operator bool() const
349{
350 return !_node.empty();
351}
352
353bool SXmlNode::empty() const
354{
355 return _node.empty();
356}
357
358XmlNodeType SXmlNode::type() const
359{
360 return (XmlNodeType)_node.type();
361}
362
363const wchar_t* SXmlNode::name() const
364{
365 return _node.name();
366}
367
368const wchar_t* SXmlNode::value() const
369{
370 return _node.value();
371}
372
374{
375 return _node.first_attribute();
376}
377
379{
380 return _node.last_attribute();
381}
382
384{
385 return _node.first_child();
386}
387
389{
390 return _node.last_child();
391}
392
394{
395 return _node.next_sibling();
396}
397
398SXmlNode SXmlNode::next_sibling(const wchar_t* name,bool bCaseSensitive/*=false*/) const
399{
400 return _node.next_sibling(name,bCaseSensitive);
401}
402
404{
405 return _node.previous_sibling();
406}
407
408SXmlNode SXmlNode::previous_sibling(const wchar_t* name,bool bCaseSensitive/*=false*/) const
409{
410 return _node.previous_sibling(name,bCaseSensitive);
411}
412
414{
415 return _node.parent();
416}
417
419{
420 return _node.root();
421}
422
423SXmlNode SXmlNode::child(const wchar_t* name,bool bCaseSensitive/*=false*/) const
424{
425 return _node.child(name,bCaseSensitive);
426}
427
428SXmlAttr SXmlNode::attribute(const wchar_t* name,bool bCaseSensitive/*=false*/) const
429{
430 return _node.attribute(name,bCaseSensitive);
431}
432
433SXmlAttr SXmlNode::attribute(const wchar_t* name, SXmlAttr& hint,bool bCaseSensitive/*=false*/) const
434{
435 return _node.attribute(name,hint._attr,bCaseSensitive);
436}
437
438const wchar_t* SXmlNode::child_value() const
439{
440 return _node.child_value();
441}
442
443const wchar_t* SXmlNode::child_value(const wchar_t* name,bool bCaseSensitive/*=false*/) const
444{
445 return _node.child_value(name,bCaseSensitive);
446}
447
448bool SXmlNode::set_name(const wchar_t* rhs)
449{
450 return _node.set_name(rhs);
451}
452
453bool SXmlNode::set_value(const wchar_t* rhs)
454{
455 return _node.set_value(rhs);
456}
457
459{
460 return _node.append_attribute(name);
461}
462
464{
465 return _node.prepend_attribute(name);
466}
467
469{
470 return _node.insert_attribute_after(name,attr._attr);
471}
472
474{
475 return _node.insert_attribute_before(name,attr._attr);
476}
477
479{
480 return _node.append_copy(proto._attr);
481}
482
484{
485 return _node.append_copy(proto._node);
486}
487
489{
490 return _node.prepend_copy(proto._attr);
491}
492
494{
495 return _node.prepend_copy(proto._node);
496}
497
499{
500 return _node.insert_copy_after(proto._attr,attr._attr);
501}
502
504{
505 return _node.insert_copy_after(proto._node,node._node);
506}
507
509{
510 return _node.insert_copy_before(proto._attr,attr._attr);
511}
512
514{
515 return _node.insert_move_before(proto._node,node._node);
516}
517
518SXmlNode SXmlNode::append_child(XmlNodeType type /*= node_element*/)
519{
520 return _node.append_child((pugi::xml_node_type)type);
521}
522
524{
525 return _node.append_child(name);
526}
527
528SXmlNode SXmlNode::prepend_child(XmlNodeType type /*= node_element*/)
529{
530 return _node.prepend_child((pugi::xml_node_type)type);
531}
532
534{
535 return _node.prepend_child(name);
536}
537
539{
540 return _node.insert_child_after((pugi::xml_node_type)type,node._node);
541}
542
544{
545 return _node.insert_child_after(name,node._node);
546}
547
549{
550 return _node.insert_child_before((pugi::xml_node_type)type,node._node);
551}
552
554{
555 return _node.insert_child_before(name,node._node);
556}
557
559{
560 return _node.append_move(moved._node);
561}
562
564{
565 return _node.prepend_move(moved._node);
566}
567
569{
570 return _node.insert_move_after(moved._node,node._node);
571}
572
574{
575 return _node.insert_move_before(moved._node,node._node);
576}
577
579{
580 return _node.remove_attribute(a._attr);
581}
582
584{
585 return _node.remove_attribute(name);
586}
587
589{
590 return _node.remove_attributes();
591}
592
594{
595 return _node.remove_child(n._node);
596}
597
598bool SXmlNode::remove_child(const wchar_t* name)
599{
600 return _node.remove_child(name);
601}
602
604{
605 return _node.remove_children();
606}
607
608
609//////////////////////////////////////////////////////////////////////////
610
612{
613 m_attrMap = new AttrMap;
614 m_nodeMap = new NodeMap;
615 _doc = new pugi::xml_document;
616 _doc->set_extra_data(this);
617}
618
620{
621 clearMap();
622 delete m_attrMap;
623 delete m_nodeMap;
624 delete _doc;
625}
626
628{
629 return SXmlNode::toIXmlNode(*_doc);
630}
631
632BOOL SXmlDoc::SaveFileW(THIS_ const wchar_t* path, const wchar_t* indent , unsigned int flags, XmlEncoding encoding) SCONST
633{
634 return _doc->save_file(path,indent,flags,(pugi::xml_encoding)encoding);
635}
636
637BOOL SXmlDoc::SaveFileA(THIS_ const char* path, const wchar_t* indent , unsigned int flags, XmlEncoding encoding) SCONST
638{
639 SStringW strPath = S_CA2W(path,CP_UTF8);
640 return SaveFileW(strPath.c_str(),indent,flags,encoding);
641}
642
643void SXmlDoc::SaveBinary(THIS_ FILE *f) SCONST
644{
645 _doc->save_bin(f);
646}
647
648BOOL SXmlDoc::LoadBufferInplaceOwn(THIS_ void* contents, size_t size, unsigned int options , XmlEncoding encoding)
649{
650 _result = _doc->load_buffer_inplace_own(contents,size,options,(pugi::xml_encoding)encoding);
651 return _result;
652}
653
654BOOL SXmlDoc::LoadBufferInplace(THIS_ void* contents, size_t size, unsigned int options , XmlEncoding encoding)
655{
656 _result = _doc->load_buffer_inplace(contents,size,options,(pugi::xml_encoding)encoding);
657 return _result;
658}
659
660BOOL SXmlDoc::LoadBuffer(THIS_ const void* contents, size_t size, unsigned int options , XmlEncoding encoding)
661{
662 _result = _doc->load_buffer(contents,size,options,(pugi::xml_encoding)encoding);
663 return _result;
664}
665
666BOOL SXmlDoc::LoadFileW(THIS_ const wchar_t* path, unsigned int options , XmlEncoding encoding)
667{
668 _result = _doc->load_file(path,options,(pugi::xml_encoding)encoding);
669 return _result;
670}
671
672BOOL SXmlDoc::LoadFileA(THIS_ const char* path, unsigned int options, XmlEncoding encoding)
673{
674 SStringW strPath = S_CA2W(path,CP_UTF8);
675 return LoadFileW(strPath.c_str(),options,encoding);
676}
677
678BOOL SXmlDoc::LoadString(THIS_ const wchar_t* contents, unsigned int options)
679{
680 _result = _doc->load_string(contents,options);
681 return _result;
682}
683
684void SXmlDoc::GetParseResult(THIS_ XmlParseResult *pResult) SCONST
685{
686 SASSERT(pResult);
687 pResult->status = (XmlStatus)_result.status;
688 pResult->offset = _result.offset;
689 pResult->encoding = (XmlEncoding)_result.encoding;
690}
691
692void SXmlDoc::Copy(THIS_ const IXmlDoc* proto)
693{
694 _doc->reset(*(pugi::xml_document*)proto->GetPrivPtr());
695}
696
698{
699 _doc->reset();
700 clearMap();
701}
702
703LPVOID SXmlDoc::GetPrivPtr(THIS) SCONST
704{
705 return _doc;
706}
707
708bool SXmlDoc::load_string(const wchar_t* contents, unsigned int options /*= xml_parse_default*/)
709{
710 _result = _doc->load_string(contents,options);
711 return _result;
712}
713
714bool SXmlDoc::load_file(const char* path, unsigned int options /*= xml_parse_default*/, XmlEncoding encoding /*= enc_auto*/)
715{
716 _result = _doc->load_file(path,options,(pugi::xml_encoding)encoding);
717 return _result;
718}
719
720bool SXmlDoc::load_file(const wchar_t* path, unsigned int options /*= xml_parse_default*/, XmlEncoding encoding /*= enc_auto*/)
721{
722 _result = _doc->load_file(path,options,(pugi::xml_encoding)encoding);
723 return _result;
724}
725
726bool SXmlDoc::load_buffer(const void* contents, size_t size, unsigned int options /*= xml_parse_default*/, XmlEncoding encoding /*= enc_auto*/)
727{
728 _result = _doc->load_buffer(contents,size,options,(pugi::xml_encoding)encoding);
729 return _result;
730}
731
732bool SXmlDoc::load_buffer_inplace(void* contents, size_t size, unsigned int options /*= xml_parse_default*/, XmlEncoding encoding /*= enc_auto*/)
733{
734 _result = _doc->load_buffer_inplace(contents,size,options,(pugi::xml_encoding)encoding);
735 return _result;
736}
737
738bool SXmlDoc::load_buffer_inplace_own(void* contents, size_t size, unsigned int options /*= xml_parse_default*/, XmlEncoding encoding /*= enc_auto*/)
739{
740 _result = _doc->load_buffer_inplace_own(contents,size,options,(pugi::xml_encoding)encoding);
741 return _result;
742}
743
744bool SXmlDoc::save_file(const char* path, const wchar_t* indent /*= L"\t"*/, unsigned int flags /*= xml_parse_default*/, XmlEncoding encoding /*= enc_auto*/) const
745{
746 return _doc->save_file(path,indent,flags,(pugi::xml_encoding)encoding);
747}
748
749bool SXmlDoc::save_file(const wchar_t* path, const wchar_t* indent /*= L"\t"*/, unsigned int flags /*= xml_parse_default*/, XmlEncoding encoding /*= enc_auto*/) const
750{
751 return _doc->save_file(path,indent,flags,(pugi::xml_encoding)encoding);
752}
753
754SXmlNode SXmlDoc::root() const
755{
756 return SXmlNode(*(pugi::xml_node*)_doc);
757}
758
759const char * SXmlDoc::GetErrDesc(XmlStatus status)
760{
761 pugi::xml_parse_result res;
762 res.status = (pugi::xml_parse_status)status;
763 return res.description();
764}
765
766IXmlAttr * SXmlDoc::toIXmlAttr(pugi::xml_attribute_struct *pAttr)
767{
768 AttrMap::CPair *pair = m_attrMap->Lookup(pAttr);
769 if(pair)
770 return pair->m_value;
771 SXmlAttr *pRet = new SXmlAttr(pAttr);
772 m_attrMap->SetAt(pAttr,pRet);
773 return pRet;
774}
775
776IXmlNode * SXmlDoc::toIXmlNode(pugi::xml_node_struct* pNode)
777{
778 NodeMap::CPair *pair = m_nodeMap->Lookup(pNode);
779 if(pair)
780 return pair->m_value;
781 SXmlNode *pRet = new SXmlNode(pNode);
782 m_nodeMap->SetAt(pNode,pRet);
783 return pRet;
784}
785
786void SXmlDoc::clearMap()
787{
788 {
789 SPOSITION pos = m_attrMap->GetStartPosition();
790 while(pos){
791 SXmlAttr *pAttr = m_attrMap->GetNextValue(pos);
792 delete pAttr;
793 }
794 m_attrMap->RemoveAll();
795 }
796 {
797 SPOSITION pos = m_nodeMap->GetStartPosition();
798 while(pos){
799 SXmlNode *pNode = m_nodeMap->GetNextValue(pos);
800 delete pNode;
801 }
802 m_nodeMap->RemoveAll();
803 }
804}
805
806SNSEND
A class representing an ASCII string.
Definition sstringw.h:96
const wchar_t * c_str() SCONST
Retrieves a C-style string representation of the string.
Class representing an XML attribute.
Definition SXml.h:20
const wchar_t * Value() SCONST OVERRIDE
Gets the attribute value.
Definition SXml.cpp:48
float as_float(float def=0) const
Converts the attribute value to a float.
Definition SXml.cpp:115
SXmlAttr next_attribute() const
Gets the next attribute in the attribute list of the parent node.
Definition SXml.cpp:180
SXmlAttr(pugi::xml_attribute attr)
Constructor for SXmlAttr.
Definition SXml.cpp:16
float AsFloat(float def=0.0f) OVERRIDE
Converts the attribute value to a float.
Definition SXml.cpp:200
IXmlAttr * Prev() OVERRIDE
Gets the previous attribute in the attribute list of the parent node.
Definition SXml.cpp:69
BOOL set_userdata(int data) OVERRIDE
Sets user data for the attribute.
Definition SXml.cpp:53
const wchar_t * Name() SCONST OVERRIDE
Gets the attribute name.
Definition SXml.cpp:43
int AsInt(int def=0) OVERRIDE
Converts the attribute value to an integer.
Definition SXml.cpp:190
int as_int(int def=0) const
Converts the attribute value to an integer.
Definition SXml.cpp:100
int get_userdata() SCONST OVERRIDE
Gets user data for the attribute.
Definition SXml.cpp:58
bool set_value(const wchar_t *rhs)
Sets the attribute value.
Definition SXml.cpp:130
bool set_name(const wchar_t *rhs)
Sets the attribute name.
Definition SXml.cpp:125
double AsDouble(double def=0.0) OVERRIDE
Converts the attribute value to a double.
Definition SXml.cpp:205
const wchar_t * name() const
Gets the attribute name.
Definition SXml.cpp:85
BOOL Empty() SCONST OVERRIDE
Checks if the attribute is empty.
Definition SXml.cpp:38
const wchar_t * as_string(const wchar_t *def=L"") const
Gets the attribute value as a string.
Definition SXml.cpp:95
unsigned int as_uint(unsigned int def=0) const
Converts the attribute value to an unsigned integer.
Definition SXml.cpp:105
bool as_bool(bool def=false) const
Converts the attribute value to a boolean.
Definition SXml.cpp:120
IXmlAttr * Next() OVERRIDE
Gets the next attribute in the attribute list of the parent node.
Definition SXml.cpp:63
double as_double(double def=0) const
Converts the attribute value to a double.
Definition SXml.cpp:110
SXmlAttr previous_attribute() const
Gets the previous attribute in the attribute list of the parent node.
Definition SXml.cpp:185
unsigned int AsUint(int def=0) OVERRIDE
Converts the attribute value to an unsigned integer.
Definition SXml.cpp:195
LPVOID GetPrivPtr() SCONST OVERRIDE
Gets the private data pointer.
Definition SXml.cpp:33
bool empty() const
Checks if the attribute is empty.
Definition SXml.cpp:80
const wchar_t * value() const
Gets the attribute value.
Definition SXml.cpp:90
BOOL AsBool(BOOL def=FALSE) OVERRIDE
Converts the attribute value to a boolean.
Definition SXml.cpp:210
Implementation of IXmlDoc.
Definition SXml.h:912
IXmlNode * Root() SCONST OVERRIDE
Retrieves the root node of the document.
Definition SXml.cpp:627
bool load_buffer_inplace(void *contents, size_t size, unsigned int options=xml_parse_default, XmlEncoding encoding=enc_auto)
Loads the document from a buffer using in-place parsing.
Definition SXml.cpp:732
void Copy(const IXmlDoc *proto) OVERRIDE
Copies the contents of another document into this document.
Definition SXml.cpp:692
BOOL LoadBufferInplaceOwn(void *contents, size_t size, unsigned int options, XmlEncoding encoding) OVERRIDE
Loads the document from a buffer using in-place parsing with automatic buffer management.
Definition SXml.cpp:648
bool load_buffer_inplace_own(void *contents, size_t size, unsigned int options=xml_parse_default, XmlEncoding encoding=enc_auto)
Loads the document from a buffer using in-place parsing with automatic buffer management.
Definition SXml.cpp:738
SXmlDoc()
Constructor for SXmlDoc.
Definition SXml.cpp:611
BOOL LoadFileA(const char *path, unsigned int options, XmlEncoding encoding) OVERRIDE
Loads the document from a file (ANSI version).
Definition SXml.cpp:672
bool save_file(const char *path, const wchar_t *indent=L"\t", unsigned int flags=xml_parse_default, XmlEncoding encoding=enc_auto) const
Saves the XML document to a file (ANSI version).
Definition SXml.cpp:744
static const char * GetErrDesc(XmlStatus status)
Retrieves the error description for a given XML status.
Definition SXml.cpp:759
void GetParseResult(XmlParseResult *pResult) SCONST OVERRIDE
Retrieves the result of the last parsing operation.
Definition SXml.cpp:684
~SXmlDoc()
Destructor for SXmlDoc.
Definition SXml.cpp:619
SXmlNode root() const
Retrieves the root node of the document.
Definition SXml.cpp:754
BOOL SaveFileW(const wchar_t *path, const wchar_t *indent, unsigned int flags, XmlEncoding encoding) SCONST OVERRIDE
Saves the XML document to a file (Unicode version).
Definition SXml.cpp:632
BOOL LoadString(const wchar_t *contents, unsigned int options) OVERRIDE
Loads the document from a zero-terminated string.
Definition SXml.cpp:678
BOOL LoadFileW(const wchar_t *path, unsigned int options, XmlEncoding encoding) OVERRIDE
Loads the document from a file (Unicode version).
Definition SXml.cpp:666
BOOL SaveFileA(const char *path, const wchar_t *indent, unsigned int flags, XmlEncoding encoding) SCONST OVERRIDE
Saves the XML document to a file (ANSI version).
Definition SXml.cpp:637
BOOL LoadBufferInplace(void *contents, size_t size, unsigned int options, XmlEncoding encoding) OVERRIDE
Loads the document from a buffer using in-place parsing.
Definition SXml.cpp:654
bool load_string(const wchar_t *contents, unsigned int options=xml_parse_default)
Loads the document from a zero-terminated string.
Definition SXml.cpp:708
BOOL LoadBuffer(const void *contents, size_t size, unsigned int options, XmlEncoding encoding) OVERRIDE
Loads the document from a buffer.
Definition SXml.cpp:660
void Reset() OVERRIDE
Resets the document, removing all nodes.
Definition SXml.cpp:697
void SaveBinary(FILE *f) SCONST OVERRIDE
Saves the XML document to a writer.
Definition SXml.cpp:643
bool load_buffer(const void *contents, size_t size, unsigned int options=xml_parse_default, XmlEncoding encoding=enc_auto)
Loads the document from a buffer.
Definition SXml.cpp:726
LPVOID GetPrivPtr() SCONST OVERRIDE
Retrieves a private pointer associated with the document.
Definition SXml.cpp:703
bool load_file(const char *path, unsigned int options=xml_parse_default, XmlEncoding encoding=enc_auto)
Loads the document from a file (ANSI version).
Definition SXml.cpp:714
SXmlAttr insert_copy_before(const SXmlAttr &proto, const SXmlAttr &attr)
Inserts a copy of the specified attribute before the specified attribute.
Definition SXml.cpp:508
SXmlNode next_sibling() const
Gets the next sibling node in the children list of the parent node.
Definition SXml.cpp:393
IXmlNode * PrevSibling2(const wchar_t *name, BOOL bCaseSensitive) SCONST OVERRIDE
Gets the previous sibling node by name.
Definition SXml.cpp:334
LPVOID GetPrivPtr() SCONST OVERRIDE
Gets the private data pointer.
Definition SXml.cpp:245
SXmlAttr first_attribute() const
Gets the first attribute of the node.
Definition SXml.cpp:373
SXmlNode parent() const
Gets the parent node of the node.
Definition SXml.cpp:413
SXmlAttr insert_attribute_before(const wchar_t *name, const SXmlAttr &attr)
Inserts an attribute with the specified name before the specified attribute.
Definition SXml.cpp:473
IXmlAttr * LastAttribute() SCONST OVERRIDE
Gets the last attribute in the attribute list.
Definition SXml.cpp:292
SXmlNode previous_sibling() const
Gets the previous sibling node in the children list of the parent node.
Definition SXml.cpp:403
SXmlNode first_child() const
Gets the first child node of the node.
Definition SXml.cpp:383
SXmlAttr append_copy(const SXmlAttr &proto)
Adds a copy of the specified attribute.
Definition SXml.cpp:478
const wchar_t * Name() SCONST OVERRIDE
Gets the node name.
Definition SXml.cpp:255
void ToString(IStringW *out) SCONST OVERRIDE
Converts the node to a string representation.
Definition SXml.cpp:238
const wchar_t * Value() SCONST OVERRIDE
Gets the node value.
Definition SXml.cpp:260
IXmlAttr * FirstAttribute() SCONST OVERRIDE
Gets the first attribute in the attribute list.
Definition SXml.cpp:286
bool remove_attribute(const SXmlAttr &a)
Removes the specified attribute.
Definition SXml.cpp:578
IXmlNode * NextSibling2(const wchar_t *name, BOOL bCaseSensitive) SCONST OVERRIDE
Gets the next sibling node by name.
Definition SXml.cpp:328
bool set_value(const wchar_t *rhs)
Sets the value of the node.
Definition SXml.cpp:453
const wchar_t * name() const
Gets the name of the node.
Definition SXml.cpp:363
SXmlNode last_child() const
Gets the last child node of the node.
Definition SXml.cpp:388
SXmlNode insert_move_after(const SXmlNode &moved, const SXmlNode &node)
Inserts the specified node to become a child of this node after the specified node.
Definition SXml.cpp:568
bool set_name(const wchar_t *rhs)
Sets the name of the node.
Definition SXml.cpp:448
bool remove_children()
Removes all child nodes from the node.
Definition SXml.cpp:603
const wchar_t * child_value() const
Gets the child value of the current node.
Definition SXml.cpp:438
SXmlNode append_move(const SXmlNode &moved)
Moves the specified node to become a child of this node.
Definition SXml.cpp:558
SXmlAttr attribute(const wchar_t *name, bool bCaseSensitive=false) const
Gets the attribute with the specified name.
Definition SXml.cpp:428
SXmlNode insert_child_before(XmlNodeType type, const SXmlNode &node)
Inserts a child node with the specified type before the specified node.
Definition SXml.cpp:548
SXmlAttr append_attribute(const wchar_t *name)
Adds an attribute with the specified name.
Definition SXml.cpp:458
SXmlNode prepend_child(XmlNodeType type=node_element)
Prepends a child node with the specified type.
Definition SXml.cpp:528
int get_userdata() SCONST OVERRIDE
Gets user data for the node.
Definition SXml.cpp:275
SXmlAttr last_attribute() const
Gets the last attribute of the node.
Definition SXml.cpp:378
bool empty() const
Checks if the node is empty.
Definition SXml.cpp:353
SXmlNode root() const
Gets the root node of the DOM tree this node belongs to.
Definition SXml.cpp:418
IXmlNode * NextSibling() SCONST OVERRIDE
Gets the next sibling node.
Definition SXml.cpp:316
XmlNodeType type() const
Gets the type of the node.
Definition SXml.cpp:358
IXmlNode * PrevSibling() SCONST OVERRIDE
Gets the previous sibling node.
Definition SXml.cpp:322
bool remove_child(const SXmlNode &n)
Removes the specified child node.
Definition SXml.cpp:593
IXmlNode * Child(const wchar_t *name, BOOL bCaseSensitive) SCONST OVERRIDE
Gets a child node by name.
Definition SXml.cpp:298
SXmlNode child(const wchar_t *name, bool bCaseSensitive=false) const
Gets the child node, attribute, or next/previous sibling with the specified name.
Definition SXml.cpp:423
IXmlAttr * Attribute(const wchar_t *name, BOOL bCaseSensitive) SCONST OVERRIDE
Gets an attribute by name.
Definition SXml.cpp:280
SXmlAttr insert_attribute_after(const wchar_t *name, const SXmlAttr &attr)
Inserts an attribute with the specified name after the specified attribute.
Definition SXml.cpp:468
SXmlAttr prepend_attribute(const wchar_t *name)
Prepends an attribute with the specified name.
Definition SXml.cpp:463
SXmlNode insert_child_after(XmlNodeType type, const SXmlNode &node)
Inserts a child node with the specified type after the specified node.
Definition SXml.cpp:538
const wchar_t * value() const
Gets the value of the node.
Definition SXml.cpp:368
bool remove_attributes()
Removes all attributes from the node.
Definition SXml.cpp:588
IXmlNode * LastChild() SCONST OVERRIDE
Gets the last child node.
Definition SXml.cpp:310
SXmlNode insert_move_before(const SXmlNode &moved, const SXmlNode &node)
Inserts the specified node to become a child of this node before the specified node.
Definition SXml.cpp:573
IXmlNode * FirstChild() SCONST OVERRIDE
Gets the first child node.
Definition SXml.cpp:304
SXmlAttr prepend_copy(const SXmlAttr &proto)
Prepends a copy of the specified attribute.
Definition SXml.cpp:488
SXmlAttr insert_copy_after(const SXmlAttr &proto, const SXmlAttr &attr)
Inserts a copy of the specified attribute after the specified attribute.
Definition SXml.cpp:498
const wchar_t * Text() SCONST OVERRIDE
Gets the node text.
Definition SXml.cpp:265
SXmlNode prepend_move(const SXmlNode &moved)
Prepends the specified node to become a child of this node.
Definition SXml.cpp:563
SXmlNode append_child(XmlNodeType type=node_element)
Adds a child node with the specified type.
Definition SXml.cpp:518
BOOL Empty() SCONST OVERRIDE
Checks if the node is empty.
Definition SXml.cpp:250
SXmlNode(pugi::xml_node node)
Constructor for SXmlNode.
Definition SXml.cpp:227
BOOL set_userdata(int data) OVERRIDE
Sets user data for the node.
Definition SXml.cpp:270
Interface for XML attributes.
Definition sxml-i.h:17
BOOL set_userdata(int data) PURE
Sets user-defined data associated with the attribute.
Interface for XML Document.
Definition sxml-i.h:472
Interface for XML nodes.
Definition sxml-i.h:128
Bitfield structure for font style attributes.