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"
30 bool CaseInsensitiveCharacterCompare( unsigned char a, unsigned char b )
32 // Converts to lower case in the current locale.
33 return std::tolower( a ) == std::tolower( b );
37 * return true if the lower cased ASCII strings are equal.
39 bool CaseInsensitiveStringCompare( const std::string& a, const std::string& b )
42 if( a.length() == b.length() )
44 result = std::equal( a.begin(), a.end(), b.begin(), CaseInsensitiveCharacterCompare );
59 mType(TreeNode::IS_NULL),
69 const char* TreeNode::GetName() const
74 TreeNode::NodeType TreeNode::GetType() const
79 const char* TreeNode::GetString() const
84 bool TreeNode::HasSubstitution() const
89 float TreeNode::GetFloat() const
94 int TreeNode::GetInteger() const
99 bool TreeNode::GetBoolean() const
101 return mIntValue == 1 ? true : false;
104 size_t TreeNode::Size() const
107 TreeNode* p = mFirstChild;
116 size_t TreeNode::Count(const std::string& childName) const
118 const TreeNode* c = GetChild(childName);
129 const TreeNode* TreeNode::GetChild(const std::string& childName) const
131 const TreeNode* p = mFirstChild;
134 if(p->mName && (std::string(p->mName) == childName) )
144 const TreeNode* TreeNode::GetChildIgnoreCase(const std::string& childName) const
146 const TreeNode* p = mFirstChild;
151 std::string nodeName(p->mName);
152 if( CaseInsensitiveStringCompare( nodeName, childName) )
162 const TreeNode* TreeNode::Find(const std::string& childName) const
164 if(mName && std::string(mName) == childName)
170 return Internal::FindIt(childName, this);
174 TreeNode::ConstIterator TreeNode::CBegin() const
176 return ConstIterator(mFirstChild);
180 TreeNode::ConstIterator TreeNode::CEnd() const
182 return ConstIterator(NULL);
186 TreeNode::ConstIterator::ConstIterator(TreeNode* v) : mNode(v)
191 TreeNode::ConstIterator& TreeNode::ConstIterator::operator ++()
195 mNode = mNode->mNextSibling;
204 TreeNode::ConstIterator TreeNode::ConstIterator::operator ++(int)
206 TreeNode::ConstIterator ret(mNode);
210 mNode = mNode->mNextSibling;
219 TreeNode::KeyNodePair TreeNode::ConstIterator::operator *()
221 return KeyNodePair(mNode->mName, *mNode);
224 bool TreeNode::ConstIterator::operator!=( const TreeNode::ConstIterator& rhs ) const
226 return mNode != rhs.mNode;
229 } // namespace Toolkit