1 #ifndef DALI_TOOLKIT_TEXT_MARKUP_PROCESSOR_ATTRIBUTE_HELPER_FUNCTIONS_H
2 #define DALI_TOOLKIT_TEXT_MARKUP_PROCESSOR_ATTRIBUTE_HELPER_FUNCTIONS_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-toolkit/internal/text/text-definitions.h>
36 * @brief Copy the value from attribute buffer to value.
38 * @param[in] attribute the value of attribute.
39 * @param[in] maxLengthAttributeValue the maximum length of any of the possible value for attribute
40 * @param[out] value the value container.
43 void CopyAttributeValueFromBuffer(const Attribute& attribute, const Length maxLengthAttributeValue, char* value);
46 * @brief Process the float attribute value from buffer.
48 * @param[in] attribute the float attribute.
50 * @return The float value.
52 float ProcessFloatAttribute(const Attribute& attribute);
55 * @brief Process the Enumeration attribute value from buffer.
57 * @param[in] attribute the Enumeration attribute.
58 * @param[in] maxLengthAttributeValue the maximum length of any of the possible value for attribute
59 * @param[in] funcStringToEnum the function converts string value to enum value
60 * @param[out] enumValue the enum value
62 * @return True if the enum value was processed successfully
66 bool ProcessEnumerationAttribute(const Attribute& attribute,
67 const Length maxLengthAttributeValue,
68 std::function<T(const char* const)> funcStringToEnum,
71 char* value = new char[maxLengthAttributeValue + 1u];
73 CopyAttributeValueFromBuffer(attribute, maxLengthAttributeValue, value);
75 enumValue = funcStringToEnum(value); // @TODO: the functions that process Enum value should be refactored to return bool from Scripting::GetEnumeration
84 } // namespace Toolkit
88 #endif // DALI_TOOLKIT_TEXT_MARKUP_PROCESSOR_ATTRIBUTE_HELPER_FUNCTIONS_H