Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
pugi::xml_node Class Reference

#include <pugixml.hpp>

Inheritance diagram for pugi::xml_node:

Public Types

typedef xml_node_iterator iterator
typedef xml_attribute_iterator attribute_iterator

Public Member Functions

 xml_node ()
 xml_node (xml_node_struct *p)
 operator unspecified_bool_type () const
bool operator! () const
bool operator== (const xml_node &r) const
bool operator!= (const xml_node &r) const
bool operator< (const xml_node &r) const
bool operator> (const xml_node &r) const
bool operator<= (const xml_node &r) const
bool operator>= (const xml_node &r) const
bool empty () const
xml_node_type type () const
const char_tname () const
const char_tvalue () const
xml_attribute first_attribute () const
xml_attribute last_attribute () const
xml_node first_child () const
xml_node last_child () const
xml_node next_sibling () const
xml_node previous_sibling () const
xml_node parent () const
xml_node root () const
xml_text text () const
xml_node child (const char_t *name) const
xml_attribute attribute (const char_t *name) const
xml_node next_sibling (const char_t *name) const
xml_node previous_sibling (const char_t *name) const
xml_attribute attribute (const char_t *name, xml_attribute &hint) const
const char_tchild_value () const
const char_tchild_value (const char_t *name) const
bool set_name (const char_t *rhs)
bool set_value (const char_t *rhs, size_t sz)
bool set_value (const char_t *rhs)
xml_attribute append_attribute (const char_t *name)
xml_attribute prepend_attribute (const char_t *name)
xml_attribute insert_attribute_after (const char_t *name, const xml_attribute &attr)
xml_attribute insert_attribute_before (const char_t *name, const xml_attribute &attr)
xml_attribute append_copy (const xml_attribute &proto)
xml_attribute prepend_copy (const xml_attribute &proto)
xml_attribute insert_copy_after (const xml_attribute &proto, const xml_attribute &attr)
xml_attribute insert_copy_before (const xml_attribute &proto, const xml_attribute &attr)
xml_node append_child (xml_node_type type=node_element)
xml_node prepend_child (xml_node_type type=node_element)
xml_node insert_child_after (xml_node_type type, const xml_node &node)
xml_node insert_child_before (xml_node_type type, const xml_node &node)
xml_node append_child (const char_t *name)
xml_node prepend_child (const char_t *name)
xml_node insert_child_after (const char_t *name, const xml_node &node)
xml_node insert_child_before (const char_t *name, const xml_node &node)
xml_node append_copy (const xml_node &proto)
xml_node prepend_copy (const xml_node &proto)
xml_node insert_copy_after (const xml_node &proto, const xml_node &node)
xml_node insert_copy_before (const xml_node &proto, const xml_node &node)
xml_node append_move (const xml_node &moved)
xml_node prepend_move (const xml_node &moved)
xml_node insert_move_after (const xml_node &moved, const xml_node &node)
xml_node insert_move_before (const xml_node &moved, const xml_node &node)
bool remove_attribute (const xml_attribute &a)
bool remove_attribute (const char_t *name)
bool remove_attributes ()
bool remove_child (const xml_node &n)
bool remove_child (const char_t *name)
bool remove_children ()
xml_parse_result append_buffer (const void *contents, size_t size, unsigned int options=parse_default, xml_encoding encoding=encoding_auto)
template<typename Predicate>
xml_attribute find_attribute (Predicate pred) const
template<typename Predicate>
xml_node find_child (Predicate pred) const
template<typename Predicate>
xml_node find_node (Predicate pred) const
xml_node find_child_by_attribute (const char_t *name, const char_t *attr_name, const char_t *attr_value) const
xml_node find_child_by_attribute (const char_t *attr_name, const char_t *attr_value) const
string_t path (char_t delimiter='/') const
xml_node first_element_by_path (const char_t *path, char_t delimiter='/') const
bool traverse (xml_tree_walker &walker)
xpath_node select_node (const char_t *query, xpath_variable_set *variables=PUGIXML_NULL) const
xpath_node select_node (const xpath_query &query) const
xpath_node_set select_nodes (const char_t *query, xpath_variable_set *variables=PUGIXML_NULL) const
xpath_node_set select_nodes (const xpath_query &query) const
PUGIXML_DEPRECATED xpath_node select_single_node (const char_t *query, xpath_variable_set *variables=PUGIXML_NULL) const
PUGIXML_DEPRECATED xpath_node select_single_node (const xpath_query &query) const
void print (xml_writer &writer, const char_t *indent=PUGIXML_TEXT("\t"), unsigned int flags=format_default, xml_encoding encoding=encoding_auto, unsigned int depth=0) const
void print (std::basic_ostream< char, std::char_traits< char > > &os, const char_t *indent=PUGIXML_TEXT("\t"), unsigned int flags=format_default, xml_encoding encoding=encoding_auto, unsigned int depth=0) const
void print (std::basic_ostream< wchar_t, std::char_traits< wchar_t > > &os, const char_t *indent=PUGIXML_TEXT("\t"), unsigned int flags=format_default, unsigned int depth=0) const
iterator begin () const
iterator end () const
attribute_iterator attributes_begin () const
attribute_iterator attributes_end () const
xml_object_range< xml_node_iteratorchildren () const
xml_object_range< xml_named_node_iteratorchildren (const char_t *name) const
xml_object_range< xml_attribute_iteratorattributes () const
ptrdiff_t offset_debug () const
size_t hash_value () const
xml_node_struct * internal_object () const

Protected Types

typedef void(* unspecified_bool_type) (xml_node ***)

Protected Attributes

xml_node_struct * _root

Friends

class xml_attribute_iterator
class xml_node_iterator
class xml_named_node_iterator

Detailed Description

Definition at line 473 of file pugixml.hpp.

Member Typedef Documentation

◆ attribute_iterator

◆ iterator

Definition at line 702 of file pugixml.hpp.

◆ unspecified_bool_type

typedef void(* pugi::xml_node::unspecified_bool_type) (xml_node ***)
protected

Definition at line 482 of file pugixml.hpp.

Constructor & Destructor Documentation

◆ xml_node() [1/2]

◆ xml_node() [2/2]

PUGI__FN pugi::xml_node::xml_node ( xml_node_struct * p)
explicit

Definition at line 5484 of file pugixml.cc.

5484 : _root(p)
5485 {
5486 }

Member Function Documentation

◆ append_attribute()

PUGI__FN xml_attribute pugi::xml_node::append_attribute ( const char_t * name)

Definition at line 5792 of file pugixml.cc.

5793 {
5794 if (!impl::allow_insert_attribute(type())) return xml_attribute();
5795
5796 impl::xml_allocator& alloc = impl::get_allocator(_root);
5797 if (!alloc.reserve()) return xml_attribute();
5798
5799 xml_attribute a(impl::allocate_attribute(alloc));
5800 if (!a) return xml_attribute();
5801
5802 impl::append_attribute(a._attr, _root);
5803
5804 a.set_name(name_);
5805
5806 return a;
5807 }
xml_node_type type() const
Definition pugixml.cc:5579

◆ append_buffer()

PUGI__FN xml_parse_result pugi::xml_node::append_buffer ( const void * contents,
size_t size,
unsigned int options = parse_default,
xml_encoding encoding = encoding_auto )

Definition at line 6255 of file pugixml.cc.

