X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Fdevel-api%2Fbuilder%2Ftree-node.cpp;h=6b0f6b3e7391934aa6bb8977d4e6558c2c9f481f;hb=14208a1e7602b4c0f068df3514ddfcfcb43f5512;hp=302c7a2cc7e497481bafe00a821c07c9ab91df03;hpb=ab01efc8b47c89288c7fbc9948dead57d0411c1f;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/devel-api/builder/tree-node.cpp b/dali-toolkit/devel-api/builder/tree-node.cpp index 302c7a2..6b0f6b3 100644 --- a/dali-toolkit/devel-api/builder/tree-node.cpp +++ b/dali-toolkit/devel-api/builder/tree-node.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,11 +17,37 @@ // EXTERNAL INCLUDES #include +#include // INTERNAL INCLUDES #include "dali-toolkit/devel-api/builder/tree-node.h" #include "dali-toolkit/internal/builder/tree-node-manipulator.h" +namespace +{ + +bool CaseInsensitiveCharacterCompare( unsigned char a, unsigned char b ) +{ + // Converts to lower case in the current locale. + return std::tolower( a ) == std::tolower( b ); +} + +/** + * return true if the lower cased ASCII strings are equal. + */ +bool CaseInsensitiveStringCompare( const std::string& a, const std::string& b ) +{ + bool result = false; + if( a.length() == b.length() ) + { + result = std::equal( a.begin(), a.end(), b.begin(), CaseInsensitiveCharacterCompare ); + } + return result; +} + +} // anonymous namespace + + namespace Dali { @@ -80,7 +106,6 @@ bool TreeNode::GetBoolean() const return mIntValue == 1 ? true : false; } - size_t TreeNode::Size() const { size_t c = 0; @@ -120,6 +145,25 @@ const TreeNode* TreeNode::GetChild(const std::string& childName) const return NULL; } + +const TreeNode* TreeNode::GetChildIgnoreCase(const std::string& childName) const +{ + const TreeNode* p = mFirstChild; + while(p) + { + if(p->mName) + { + std::string nodeName(p->mName); + if( CaseInsensitiveStringCompare( nodeName, childName) ) + { + return p; + } + } + p = p->mNextSibling; + } + return NULL; +} + const TreeNode* TreeNode::Find(const std::string& childName) const { if(mName && std::string(mName) == childName)