1 #ifndef DALI_PROPERTY_ARRAY_H
2 #define DALI_PROPERTY_ARRAY_H
5 * Copyright (c) 2019 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.
22 #include <initializer_list>
26 #include <dali/public-api/common/dali-common.h>
27 #include <dali/public-api/object/property-value.h>
28 #include <dali/public-api/object/property.h>
33 * @addtogroup dali_core_object
38 * @brief A Array of property values.
41 class DALI_CORE_API Property::Array
45 typedef std::size_t SizeType;
48 * @brief Default constructor.
54 * @brief Constructor from initializer_list.
57 * @param[in] values An initializer_list of values
59 Array( const std::initializer_list< Value >& values );
62 * @brief Copy constructor.
65 * @param[in] other The Array to copy from
67 Array( const Array& other );
70 * @brief Move constructor.
72 * A move constructor enables the resources owned by an r-value object to be moved into an l-value without copying.
74 * @param[in] other The Array to move from
75 * @note After the @a other array is used, it becomes invalid and is no longer usable.
77 Array( Array&& other );
80 * @brief Non-virtual destructor.
86 * @brief Retrieves the number of elements in the array.
89 * @return The number of elements in the array
97 * @brief Retrieves the number of elements in the array.
100 * @return The number of elements in the array
102 SizeType Count() const;
105 * @brief Returns whether the array is empty.
108 * @return @c true if empty, @c false otherwise
116 * @brief Clears the array.
122 * @brief Increases the capacity of the array.
124 * @param[in] size The size to reserve
126 void Reserve( SizeType size );
129 * @brief Resizes to size.
131 * @param[in] size The size to resize
133 void Resize( SizeType size );
136 * @brief Retrieves the capacity of the array.
139 * @return The allocated capacity of the array
144 * @brief Adds an element to the array.
147 * @param[in] value The value to add to the end of the array
149 void PushBack( const Value& value );
152 * @brief Add an element to the array.
155 * @param[in] value The value to add to the end of the array
156 * @return A reference to this object
158 inline Property::Array& Add( const Value& value )
165 * @brief Const access an element.
168 * @param[in] index The element index to access. No bounds checking is performed
169 * @return The a reference to the element
171 const Value& GetElementAt( SizeType index ) const
173 return operator[]( index );
177 * @brief Accesses an element.
180 * @param[in] index The element index to access. No bounds checking is performed
181 * @return The a reference to the element
183 Value& GetElementAt( SizeType index )
185 return operator[]( index );
189 * @brief Const operator to access an element.
192 * @param[in] index The element index to access. No bounds checking is performed
193 * @return The a reference to the element
196 const Value& operator[]( SizeType index ) const;
199 * @brief Operator to access an element.
202 * @param[in] index The element index to access. No bounds checking is performed
203 * @return The a reference to the element
206 Value& operator[]( SizeType index );
209 * @brief Assignment operator.
212 * @param[in] other The array to copy from
214 * @return The copied array.
216 Array& operator=( const Array& other );
219 * @brief Move assignment operator.
222 * @param[in] other The array to copy from
224 * @return The moved array.
226 * @note After the @a other array is used, it becomes invalid and is no longer usable.
228 Array& operator=( Array&& other );
231 * @brief Output to stream.
234 friend DALI_CORE_API std::ostream& operator<<( std::ostream& stream, const Property::Array& array );
237 struct DALI_INTERNAL Impl; ///< Private data
238 Impl* mImpl; ///< Pointer to private data
242 * @brief Converts the values of the property array into a string and append to an output stream.
245 * @param[in] stream The output stream operator
246 * @param[in] array The array to insert
247 * @return The output stream operator
249 DALI_CORE_API std::ostream& operator<<( std::ostream& stream, const Property::Array& array );
256 #endif // DALI_PROPERTY_ARRAY_H