1 #ifndef __DALI_PROPERTY_MAP_H__
2 #define __DALI_PROPERTY_MAP_H__
5 * Copyright (c) 2015 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.
25 #include <dali/public-api/common/dali-common.h>
26 #include <dali/public-api/object/property-value.h>
27 #include <dali/public-api/object/property.h>
31 typedef std::pair<std::string, Property::Value> StringValuePair;
34 * @brief A Map of property values.
36 class DALI_IMPORT_API Property::Map
40 typedef std::size_t SizeType;
43 * @brief Default constructor.
48 * @brief Copy Constructor.
50 * @param[in] other The Map to copy from.
52 Map( const Map& other );
55 * @brief Non-virtual destructor.
60 * @brief Retrieve the number of elements in the map.
62 * @return The number of elements in the map.
64 SizeType Count() const;
67 * @brief Returns whether the map is empty.
69 * @return true if empty, false otherwise
74 * @brief Inserts the key-value pair in the Map.
76 * Does not check for duplicates
77 * @param key to insert
78 * @param value to insert
80 void Insert( const char* key, const Value& value );
83 * @brief Inserts the key-value pair in the Map.
85 * Does not check for duplicates
86 * @param key to insert
87 * @param value to insert
89 void Insert( const std::string& key, const Value& value );
92 * @brief Retrieve the value at the specified position.
94 * @return A reference to the value at the specified position.
96 * @note Will assert if position >= Count()
98 Value& GetValue( SizeType position ) const;
101 * @brief Retrieve the key at the specified position.
103 * @return A const reference to the key at the specified position.
105 * @note Will assert if position >= Count()
107 const std::string& GetKey( SizeType position ) const;
110 * @brief Retrieve the key & the value at the specified position.
112 * @return A reference to the pair of key and value at the specified position.
114 * @note Will assert if position >= Count()
116 StringValuePair& GetPair( SizeType position ) const;
119 * @brief Finds the value for the specified key if it exists.
121 * @param[in] key The key to find.
123 * @return A const pointer to the value if it exists, NULL otherwise
125 Value* Find( const char* key ) const;
128 * @brief Finds the value for the specified key if it exists.
130 * @param[in] key The key to find.
132 * @return A const pointer to the value if it exists, NULL otherwise
134 Value* Find( const std::string& key ) const;
137 * @brief Finds the value for the specified key if it exists and its type is type
139 * @param[in] key The key to find.
140 * @param[in] type The type to check.
142 * @return A const pointer to the value if it exists, NULL otherwise
144 Value* Find( const std::string& key, Property::Type type ) const;
147 * @brief Clears the map.
152 * @brief Merges values from the map 'from' to the current.
154 * Any values in 'from' will overwrite the values in the current map.
156 * @param[in] from The map to merge from.
158 void Merge( const Map& from );
161 * @brief Const operator to access element with the specified key.
163 * @param[in] key The key whose value to access.
165 * @return The value for the element with the specified key, if key doesn't exist, then Property::NONE is returned.
167 * @note Will assert if invalid-key is given.
169 const Value& operator[]( const std::string& key ) const;
172 * @brief Operator to access the element with the specified key.
174 * @param[in] key The key whose value to access.
176 * @return A reference to the value for the element with the specified key.
178 * @note If an element with the key does not exist, then it is created.
180 Value& operator[]( const std::string& key );
183 * @brief Assignment Operator
185 * @param[in] other The map to copy from.
187 * @return The copied map.
189 Map& operator=( const Map& other );
192 struct DALI_INTERNAL Impl; ///< Private data
193 Impl* mImpl; ///< Pointer to private data
198 #endif // __DALI_PROPERTY_MAP_H__