2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
25 #include "dali-toolkit/devel-api/builder/tree-node.h"
26 #include "dali-toolkit/internal/builder/tree-node-manipulator.h"
32 bool CaseInsensitiveCharacterCompare( unsigned char a, unsigned char b )
34 // Converts to lower case in the current locale.
35 return std::tolower( a ) == std::tolower( b );
39 * return true if the lower cased ASCII strings are equal.
41 bool CaseInsensitiveStringCompare( const std::string& a, const std::string& b )
44 if( a.length() == b.length() )
46 result = std::equal( a.begin(), a.end(), b.begin(), CaseInsensitiveCharacterCompare );
61 mType(TreeNode::IS_NULL),
71 const char* TreeNode::GetName() const
76 TreeNode::NodeType TreeNode::GetType() const
81 const char* TreeNode::GetString() const
86 bool TreeNode::HasSubstitution() const
91 float TreeNode::GetFloat() const
96 int TreeNode::GetInteger() const
101 bool TreeNode::GetBoolean() const
103 return mIntValue == 1 ? true : false;
106 size_t TreeNode::Size() const
109 TreeNode* p = mFirstChild;
118 size_t TreeNode::Count(const std::string& childName) const
120 const TreeNode* c = GetChild(childName);
131 const TreeNode* TreeNode::GetChild(const std::string& childName) const
133 const TreeNode* p = mFirstChild;
136 if(p->mName && (std::string(p->mName) == childName) )
146 const TreeNode* TreeNode::GetChildIgnoreCase(const std::string& childName) const
148 const TreeNode* p = mFirstChild;
153 std::string nodeName(p->mName);
154 if( CaseInsensitiveStringCompare( nodeName, childName) )
164 const TreeNode* TreeNode::Find(const std::string& childName) const
166 if(mName && std::string(mName) == childName)
172 return Internal::FindIt(childName, this);
176 TreeNode::ConstIterator TreeNode::CBegin() const
178 return ConstIterator(mFirstChild);
182 TreeNode::ConstIterator TreeNode::CEnd() const
184 return ConstIterator(NULL);
188 TreeNode::ConstIterator::ConstIterator(TreeNode* v) : mNode(v)
193 TreeNode::ConstIterator& TreeNode::ConstIterator::operator ++()
197 mNode = mNode->mNextSibling;
206 TreeNode::ConstIterator TreeNode::ConstIterator::operator ++(int)
208 TreeNode::ConstIterator ret(mNode);
212 mNode = mNode->mNextSibling;
221 TreeNode::KeyNodePair TreeNode::ConstIterator::operator *()
223 return KeyNodePair(mNode->mName, *mNode);
226 bool TreeNode::ConstIterator::operator!=( const TreeNode::ConstIterator& rhs ) const
228 return mNode != rhs.mNode;
231 } // namespace Toolkit