6256 {
6257 // append_buffer is only valid for elements/documents
6258 if (!impl::allow_insert_child(type(), node_element)) return impl::make_parse_result(status_append_invalid_root);
6259
6260 // get document node
6261 impl::xml_document_struct* doc = &impl::get_document(_root);
6262
6263 // disable document_buffer_order optimization since in a document with multiple buffers comparing buffer pointers does not make sense
6264 doc->header |= impl::xml_memory_page_contents_shared_mask;
6265
6266 // get extra buffer element (we'll store the document fragment buffer there so that we can deallocate it later)
6267 impl::xml_memory_page* page = 0;
6268 impl::xml_extra_buffer* extra = static_cast<impl::xml_extra_buffer*>(doc->allocate_memory(sizeof(impl::xml_extra_buffer) + sizeof(void*), page));
6269 (void)page;
6270
6271 if (!extra) return impl::make_parse_result(status_out_of_memory);
6272
6273 #ifdef PUGIXML_COMPACT
6274 // align the memory block to a pointer boundary; this is required for compact mode where memory allocations are only 4b aligned
6275 // note that this requires up to sizeof(void*)-1 additional memory, which the allocation above takes into account
6276 extra = reinterpret_cast<impl::xml_extra_buffer*>((reinterpret_cast<uintptr_t>(extra) + (sizeof(void*) - 1)) & ~(sizeof(void*) - 1));
6277 #endif
6278
6279 // add extra buffer to the list
6280 extra->buffer = 0;
6281 extra->next = doc->extra_buffers;
6282 doc->extra_buffers = extra;
6283
6284 // name of the root has to be NULL before parsing - otherwise closing node mismatches will not be detected at the top level
6285 impl::name_null_sentry sentry(_root);
6286
6287 return impl::load_buffer_impl(doc, _root, const_cast<void*>(contents), size, options, encoding, false, false, &extra->buffer);
6288 }
@ node_element
Definition pugixml.hpp:153
@ status_append_invalid_root
Definition pugixml.hpp:1001
@ status_out_of_memory
Definition pugixml.hpp:986

◆ append_child() [1/2]

PUGI__FN xml_node pugi::xml_node::append_child ( const char_t * name)

Definition at line 6002 of file pugixml.cc.

6003 {
6005
6006 result.set_name(name_);
6007
6008 return result;
6009 }
xml_node append_child(xml_node_type type=node_element)
Definition pugixml.cc:5932

◆ append_child() [2/2]

PUGI__FN xml_node pugi::xml_node::append_child ( xml_node_type type = node_element)

Definition at line 5932 of file pugixml.cc.

5933 {
5934 if (!impl::allow_insert_child(type(), type_)) return xml_node();
5935
5936 impl::xml_allocator& alloc = impl::get_allocator(_root);
5937 if (!alloc.reserve()) return xml_node();
5938
5939 xml_node n(impl::allocate_node(alloc, type_));
5940 if (!n) return xml_node();
5941
5942 impl::append_node(n._root, _root);
5943
5944 if (type_ == node_declaration) n.set_name(PUGIXML_TEXT("xml"));
5945
5946 return n;
5947 }
@ node_declaration
Definition pugixml.hpp:158
#define PUGIXML_TEXT(t)
Definition pugixml.hpp:130

Referenced by append_child().

◆ append_copy() [1/2]

PUGI__FN xml_attribute pugi::xml_node::append_copy ( const xml_attribute & proto)

Definition at line 5862 of file pugixml.cc.

5863 {
5864 if (!proto) return xml_attribute();
5865 if (!impl::allow_insert_attribute(type())) return xml_attribute();
5866
5867 impl::xml_allocator& alloc = impl::get_allocator(_root);
5868 if (!alloc.reserve()) return xml_attribute();
5869
5870 xml_attribute a(impl::allocate_attribute(alloc));
5871 if (!a) return xml_attribute();
5872
5873 impl::append_attribute(a._attr, _root);
5874 impl::node_copy_attribute(a._attr, proto._attr);
5875
5876 return a;
5877 }

◆ append_copy() [2/2]

PUGI__FN xml_node pugi::xml_node::append_copy ( const xml_node & proto)

Definition at line 6038 of file pugixml.cc.

6039 {
6040 xml_node_type type_ = proto.type();
6041 if (!impl::allow_insert_child(type(), type_)) return xml_node();
6042
6043 impl::xml_allocator& alloc = impl::get_allocator(_root);
6044 if (!alloc.reserve()) return xml_node();
6045
6046 xml_node n(impl::allocate_node(alloc, type_));
6047 if (!n) return xml_node();
6048
6049 impl::append_node(n._root, _root);
6050 impl::node_copy_tree(n._root, proto._root);
6051
6052 return n;
6053 }
xml_node_type
Definition pugixml.hpp:150

◆ append_move()

PUGI__FN xml_node pugi::xml_node::append_move ( const xml_node & moved)

Definition at line 6108 of file pugixml.cc.

6109 {
6110 if (!impl::allow_move(*this, moved)) return xml_node();
6111
6112 impl::xml_allocator& alloc = impl::get_allocator(_root);
6113 if (!alloc.reserve()) return xml_node();
6114
6115 // disable document_buffer_order optimization since moving nodes around changes document order without changing buffer pointers
6116 impl::get_document(_root).header |= impl::xml_memory_page_contents_shared_mask;
6117
6118 impl::remove_node(moved._root);
6119 impl::append_node(moved._root, _root);
6120
6121 return moved;
6122 }

◆ attribute() [1/2]

PUGI__FN xml_attribute pugi::xml_node::attribute ( const char_t * name) const

Definition at line 5605 of file pugixml.cc.

5606 {
5607 if (!_root) return xml_attribute();
5608
5609 for (xml_attribute_struct* i = _root->first_attribute; i; i = i->next_attribute)
5610 {
5611 const char_t* iname = i->name;
5612 if (iname && impl::strequal(name_, iname))
5613 return xml_attribute(i);
5614 }
5615
5616 return xml_attribute();
5617 }
PUGIXML_CHAR char_t
Definition pugixml.hpp:137

Referenced by remove_attribute().

◆ attribute() [2/2]

PUGI__FN xml_attribute pugi::xml_node::attribute ( const char_t * name,
xml_attribute & hint ) const

Definition at line 5652 of file pugixml.cc.

5653 {
5654 xml_attribute_struct* hint = hint_._attr;
5655
5656 // if hint is not an attribute of node, behavior is not defined
5657 assert(!hint || (_root && impl::is_attribute_of(hint, _root)));
5658
5659 if (!_root) return xml_attribute();
5660
5661 // optimistically search from hint up until the end
5662 for (xml_attribute_struct* i = hint; i; i = i->next_attribute)
5663 {
5664 const char_t* iname = i->name;
5665 if (iname && impl::strequal(name_, iname))
5666 {
5667 // update hint to maximize efficiency of searching for consecutive attributes
5668 hint_._attr = i->next_attribute;
5669
5670 return xml_attribute(i);
5671 }
5672 }
5673
5674 // wrap around and search from the first attribute until the hint
5675 // 'j' null pointer check is technically redundant, but it prevents a crash in case the assertion above fails
5676 for (xml_attribute_struct* j = _root->first_attribute; j && j != hint; j = j->next_attribute)
5677 {
5678 const char_t* jname = j->name;
5679 if (jname && impl::strequal(name_, jname))
5680 {
5681 // update hint to maximize efficiency of searching for consecutive attributes
5682 hint_._attr = j->next_attribute;
5683
5684 return xml_attribute(j);
5685 }
5686 }
5687
5688 return xml_attribute();
5689 }

◆ attributes()

PUGI__FN xml_object_range< xml_attribute_iterator > pugi::xml_node::attributes ( ) const

Definition at line 5532 of file pugixml.cc.

5533 {
5534 return xml_object_range<xml_attribute_iterator>(attributes_begin(), attributes_end());
5535 }
attribute_iterator attributes_end() const
Definition pugixml.cc:5517
attribute_iterator attributes_begin() const
Definition pugixml.cc:5512

◆ attributes_begin()

PUGI__FN xml_node::attribute_iterator pugi::xml_node::attributes_begin ( ) const

Definition at line 5512 of file pugixml.cc.

5513 {
5514 return attribute_iterator(_root ? _root->first_attribute + 0 : 0, _root);
5515 }
xml_attribute_iterator attribute_iterator
Definition pugixml.hpp:708

Referenced by attributes().

◆ attributes_end()

PUGI__FN xml_node::attribute_iterator pugi::xml_node::attributes_end ( ) const

Definition at line 5517 of file pugixml.cc.

5518 {
5519 return attribute_iterator(0, _root);
5520 }

Referenced by attributes().

◆ begin()

PUGI__FN xml_node::iterator pugi::xml_node::begin ( ) const

Definition at line 5502 of file pugixml.cc.

5503 {
5504 return iterator(_root ? _root->first_child + 0 : 0, _root);
5505 }
xml_node_iterator iterator
Definition pugixml.hpp:702

Referenced by children().

◆ child()

PUGI__FN xml_node pugi::xml_node::child ( const char_t * name) const

Definition at line 5591 of file pugixml.cc.

5592 {
5593 if (!_root) return xml_node();
5594
5595 for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling)
5596 {
5597 const char_t* iname = i->name;
5598 if (iname && impl::strequal(name_, iname))
5599 return xml_node(i);
5600 }
5601
5602 return xml_node();
5603 }

Referenced by child_value(), children(), and remove_child().

◆ child_value() [1/2]

PUGI__FN const char_t * pugi::xml_node::child_value ( ) const

Definition at line 5713 of file pugixml.cc.

5714 {
5715 if (!_root) return PUGIXML_TEXT("");
5716
5717 // element nodes can have value if parse_embed_pcdata was used
5718 if (PUGI__NODETYPE(_root) == node_element && _root->value)
5719 return _root->value;
5720
5721 for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling)
5722 {
5723 const char_t* ivalue = i->value;
5724 if (impl::is_text_node(i) && ivalue)
5725 return ivalue;
5726 }
5727
5728 return PUGIXML_TEXT("");
5729 }
#define PUGI__NODETYPE(n)
Definition pugixml.cc:456

Referenced by child_value().

◆ child_value() [2/2]

PUGI__FN const char_t * pugi::xml_node::child_value ( const char_t * name) const

Definition at line 5731 of file pugixml.cc.

5732 {
5733 return child(name_).child_value();
5734 }
xml_node child(const char_t *name) const
Definition pugixml.cc:5591
const char_t * child_value() const
Definition pugixml.cc:5713

◆ children() [1/2]

PUGI__FN xml_object_range< xml_node_iterator > pugi::xml_node::children ( ) const

Definition at line 5522 of file pugixml.cc.

5523 {
5524 return xml_object_range<xml_node_iterator>(begin(), end());
5525 }
iterator end() const
Definition pugixml.cc:5507
iterator begin() const
Definition pugixml.cc:5502

◆ children() [2/2]

PUGI__FN xml_object_range< xml_named_node_iterator > pugi::xml_node::children ( const char_t * name) const

Definition at line 5527 of file pugixml.cc.

5528 {
5529 return xml_object_range<xml_named_node_iterator>(xml_named_node_iterator(child(name_)._root, _root, name_), xml_named_node_iterator(0, _root, name_));
5530 }
friend class xml_named_node_iterator
Definition pugixml.hpp:477

◆ empty()

PUGI__FN bool pugi::xml_node::empty ( ) const

Definition at line 5567 of file pugixml.cc.

5568 {
5569 return !_root;
5570 }

◆ end()

PUGI__FN xml_node::iterator pugi::xml_node::end ( ) const

Definition at line 5507 of file pugixml.cc.

5508 {
5509 return iterator(0, _root);
5510 }

Referenced by children().

◆ find_attribute()

template<typename Predicate>
xml_attribute pugi::xml_node::find_attribute ( Predicate pred) const
inline

Definition at line 615 of file pugixml.hpp.

616 {
617 if (!_root) return xml_attribute();
618
619 for (xml_attribute attrib = first_attribute(); attrib; attrib = attrib.next_attribute())
620 if (pred(attrib))
621 return attrib;
622
623 return xml_attribute();
624 }
xml_attribute next_attribute() const
Definition pugixml.cc:5206
xml_attribute first_attribute() const
Definition pugixml.cc:5736

◆ find_child()

template<typename Predicate>
xml_node pugi::xml_node::find_child ( Predicate pred) const
inline

Definition at line 627 of file pugixml.hpp.

628 {
629 if (!_root) return xml_node();
630
631 for (xml_node node = first_child(); node; node = node.next_sibling())
632 if (pred(node))
633 return node;
634
635 return xml_node();
636 }
xml_node first_child() const
Definition pugixml.cc:5749
xml_node next_sibling() const
Definition pugixml.cc:5633

◆ find_child_by_attribute() [1/2]

PUGI__FN xml_node pugi::xml_node::find_child_by_attribute ( const char_t * attr_name,
const char_t * attr_value ) const

Definition at line 6315 of file pugixml.cc.

6316 {
6317 if (!_root) return xml_node();
6318
6319 for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling)
6320 for (xml_attribute_struct* a = i->first_attribute; a; a = a->next_attribute)
6321 {
6322 const char_t* aname = a->name;
6323 if (aname && impl::strequal(attr_name, aname))
6324 {
6325 const char_t* avalue = a->value;
6326 if (impl::strequal(attr_value, avalue ? avalue : PUGIXML_TEXT("")))
6327 return xml_node(i);
6328 }
6329 }
6330
6331 return xml_node();
6332 }

◆ find_child_by_attribute() [2/2]

PUGI__FN xml_node pugi::xml_node::find_child_by_attribute ( const char_t * name,
const char_t * attr_name,
const char_t * attr_value ) const

Definition at line 6290 of file pugixml.cc.

6291 {
6292 if (!_root) return xml_node();
6293
6294 for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling)
6295 {
6296 const char_t* iname = i->name;
6297 if (iname && impl::strequal(name_, iname))
6298 {
6299 for (xml_attribute_struct* a = i->first_attribute; a; a = a->next_attribute)
6300 {
6301 const char_t* aname = a->name;
6302 if (aname && impl::strequal(attr_name, aname))
6303 {
6304 const char_t* avalue = a->value;
6305 if (impl::strequal(attr_value, avalue ? avalue : PUGIXML_TEXT("")))
6306 return xml_node(i);
6307 }
6308 }
6309 }
6310 }
6311
6312 return xml_node();
6313 }

◆ find_node()

template<typename Predicate>
xml_node pugi::xml_node::find_node ( Predicate pred) const
inline

Definition at line 639 of file pugixml.hpp.

