Modify to override operator[] into xml_node
Currently, users can add xml_node by calling append_child(). If repeatedly insert xml_nodes, operator[] may be more useful than using this function. This commit modifies to override operator[] to make appending xml_node more useful. In additional, this operator inserts a new element with that key and returns a reference to its mapped value. Notice that this always increases the xml size by one, even if no mapped value is assigned to the element. Signed-off-by: Jihun Ahn <jhun.ahnn@gmail.com>
This commit is contained in:
parent
5e64076af9
commit
39055a06a3
@ -5496,6 +5496,11 @@ namespace pugi
|
||||
return (_root >= r._root);
|
||||
}
|
||||
|
||||
PUGI__FN xml_node xml_node::operator[](const char_t* name_)
|
||||
{
|
||||
return append_child(name_);
|
||||
}
|
||||
|
||||
PUGI__FN bool xml_node::empty() const
|
||||
{
|
||||
return !_root;
|
||||
|
||||
@ -488,6 +488,8 @@ namespace pugi
|
||||
bool operator<=(const xml_node& r) const;
|
||||
bool operator>=(const xml_node& r) const;
|
||||
|
||||
xml_node operator[](const char_t* name_);
|
||||
|
||||
// Check if node is empty.
|
||||
bool empty() const;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user