2 * Copyright (c) 2020 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"
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);
58 mType(TreeNode::IS_NULL),
67 const char* TreeNode::GetName() const
72 TreeNode::NodeType TreeNode::GetType() const
77 const char* TreeNode::GetString() const
82 bool TreeNode::HasSubstitution() const
87 float TreeNode::GetFloat() const
92 int TreeNode::GetInteger() const
97 bool TreeNode::GetBoolean() const
99 return mIntValue == 1 ? true : false;
102 size_t TreeNode::Size() const
105 TreeNode* p = mFirstChild;
114 size_t TreeNode::Count(const std::string& childName) const
116 const TreeNode* c = GetChild(childName);
127 const TreeNode* TreeNode::GetChild(const std::string& childName) const
129 const TreeNode* p = mFirstChild;
132 if(p->mName && (std::string(p->mName) == childName))
141 const TreeNode* TreeNode::GetChildIgnoreCase(const std::string& childName) const
143 const TreeNode* p = mFirstChild;
148 std::string nodeName(p->mName);
149 if(CaseInsensitiveStringCompare(nodeName, childName))
159 const TreeNode* TreeNode::Find(const std::string& childName) const
161 if(mName && std::string(mName) == childName)
167 return Internal::FindIt(childName, this);
171 TreeNode::ConstIterator TreeNode::CBegin() const
173 return ConstIterator(mFirstChild);
176 TreeNode::ConstIterator TreeNode::CEnd() const
178 return ConstIterator(NULL);
181 TreeNode::ConstIterator::ConstIterator(TreeNode* v)
186 TreeNode::ConstIterator& TreeNode::ConstIterator::operator++()
190 mNode = mNode->mNextSibling;
199 TreeNode::ConstIterator TreeNode::ConstIterator::operator++(int)
201 TreeNode::ConstIterator ret(mNode);
205 mNode = mNode->mNextSibling;
214 TreeNode::KeyNodePair TreeNode::ConstIterator::operator*()
216 return KeyNodePair(mNode->mName, *mNode);
219 bool TreeNode::ConstIterator::operator!=(const TreeNode::ConstIterator& rhs) const
221 return mNode != rhs.mNode;
224 } // namespace Toolkit