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);
// by construction, the new element has the same Document, so this
// call will always succeed
InsertEndChild(element);
return element;
XMLElement* node = _document->NewElement(name);
return InsertEndChild(node) ? node : 0;
}
XMLComment* XMLElement::PushNewChildComment(const char* comment)
XMLComment* XMLElement::InsertNewComment(const char* comment)
{
XMLComment* element = _document->NewComment(comment);
InsertEndChild(element);
return element;
XMLComment* node = _document->NewComment(comment);
return InsertEndChild(node) ? node : 0;
}
XMLText* XMLElement::PushNewChildText(const char* text)
XMLText* XMLElement::InsertNewText(const char* text)
{
XMLText* element = _document->NewText(text);
InsertEndChild(element);
return element;
XMLText* node = _document->NewText(text);
return InsertEndChild(node) ? node : 0;
}
XMLDeclaration* XMLElement::PushNewChildDeclaration(const char* text)
XMLDeclaration* XMLElement::InsertNewDeclaration(const char* text)
{
XMLDeclaration* element = _document->NewDeclaration(text);
InsertEndChild(element);
return element;
XMLDeclaration* node = _document->NewDeclaration(text);
return InsertEndChild(node) ? node : 0;
}
XMLUnknown* XMLElement::PushNewUnknown(const char* text)
XMLUnknown* XMLElement::InsertNewUnknown(const char* text)
{
XMLUnknown* element = _document->NewUnknown(text);
InsertEndChild(element);
return element;
XMLUnknown* node = _document->NewUnknown(text);
return InsertEndChild(node) ? node : 0;
}