From cf4550c3198d6b3d92cdc52707fe70d7cc0caa9f Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Queru Date: Tue, 21 Jul 2009 11:16:54 -0700 Subject: donut snapshot --- tools/aapt/XMLNode.cpp | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'tools/aapt/XMLNode.cpp') diff --git a/tools/aapt/XMLNode.cpp b/tools/aapt/XMLNode.cpp index d4765672274e..2a85bc7e8b6d 100644 --- a/tools/aapt/XMLNode.cpp +++ b/tools/aapt/XMLNode.cpp @@ -524,12 +524,30 @@ const Vector >& XMLNode::getChildren() const return mChildren; } +const String8& XMLNode::getFilename() const +{ + return mFilename; +} + const Vector& XMLNode::getAttributes() const { return mAttributes; } +const XMLNode::attribute_entry* XMLNode::getAttribute(const String16& ns, + const String16& name) const +{ + for (size_t i=0; i XMLNode::searchElement(const String16& tagNamespace, const String16& tagName) +{ + if (getType() == XMLNode::TYPE_ELEMENT + && mNamespaceUri == tagNamespace + && mElementName == tagName) { + return this; + } + + for (size_t i=0; i found = mChildren.itemAt(i)->searchElement(tagNamespace, tagName); + if (found != NULL) { + return found; + } + } + + return NULL; +} + +sp XMLNode::getChildElement(const String16& tagNamespace, const String16& tagName) +{ + for (size_t i=0; i child = mChildren.itemAt(i); + if (child->getType() == XMLNode::TYPE_ELEMENT + && child->mNamespaceUri == tagNamespace + && child->mElementName == tagName) { + return child; + } + } + + return NULL; +} + status_t XMLNode::addChild(const sp& child) { if (getType() == TYPE_CDATA) { @@ -561,6 +611,17 @@ status_t XMLNode::addChild(const sp& child) return NO_ERROR; } +status_t XMLNode::insertChildAt(const sp& child, size_t index) +{ + if (getType() == TYPE_CDATA) { + SourcePos(mFilename, child->getStartLineNumber()).error("Child to CDATA node."); + return UNKNOWN_ERROR; + } + //printf("Adding child %p to parent %p\n", child.get(), this); + mChildren.insertAt(child, index); + return NO_ERROR; +} + status_t XMLNode::addAttribute(const String16& ns, const String16& name, const String16& value) { -- cgit v1.2.3-59-g8ed1b