640 {
641 if (!_root) return xml_node();
642
643 xml_node cur = first_child();
644
645 while (cur._root && cur._root != _root)
646 {
647 if (pred(cur)) return cur;
648
649 if (cur.first_child()) cur = cur.first_child();
650 else if (cur.next_sibling()) cur = cur.next_sibling();
651 else
652 {
653 while (!cur.next_sibling() && cur._root != _root) cur = cur.parent();
654
655 if (cur._root != _root) cur = cur.next_sibling();
656 }
657 }
658
659 return xml_node();
660 }

◆ first_attribute()

PUGI__FN xml_attribute pugi::xml_node::first_attribute ( ) const

Definition at line 5736 of file pugixml.cc.

5737 {
5738 if (!_root) return xml_attribute();
5739 return xml_attribute(_root->first_attribute);
5740 }

Referenced by find_attribute().

◆ first_child()

PUGI__FN xml_node pugi::xml_node::first_child ( ) const

Definition at line 5749 of file pugixml.cc.

5750 {
5751 if (!_root) return xml_node();
5752 return xml_node(_root->first_child);
5753 }

Referenced by PoPI::Database::addDatabase(), find_child(), and find_node().

◆ first_element_by_path()

PUGI__FN xml_node pugi::xml_node::first_element_by_path ( const char_t * path,
char_t delimiter = '/' ) const

Definition at line 6372 of file pugixml.cc.

6373 {
6374 xml_node context = path_[0] == delimiter ? root() : *this;
6375
6376 if (!context._root) return xml_node();
6377
6378 const char_t* path_segment = path_;
6379
6380 while (*path_segment == delimiter) ++path_segment;
6381
6382 const char_t* path_segment_end = path_segment;
6383
6384 while (*path_segment_end && *path_segment_end != delimiter) ++path_segment_end;
6385
6386 if (path_segment == path_segment_end) return context;
6387
6388 const char_t* next_segment = path_segment_end;
6389
6390 while (*next_segment == delimiter) ++next_segment;
6391
6392 if (*path_segment == '.' && path_segment + 1 == path_segment_end)
6393 return context.first_element_by_path(next_segment, delimiter);
6394 else if (*path_segment == '.' && *(path_segment+1) == '.' && path_segment + 2 == path_segment_end)
6395 return context.parent().first_element_by_path(next_segment, delimiter);
6396 else
6397 {
6398 for (xml_node_struct* j = context._root->first_child; j; j = j->next_sibling)
6399 {
6400 const char_t* jname = j->name;
6401 if (jname && impl::strequalrange(jname, path_segment, static_cast<size_t>(path_segment_end - path_segment)))
6402 {
6403 xml_node subsearch = xml_node(j).first_element_by_path(next_segment, delimiter);
6404
6405 if (subsearch) return subsearch;
6406 }
6407 }
6408
6409 return xml_node();
6410 }
6411 }
xml_node root() const
Definition pugixml.cc:5703

Referenced by first_element_by_path().

◆ hash_value()

PUGI__FN size_t pugi::xml_node::hash_value ( ) const

Definition at line 6460 of file pugixml.cc.

6461 {
6462 return static_cast<size_t>(reinterpret_cast<uintptr_t>(_root) / sizeof(xml_node_struct));
6463 }

◆ insert_attribute_after()

PUGI__FN xml_attribute pugi::xml_node::insert_attribute_after ( const char_t * name,
const xml_attribute & attr )

Definition at line 5826 of file pugixml.cc.

5827 {
5828 if (!impl::allow_insert_attribute(type())) return xml_attribute();
5829 if (!attr || !impl::is_attribute_of(attr._attr, _root)) return xml_attribute();
5830
5831 impl::xml_allocator& alloc = impl::get_allocator(_root);
5832 if (!alloc.reserve()) return xml_attribute();
5833
5834 xml_attribute a(impl::allocate_attribute(alloc));
5835 if (!a) return xml_attribute();
5836
5837 impl::insert_attribute_after(a._attr, attr._attr, _root);
5838
5839 a.set_name(name_);
5840
5841 return a;
5842 }

◆ insert_attribute_before()

PUGI__FN xml_attribute pugi::xml_node::insert_attribute_before ( const char_t * name,
const xml_attribute & attr )

Definition at line 5844 of file pugixml.cc.

5845 {
5846 if (!impl::allow_insert_attribute(type())) return xml_attribute();
5847 if (!attr || !impl::is_attribute_of(attr._attr, _root)) return xml_attribute();
5848
5849 impl::xml_allocator& alloc = impl::get_allocator(_root);
5850 if (!alloc.reserve()) return xml_attribute();
5851
5852 xml_attribute a(impl::allocate_attribute(alloc));
5853 if (!a) return xml_attribute();
5854
5855 impl::insert_attribute_before(a._attr, attr._attr, _root);
5856
5857 a.set_name(name_);
5858
5859 return a;
5860 }

◆ insert_child_after() [1/2]

PUGI__FN xml_node pugi::xml_node::insert_child_after ( const char_t * name,
const xml_node & node )

Definition at line 6020 of file pugixml.cc.

6021 {
6023
6024 result.set_name(name_);
6025
6026 return result;
6027 }
xml_node insert_child_after(xml_node_type type, const xml_node &node)
Definition pugixml.cc:5984

◆ insert_child_after() [2/2]

PUGI__FN xml_node pugi::xml_node::insert_child_after ( xml_node_type type,
const xml_node & node )

Definition at line 5984 of file pugixml.cc.

5985 {
5986 if (!impl::allow_insert_child(type(), type_)) return xml_node();
5987 if (!node._root || node._root->parent != _root) return xml_node();
5988
5989 impl::xml_allocator& alloc = impl::get_allocator(_root);
5990 if (!alloc.reserve()) return xml_node();
5991
5992 xml_node n(impl::allocate_node(alloc, type_));
5993 if (!n) return xml_node();
5994
5995 impl::insert_node_after(n._root, node._root);
5996
5997 if (type_ == node_declaration) n.set_name(PUGIXML_TEXT("xml"));
5998
5999 return n;
6000 }

Referenced by insert_child_after().

◆ insert_child_before() [1/2]

PUGI__FN xml_node pugi::xml_node::insert_child_before ( const char_t * name,
const xml_node & node )

Definition at line 6029 of file pugixml.cc.

6030 {
6032
6033 result.set_name(name_);
6034
6035 return result;
6036 }
xml_node insert_child_before(xml_node_type type, const xml_node &node)
Definition pugixml.cc:5966

◆ insert_child_before() [2/2]

PUGI__FN xml_node pugi::xml_node::insert_child_before ( xml_node_type type,
const xml_node & node )

Definition at line 5966 of file pugixml.cc.

5967 {
5968 if (!impl::allow_insert_child(type(), type_)) return xml_node();
5969 if (!node._root || node._root->parent != _root) return xml_node();
5970
5971 impl::xml_allocator& alloc = impl::get_allocator(_root);
5972 if (!alloc.reserve()) return xml_node();
5973
5974 xml_node n(impl::allocate_node(alloc, type_));
5975 if (!n) return xml_node();
5976
5977 impl::insert_node_before(n._root, node._root);
5978
5979 if (type_ == node_declaration) n.set_name(PUGIXML_TEXT("xml"));
5980
5981 return n;
5982 }

Referenced by insert_child_before().

◆ insert_copy_after() [1/2]

PUGI__FN xml_attribute pugi::xml_node::insert_copy_after ( const xml_attribute & proto,
const xml_attribute & attr )

Definition at line 5896 of file pugixml.cc.

