[vlc-commits] dash: DOMHelper: Adding a helper to get the first child element.
Hugo Beauzée-Luyssen
git at videolan.org
Thu Nov 24 18:14:56 CET 2011
vlc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Thu Nov 24 17:06:20 2011 +0100| [1086074c0da8e56d1ca2ce8c6af14a4268489a47] | committer: Rémi Denis-Courmont
dash: DOMHelper: Adding a helper to get the first child element.
Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1086074c0da8e56d1ca2ce8c6af14a4268489a47
---
modules/stream_filter/dash/xml/DOMHelper.cpp | 12 ++++++++++++
modules/stream_filter/dash/xml/DOMHelper.h | 1 +
2 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/modules/stream_filter/dash/xml/DOMHelper.cpp b/modules/stream_filter/dash/xml/DOMHelper.cpp
index 581bda5..52f97dd 100644
--- a/modules/stream_filter/dash/xml/DOMHelper.cpp
+++ b/modules/stream_filter/dash/xml/DOMHelper.cpp
@@ -40,6 +40,7 @@ std::vector<Node *> DOMHelper::getElementByTagName (Node *root, std::string
return elements;
}
+
std::vector<Node *> DOMHelper::getChildElementByTagName (Node *root, std::string name)
{
std::vector<Node *> elements;
@@ -52,6 +53,7 @@ std::vector<Node *> DOMHelper::getChildElementByTagName (Node *root, std::string
return elements;
}
+
void DOMHelper::getElementsByTagName (Node *root, std::string name, std::vector<Node*> *elements, bool selfContain)
{
if(!selfContain && !root->getName().compare(name))
@@ -68,3 +70,13 @@ void DOMHelper::getElementsByTagName (Node *root, std::string
getElementsByTagName(root->getSubNodes().at(i), name, elements, selfContain);
}
}
+
+Node* DOMHelper::getFirstChildElementByName( Node *root, const std::string &name )
+{
+ for(size_t i = 0; i < root->getSubNodes().size(); i++)
+ {
+ if( !root->getSubNodes().at( i )->getName().compare( name ) )
+ return root->getSubNodes().at( i );
+ }
+ return NULL;
+}
diff --git a/modules/stream_filter/dash/xml/DOMHelper.h b/modules/stream_filter/dash/xml/DOMHelper.h
index 75a93bb..775b8f3 100644
--- a/modules/stream_filter/dash/xml/DOMHelper.h
+++ b/modules/stream_filter/dash/xml/DOMHelper.h
@@ -39,6 +39,7 @@ namespace dash
public:
static std::vector<Node *> getElementByTagName (Node *root, std::string name, bool selfContain);
static std::vector<Node *> getChildElementByTagName (Node *root, std::string name);
+ static Node* getFirstChildElementByName( Node *root, const std::string& name );
private:
static void getElementsByTagName(Node *root, std::string name, std::vector<Node *> *elements, bool selfContain);
More information about the vlc-commits
mailing list