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>
32 * @addtogroup dali-core-object
36 typedef std::pair<std::string, Property::Value> StringValuePair;
39 * @brief A Map of property values.
41 class DALI_IMPORT_API Property::Map
45 typedef std::size_t SizeType;
48 * @brief Default constructor.
53 * @brief Copy Constructor.
55 * @param[in] other The Map to copy from.
57 Map( const Map& other );
60 * @brief Non-virtual destructor.
65 * @brief Retrieve the number of elements in the map.
67 * @return The number of elements in the map.
69 SizeType Count() const;
72 * @brief Returns whether the map is empty.
74 * @return true if empty, false otherwise
79 * @brief Inserts the key-value pair in the Map.
81 * Does not check for duplicates
82 * @param key to insert
83 * @param value to insert
85 void Insert( const char* key, const Value& value );
88 * @brief Inserts the key-value pair in the Map.
90 * Does not check for duplicates
91 * @param key to insert
92 * @param value to insert
94 void Insert( const std::string& key, const Value& value );
97 * @brief Retrieve the value at the specified position.
99 * @return A reference to the value at the specified position.
101 * @note Will assert if position >= Count()
103 Value& GetValue( SizeType position ) const;
106 * @brief Retrieve the key at the specified position.
108 * @return A const reference to the key at the specified position.
110 * @note Will assert if position >= Count()
112 const std::string& GetKey( SizeType position ) const;
115 * @brief Retrieve the key & the value at the specified position.
117 * @return A reference to the pair of key and value at the specified position.
119 * @note Will assert if position >= Count()
121 StringValuePair& GetPair( SizeType position ) const;
124 * @brief Finds the value for the specified key if it exists.
126 * @param[in] key The key to find.
128 * @return A const pointer to the value if it exists, NULL otherwise
130 Value* Find( const char* key ) const;
133 * @brief Finds the value for the specified key if it exists.
135 * @param[in] key The key to find.
137 * @return A const pointer to the value if it exists, NULL otherwise
139 Value* Find( const std::string& key ) const;
142 * @brief Finds the value for the specified key if it exists and its type is type
144 * @param[in] key The key to find.
145 * @param[in] type The type to check.
147 * @return A const pointer to the value if it exists, NULL otherwise
149 Value* Find( const std::string& key, Property::Type type ) const;
152 * @brief Clears the map.
157 * @brief Merges values from the map 'from' to the current.
159 * Any values in 'from' will overwrite the values in the current map.
161 * @param[in] from The map to merge from.
163 void Merge( const Map& from );
166 * @brief Const operator to access element with the specified key.
168 * @param[in] key The key whose value to access.
170 * @return The value for the element with the specified key, if key doesn't exist, then Property::NONE is returned.
172 * @note Will assert if invalid-key is given.
174 const Value& operator[]( const std::string& key ) const;
177 * @brief Operator to access the element with the specified key.
179 * @param[in] key The key whose value to access.
181 * @return A reference to the value for the element with the specified key.
183 * @note If an element with the key does not exist, then it is created.
185 Value& operator[]( const std::string& key );
188 * @brief Assignment Operator
190 * @param[in] other The map to copy from.
192 * @return The copied map.
194 Map& operator=( const Map& other );
197 struct DALI_INTERNAL Impl; ///< Private data
198 Impl* mImpl; ///< Pointer to private data
206 #endif // __DALI_PROPERTY_MAP_H__