5897 {
5898 if (!proto) return xml_attribute();
5899 if (!impl::allow_insert_attribute(type())) return xml_attribute();
5900 if (!attr || !impl::is_attribute_of(attr._attr, _root)) return xml_attribute();
5901
5902 impl::xml_allocator& alloc = impl::get_allocator(_root);
5903 if (!alloc.reserve()) return xml_attribute();
5904
5905 xml_attribute a(impl::allocate_attribute(alloc));
5906 if (!a) return xml_attribute();
5907
5908 impl::insert_attribute_after(a._attr, attr._attr, _root);
5909 impl::node_copy_attribute(a._attr, proto._attr);
5910
5911 return a;
5912 }

◆ insert_copy_after() [2/2]

PUGI__FN xml_node pugi::xml_node::insert_copy_after ( const xml_node & proto,
const xml_node & node )

Definition at line 6072 of file pugixml.cc.

6073 {
6074 xml_node_type type_ = proto.type();
6075 if (!impl::allow_insert_child(type(), type_)) return xml_node();
6076 if (!node._root || node._root->parent != _root) return xml_node();
6077
6078 impl::xml_allocator& alloc = impl::get_allocator(_root);
6079 if (!alloc.reserve()) return xml_node();
6080
6081 xml_node n(impl::allocate_node(alloc, type_));
6082 if (!n) return xml_node();
6083
6084 impl::insert_node_after(n._root, node._root);
6085 impl::node_copy_tree(n._root, proto._root);
6086
6087 return n;
6088 }

◆ insert_copy_before() [1/2]

PUGI__FN xml_attribute pugi::xml_node::insert_copy_before ( const xml_attribute & proto,
const xml_attribute & attr )

Definition at line 5914 of file pugixml.cc.

5915 {
5916 if (!proto) return xml_attribute();
5917 if (!impl::allow_insert_attribute(type())) return xml_attribute();
5918 if (!attr || !impl::is_attribute_of(attr._attr, _root)) return xml_attribute();
5919
5920 impl::xml_allocator& alloc = impl::get_allocator(_root);
5921 if (!alloc.reserve()) return xml_attribute();
5922
5923 xml_attribute a(impl::allocate_attribute(alloc));
5924 if (!a) return xml_attribute();
5925
5926 impl::insert_attribute_before(a._attr, attr._attr, _root);
5927 impl::node_copy_attribute(a._attr, proto._attr);
5928
5929 return a;
5930 }

◆ insert_copy_before() [2/2]

PUGI__FN xml_node pugi::xml_node::insert_copy_before ( const xml_node & proto,
const xml_node & node )

Definition at line 6090 of file pugixml.cc.

6091 {
6092 xml_node_type type_ = proto.type();
6093 if (!impl::allow_insert_child(type(), type_)) return xml_node();
6094 if (!node._root || node._root->parent != _root) return xml_node();
6095
6096 impl::xml_allocator& alloc = impl::get_allocator(_root);
6097 if (!alloc.reserve()) return xml_node();
6098
6099 xml_node n(impl::allocate_node(alloc, type_));
6100 if (!n) return xml_node();
6101
6102 impl::insert_node_before(n._root, node._root);
6103 impl::node_copy_tree(n._root, proto._root);
6104
6105 return n;
6106 }

◆ insert_move_after()

PUGI__FN xml_node pugi::xml_node::insert_move_after ( const xml_node & moved,
const xml_node & node )

Definition at line 6140 of file pugixml.cc.

6141 {
6142 if (!impl::allow_move(*this, moved)) return xml_node();
6143 if (!node._root || node._root->parent != _root) return xml_node();
6144 if (moved._root == node._root) return xml_node();
6145
6146 impl::xml_allocator& alloc = impl::get_allocator(_root);
6147 if (!alloc.reserve()) return xml_node();
6148
6149 // disable document_buffer_order optimization since moving nodes around changes document order without changing buffer pointers
6150 impl::get_document(_root).header |= impl::xml_memory_page_contents_shared_mask;
6151
6152 impl::remove_node(moved._root);
6153 impl::insert_node_after(moved._root, node._root);
6154
6155 return moved;
6156 }

◆ insert_move_before()

PUGI__FN xml_node pugi::xml_node::insert_move_before ( const xml_node & moved,
const xml_node & node )

Definition at line 6158 of file pugixml.cc.

6159 {
6160 if (!impl::allow_move(*this, moved)) return xml_node();
6161 if (!node._root || node._root->parent != _root) return xml_node();
6162 if (moved._root == node._root) return xml_node();
6163
6164 impl::xml_allocator& alloc = impl::get_allocator(_root);
6165 if (!alloc.reserve()) return xml_node();
6166
6167 // disable document_buffer_order optimization since moving nodes around changes document order without changing buffer pointers
6168 impl::get_document(_root).header |= impl::xml_memory_page_contents_shared_mask;
6169
6170 impl::remove_node(moved._root);
6171 impl::insert_node_before(moved._root, node._root);
6172
6173 return moved;
6174 }

◆ internal_object()

PUGI__FN xml_node_struct * pugi::xml_node::internal_object ( ) const

Definition at line 6465 of file pugixml.cc.

6466 {
6467 return _root;
6468 }

◆ last_attribute()

PUGI__FN xml_attribute pugi::xml_node::last_attribute ( ) const

Definition at line 5742 of file pugixml.cc.

5743 {
5744 if (!_root) return xml_attribute();
5745 xml_attribute_struct* first = _root->first_attribute;
5746 return first ? xml_attribute(first->prev_attribute_c) : xml_attribute();
5747 }

◆ last_child()

PUGI__FN xml_node pugi::xml_node::last_child ( ) const

Definition at line 5755 of file pugixml.cc.

5756 {
5757 if (!_root) return xml_node();
5758 xml_node_struct* first = _root->first_child;
5759 return first ? xml_node(first->prev_sibling_c) : xml_node();
5760 }

◆ name()

PUGI__FN const char_t * pugi::xml_node::name ( ) const

Definition at line 5572 of file pugixml.cc.

5573 {
5574 if (!_root) return PUGIXML_TEXT("");
5575 const char_t* name = _root->name;
5576 return name ? name : PUGIXML_TEXT("");
5577 }
const char_t * name() const
Definition pugixml.cc:5572

Referenced by name().

◆ next_sibling() [1/2]

PUGI__FN xml_node pugi::xml_node::next_sibling ( ) const

Definition at line 5633 of file pugixml.cc.

5634 {
5635 return _root ? xml_node(_root->next_sibling) : xml_node();
5636 }

Referenced by find_node().

◆ next_sibling() [2/2]

PUGI__FN xml_node pugi::xml_node::next_sibling ( const char_t * name) const

Definition at line 5619 of file pugixml.cc.

5620 {
5621 if (!_root) return xml_node();
5622
5623 for (xml_node_struct* i = _root->next_sibling; i; i = i->next_sibling)
5624 {
5625 const char_t* iname = i->name;
5626 if (iname && impl::strequal(name_, iname))
5627 return xml_node(i);
5628 }
5629
5630 return xml_node();
5631 }

◆ offset_debug()

PUGI__FN ptrdiff_t pugi::xml_node::offset_debug ( ) const

Definition at line 6497 of file pugixml.cc.

