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.
23 #include "dali-toolkit/devel-api/builder/tree-node.h"
24 #include "dali-toolkit/internal/builder/tree-node-manipulator.h"
29 bool CaseInsensitiveCharacterCompare( unsigned char a, unsigned char b )
31 // Converts to lower case in the current locale.
32 return std::tolower( a ) == std::tolower( b );
36 * return true if the lower cased ASCII strings are equal.
38 bool CaseInsensitiveStringCompare( const std::string& a, const std::string& b )
41 if( a.length() == b.length() )
43 result = std::equal( a.begin(), a.end(), b.begin(), CaseInsensitiveCharacterCompare );
48 } // anonymous namespace
64 mType(TreeNode::IS_NULL),
74 const char* TreeNode::GetName() const
79 TreeNode::NodeType TreeNode::GetType() const
84 const char* TreeNode::GetString() const
89 bool TreeNode::HasSubstitution() const
94 float TreeNode::GetFloat() const
99 int TreeNode::GetInteger() const
104 bool TreeNode::GetBoolean() const
106 return mIntValue == 1 ? true : false;
109 size_t TreeNode::Size() const
112 TreeNode* p = mFirstChild;
121 size_t TreeNode::Count(const std::string& childName) const
123 const TreeNode* c = GetChild(childName);
134 const TreeNode* TreeNode::GetChild(const std::string& childName) const
136 const TreeNode* p = mFirstChild;
139 if(p->mName && (std::string(p->mName) == childName) )
149 const TreeNode* TreeNode::GetChildIgnoreCase(const std::string& childName) const
151 const TreeNode* p = mFirstChild;
156 std::string nodeName(p->mName);
157 if( CaseInsensitiveStringCompare( nodeName, childName) )
167 const TreeNode* TreeNode::Find(const std::string& childName) const
169 if(mName && std::string(mName) == childName)
175 return Internal::FindIt(childName, this);
179 TreeNode::ConstIterator TreeNode::CBegin() const
181 return ConstIterator(mFirstChild);
185 TreeNode::ConstIterator TreeNode::CEnd() const
187 return ConstIterator(NULL);
191 TreeNode::ConstIterator::ConstIterator(TreeNode* v) : mNode(v)
196 TreeNode::ConstIterator& TreeNode::ConstIterator::operator ++()
200 mNode = mNode->mNextSibling;
209 TreeNode::ConstIterator TreeNode::ConstIterator::operator ++(int)
211 TreeNode::ConstIterator ret(mNode);
215 mNode = mNode->mNextSibling;
224 TreeNode::KeyNodePair TreeNode::ConstIterator::operator *()
226 return KeyNodePair(mNode->mName, *mNode);
229 bool TreeNode::ConstIterator::operator!=( const TreeNode::ConstIterator& rhs ) const
231 return mNode != rhs.mNode;
234 } // namespace Toolkit