Newer
Older
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
/**
* pugixml parser - version 0.9
* --------------------------------------------------------
* Copyright (C) 2006-2010, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
* Report bugs and download new versions at http://code.google.com/p/pugixml/
*
* This library is distributed under the MIT License. See notice at the end
* of this file.
*
* This work is based on the pugxml parser, which is:
* Copyright (C) 2003, by Kristen Wegner (kristen@tima.net)
*/
#ifndef HEADER_PUGIXML_HPP
#define HEADER_PUGIXML_HPP
#include "pugiconfig.hpp"
#ifndef PUGIXML_NO_STL
namespace std
{
struct bidirectional_iterator_tag;
#ifdef __SUNPRO_CC
// Sun C++ compiler has a bug which forces template argument names in forward declarations to be the same as in actual definitions
template <class _T> class allocator;
template <class _charT> struct char_traits;
template <class _charT, class _Traits> class basic_istream;
template <class _charT, class _Traits> class basic_ostream;
template <class _charT, class _Traits, class _Allocator> class basic_string;
#else
// Borland C++ compiler has a bug which forces template argument names in forward declarations to be the same as in actual definitions
template <class _Ty> class allocator;
template <class _Ty> struct char_traits;
template <class _Elem, class _Traits> class basic_istream;
template <class _Elem, class _Traits> class basic_ostream;
template <class _Elem, class _Traits, class _Ax> class basic_string;
#endif
// Digital Mars compiler has a bug which requires a forward declaration for explicit instantiation (otherwise type selection is messed up later, producing link errors)
// Also note that we have to declare char_traits as a class here, since it's defined that way
#ifdef __DMC__
template <> class char_traits<char>;
#endif
}
#endif
// Macro for deprecated features
#ifndef PUGIXML_DEPRECATED
# if defined(__GNUC__)
# define PUGIXML_DEPRECATED __attribute__((deprecated))
# elif defined(_MSC_VER) && _MSC_VER >= 1300
# define PUGIXML_DEPRECATED __declspec(deprecated)
# else
# define PUGIXML_DEPRECATED
# endif
#endif
// Include exception header for XPath
#if !defined(PUGIXML_NO_XPATH) && !defined(PUGIXML_NO_EXCEPTIONS)
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
# include <exception>
#endif
// If no API is defined, assume default
#ifndef PUGIXML_API
# define PUGIXML_API
#endif
// If no API for classes is defined, assume default
#ifndef PUGIXML_CLASS
# define PUGIXML_CLASS PUGIXML_API
#endif
// If no API for functions is defined, assume default
#ifndef PUGIXML_FUNCTION
# define PUGIXML_FUNCTION PUGIXML_API
#endif
#include <stddef.h>
// Character interface macros
#ifdef PUGIXML_WCHAR_MODE
# define PUGIXML_TEXT(t) L ## t
namespace pugi
{
/// Character type used for all internal storage and operations; depends on PUGIXML_WCHAR_MODE
typedef wchar_t char_t;
#ifndef PUGIXML_NO_STL
/// String type used for operations that work with STL string; depends on PUGIXML_WCHAR_MODE
typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > string_t;
#endif
}
#else
# define PUGIXML_TEXT(t) t
namespace pugi
{
/// Character type used for all internal storage and operations; depends on PUGIXML_WCHAR_MODE
typedef char char_t;
# ifndef PUGIXML_NO_STL
// GCC 3.4 has a bug which prevents string_t instantiation using char_t, so we have to use char type explicitly
/// String type used for operations that work with STL string; depends on PUGIXML_WCHAR_MODE
typedef std::basic_string<char, std::char_traits<char>, std::allocator<char> > string_t;
# endif
}
#endif
/// The PugiXML Parser namespace.
namespace pugi
{
/// Tree node classification.
enum xml_node_type
{
node_null, ///< Undifferentiated entity
node_document, ///< A document tree's absolute root.
node_element, ///< E.g. '<...>'
node_pcdata, ///< E.g. '>...<'
node_cdata, ///< E.g. '<![CDATA[...]]>'
node_comment, ///< E.g. '<!--...-->'
node_pi, ///< E.g. '<?...?>'
node_declaration ///< E.g. '<?xml ...?>'
};
// Parsing options
/**
* Minimal parsing mode. Equivalent to turning all other flags off. This set of flags means
* that pugixml does not add pi/cdata sections or comments to DOM tree and does not perform
* any conversions for input data, meaning fastest parsing.
*/
const unsigned int parse_minimal = 0x0000;
/**
* This flag determines if processing instructions (nodes with type node_pi; such nodes have the
* form of <? target content ?> or <? target ?> in XML) are to be put in DOM tree. If this flag is off,
* they are not put in the tree, but are still parsed and checked for correctness.
*
* The corresponding node in DOM tree will have type node_pi, name "target" and value "content",
* if any.
*
* Note that <?xml ...?> (document declaration) is not considered to be a PI.
*
* This flag is off by default.
*/
const unsigned int parse_pi = 0x0001;
/**
* This flag determines if comments (nodes with type node_comment; such nodes have the form of
* <!-- content --> in XML) are to be put in DOM tree. If this flag is off, they are not put in
* the tree, but are still parsed and checked for correctness.
*
* The corresponding node in DOM tree will have type node_comment, empty name and value "content".
*
* This flag is off by default.
*/
const unsigned int parse_comments = 0x0002;
/**
* This flag determines if CDATA sections (nodes with type node_cdata; such nodes have the form
* of <![CDATA[[content]]> in XML) are to be put in DOM tree. If this flag is off, they are not
* put in the tree, but are still parsed and checked for correctness.
*
* The corresponding node in DOM tree will have type node_cdata, empty name and value "content".
*
* This flag is on by default.
*/
const unsigned int parse_cdata = 0x0004;
/**
* This flag determines if nodes with PCDATA (regular text) that consist only of whitespace
* characters are to be put in DOM tree. Often whitespace-only data is not significant for the
* application, and the cost of allocating and storing such nodes (both memory and speed-wise)
* can be significant. For example, after parsing XML string "<node> <a/> </node>", <node> element
* will have 3 children when parse_ws_pcdata is set (child with type node_pcdata and value=" ",
* child with type node_element and name "a", and another child with type node_pcdata and
* value=" "), and only 1 child when parse_ws_pcdata is not set.
*
* This flag is off by default.
*/
const unsigned int parse_ws_pcdata = 0x0008;
/**
* This flag determines if character and entity references are to be expanded during the parsing
* process. Character references are &#...; or &#x...; (... is Unicode numeric representation of
* character in either decimal (&#...;) or hexadecimal (&#x...;) form), entity references are &...;
* Note that as pugixml does not handle DTD, the only allowed entities are predefined ones -
* &lt;, &gt;, &amp;, &apos; and &quot;. If character/entity reference can not be expanded, it is
* leaved as is, so you can do additional processing later.
* Reference expansion is performed in attribute values and PCDATA content.
*
* This flag is on by default.
*/
const unsigned int parse_escapes = 0x0010;
/**
* This flag determines if EOL handling (that is, replacing sequences 0x0d 0x0a by a single 0x0a
* character, and replacing all standalone 0x0d characters by 0x0a) is to be performed on input
* data (that is, comments contents, PCDATA/CDATA contents and attribute values).
*
* This flag is on by default.
*/
const unsigned int parse_eol = 0x0020;
/**
* This flag determines if attribute value normalization should be performed for all attributes.
* This means, that:
* 1. Whitespace characters (new line, tab and space) are replaced with space (' ')
* 2. Afterwards sequences of spaces are replaced with a single space
* 3. Leading/trailing whitespace characters are trimmed
*
* This flag is off by default.
*/
const unsigned int parse_wnorm_attribute = 0x0080;
/**
* This flag determines if attribute value normalization should be performed for all attributes.
* This means, that whitespace characters (new line, tab and space) are replaced with space (' ').
* Note, that the actions performed while this flag is on are also performed if parse_wnorm_attribute
* is on, so this flag has no effect if parse_wnorm_attribute flag is set.
* New line characters are always treated as if parse_eol is set, i.e. \r\n is converted to single space.
*
* This flag is on by default.
*/
const unsigned int parse_wconv_attribute = 0x0040;
/**
* This flag determines if XML document declaration (this node has the form of <?xml ... ?> in XML)
* are to be put in DOM tree. If this flag is off, it is not put in the tree, but is still parsed
* and checked for correctness.
*
* The corresponding node in DOM tree will have type node_declaration, name "xml" and attributes,
* if any.
*
* This flag is off by default.
*/
const unsigned int parse_declaration = 0x0100;
/**
* This is the default set of flags. It includes parsing CDATA sections (comments/PIs are not
* parsed), performing character and entity reference expansion, replacing whitespace characters
* with spaces in attribute values and performing EOL handling. Note, that PCDATA sections
* consisting only of whitespace characters are not parsed (by default) for performance reasons.
*/
const unsigned int parse_default = parse_cdata | parse_escapes | parse_wconv_attribute | parse_eol;
/**
* These flags determine the encoding of input data for XML document. Default mode is encoding_auto,
* which means that document encoding is auto-detected from BOM and necessary encoding conversions are
* applied. You can override this mode by using any of the specific encodings.
*/
enum xml_encoding
{
encoding_auto, //!< Auto-detect input encoding using BOM or < / <? detection; use UTF8 if BOM is not found
encoding_utf8, //!< UTF8 encoding
encoding_utf16_le, //!< Little-endian UTF16
encoding_utf16_be, //!< Big-endian UTF16
encoding_utf16, //!< UTF16 with native endianness
encoding_utf32_le, //!< Little-endian UTF32
encoding_utf32_be, //!< Big-endian UTF32
encoding_utf32, //!< UTF32 with native endianness
encoding_wchar //!< The same encoding wchar_t has (either UTF16 or UTF32)
};
// Formatting flags
/**
* Indent the nodes that are written to output stream with as many indentation strings as deep
* the node is in DOM tree.
*
* This flag is on by default.
*/
const unsigned int format_indent = 0x01;
/**
* This flag determines if encoding-specific BOM is to be written to output stream.
*
* This flag is off by default.
*/
const unsigned int format_write_bom = 0x02;
/**
* If this flag is on, no indentation is performed and no line breaks are written to output file.
* This means that the data is written to output stream as is.
*
* This flag is off by default.
*/
const unsigned int format_raw = 0x04;
/**
* If this flag is on, no default XML declaration is written to output file.
* This means that there will be no XML declaration in output stream unless there was one in XML document
* (i.e. if it was parsed with parse_declaration flag).
*
* This flag is off by default.
*/
const unsigned int format_no_declaration = 0x08;
/**
* This is the default set of formatting flags. It includes indenting nodes depending on their
* depth in DOM tree.
*/
const unsigned int format_default = format_indent;
// Forward declarations
struct xml_attribute_struct;
struct xml_node_struct;
class xml_node_iterator;
class xml_attribute_iterator;
class xml_tree_walker;
class xml_node;
#ifndef PUGIXML_NO_XPATH
class xpath_node;
class xpath_node_set;
class xpath_query;
class xpath_variable_set;
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
/**
* Abstract writer class
* \see xml_node::print
*/
class PUGIXML_CLASS xml_writer
{
public:
/**
* Virtual destructor
*/
virtual ~xml_writer() {}
/**
* Write memory chunk into stream/file/whatever
*
* \param data - data pointer
* \param size - data size
*/
virtual void write(const void* data, size_t size) = 0;
};
/** xml_writer implementation for FILE*
* \see xml_writer
*/
class PUGIXML_CLASS xml_writer_file: public xml_writer
{
public:
/**
* Construct writer instance
*
* \param file - this is FILE* object, void* is used to avoid header dependencies on stdio
*/
xml_writer_file(void* file);
virtual void write(const void* data, size_t size);
private:
void* file;
};
#ifndef PUGIXML_NO_STL
/** xml_writer implementation for streams
* \see xml_writer
*/
class PUGIXML_CLASS xml_writer_stream: public xml_writer
{
public:
/**
* Construct writer instance
*
* \param stream - output stream object
*/
xml_writer_stream(std::basic_ostream<char, std::char_traits<char> >& stream);
/**
* Construct writer instance
*
* \param stream - output stream object
*/
xml_writer_stream(std::basic_ostream<wchar_t, std::char_traits<wchar_t> >& stream);
virtual void write(const void* data, size_t size);
private:
std::basic_ostream<char, std::char_traits<char> >* narrow_stream;
std::basic_ostream<wchar_t, std::char_traits<wchar_t> >* wide_stream;
};
#endif
/**
* A light-weight wrapper for manipulating attributes in DOM tree.
* Note: xml_attribute does not allocate any memory for the attribute it wraps; it only wraps a
* pointer to existing attribute.
*/
class PUGIXML_CLASS xml_attribute
{
friend class xml_attribute_iterator;
friend class xml_node;
private:
xml_attribute_struct* _attr;
/// \internal Safe bool type
typedef xml_attribute_struct* xml_attribute::*unspecified_bool_type;
/// \internal Initializing constructor
explicit xml_attribute(xml_attribute_struct* attr);
public:
/**
* Default constructor. Constructs an empty attribute.
*/
xml_attribute();
public:
/**
* Safe bool conversion.
* Allows xml_node to be used in a context where boolean variable is expected, such as 'if (node)'.
*/
operator unspecified_bool_type() const;
// Borland C++ workaround
bool operator!() const;
/**
* Compare wrapped pointer to the attribute to the pointer that is wrapped by \a r.
*
* \param r - value to compare to
* \return comparison result
*/
bool operator==(const xml_attribute& r) const;
/**
* Compare wrapped pointer to the attribute to the pointer that is wrapped by \a r.
*
* \param r - value to compare to
* \return comparison result
*/
bool operator!=(const xml_attribute& r) const;
/**
* Compare wrapped pointer to the attribute to the pointer that is wrapped by \a r.
*
* \param r - value to compare to
* \return comparison result
*/
bool operator<(const xml_attribute& r) const;
/**
* Compare wrapped pointer to the attribute to the pointer that is wrapped by \a r.
*
* \param r - value to compare to
* \return comparison result
*/
bool operator>(const xml_attribute& r) const;
/**
* Compare wrapped pointer to the attribute to the pointer that is wrapped by \a r.
*
* \param r - value to compare to
* \return comparison result
*/
bool operator<=(const xml_attribute& r) const;
/**
* Compare wrapped pointer to the attribute to the pointer that is wrapped by \a r.
*
* \param r - value to compare to
* \return comparison result
*/
bool operator>=(const xml_attribute& r) const;
public:
/**
* Get next attribute in attribute list of node that contains the attribute.
*
* \return next attribute, if any; empty attribute otherwise
*/
xml_attribute next_attribute() const;
/**
* Get previous attribute in attribute list of node that contains the attribute.
*
* \return previous attribute, if any; empty attribute otherwise
*/
xml_attribute previous_attribute() const;
/**
* Cast attribute value as int.
*
* \return attribute value as int, or 0 if conversion did not succeed or attribute is empty
*/
int as_int() const;
/**
* Cast attribute value as unsigned int.
*
* \return attribute value as unsigned int, or 0 if conversion did not succeed or attribute is empty
* \note values out of non-negative int range (usually [0, 2^31-1]) get clamped to range boundaries
*/
unsigned int as_uint() const;
/**
* Cast attribute value as double.
*
* \return attribute value as double, or 0.0 if conversion did not succeed or attribute is empty
*/
double as_double() const;
/**
* Cast attribute value as float.
*
* \return attribute value as float, or 0.0f if conversion did not succeed or attribute is empty
*/
float as_float() const;
/**
* Cast attribute value as bool. Returns true for attributes with values that start with '1',
* 't', 'T', 'y', 'Y', returns false for other attributes.
*
* \return attribute value as bool, or false if conversion did not succeed or attribute is empty
*/
bool as_bool() const;
/// \internal Document order or 0 if not set
arseny.kapoulkine
committed
const void* document_order() const;
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
public:
/**
* Set attribute value to \a rhs.
*
* \param rhs - new attribute value
* \return self
*/
xml_attribute& operator=(const char_t* rhs);
/**
* Set attribute value to \a rhs.
*
* \param rhs - new attribute value
* \return self
*/
xml_attribute& operator=(int rhs);
/**
* Set attribute value to \a rhs.
*
* \param rhs - new attribute value
* \return self
*/
xml_attribute& operator=(unsigned int rhs);
/**
* Set attribute value to \a rhs.
*
* \param rhs - new attribute value
* \return self
*/
xml_attribute& operator=(double rhs);
/**
* Set attribute value to either 'true' or 'false' (depends on whether \a rhs is true or false).
*
* \param rhs - new attribute value
* \return self
*/
xml_attribute& operator=(bool rhs);
/**
* Set attribute name to \a rhs.
*
* \param rhs - new attribute name
* \return success flag (call fails if attribute is empty or there is not enough memory)
*/
bool set_name(const char_t* rhs);
/**
* Set attribute value to \a rhs.
*
* \param rhs - new attribute value
* \return success flag (call fails if attribute is empty or there is not enough memory)
*/
bool set_value(const char_t* rhs);
/**
* Set attribute value to \a rhs.
*
* \param rhs - new attribute value
* \return success flag (call fails if attribute is empty or there is not enough memory)
*/
bool set_value(int rhs);
/**
* Set attribute value to \a rhs.
*
* \param rhs - new attribute value
* \return success flag (call fails if attribute is empty or there is not enough memory)
*/
bool set_value(unsigned int rhs);
/**
* Set attribute value to \a rhs.
*
* \param rhs - new attribute value
* \return success flag (call fails if attribute is empty or there is not enough memory)
*/
bool set_value(double rhs);
/**
* Set attribute value to either 'true' or 'false' (depends on whether \a rhs is true or false).
*
* \param rhs - new attribute value
* \return success flag (call fails if attribute is empty or there is not enough memory)
*/
bool set_value(bool rhs);
public:
/**
* Check if attribute is empty.
*
* \return true if attribute is empty, false otherwise
*/
bool empty() const;
public:
/**
* Get attribute name.
*
* \return attribute name, or "" if attribute is empty
*/
const char_t* name() const;
/**
* Get attribute value.
*
* \return attribute value, or "" if attribute is empty
*/
const char_t* value() const;
};
#ifdef __BORLANDC__
// Borland C++ workaround
bool PUGIXML_FUNCTION operator&&(const xml_attribute& lhs, bool rhs);
bool PUGIXML_FUNCTION operator||(const xml_attribute& lhs, bool rhs);
#endif
/**
* A light-weight wrapper for manipulating nodes in DOM tree.
* Note: xml_node does not allocate any memory for the node it wraps; it only wraps a pointer to
* existing node.
*/
class PUGIXML_CLASS xml_node
{
friend class xml_attribute_iterator;
friend class xml_node_iterator;
protected:
xml_node_struct* _root;
/// \internal Safe bool type
typedef xml_node_struct* xml_node::*unspecified_bool_type;
/// \internal Initializing constructor
explicit xml_node(xml_node_struct* p);
public:
/**
* Default constructor. Constructs an empty node.
*/
xml_node();
public:
/**
* Safe bool conversion.
* Allows xml_node to be used in a context where boolean variable is expected, such as 'if (node)'.
*/
operator unspecified_bool_type() const;
// Borland C++ workaround
bool operator!() const;
/**
* Compare wrapped pointer to the attribute to the pointer that is wrapped by \a r.
*
* \param r - value to compare to
* \return comparison result
*/
bool operator==(const xml_node& r) const;
/**
* Compare wrapped pointer to the attribute to the pointer that is wrapped by \a r.
*
* \param r - value to compare to
* \return comparison result
*/
bool operator!=(const xml_node& r) const;
/**
* Compare wrapped pointer to the attribute to the pointer that is wrapped by \a r.
*
* \param r - value to compare to
* \return comparison result
*/
bool operator<(const xml_node& r) const;
/**
* Compare wrapped pointer to the attribute to the pointer that is wrapped by \a r.
*
* \param r - value to compare to
* \return comparison result
*/
bool operator>(const xml_node& r) const;
/**
* Compare wrapped pointer to the attribute to the pointer that is wrapped by \a r.
*
* \param r - value to compare to
* \return comparison result
*/
bool operator<=(const xml_node& r) const;
/**
* Compare wrapped pointer to the attribute to the pointer that is wrapped by \a r.
*
* \param r - value to compare to
* \return comparison result
*/
bool operator>=(const xml_node& r) const;
public:
/**
* Node iterator type (for child nodes).
* \see xml_node_iterator
*/
typedef xml_node_iterator iterator;
/**
* Node iterator type (for child nodes).
* \see xml_attribute_iterator
*/
typedef xml_attribute_iterator attribute_iterator;
/**
* Access the begin iterator for this node's collection of child nodes.
*
* \return iterator that points to the first child node, or past-the-end iterator if node is empty or has no children
*/
iterator begin() const;
/**
* Access the end iterator for this node's collection of child nodes.
*
* \return past-the-end iterator for child list
*/
iterator end() const;
/**
* Access the begin iterator for this node's collection of attributes.
*
* \return iterator that points to the first attribute, or past-the-end iterator if node is empty or has no attributes
*/
attribute_iterator attributes_begin() const;
/**
* Access the end iterator for this node's collection of attributes.
*
* \return past-the-end iterator for attribute list
*/
attribute_iterator attributes_end() const;
public:
/**
* Check if node is empty.
*
* \return true if node is empty, false otherwise
*/
bool empty() const;
public:
/**
* Get node type
*
* \return node type; node_null for empty nodes
*/
xml_node_type type() const;
/**
* Get node name (element name for element nodes, PI target for PI)
*
* \return node name, if any; "" otherwise
*/
const char_t* name() const;
/**
* Get node value (comment/PI/PCDATA/CDATA contents, depending on node type)
*
* \return node value, if any; "" otherwise
*/
const char_t* value() const;
/**
* Get child with the specified name
*
* \param name - child name
* \return child with the specified name, if any; empty node otherwise
*/
xml_node child(const char_t* name) const;
/**
* Get attribute with the specified name
*
* \param name - attribute name
* \return attribute with the specified name, if any; empty attribute otherwise
*/
xml_attribute attribute(const char_t* name) const;
/**
* Get first of following sibling nodes with the specified name
*
* \param name - sibling name
* \return node with the specified name, if any; empty node otherwise
*/
xml_node next_sibling(const char_t* name) const;
/**
* Get following sibling
*
* \return following sibling node, if any; empty node otherwise
*/
xml_node next_sibling() const;
/**
* Get first of preceding sibling nodes with the specified name
*
* \param name - sibling name
* \return node with the specified name, if any; empty node otherwise
*/
xml_node previous_sibling(const char_t* name) const;
/**
* Get preceding sibling
*
* \return preceding sibling node, if any; empty node otherwise
*/
xml_node previous_sibling() const;
/**
* Get parent node
*
* \return parent node if any; empty node otherwise
*/
xml_node parent() const;
/**
* Get root of DOM tree this node belongs to.
*
* \return tree root
*/
xml_node root() const;
/**
* Get child value of current node; that is, value of the first child node of type PCDATA/CDATA
*
* \return child value of current node, if any; "" otherwise
*/
const char_t* child_value() const;
/**
* Get child value of child with specified name. \see child_value
* node.child_value(name) is equivalent to node.child(name).child_value()
*
* \param name - child name
* \return child value of specified child node, if any; "" otherwise
*/
const char_t* child_value(const char_t* name) const;
public:
/**
* Set node name to \a rhs (for PI/element nodes). \see name
*
* \param rhs - new node name
* \return success flag (call fails if node is of the wrong type or there is not enough memory)
*/
bool set_name(const char_t* rhs);
/**
* Set node value to \a rhs (for PI/PCDATA/CDATA/comment nodes). \see value
*
* \param rhs - new node value
* \return success flag (call fails if node is of the wrong type or there is not enough memory)
*/
bool set_value(const char_t* rhs);
/**
* Add attribute with specified name (for element nodes)
*
* \param name - attribute name
* \return added attribute, or empty attribute if there was an error (wrong node type)
*/
xml_attribute append_attribute(const char_t* name);
/**
* Insert attribute with specified name after \a attr (for element nodes)
*
* \param name - attribute name
* \param attr - attribute to insert a new one after
* \return inserted attribute, or empty attribute if there was an error (wrong node type, or attr does not belong to node)
*/
xml_attribute insert_attribute_after(const char_t* name, const xml_attribute& attr);
/**
* Insert attribute with specified name before \a attr (for element nodes)
*
* \param name - attribute name
* \param attr - attribute to insert a new one before
* \return inserted attribute, or empty attribute if there was an error (wrong node type, or attr does not belong to node)
*/
xml_attribute insert_attribute_before(const char_t* name, const xml_attribute& attr);
/**
* Add a copy of the specified attribute (for element nodes)
*
* \param proto - attribute prototype which is to be copied
* \return inserted attribute, or empty attribute if there was an error (wrong node type)
*/
xml_attribute append_copy(const xml_attribute& proto);
/**
* Insert a copy of the specified attribute after \a attr (for element nodes)
*
* \param proto - attribute prototype which is to be copied
* \param attr - attribute to insert a new one after
* \return inserted attribute, or empty attribute if there was an error (wrong node type, or attr does not belong to node)
*/
xml_attribute insert_copy_after(const xml_attribute& proto, const xml_attribute& attr);
/**
* Insert a copy of the specified attribute before \a attr (for element nodes)
*
* \param proto - attribute prototype which is to be copied
* \param attr - attribute to insert a new one before
* \return inserted attribute, or empty attribute if there was an error (wrong node type, or attr does not belong to node)
*/
xml_attribute insert_copy_before(const xml_attribute& proto, const xml_attribute& attr);
/**
* Add child node with specified type (for element nodes)
*
* \param type - node type
* \return added node, or empty node if there was an error (wrong node type)
*/
xml_node append_child(xml_node_type type = node_element);
/**
* Insert child node with specified type after \a node (for element nodes)
*
* \param type - node type
* \param node - node to insert a new one after
* \return inserted node, or empty node if there was an error (wrong node type, or \a node is not a child of this node)
*/
xml_node insert_child_after(xml_node_type type, const xml_node& node);
/**
* Insert child node with specified type before \a node (for element nodes)
*
* \param type - node type
* \param node - node to insert a new one before
* \return inserted node, or empty node if there was an error (wrong node type, or \a node is not a child of this node)
*/
xml_node insert_child_before(xml_node_type type, const xml_node& node);
/**
* Add a copy of the specified node as a child (for element nodes)
*
* \param proto - node prototype which is to be copied
* \return inserted node, or empty node if there was an error (wrong node type)
*/
xml_node append_copy(const xml_node& proto);
/**
* Insert a copy of the specified node after \a node (for element nodes)
*
* \param proto - node prototype which is to be copied
* \param node - node to insert a new one after
* \return inserted node, or empty node if there was an error (wrong node type, or \a node is not a child of this node)
*/
xml_node insert_copy_after(const xml_node& proto, const xml_node& node);
/**
* Insert a copy of the specified node before \a node (for element nodes)
*
* \param proto - node prototype which is to be copied
* \param node - node to insert a new one before
* \return inserted node, or empty node if there was an error (wrong node type, or \a node is not a child of this node)
*/
xml_node insert_copy_before(const xml_node& proto, const xml_node& node);