Added code for stylable transitions
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / markup-processor-helper-functions.h
1 #ifndef __DALI_TOOLKIT_TEXT_MARKUP_PROCESSOR_HELPER_FUNCTIONS_H__
2 #define __DALI_TOOLKIT_TEXT_MARKUP_PROCESSOR_HELPER_FUNCTIONS_H__
3
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/common/dali-vector.h>
23 #include <string>
24
25 // INTERNAL INCLUDES
26 #include <dali-toolkit/internal/text/text-definitions.h>
27
28 namespace Dali
29 {
30
31 struct Vector4;
32
33 namespace Toolkit
34 {
35
36 namespace Text
37 {
38
39 /**
40  * @brief Stores an attribute pair: name, value.
41  */
42 struct Attribute
43 {
44   const char* nameBuffer;
45   const char* valueBuffer;
46   Length nameLength;
47   Length valueLength;
48 };
49
50 /**
51  * @brief Stores a tag and its attributes.
52  */
53  struct Tag
54  {
55    Vector<Attribute> attributes;
56    const char* buffer;
57    Length length;
58    bool isEndTag;
59  };
60
61 /**
62  * @brief Compare if two tokens are equal.
63  *
64  * @pre @p string1 must be lower case. (The html-ish constant tokens)
65  * The @p stringBuffer2 parameter is transformed to lower case.
66  * This function is used in the mark-up parser.
67  * It has no sense to transform the constants html-ish tokens to lower case when
68  * it's known they already are.
69  *
70  * @param[in] string1 The html-ish constant token.
71  * @param[in] stringBuffer2 Pointer to the html-ish token buffer.
72  * @param[in] length The length of the html-ish token.
73  *
74  * @return @e true if both strings are equal.
75  */
76 bool TokenComparison( const std::string& string1, const char* const stringBuffer2, Length length );
77
78 /**
79  * @brief Skips any unnecessary white space.
80  *
81  * @param[in,out] markupStringBuffer The mark-up string buffer. It's a const iterator pointing the current character.
82  * @param[in] markupStringEndBuffer Pointer to one character after the end of the mark-up string buffer.
83  */
84 void SkipWhiteSpace( const char*& markupStringBuffer,
85                      const char* const markupStringEndBuffer );
86
87 /**
88  * @brief Converts a string into an hexadecimal unsigned int.
89  *
90  * @param[in] uintStr An hexadecimal unsigned int packed inside a string.
91  *
92  * @return The hexadecimal value.
93  */
94 unsigned int StringToHex( const char* const uintStr );
95
96 /**
97  * @brief Converts a string into a float value.
98  *
99  * @param[in] floatStr A float packed inside a string.
100  *
101  * @return The float value.
102  */
103 float StringToFloat( const char* const floatStr );
104
105 /**
106  * @brief Converts an ARGB color packed in 4 byte unsigned int into a Vector4 color used in Dali.
107  *
108  * @param[in] color An ARGB color packed in an unsigned int.
109  * @param[out] retColor A Vector4 with the converted color.
110  */
111 void UintColorToVector4( unsigned int color, Vector4& retColor );
112
113 /**
114  * @brief Converts a color packed inside a string into an ARGB Vector4 color.
115  *
116  * The string color could be in hexadecimal ( 0xFF0000FF ), webcolor ( #0000FF or #00F ) or some constant values:
117  * black, white, red, green, blue, yellow, magenta, cyan, transparent.
118  *
119  * @param[in] colorStr A color packed inside a string.
120  * @param[in] length The length of the color string.
121  * @param[out] retColor A color packed inside a Vector4.
122  */
123 void ColorStringToVector4( const char* const colorStr, Length length, Vector4& retColor );
124
125 } // namespace Text
126
127 } // namespace Toolkit
128
129 } // namespace Dali
130
131 #endif // __DALI_TOOLKIT_TEXT_MARKUP_PROCESSOR_HELPER_FUNCTIONS_H__