summaryrefslogtreecommitdiff
path: root/src/pugixml.hpp
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2017-11-13 13:24:43 -0800
committerGitHub <noreply@github.com>2017-11-13 13:24:43 -0800
commit7c6d0010b30111dbfb8e523634e7b63328992106 (patch)
tree708c0ccd524bc87a90bea24378bc7fe3700527a2 /src/pugixml.hpp
parent6016e2180e7364f8e203aa2bac6ecb093be0e875 (diff)
parent3860b5076fd650e8cb0e7378675b241ec96b2e41 (diff)
Merge pull request #170 from zeux/move
This change implements move ctor and assign support for xml_document. All node handles remain valid after the move and point to the new document; the only exception is the document node itself (that remains unmoved). Move is O(document size) in theory because it needs to relocate immediate document children (there is just one in conformant documents) and all memory pages; in practice the memory pages only need the header adjusted, which is ~0.1% of the actual data size. Move requires no allocations in general, except when using compact mode where some moves need to grow the hash table which can fail (throw). Fixes #104
Diffstat (limited to 'src/pugixml.hpp')
-rw-r--r--src/pugixml.hpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/pugixml.hpp b/src/pugixml.hpp
index 5059c96..0058fd3 100644
--- a/src/pugixml.hpp
+++ b/src/pugixml.hpp
@@ -983,6 +983,7 @@ namespace pugi
void _create();
void _destroy();
+ void _move(xml_document& rhs);
public:
// Default constructor, makes empty document
@@ -991,6 +992,12 @@ namespace pugi
// Destructor, invalidates all node/attribute handles to this document
~xml_document();
+ #ifdef PUGIXML_HAS_MOVE
+ // Move semantics support
+ xml_document(xml_document&& rhs);
+ xml_document& operator=(xml_document&& rhs);
+ #endif
+
// Removes all nodes, leaving the empty document
void reset();