1 #ifndef DALI_TOOLKIT_INTERNAL_BUILDER_REPLACEMENT_H
2 #define DALI_TOOLKIT_INTERNAL_BUILDER_REPLACEMENT_H
5 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/object/property-value.h>
25 #include <dali-toolkit/devel-api/builder/builder.h>
26 #include <dali-toolkit/internal/builder/builder-get-is.inl.h>
40 * Supports template replacement functionality
52 * Constructor with default and overriding map
54 * Make a deep copy of the tree.
55 * @param overrideMap The user overriding map
56 * @param defaultMap The default map to use
58 Replacement(const Property::Map& overrideMap, const Property::Map& defaultMap);
61 * Constructor with default map
63 * Make a deep copy of the tree.
64 * @param overrideMap The user overriding map
66 Replacement(const Property::Map& defaultMap);
68 /* @brief Check node for a type
70 * @param node The TreeNode to check
71 * @return Optional value
73 OptionalString IsString(const TreeNode& node) const;
75 /* @brief Check node for a type
77 * @param node The TreeNode to check
78 * @return Optional value
80 OptionalBoolean IsBoolean(const TreeNode& node) const;
82 /* @brief Check node for a type
84 * @param node The TreeNode to check
85 * @return Optional value
87 OptionalFloat IsFloat(const TreeNode& node) const;
89 /* @brief Check node for a type
91 * @param node The TreeNode to check
92 * @return Optional value
94 OptionalInteger IsInteger(const TreeNode& node) const;
96 /* @brief Check node for a type
98 * @param node The TreeNode to check
99 * @return Optional value
101 OptionalVector2 IsVector2(const TreeNode& node) const;
103 /* @brief Check node for a type
105 * @param node The TreeNode to check
106 * @return Optional value
108 OptionalVector3 IsVector3(const TreeNode& node) const;
110 /* @brief Check node for a type
112 * @param node The TreeNode to check
113 * @return Optional value
115 OptionalVector4 IsVector4(const TreeNode& node) const;
117 /* @brief Check node for a type
119 * @param node The TreeNode to check
120 * @return Optional value
122 OptionalMatrix IsMatrix(const TreeNode& node) const;
124 /* @brief Check node for a type
126 * @param node The TreeNode to check
127 * @return Optional value
129 OptionalMatrix3 IsMatrix3(const TreeNode& node) const;
131 /* @brief Check node for a type
133 * @param node The TreeNode to check
134 * @return Optional value
136 OptionalRect IsRect(const TreeNode& node) const;
138 /* @brief Check node for a type
140 * @param node The TreeNode to check
141 * @return Optional value
143 OptionalExtents IsExtents(const TreeNode& node) const;
145 /* @brief Check node for a type
147 * @param child The optional child TreeNode
148 * @return Optional value
150 OptionalString IsString(OptionalChild child) const;
152 /* @brief Check node for a type
154 * @param child The optional child TreeNode
155 * @return Optional value
157 OptionalFloat IsFloat(OptionalChild child) const;
159 /* @brief Check node for a type
161 * @param child The optional child TreeNode
162 * @return Optional value
164 OptionalBoolean IsBoolean(OptionalChild child) const;
166 /* @brief Check node for a type
168 * @param child The optional child TreeNode
169 * @return Optional value
171 OptionalInteger IsInteger(OptionalChild child) const;
173 /* @brief Check node for a type
175 * @param child The optional child TreeNode
176 * @return Optional value
178 OptionalVector2 IsVector2(OptionalChild child) const;
180 /* @brief Check node for a type
182 * @param child The optional child TreeNode
183 * @return Optional value
185 OptionalVector3 IsVector3(OptionalChild child) const;
187 /* @brief Check node for a type
189 * @param child The optional child TreeNode
190 * @return Optional value
192 OptionalVector4 IsVector4(OptionalChild child) const;
194 /* @brief Check node for a type
196 * @param child The optional child TreeNode
197 * @return Optional value
199 OptionalMatrix IsMatrix(OptionalChild child) const;
201 /* @brief Check node for a type
203 * @param child The optional child TreeNode
204 * @return Optional value
206 OptionalMatrix3 IsMatrix3(OptionalChild child) const;
208 /* @brief Check node for a type
210 * @param child The optional child TreeNode
211 * @return Optional value
213 OptionalRect IsRect(OptionalChild child) const;
215 /* @brief Check node for a type
217 * @param child The optional child TreeNode
218 * @return Optional value
220 bool IsMap(OptionalChild child, Property::Value& out) const;
222 /* @brief Check node for a type
224 * @param child The optional child TreeNode
225 * @return Optional value
227 bool IsArray(OptionalChild child, Property::Value& out) const;
229 /* @brief Check node for a type
231 * @param child The optional child TreeNode
232 * @return Optional value
234 OptionalExtents IsExtents(OptionalChild child) const;
237 // Overriding map (overrides the default map). The map is not owned.
238 const Property::Map* const mOverrideMap;
240 // Default map. The map is not owned.
241 const Property::Map* const mDefaultMap;
244 // Replacement & operation=( Replacement& replacement );
245 // Replacement( const Replacement& copy );
247 // Returns the string if the node has a full replacement ie IMAGES if node is "{IMAGES}"
248 OptionalString HasFullReplacement(const TreeNode& node) const;
250 // Returns the property value for a full replacement from the maps
251 Property::Value GetFullReplacement(const std::string& replacementString) const;
254 } // namespace Internal
256 } // namespace Toolkit
260 #endif // DALI_TOOLKIT_INTERNAL_BUILDER_REPLACEMENT_H