6498 {
6499 if (!_root) return -1;
6500
6501 impl::xml_document_struct& doc = impl::get_document(_root);
6502
6503 // we can determine the offset reliably only if there is exactly once parse buffer
6504 if (!doc.buffer || doc.extra_buffers) return -1;
6505
6506 switch (type())
6507 {
6508 case node_document:
6509 return 0;
6510
6511 case node_element:
6512 case node_declaration:
6513 case node_pi:
6514 return _root->name && (_root->header & impl::xml_memory_page_name_allocated_or_shared_mask) == 0 ? _root->name - doc.buffer : -1;
6515
6516 case node_pcdata:
6517 case node_cdata:
6518 case node_comment:
6519 case node_doctype:
6520 return _root->value && (_root->header & impl::xml_memory_page_value_allocated_or_shared_mask) == 0 ? _root->value - doc.buffer : -1;
6521
6522 default:
6523 assert(false && "Invalid node type"); // unreachable
6524 return -1;
6525 }
6526 }
@ node_comment
Definition pugixml.hpp:156
@ node_pcdata
Definition pugixml.hpp:154
@ node_doctype
Definition pugixml.hpp:159
@ node_document
Definition pugixml.hpp:152
@ node_pi
Definition pugixml.hpp:157
@ node_cdata
Definition pugixml.hpp:155

◆ operator unspecified_bool_type()

PUGI__FN pugi::xml_node::operator xml_node::unspecified_bool_type ( ) const

Definition at line 5492 of file pugixml.cc.

5493 {
5494 return _root ? unspecified_bool_xml_node : 0;
5495 }

◆ operator!()

PUGI__FN bool pugi::xml_node::operator! ( ) const

Definition at line 5497 of file pugixml.cc.

5498 {
5499 return !_root;
5500 }

◆ operator!=()

PUGI__FN bool pugi::xml_node::operator!= ( const xml_node & r) const

Definition at line 5542 of file pugixml.cc.

5543 {
5544 return (_root != r._root);
5545 }

◆ operator<()

PUGI__FN bool pugi::xml_node::operator< ( const xml_node & r) const

Definition at line 5547 of file pugixml.cc.

5548 {
5549 return (_root < r._root);
5550 }

◆ operator<=()

PUGI__FN bool pugi::xml_node::operator<= ( const xml_node & r) const

Definition at line 5557 of file pugixml.cc.

5558 {
5559 return (_root <= r._root);
5560 }

◆ operator==()

PUGI__FN bool pugi::xml_node::operator== ( const xml_node & r) const

Definition at line 5537 of file pugixml.cc.

5538 {
5539 return (_root == r._root);
5540 }

◆ operator>()

PUGI__FN bool pugi::xml_node::operator> ( const xml_node & r) const

Definition at line 5552 of file pugixml.cc.

5553 {
5554 return (_root > r._root);
5555 }

◆ operator>=()

PUGI__FN bool pugi::xml_node::operator>= ( const xml_node & r) const

Definition at line 5562 of file pugixml.cc.

5563 {
5564 return (_root >= r._root);
5565 }

◆ parent()

PUGI__FN xml_node pugi::xml_node::parent ( ) const

Definition at line 5698 of file pugixml.cc.

5699 {
5700 return _root ? xml_node(_root->parent) : xml_node();
5701 }

Referenced by find_node(), first_element_by_path(), and pugi::xpath_node::parent().

◆ path()

PUGI__FN string_t pugi::xml_node::path ( char_t delimiter = '/') const

Definition at line 6335 of file pugixml.cc.

6336 {
6337 if (!_root) return string_t();
6338
6339 size_t offset = 0;
6340
6341 for (xml_node_struct* i = _root; i; i = i->parent)
6342 {
6343 const char_t* iname = i->name;
6344 offset += (i != _root);
6345 offset += iname ? impl::strlength(iname) : 0;
6346 }
6347
6348 string_t result;
6349 result.resize(offset);
6350
6351 for (xml_node_struct* j = _root; j; j = j->parent)
6352 {
6353 if (j != _root)
6354 result[--offset] = delimiter;
6355
6356 const char_t* jname = j->name;
6357 if (jname)
6358 {
6359 size_t length = impl::strlength(jname);
6360
6361 offset -= length;
6362 memcpy(&result[offset], jname, length * sizeof(char_t));
6363 }
6364 }
6365
6366 assert(offset == 0);
6367
6368 return result;
6369 }
G4ThreadLocal T * G4GeomSplitter< T >::offset
std::basic_string< PUGIXML_CHAR, std::char_traits< PUGIXML_CHAR >, std::allocator< PUGIXML_CHAR > > string_t
Definition pugixml.hpp:141

◆ prepend_attribute()

PUGI__FN xml_attribute pugi::xml_node::prepend_attribute ( const char_t * name)

Definition at line 5809 of file pugixml.cc.

5810 {
5811 if (!impl::allow_insert_attribute(type())) return xml_attribute();
5812
5813 impl::xml_allocator& alloc = impl::get_allocator(_root);
5814 if (!alloc.reserve()) return xml_attribute();
5815
5816 xml_attribute a(impl::allocate_attribute(alloc));
5817 if (!a) return xml_attribute();
5818
5819 impl::prepend_attribute(a._attr, _root);
5820
5821 a.set_name(name_);
5822
5823 return a;
5824 }

◆ prepend_child() [1/2]

PUGI__FN xml_node pugi::xml_node::prepend_child ( const char_t * name)

Definition at line 6011 of file pugixml.cc.

6012 {
6014
6015 result.set_name(name_);
6016
6017 return result;
6018 }
xml_node prepend_child(xml_node_type type=node_element)
Definition pugixml.cc:5949

◆ prepend_child() [2/2]

PUGI__FN xml_node pugi::xml_node::prepend_child ( xml_node_type type = node_element)

Definition at line 5949 of file pugixml.cc.

5950 {
5951 if (!impl::allow_insert_child(type(), type_)) return xml_node();
5952
5953 impl::xml_allocator& alloc = impl::get_allocator(_root);
5954 if (!alloc.reserve()) return xml_node();
5955
5956 xml_node n(impl::allocate_node(alloc, type_));
5957 if (!n) return xml_node();
5958
5959 impl::prepend_node(n._root, _root);
5960
5961 if (type_ == node_declaration) n.set_name(PUGIXML_TEXT("xml"));
5962
5963 return n;
5964 }

Referenced by prepend_child().

◆ prepend_copy() [1/2]

PUGI__FN xml_attribute pugi::xml_node::prepend_copy ( const xml_attribute & proto)

Definition at line 5879 of file pugixml.cc.

5880 {
5881 if (!proto) return xml_attribute();
5882 if (!impl::allow_insert_attribute(type())) return xml_attribute();
5883
5884 impl::xml_allocator& alloc = impl::get_allocator(_root);
5885 if (!alloc.reserve()) return xml_attribute();
5886
5887 xml_attribute a(impl::allocate_attribute(alloc));
5888 if (!a) return xml_attribute();
5889
5890 impl::prepend_attribute(a._attr, _root);
5891 impl::node_copy_attribute(a._attr, proto._attr);
5892
5893 return a;
5894 }

◆ prepend_copy() [2/2]

PUGI__FN xml_node pugi::xml_node::prepend_copy ( const xml_node & proto)

Definition at line 6055 of file pugixml.cc.

6056 {
6057 xml_node_type type_ = proto.type();
6058 if (!impl::allow_insert_child(type(), type_)) return xml_node();
6059
6060 impl::xml_allocator& alloc = impl::get_allocator(_root);
6061 if (!alloc.reserve()) return xml_node();
6062
6063 xml_node n(impl::allocate_node(alloc, type_));
6064 if (!n) return xml_node();
6065
6066 impl::prepend_node(n._root, _root);
6067 impl::node_copy_tree(n._root, proto._root);
6068
6069 return n;
6070 }

