variant_array_view.h Source File - 0.9.5 |RTTR
variant_array_view.h
Go to the documentation of this file.
1 /************************************************************************************
2 * *
3 * Copyright (c) 2014, 2015 - 2016 Axel Menzel <info@rttr.org> *
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 
31 #include "rttr/detail/base/core_prerequisites.h"
32 #include "rttr/detail/misc/misc_type_traits.h"
33 #include "rttr/variant.h"
34 
35 #include <cstddef>
36 #include <vector>
37 #include <memory>
38 
39 namespace rttr
40 {
41  class type;
42  class variant_array_view;
43  class instance;
44  class argument;
45 
46 namespace detail
47 {
48  class array_wrapper_base;
49 }
50 
137 class RTTR_API variant_array_view
138 {
139  public:
146 
151 
156 
161 
167  variant_array_view& operator=(const variant_array_view& other);
168 
175  bool is_valid() const;
176 
184  explicit operator bool() const;
185 
189  void swap(variant_array_view& other);
190 
191 
201  bool is_dynamic() const;
202 
214  std::size_t get_rank() const;
215 
227  type get_rank_type(std::size_t index) const;
228 
236  type get_type() const;
237 
243  std::size_t get_size() const;
244 
251  std::size_t get_size(std::size_t index_1) const;
252 
259  std::size_t get_size(std::size_t index_1, std::size_t index_2) const;
260 
267  std::size_t get_size_variadic(const std::vector<std::size_t>& index_list) const;
268 
274  bool set_size(std::size_t new_size);
275 
282  bool set_size(std::size_t new_size, std::size_t index_1);
283 
291  bool set_size(std::size_t new_size, std::size_t index_1, std::size_t index_2);
292 
299  bool set_size_variadic(std::size_t new_size, const std::vector<std::size_t>& index_list);
300 
306  bool set_value(argument arg);
307 
314  bool set_value(std::size_t index_1, argument arg);
315 
322  bool set_value(std::size_t index_1, std::size_t index_2, argument arg);
323 
330  bool set_value(std::size_t index_1, std::size_t index_2, std::size_t index_3, argument arg);
331 
340  bool set_value_variadic(const std::vector<std::size_t>& index_list, argument arg);
341 
342 
348  variant get_value(std::size_t index_1) const;
349 
356  variant get_value(std::size_t index_1, std::size_t index_2) const;
357 
364  variant get_value(std::size_t index_1, std::size_t index_2, std::size_t index_3) const;
365 
371  variant get_value_variadic(const std::vector<std::size_t>& index_list) const;
372 
380  bool insert_value(std::size_t index_1, argument arg);
381 
390  bool insert_value(std::size_t index_1, std::size_t index_2, argument arg);
391 
400  bool insert_value(std::size_t index_1, std::size_t index_2, std::size_t index_3, argument arg);
401 
409  bool insert_value_variadic(const std::vector<std::size_t>& index_list, argument arg);
410 
416  bool remove_value(std::size_t index_1);
417 
424  bool remove_value(std::size_t index_1, std::size_t index_2);
425 
432  bool remove_value(std::size_t index_1, std::size_t index_2, std::size_t index_3);
433 
439  bool remove_value_variadic(const std::vector<std::size_t>& index_list);
440 
441  private:
442  friend class variant;
443  friend class argument;
444 
445  std::unique_ptr<detail::array_wrapper_base> m_array_wrapper;
446 };
447 
448 } // end namespace rttr
449 
450 #include "rttr/detail/variant_array_view/variant_array_view_impl.h"
451 
452 #endif // RTTR_VARIANT_ARRAY_H_
Definition: access_levels.h:33
The type class holds the type information for any arbitrary object.
Definition: type.h:153
The variant_array_view describes a class that refers to an array inside a variant.
Definition: variant_array_view.h:137
The argument class is used for forwarding arguments to properties or methods.
Definition: argument.h:51
The variant class allows to store data of any type and convert between these types transparently...
Definition: variant.h:192