Merge branch 'devel/master' into tizen
[platform/core/uifw/dali-core.git] / dali / public-api / object / property-key.h
1 #ifndef DALI_PROPERTY_KEY_H
2 #define DALI_PROPERTY_KEY_H
3
4 /*
5  * Copyright (c) 2020 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 <sstream>
23 #include <string>
24
25 // INTERNAL INCLUDES
26 #include <dali/public-api/common/dali-common.h>
27 #include <dali/public-api/object/property.h>
28
29 namespace Dali
30 {
31 /**
32  * @addtogroup dali_core_object
33  * @{
34  */
35
36 /**
37  * @brief A key type which can be either a std::string or a Property::Index
38  * @SINCE_1_2.7
39  */
40 struct DALI_CORE_API Property::Key
41 {
42   /**
43    * @brief The type of key
44    * @SINCE_1_2.7
45    */
46   enum Type
47   {
48     INDEX, ///< The key is a Property::Index
49     STRING ///< The key is a string
50   } type;  ///< The type of the key
51
52   Property::Index indexKey;  ///< The index key.
53   std::string     stringKey; ///< The string key.
54
55   /**
56    * @brief Constructor
57    * @SINCE_1_2.7
58    *
59    * @param[in] key The string key
60    */
61   Key(const std::string& key);
62
63   /**
64    * @brief Constructor
65    * @SINCE_1_4.16
66    *
67    * @param[in] key The string key as a const char *
68    */
69   Key(const char* key);
70
71   /**
72    * @brief Constructor
73    * @SINCE_1_2.7
74    *
75    * @param[in] key The index key
76    */
77   Key(Property::Index key);
78
79   /**
80    * @brief The equality operator
81    * @SINCE_1_2.7
82    *
83    * @param[in] rhs A string key to compare against.
84    * @return true if the key compares, or false if it isn't equal or of the wrong type
85    */
86   bool operator==(const std::string& rhs);
87
88   /**
89    * @brief Constructor
90    * @SINCE_1_4.16
91    *
92    * @param[in] key The string key as a const char *
93    * @return true if the key compares, or false if it isn't equal or of the wrong type
94    */
95   bool operator==(const char* key);
96
97   /**
98    * @brief The equality operator
99    * @SINCE_1_2.7
100    *
101    * @param[in] rhs An index key to compare against.
102    * @return true if the key compares, or false if it isn't equal or of the wrong type
103    */
104   bool operator==(Property::Index rhs);
105
106   /**
107    * @brief The equality operator
108    * @SINCE_1_2.7
109    *
110    * @param[in] rhs A key  to compare against.
111    * @return true if the keys are of the same type and have the same value
112    */
113   bool operator==(const Key& rhs);
114
115   /**
116    * @brief The inequality operator
117    * @SINCE_1_2.7
118    *
119    * @param[in] rhs A string key to compare against.
120    * @return true if the key is not equal or not a string key
121    */
122   bool operator!=(const std::string& rhs);
123
124   /**
125    * @brief The inequality operator
126    * @SINCE_1_4.16
127    *
128    * @param[in] rhs A const char* key to compare against.
129    * @return true if the key is not equal or not a string key
130    */
131   bool operator!=(const char* rhs);
132
133   /**
134    * @brief The inequality operator
135    * @SINCE_1_2.7
136    *
137    * @param[in] rhs An index key to compare against.
138    * @return true if the key is not equal, or not an index key
139    */
140   bool operator!=(Property::Index rhs);
141
142   /**
143    * @brief The inequality operator
144    * @SINCE_1_2.7
145    *
146    * @param[in] rhs A key to compare against.
147    * @return true if the keys are not of the same type or are not equal
148    */
149   bool operator!=(const Key& rhs);
150 };
151
152 /**
153  * @brief Convert the key into a string and append to an output stream.
154  *
155  * @SINCE_1_2.7
156  * @param [in] stream The output stream operator.
157  * @param [in] key the key to convert
158  * @return The output stream operator.
159  */
160 DALI_CORE_API std::ostream& operator<<(std::ostream& stream, const Property::Key& key);
161
162 /**
163  * @}
164  */
165 } // namespace Dali
166
167 #endif // DALI_PROPERTY_KEY_H