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.
22 #include <string_view>
25 #include "dali-toolkit/devel-api/builder/tree-node.h"
26 #include "dali-toolkit/internal/builder/tree-node-manipulator.h"
32 * return true if the lower cased ASCII strings are equal.
34 bool CaseInsensitiveStringCompare(std::string_view a, std::string_view b)
36 return (a.length() == b.length()) && std::equal(a.begin(), a.end(), b.begin(), [](auto x, auto y) {
37 return std::tolower(x) == std::tolower(y);
50 mType(TreeNode::IS_NULL),
59 const char* TreeNode::GetName() const
64 TreeNode::NodeType TreeNode::GetType() const
69 const char* TreeNode::GetString() const
74 bool TreeNode::HasSubstitution() const
79 float TreeNode::GetFloat() const
84 int TreeNode::GetInteger() const
89 bool TreeNode::GetBoolean() const
91 return mIntValue == 1 ? true : false;
94 size_t TreeNode::Size() const
97 TreeNode* p = mFirstChild;
106 size_t TreeNode::Count(const std::string& childName) const
108 const TreeNode* c = GetChild(childName);
119 const TreeNode* TreeNode::GetChild(const std::string& childName) const
121 const TreeNode* p = mFirstChild;
124 if(p->mName && (std::string(p->mName) == childName))
133 const TreeNode* TreeNode::GetChildIgnoreCase(const std::string& childName) const
135 const TreeNode* p = mFirstChild;
138 if(p->mName && CaseInsensitiveStringCompare(p->mName, childName))
147 const TreeNode* TreeNode::Find(const std::string& childName) const
149 if(mName && std::string(mName) == childName)
155 return Internal::FindIt(childName, this);
159 TreeNode::ConstIterator TreeNode::CBegin() const
161 return ConstIterator(mFirstChild);
164 TreeNode::ConstIterator TreeNode::CEnd() const
166 return ConstIterator(NULL);
169 TreeNode::ConstIterator::ConstIterator(TreeNode* v)
174 TreeNode::ConstIterator& TreeNode::ConstIterator::operator++()
178 mNode = mNode->mNextSibling;
187 TreeNode::ConstIterator TreeNode::ConstIterator::operator++(int)
189 TreeNode::ConstIterator ret(mNode);
193 mNode = mNode->mNextSibling;
202 TreeNode::KeyNodePair TreeNode::ConstIterator::operator*()
204 return KeyNodePair(mNode->mName, *mNode);
207 bool TreeNode::ConstIterator::operator!=(const TreeNode::ConstIterator& rhs) const
209 return mNode != rhs.mNode;
212 } // namespace Toolkit