mirror of
https://github.com/AxioDL/tinyxml2.git
synced 2025-06-07 07:03:41 +00:00
tweak comments. fix copy to self case.
This commit is contained in:
parent
1bbc66b193
commit
1346a174ae
@ -2052,7 +2052,9 @@ void XMLDocument::Clear()
|
|||||||
void XMLDocument::DeepCopy(XMLDocument* target)
|
void XMLDocument::DeepCopy(XMLDocument* target)
|
||||||
{
|
{
|
||||||
TIXMLASSERT(target);
|
TIXMLASSERT(target);
|
||||||
TIXMLASSERT(target != this);
|
if (target == this) {
|
||||||
|
return; // technically success - a no-op.
|
||||||
|
}
|
||||||
|
|
||||||
target->Clear();
|
target->Clear();
|
||||||
for (const XMLNode* node = this->FirstChild(); node; node = node->NextSibling()) {
|
for (const XMLNode* node = this->FirstChild(); node; node = node->NextSibling()) {
|
||||||
|
14
tinyxml2.h
14
tinyxml2.h
@ -866,16 +866,17 @@ public:
|
|||||||
virtual XMLNode* ShallowClone( XMLDocument* document ) const = 0;
|
virtual XMLNode* ShallowClone( XMLDocument* document ) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Make a copy of this node and all of the children
|
Make a copy of this node and all its children.
|
||||||
of this node.
|
|
||||||
|
|
||||||
If the 'document' is null, then the nodes will
|
If the 'document' is null, then the nodes will
|
||||||
be allocated in the current document. If specified,
|
be allocated in the current document. If document
|
||||||
memory will e allocated is the specified document.
|
is specified, the memory will be allocated is the
|
||||||
|
specified XMLDocument.
|
||||||
|
|
||||||
NOTE: This is probably not the correct tool to
|
NOTE: This is probably not the correct tool to
|
||||||
copy a document, since XMLDocuments can have multiple
|
copy a document, since XMLDocuments can have multiple
|
||||||
top level XMLNodes. You probably want XMLDocument::DeepCopy()
|
top level XMLNodes. You probably want to use
|
||||||
|
XMLDocument::DeepCopy()
|
||||||
*/
|
*/
|
||||||
XMLNode* DeepClone( XMLDocument* document ) const;
|
XMLNode* DeepClone( XMLDocument* document ) const;
|
||||||
|
|
||||||
@ -1825,8 +1826,7 @@ public:
|
|||||||
The target will be completely cleared before the copy.
|
The target will be completely cleared before the copy.
|
||||||
If you want to copy a sub-tree, see XMLNode::DeepClone().
|
If you want to copy a sub-tree, see XMLNode::DeepClone().
|
||||||
|
|
||||||
NOTE: that the 'target' must be non-null and not
|
NOTE: that the 'target' must be non-null.
|
||||||
the source document.
|
|
||||||
*/
|
*/
|
||||||
void DeepCopy(XMLDocument* target);
|
void DeepCopy(XMLDocument* target);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user