◆ prepend_move()

PUGI__FN xml_node pugi::xml_node::prepend_move ( const xml_node & moved)

Definition at line 6124 of file pugixml.cc.

6125 {
6126 if (!impl::allow_move(*this, moved)) return xml_node();
6127
6128 impl::xml_allocator& alloc = impl::get_allocator(_root);
6129 if (!alloc.reserve()) return xml_node();
6130
6131 // disable document_buffer_order optimization since moving nodes around changes document order without changing buffer pointers
6132 impl::get_document(_root).header |= impl::xml_memory_page_contents_shared_mask;
6133
6134 impl::remove_node(moved._root);
6135 impl::prepend_node(moved._root, _root);
6136
6137 return moved;
6138 }

◆ previous_sibling() [1/2]

PUGI__FN xml_node pugi::xml_node::previous_sibling ( ) const

Definition at line 5691 of file pugixml.cc.

5692 {
5693 if (!_root) return xml_node();
5694 xml_node_struct* prev = _root->prev_sibling_c;
5695 return prev->next_sibling ? xml_node(prev) : xml_node();
5696 }

◆ previous_sibling() [2/2]

PUGI__FN xml_node pugi::xml_node::previous_sibling ( const char_t * name) const

Definition at line 5638 of file pugixml.cc.

5639 {
5640 if (!_root) return xml_node();
5641
5642 for (xml_node_struct* i = _root->prev_sibling_c; i->next_sibling; i = i->prev_sibling_c)
5643 {
5644 const char_t* iname = i->name;
5645 if (iname && impl::strequal(name_, iname))
5646 return xml_node(i);
5647 }
5648
5649 return xml_node();
5650 }

◆ print() [1/3]

PUGI__FN void pugi::xml_node::print ( std::basic_ostream< char, std::char_traits< char > > & os,
const char_t * indent = PUGIXML_TEXT("\t"),
unsigned int flags = format_default,
xml_encoding encoding = encoding_auto,
unsigned int depth = 0 ) const

Definition at line 6482 of file pugixml.cc.

6483 {
6484 xml_writer_stream writer(stream);
6485
6486 print(writer, indent, flags, encoding, depth);
6487 }
void print(xml_writer &writer, const char_t *indent=PUGIXML_TEXT("\t"), unsigned int flags=format_default, xml_encoding encoding=encoding_auto, unsigned int depth=0) const
Definition pugixml.cc:6470

◆ print() [2/3]

PUGI__FN void pugi::xml_node::print ( std::basic_ostream< wchar_t, std::char_traits< wchar_t > > & os,
const char_t * indent = PUGIXML_TEXT("\t"),
unsigned int flags = format_default,
unsigned int depth = 0 ) const

Definition at line 6489 of file pugixml.cc.

6490 {
6491 xml_writer_stream writer(stream);
6492
6493 print(writer, indent, flags, encoding_wchar, depth);
6494 }
@ encoding_wchar
Definition pugixml.hpp:237

◆ print() [3/3]

PUGI__FN void pugi::xml_node::print ( xml_writer & writer,
const char_t * indent = PUGIXML_TEXT("\t"),
unsigned int flags = format_default,
xml_encoding encoding = encoding_auto,
unsigned int depth = 0 ) const

Definition at line 6470 of file pugixml.cc.

6471 {
6472 if (!_root) return;
6473
6474 impl::xml_buffered_writer buffered_writer(writer, encoding);
6475
6476 impl::node_output(buffered_writer, _root, indent, flags, depth);
6477
6478 buffered_writer.flush();
6479 }

Referenced by print(), and print().

◆ remove_attribute() [1/2]

PUGI__FN bool pugi::xml_node::remove_attribute ( const char_t * name)

Definition at line 6176 of file pugixml.cc.

6177 {
6178 return remove_attribute(attribute(name_));
6179 }
xml_attribute attribute(const char_t *name) const
Definition pugixml.cc:5605
bool remove_attribute(const xml_attribute &a)
Definition pugixml.cc:6181

◆ remove_attribute() [2/2]

PUGI__FN bool pugi::xml_node::remove_attribute ( const xml_attribute & a)

Definition at line 6181 of file pugixml.cc.

6182 {
6183 if (!_root || !a._attr) return false;
6184 if (!impl::is_attribute_of(a._attr, _root)) return false;
6185
6186 impl::xml_allocator& alloc = impl::get_allocator(_root);
6187 if (!alloc.reserve()) return false;
6188
6189 impl::remove_attribute(a._attr, _root);
6190 impl::destroy_attribute(a._attr, alloc);
6191
6192 return true;
6193 }

Referenced by remove_attribute().

◆ remove_attributes()

PUGI__FN bool pugi::xml_node::remove_attributes ( )

Definition at line 6195 of file pugixml.cc.

6196 {
6197 if (!_root) return false;
6198
6199 impl::xml_allocator& alloc = impl::get_allocator(_root);
6200 if (!alloc.reserve()) return false;
6201
6202 for (xml_attribute_struct* attr = _root->first_attribute; attr; )
6203 {
6204 xml_attribute_struct* next = attr->next_attribute;
6205
6206 impl::destroy_attribute(attr, alloc);
6207
6208 attr = next;
6209 }
6210
6211 _root->first_attribute = 0;
6212
6213 return true;
6214 }

◆ remove_child() [1/2]

PUGI__FN bool pugi::xml_node::remove_child ( const char_t * name)

Definition at line 6216 of file pugixml.cc.

6217 {
6218 return remove_child(child(name_));
6219 }
bool remove_child(const xml_node &n)
Definition pugixml.cc:6221

◆ remove_child() [2/2]

PUGI__FN bool pugi::xml_node::remove_child ( const xml_node & n)

Definition at line 6221 of file pugixml.cc.

6222 {
6223 if (!_root || !n._root || n._root->parent != _root) return false;
6224
6225 impl::xml_allocator& alloc = impl::get_allocator(_root);
6226 if (!alloc.reserve()) return false;
6227
6228 impl::remove_node(n._root);
6229 impl::destroy_node(n._root, alloc);
6230
6231 return true;
6232 }

Referenced by remove_child().

◆ remove_children()

PUGI__FN bool pugi::xml_node::remove_children ( )

Definition at line 6234 of file pugixml.cc.

6235 {
6236 if (!_root) return false;
6237
6238 impl::xml_allocator& alloc = impl::get_allocator(_root);
6239 if (!alloc.reserve()) return false;
6240
6241 for (xml_node_struct* cur = _root->first_child; cur; )
6242 {
6243 xml_node_struct* next = cur->next_sibling;
6244
6245 impl::destroy_node(cur, alloc);
6246
6247 cur = next;
6248 }
6249
6250 _root->first_child = 0;
6251
6252 return true;
6253 }

◆ root()

PUGI__FN xml_node pugi::xml_node::root ( ) const

Definition at line 5703 of file pugixml.cc.

5704 {
5705 return _root ? xml_node(&impl::get_document(_root)) : xml_node();
5706 }

Referenced by first_element_by_path().

◆ select_node() [1/2]

PUGI__FN xpath_node pugi::xml_node::select_node ( const char_t * query,
xpath_variable_set * variables = PUGIXML_NULL ) const

Definition at line 13052 of file pugixml.cc.

13053 {
13054 xpath_query q(query, variables);
13055 return q.evaluate_node(*this);
13056 }

◆ select_node() [2/2]

