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
41 * @brief Default constructor.
46 * @brief Copy Constructor.
48 * @param[in] other The Map to copy from.
50 Map( const Map& other );
53 * @brief Non-virtual destructor.
58 * @brief Retrieve the number of elements in the map.
60 * @return The number of elements in the map.
62 unsigned int Count() const;
65 * @brief Returns whether the map is empty.
67 * @return true if empty, false otherwise
72 * @brief Retrieve the value at the specified position.
74 * @return A reference to the value at the specified position.
76 * @note Will assert if position >= Count()
78 Value& GetValue( unsigned int position ) const;
81 * @brief Retrieve the key at the specified position.
83 * @return A const reference to the key at the specified position.
85 * @note Will assert if position >= Count()
87 const std::string& GetKey( unsigned int position ) const;
90 * @brief Retrieve the key & the value at the specified position.
92 * @return A reference to the pair of key and value at the specified position.
94 * @note Will assert if position >= Count()
96 StringValuePair& GetPair( unsigned int position ) const;
99 * @brief Finds the value for the specified key if it exists.
101 * @param[in] key The key to find.
103 * @return A const pointer to the value if it exists, NULL otherwise
105 Value* Find( const std::string& key ) const;
108 * @brief Finds the value for the specified key if it exists and its type is type
110 * @param[in] key The key to find.
111 * @param[in] type The type to check.
113 * @return A const pointer to the value if it exists, NULL otherwise
115 Value* Find( const std::string& key, Property::Type type ) const;
118 * @brief Clears the map.
123 * @brief Merges values from the map 'from' to the current.
125 * Any values in 'from' will overwrite the values in the current map.
127 * @param[in] from The map to merge from.
129 void Merge( const Map& from );
132 * @brief Const operator to access element with the specified key.
134 * @param[in] key The key whose value to access.
136 * @return The value for the element with the specified key, if key doesn't exist, then Property::NONE is returned.
138 * @note Will assert if invalid-key is given.
140 const Value& operator[]( const std::string& key ) const;
143 * @brief Operator to access the element with the specified key.
145 * @param[in] key The key whose value to access.
147 * @return A reference to the value for the element with the specified key.
149 * @note If an element with the key does not exist, then it is created.
151 Value& operator[]( const std::string& key );
154 * @brief Assignment Operator
156 * @param[in] other The map to copy from.
158 * @return The copied map.
160 Map& operator=( const Map& other );
163 struct DALI_INTERNAL Impl; ///< Private data
164 Impl* mImpl; ///< Pointer to private data
169 #endif // __DALI_PROPERTY_MAP_H__