variant_array.h Source File - 0.9.0 |RTTR
variant_array.h
Go to the documentation of this file.
1 /************************************************************************************
2 * *
3 * Copyright (c) 2014 Axel Menzel <info@axelmenzel.de> *
4 * *
5 * This file is part of RTTR (Run Time Type Reflection) *
6 * License: MIT License *
7 * *
8 * Permission is hereby granted, free of charge, to any person obtaining *
9 * a copy of this software and associated documentation files (the "Software"), *
10 * to deal in the Software without restriction, including without limitation *
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense, *
12 * and/or sell copies of the Software, and to permit persons to whom the *
13 * Software is furnished to do so, subject to the following conditions: *
14 * *
15 * The above copyright notice and this permission notice shall be included in *
16 * all copies or substantial portions of the Software. *
17 * *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *
24 * SOFTWARE. *
25 * *
26 *************************************************************************************/
27 
28 #ifndef __RTTR_VARIANT_ARRAY_H__
29 #define __RTTR_VARIANT_ARRAY_H__
30 
32 #include <cstddef>
33 #include <vector>
34 
35 namespace rttr
36 {
37 class variant;
38 class type;
39 
40 namespace detail
41 {
42 class array_container_base;
43 class instance;
44 class argument;
45 }
46 
170 {
171  public:
177  variant_array();
178 
182  template<typename T>
183  variant_array(const T& value);
184 
188  template<typename T>
189  variant_array(T&& value
190 #ifndef DOXYGEN
191  , typename std::enable_if<!std::is_same<variant_array&, T>::value >::type* = 0
192  , typename std::enable_if<!std::is_const<T>::value >::type* = 0
193 #endif
194  );
195 
199  variant_array(const variant_array& other);
200 
204  variant_array(variant_array&& other);
205 
209  ~variant_array();
210 
216  bool is_valid() const;
217 
221  void swap(variant_array& other);
222 
228  template<typename T>
229  variant_array& operator=(T&& other);
230 
236  variant_array& operator=(variant_array&& other);
237 
243  variant_array& operator=(const variant_array& other);
244 
245 
253  bool is_dynamic() const;
254 
261  std::size_t get_rank() const;
262 
270  type get_rank_type(std::size_t index) const;
271 
279  type get_type() const;
280 
286  bool is_raw_array() const;
287 
293  std::size_t get_size() const;
294 
301  std::size_t get_size(std::size_t index_1) const;
302 
309  std::size_t get_size(std::size_t index_1, std::size_t index_2) const;
310 
317  std::size_t get_size_variadic(const std::vector<std::size_t>& index_list) const;
318 
324  bool set_size(std::size_t new_size);
325 
332  bool set_size(std::size_t new_size, std::size_t index_1);
333 
341  bool set_size(std::size_t new_size, std::size_t index_1, std::size_t index_2);
342 
349  bool set_size_variadic(std::size_t new_size, const std::vector<std::size_t>& index_list);
350 
356  bool set_value(detail::argument arg);
357 
364  bool set_value(std::size_t index_1, detail::argument arg);
365 
372  bool set_value(std::size_t index_1, std::size_t index_2, detail::argument arg);
373 
380  bool set_value(std::size_t index_1, std::size_t index_2, std::size_t index_3, detail::argument arg);
381 
390  bool set_value_variadic(const std::vector<std::size_t>& index_list, detail::argument arg);
391 
392 
398  variant get_value(std::size_t index_1) const;
399 
406  variant get_value(std::size_t index_1, std::size_t index_2) const;
407 
414  variant get_value(std::size_t index_1, std::size_t index_2, std::size_t index_3) const;
415 
421  variant get_value_variadic(const std::vector<std::size_t>& index_list) const;
422 
430  bool insert_value(std::size_t index_1, detail::argument arg);
431 
440  bool insert_value(std::size_t index_1, std::size_t index_2, detail::argument arg);
441 
450  bool insert_value(std::size_t index_1, std::size_t index_2, std::size_t index_3, detail::argument arg);
451 
459  bool insert_value_variadic(const std::vector<std::size_t>& index_list, detail::argument arg);
460 
466  bool remove_value(std::size_t index_1);
467 
474  bool remove_value(std::size_t index_1, std::size_t index_2);
475 
482  bool remove_value(std::size_t index_1, std::size_t index_2, std::size_t index_3);
483 
489  bool remove_value_variadic(const std::vector<std::size_t>& index_list);
490 
491  private:
492  variant_array(detail::array_container_base* container);
493 
499  void* get_ptr() const;
500 
501  private:
502  friend class variant;
503  friend class detail::argument;
504  detail::array_container_base* _container;
505 };
506 
508 
509 } // end namespace rttr
510 
511 #include "rttr/impl/variant_array_impl.h"
512 
513 #endif // __RTTR_VARIANT_ARRAY_H__
The namespace for all rttr components.
Definition: core_prerequisites.h:33
This class holds the type information for any arbitrary object.
Definition: type.h:165
The variant class allows to store data of any type and convert between these types transparently...
Definition: variant.h:125
The variant_array class is a specialization of a variant, but for array types.
Definition: variant_array.h:169
#define RTTR_API
Definition: core_prerequisites.h:124