PUGI__FN xpath_node pugi::xml_node::select_node ( const xpath_query & query) const

Definition at line 13058 of file pugixml.cc.

13059 {
13060 return query.evaluate_node(*this);
13061 }

◆ select_nodes() [1/2]

PUGI__FN xpath_node_set pugi::xml_node::select_nodes ( const char_t * query,
xpath_variable_set * variables = PUGIXML_NULL ) const

Definition at line 13063 of file pugixml.cc.

13064 {
13065 xpath_query q(query, variables);
13066 return q.evaluate_node_set(*this);
13067 }

◆ select_nodes() [2/2]

PUGI__FN xpath_node_set pugi::xml_node::select_nodes ( const xpath_query & query) const

Definition at line 13069 of file pugixml.cc.

13070 {
13071 return query.evaluate_node_set(*this);
13072 }

◆ select_single_node() [1/2]

PUGI__FN xpath_node pugi::xml_node::select_single_node ( const char_t * query,
xpath_variable_set * variables = PUGIXML_NULL ) const

Definition at line 13074 of file pugixml.cc.

13075 {
13076 xpath_query q(query, variables);
13077 return q.evaluate_node(*this);
13078 }

◆ select_single_node() [2/2]

PUGI__FN xpath_node pugi::xml_node::select_single_node ( const xpath_query & query) const

Definition at line 13080 of file pugixml.cc.

13081 {
13082 return query.evaluate_node(*this);
13083 }

◆ set_name()

PUGI__FN bool pugi::xml_node::set_name ( const char_t * rhs)

Definition at line 5762 of file pugixml.cc.

5763 {
5765
5766 if (type_ != node_element && type_ != node_pi && type_ != node_declaration)
5767 return false;
5768
5769 return impl::strcpy_insitu(_root->name, _root->header, impl::xml_memory_page_name_allocated_mask, rhs, impl::strlength(rhs));
5770 }
@ node_null
Definition pugixml.hpp:151

Referenced by append_child(), insert_child_after(), insert_child_before(), and prepend_child().

◆ set_value() [1/2]

PUGI__FN bool pugi::xml_node::set_value ( const char_t * rhs)

Definition at line 5782 of file pugixml.cc.

5783 {
5785
5786 if (type_ != node_pcdata && type_ != node_cdata && type_ != node_comment && type_ != node_pi && type_ != node_doctype)
5787 return false;
5788
5789 return impl::strcpy_insitu(_root->value, _root->header, impl::xml_memory_page_value_allocated_mask, rhs, impl::strlength(rhs));
5790 }

◆ set_value() [2/2]

PUGI__FN bool pugi::xml_node::set_value ( const char_t * rhs,
size_t sz )

Definition at line 5772 of file pugixml.cc.

5773 {
5775
5776 if (type_ != node_pcdata && type_ != node_cdata && type_ != node_comment && type_ != node_pi && type_ != node_doctype)
5777 return false;
5778
5779 return impl::strcpy_insitu(_root->value, _root->header, impl::xml_memory_page_value_allocated_mask, rhs, sz);
5780 }

◆ text()

PUGI__FN xml_text pugi::xml_node::text ( ) const

Definition at line 5708 of file pugixml.cc.

5709 {
5710 return xml_text(_root);
5711 }

◆ traverse()

PUGI__FN bool pugi::xml_node::traverse ( xml_tree_walker & walker)

Definition at line 6413 of file pugixml.cc.

6414 {
6415 walker._depth = -1;
6416
6417 xml_node arg_begin(_root);
6418 if (!walker.begin(arg_begin)) return false;
6419
6420 xml_node_struct* cur = _root ? _root->first_child + 0 : 0;
6421
6422 if (cur)
6423 {
6424 ++walker._depth;
6425
6426 do
6427 {
6428 xml_node arg_for_each(cur);
6429 if (!walker.for_each(arg_for_each))
6430 return false;
6431
6432 if (cur->first_child)
6433 {
6434 ++walker._depth;
6435 cur = cur->first_child;
6436 }
6437 else if (cur->next_sibling)
6438 cur = cur->next_sibling;
6439 else
6440 {
6441 while (!cur->next_sibling && cur != _root && cur->parent)
6442 {
6443 --walker._depth;
6444 cur = cur->parent;
6445 }
6446
6447 if (cur != _root)
6448 cur = cur->next_sibling;
6449 }
6450 }
6451 while (cur && cur != _root);
6452 }
6453
6454 assert(walker._depth == -1);
6455
6456 xml_node arg_end(_root);
6457 return walker.end(arg_end);
6458 }

◆ type()

◆ value()

PUGI__FN const char_t * pugi::xml_node::value ( ) const

Definition at line 5584 of file pugixml.cc.

5585 {
5586 if (!_root) return PUGIXML_TEXT("");
5587 const char_t* value = _root->value;
5588 return value ? value : PUGIXML_TEXT("");
5589 }
const char_t * value() const
Definition pugixml.cc:5584

Referenced by value().

◆ xml_attribute_iterator

friend class xml_attribute_iterator
friend

Definition at line 475 of file pugixml.hpp.

Referenced by xml_attribute_iterator.

◆ xml_named_node_iterator

friend class xml_named_node_iterator
friend

Definition at line 477 of file pugixml.hpp.

Referenced by children(), and xml_named_node_iterator.

◆ xml_node_iterator

friend class xml_node_iterator
friend

Definition at line 476 of file pugixml.hpp.

Referenced by xml_node_iterator.

Member Data Documentation

◆ _root

xml_node_struct* pugi::xml_node::_root
protected

Definition at line 480 of file pugixml.hpp.

Referenced by append_attribute(), append_buffer(), append_child(), append_copy(), append_copy(), append_move(), attribute(), attribute(), attributes_begin(), attributes_end(), begin(), child(), child_value(), children(), pugi::xml_document::document_element(), empty(), end(), find_attribute(), find_child(), find_child_by_attribute(), find_child_by_attribute(), find_node(), first_attribute(), first_child(), first_element_by_path(), hash_value(), insert_attribute_after(), insert_attribute_before(), insert_child_after(), insert_child_before(), insert_copy_after(), insert_copy_after(), insert_copy_before(), insert_copy_before(), insert_move_after(), insert_move_before(), internal_object(), last_attribute(), last_child(), pugi::xml_document::load(), pugi::xml_document::load(), pugi::xml_document::load_buffer(), pugi::xml_document::load_buffer_inplace(), pugi::xml_document::load_buffer_inplace_own(), pugi::xml_document::load_file(), pugi::xml_document::load_file(), name(), next_sibling(), next_sibling(), offset_debug(), operator unspecified_bool_type(), operator!(), pugi::xml_attribute_iterator::operator!=(), pugi::xml_named_node_iterator::operator!=(), operator!=(), pugi::xml_node_iterator::operator!=(), operator<(), operator<=(), pugi::xml_attribute_iterator::operator==(), pugi::xml_named_node_iterator::operator==(), operator==(), pugi::xml_node_iterator::operator==(), operator>(), operator>=(), parent(), path(), prepend_attribute(), prepend_child(), prepend_copy(), prepend_copy(), prepend_move(), previous_sibling(), previous_sibling(), print(), remove_attribute(), remove_attributes(), remove_child(), remove_children(), pugi::xml_document::reset(), root(), pugi::xml_document::save(), set_name(), set_value(), set_value(), text(), traverse(), type(), value(), xml_node(), and xml_node().


The documentation for this class was generated from the following files: