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
40namespace rttr
41{
42 class type;
43 class instance;
44 class argument;
45
96{
97 public:
98 class const_iterator;
99
106
111
118
125
132 bool is_valid() const RTTR_NOEXCEPT;
133
142
147
148
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
233
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
275
284
310 {
311 public:
314
319
324
329
337 const variant operator*() const;
338
345 const variant get_data() const;
346
355
361
370
376
381
386
391
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_
The argument class is used for forwarding arguments to properties or methods.
Definition argument.h:52
The array_range class provides a view into an underlying data structure with lower and upper limits.
Definition array_range.h:64
const_iterator end()
Returns an iterator to the element following the last element of the range.
array_iterator< const T > const_iterator
A constant forward iterator.
Definition array_range.h:170
const_iterator begin()
Returns an iterator to the first element of the range.
size_t size() const
Returns the number of elements in the range.
array_range()
Default constructor.
The type class holds the type information for any arbitrary object.
Definition type.h:178
The variant_sequential_view::const_iterator allows iteration over an sequential container in a varian...
Definition variant_sequential_view.h:310
const_iterator & operator-=(int i)
Returns an iterator to the item at i positions backward from this iterator.
const_iterator operator-(int i) const
Returns an iterator to the item at i positions backward from this iterator.
const_iterator & operator+=(int i)
Advances the iterator by i items.
const_iterator operator--(int)
Post-decrement operator makes the preceding item current and returns an iterator to the previously cu...
const_iterator & operator++()
Pre-increment operator advances the iterator to the next item in the container and returns an iterato...
const variant get_data() const
Returns the current value, stored inside a std::reference_wrapper<T> and copied to a variant.
const variant operator*() const
Returns the underlying value in a variant stored in a std::reference_wrapper<T>.
const_iterator(const const_iterator &other)
Creates a copy of other.
~const_iterator()
Destroys the variant_sequential_view::const_iterator.
const_iterator & operator=(const_iterator other)
Assigns other to this.
const_iterator operator+(int i) const
Returns an iterator to the item at i positions forward from this iterator.
bool operator==(const const_iterator &other) const
Returns true if other points to the same item as this iterator; otherwise returns false.
const_iterator & operator--()
Pre-decrement operator makes the preceding item current and returns an iterator to the new current it...
const_iterator operator++(int)
Post-increment operator advances the iterator to the next item in the container and returns an iterat...
bool operator!=(const const_iterator &other) const
Returns true if other points to a different item than this iterator; otherwise returns false.
The variant_sequential_view describes a class that refers to an sequence container (e....
Definition variant_sequential_view.h:96
~variant_sequential_view() noexcept
Destroys the variant_sequential_view.
variant_sequential_view()
Constructs an invalid variant_sequential_view object.
variant_sequential_view(const variant_sequential_view &other)
Constructs a copy of the given variant_sequential_view other.
The variant class allows to store data of any type and convert between these types transparently.
Definition variant.h:199
Definition access_levels.h:34
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...