add convenience methods

This commit is contained in:
Lee Thomason
2020-03-01 17:10:38 -08:00
parent 6ac05b2b9a
commit e444268103
2 changed files with 24 additions and 31 deletions

View File

@@ -1962,41 +1962,34 @@ XMLAttribute* XMLElement::CreateAttribute()
} }
XMLElement* XMLElement::PushNewChildElement(const char* name) XMLElement* XMLElement::InsertNewChildElement(const char* name)
{ {
XMLElement* element = _document->NewElement(name); XMLElement* node = _document->NewElement(name);
// by construction, the new element has the same Document, so this return InsertEndChild(node) ? node : 0;
// call will always succeed
InsertEndChild(element);
return element;
} }
XMLComment* XMLElement::PushNewChildComment(const char* comment) XMLComment* XMLElement::InsertNewComment(const char* comment)
{ {
XMLComment* element = _document->NewComment(comment); XMLComment* node = _document->NewComment(comment);
InsertEndChild(element); return InsertEndChild(node) ? node : 0;
return element;
} }
XMLText* XMLElement::PushNewChildText(const char* text) XMLText* XMLElement::InsertNewText(const char* text)
{ {
XMLText* element = _document->NewText(text); XMLText* node = _document->NewText(text);
InsertEndChild(element); return InsertEndChild(node) ? node : 0;
return element;
} }
XMLDeclaration* XMLElement::PushNewChildDeclaration(const char* text) XMLDeclaration* XMLElement::InsertNewDeclaration(const char* text)
{ {
XMLDeclaration* element = _document->NewDeclaration(text); XMLDeclaration* node = _document->NewDeclaration(text);
InsertEndChild(element); return InsertEndChild(node) ? node : 0;
return element;
} }
XMLUnknown* XMLElement::PushNewUnknown(const char* text) XMLUnknown* XMLElement::InsertNewUnknown(const char* text)
{ {
XMLUnknown* element = _document->NewUnknown(text); XMLUnknown* node = _document->NewUnknown(text);
InsertEndChild(element); return InsertEndChild(node) ? node : 0;
return element;
} }

View File

@@ -1646,15 +1646,15 @@ public:
Convenience method to create a new XMLElement and add it as last (right) Convenience method to create a new XMLElement and add it as last (right)
child of this node. Returns the created and inserted element. child of this node. Returns the created and inserted element.
*/ */
XMLElement* PushNewChildElement(const char* name); XMLElement* InsertNewChildElement(const char* name);
/// See PushNewChildElement() /// See InsertNewChildElement()
XMLComment* PushNewChildComment(const char* comment); XMLComment* InsertNewComment(const char* comment);
/// See PushNewChildElement() /// See InsertNewChildElement()
XMLText* PushNewChildText(const char* text); XMLText* InsertNewText(const char* text);
/// See PushNewChildElement() /// See InsertNewChildElement()
XMLDeclaration* PushNewChildDeclaration(const char* text); XMLDeclaration* InsertNewDeclaration(const char* text);
/// See PushNewChildElement() /// See InsertNewChildElement()
XMLUnknown* PushNewUnknown(const char* text); XMLUnknown* InsertNewUnknown(const char* text);
// internal: // internal: