variant_sequential_view.h Source File - 0.9.7 |RTTR
variant_sequential_view.h
Go to the documentation of this file.
1 /************************************************************************************
2 * *
3 * Copyright (c) 2014 - 2018 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_SEQUENTIAL_VIEW_H_
29 #define RTTR_VARIANT_SEQUENTIAL_VIEW_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 #include "rttr/detail/variant_sequential_view/variant_sequential_view_private.h"
35 
36 #include <cstddef>
37 #include <vector>
38 #include <memory>
39 
40 namespace rttr
41 {
42  class type;
43  class instance;
44  class argument;
45 
96 {
97  public:
98  class const_iterator;
99 
106 
111 
117  ~variant_sequential_view() RTTR_NOEXCEPT;
118 
124  variant_sequential_view& operator=(const variant_sequential_view& other) RTTR_NOEXCEPT;
125 
132  bool is_valid() const RTTR_NOEXCEPT;
133 
141  explicit operator bool() const RTTR_NOEXCEPT;
142 
146  void swap(variant_sequential_view& other) RTTR_NOEXCEPT;
147 
148 
156  type get_type() const RTTR_NOEXCEPT;
157 
165  type get_value_type() const RTTR_NOEXCEPT;
166 
172  bool is_empty() const RTTR_NOEXCEPT;
173 
183  bool is_dynamic() const RTTR_NOEXCEPT;
184 
196  std::size_t get_rank() const RTTR_NOEXCEPT;
197 
209  type get_rank_type(std::size_t index) const RTTR_NOEXCEPT;
210 
216  std::size_t get_size() const RTTR_NOEXCEPT;
217 
225  bool set_size(std::size_t size) const RTTR_NOEXCEPT;
226 
232  const_iterator insert(const const_iterator& pos, argument value);
233 
239  const_iterator erase(const const_iterator& pos);
240 
246  void clear();
247 
254  bool set_value(std::size_t index, argument arg);
255 
265  variant get_value(std::size_t index) const;
266 
274  const_iterator begin() const;
275 
283  const_iterator end() const;
284 
309  class RTTR_API const_iterator
310  {
311  public:
314 
318  ~const_iterator();
319 
323  const_iterator(const const_iterator& other);
324 
328  const_iterator& operator=(const_iterator other);
329 
337  const variant operator*() const;
338 
345  const variant get_data() const;
346 
354  const_iterator &operator++();
355 
360  const_iterator operator++(int);
361 
369  const_iterator &operator--();
370 
375  const_iterator operator--(int);
376 
380  const_iterator &operator+=(int i);
381 
385  const_iterator &operator-=(int i);
386 
390  const_iterator operator+(int i) const;
391 
395  const_iterator operator-(int i) const;
396 
403  bool operator==(const const_iterator& other) const;
404 
411  bool operator!=(const const_iterator& other) const;
412 
413  private:
414  const_iterator(const detail::variant_sequential_view_private* view) RTTR_NOEXCEPT;
415  void swap(const_iterator& other);
416 
418 
419  const detail::variant_sequential_view_private* m_view;
420  detail::iterator_data m_itr;
421  };
422  private:
423  friend class variant;
424  friend class argument;
425 
426  detail::variant_sequential_view_private m_view;
427 };
428 
429 } // end namespace rttr
430 
431 #endif // RTTR_VARIANT_SEQUENTIAL_VIEW_H_
Definition: access_levels.h:33
The type class holds the type information for any arbitrary object.
Definition: type.h:177
constexpr bool operator==(basic_string_view< CharT, Traits > lhs, basic_string_view< CharT, Traits > rhs) noexcept
Compares the two views lhs and rhs.
detail::enum_data< Enum_Type > value(string_view, Enum_Type value)
The value function should be used to add a mapping from enum name to value during the registration pr...
The variant_sequential_view::const_iterator allows iteration over an sequential container in a varian...
Definition: variant_sequential_view.h:309
The variant_sequential_view describes a class that refers to an sequence container (e...
Definition: variant_sequential_view.h:95
constexpr bool operator!=(basic_string_view< CharT, Traits > lhs, basic_string_view< CharT, Traits > rhs) noexcept
Compares the two views lhs and rhs.
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:197
std::basic_string< CharT, Traits > operator+(basic_string_view< CharT, Traits > lhs, const std::basic_string< CharT, Traits > &rhs)