The variant_array_view describes a class that refers to an array inside a variant. More...
#include <variant_array_view.h>
Public Member Functions | |
variant_array_view () | |
Constructs an invalid variant_array_view object. More... | |
variant_array_view (const variant_array_view &other) | |
Constructs a copy of the given variant_array_view other . More... | |
variant_array_view (variant_array_view &&other) | |
Constructs a new variant_array_view via move constructor. More... | |
~variant_array_view () | |
Destroys the variant_array_view and the contained data. More... | |
std::size_t | get_rank () const |
Gets the rank (number of dimensions) of the array. More... | |
type | get_rank_type (std::size_t index) const |
Gets the type of the given rank index. More... | |
std::size_t | get_size () const |
Returns the size of the first dimension from the array. More... | |
std::size_t | get_size (std::size_t index_1) const |
Returns the size of the array at the second dimension at index index_1 . More... | |
std::size_t | get_size (std::size_t index_1, std::size_t index_2) const |
Returns the size of the array at the third dimension at index index_2 , relative to the first dimension at index index_1 . More... | |
std::size_t | get_size_variadic (const std::vector< std::size_t > &index_list) const |
Returns the size from of the array at the specified indices in list index_list . More... | |
type | get_type () const |
Returns the type object of this array. More... | |
variant | get_value (std::size_t index_1) const |
Returns the value of the array in the first dimension at index index_1 . More... | |
variant | get_value (std::size_t index_1, std::size_t index_2) const |
Returns the value of the array in the second dimension at index index_2 , relative to the first dimension at index index_1 . More... | |
variant | get_value (std::size_t index_1, std::size_t index_2, std::size_t index_3) const |
Returns the value of the array in the third dimension at index index_3 , relative to the first dimension at index index_1 and second dimension at index index_2 . More... | |
variant | get_value_variadic (const std::vector< std::size_t > &index_list) const |
Returns the value of the array relative to indices given in the list index_list . More... | |
bool | insert_value (std::size_t index_1, argument arg) |
Inserts the given argument arg into the array, in the first dimension at index index_1 . More... | |
bool | insert_value (std::size_t index_1, std::size_t index_2, argument arg) |
Inserts the given argument arg into the array, in the second dimension at index index_2 , relative to the first dimension at index index_1 . More... | |
bool | insert_value (std::size_t index_1, std::size_t index_2, std::size_t index_3, argument arg) |
Inserts the given argument arg into the array, in the third dimension at index index_3 , relative to the first dimension at index index_1 and the second dimension at index index_2 . More... | |
bool | insert_value_variadic (const std::vector< std::size_t > &index_list, argument arg) |
Inserts the given argument arg into the array, relative to to indices given in the list index_list . More... | |
bool | is_dynamic () const |
Returns true if this array is dynamic, otherwise false. More... | |
bool | is_valid () const |
Returns true if this variant_array_view is valid, that means the object is holding some data. More... | |
operator bool () const | |
Convenience function to check if this variant_array_view is valid or not. More... | |
variant_array_view & | operator= (const variant_array_view &other) |
Assigns the value of the other variant_array_view to this variant_array_view. More... | |
bool | remove_value (std::size_t index_1) |
Removes the value at index index_1 in the first dimension of the array. More... | |
bool | remove_value (std::size_t index_1, std::size_t index_2) |
Removes the value at index index_2 in the second dimension of the array relative to the first dimension at index index_1 . More... | |
bool | remove_value (std::size_t index_1, std::size_t index_2, std::size_t index_3) |
Removes the value at index index_3 in the third dimension of the array. More... | |
bool | remove_value_variadic (const std::vector< std::size_t > &index_list) |
Removes the value at index index_1 in the first dimension of the array. More... | |
bool | set_size (std::size_t new_size) |
Sets the size of the array at the first dimension to new_size . More... | |
bool | set_size (std::size_t new_size, std::size_t index_1) |
Sets the size of the array at the second dimension relative to the first dimension at index index_1 to new_size . More... | |
bool | set_size (std::size_t new_size, std::size_t index_1, std::size_t index_2) |
Sets the size of the array at the third dimension relative to the first dimension at index index_1 and the second dimension at index index_2 to new_size . More... | |
bool | set_size_variadic (std::size_t new_size, const std::vector< std::size_t > &index_list) |
Sets the size of the array at the specified indices in list index_list . More... | |
bool | set_value (argument arg) |
Copies the content of the the array arg into the underlying array. More... | |
bool | set_value (std::size_t index_1, argument arg) |
Set the content of the the argument arg into the in the first dimension of the array at index index_1 . More... | |
bool | set_value (std::size_t index_1, std::size_t index_2, argument arg) |
Set the content of the the argument arg into the in the second dimension at index_2 of the array relative to the first dimension at index_1. More... | |
bool | set_value (std::size_t index_1, std::size_t index_2, std::size_t index_3, argument arg) |
Set the content of the the argument arg into the in the third dimension at index_3 of the array relative to the first dimension at index_1 and second dimension at index_2 . More... | |
bool | set_value_variadic (const std::vector< std::size_t > &index_list, argument arg) |
Set the content of the the argument arg into the array in the n-th dimension given in the list index_list . More... | |
void | swap (variant_array_view &other) |
Swaps this variant_array_view with the other variant_array_view. More... | |
Detailed Description
The variant_array_view describes a class that refers to an array inside a variant.
With an instance of that class you can set/get values of an array, without having access to the type declaration of the type or it's elements.
A variant_array_view can be created directly from a variant with its member function create_array_view().
- Remarks
- The instance of an variant_array_view is always valid till the referenced variant is valid, otherwise accessing a variant_array_view is undefined behaviour.
Meta Information
An array is defined by its rank, it's size and whether he is dynamic or not.
The rank of an array describes the number of dimensions. E.g. int[10]
has a rank of 1
. int[2][10]
has an rank of 2
and so on. For retrieving the size of an array use get_size(). With this function it is also possible to determine the size of the array relative to its rank level and it's index. Take a look at following example:
When the given array type is dynamic you can change the size of the array, therefore set_size() should be used. A value of an array can be accessed with get_value() or set with set_value. These function expect an index for up to rank level 3. The array class has here one interesting feature, you can set and get the value of an array up to its rank count. e.g:
When you have arrays bigger then rank count three, use the counterpart functions: get_value_variadic and set_value_variadic which expects a list of indices. When the array is dynamic it is also possible to insert or remove values.
RTTR recognize whether a type is an array or not with the help of the array_mapper class template. This call can access different array types via one common interface. At the moment there exist specializations for following types: std::array<T, N>
, std::vector<T>
, std::list<T>
and raw-arrays T[N]
.
Copying and Assignment
A variant_array_view object can be copied and assigned, however each copy will reference the address of same underlying variant array value.
Typical Usage
- See also
- variant
Constructor & Destructor Documentation
rttr::variant_array_view::variant_array_view | ( | ) |
Constructs an invalid variant_array_view object.
- See also
- is_valid()
rttr::variant_array_view::variant_array_view | ( | const variant_array_view & | other | ) |
Constructs a copy of the given variant_array_view other
.
rttr::variant_array_view::variant_array_view | ( | variant_array_view && | other | ) |
Constructs a new variant_array_view via move constructor.
rttr::variant_array_view::~variant_array_view | ( | ) |
Destroys the variant_array_view and the contained data.
Member Function Documentation
std::size_t rttr::variant_array_view::get_rank | ( | ) | const |
Gets the rank (number of dimensions) of the array.
Take a look at following return values:
=>int
[4]1
=>int
[4][4]2
=>int
[4][4][4]3
- ...
- Returns
- Returns the rank of the array.
type rttr::variant_array_view::get_rank_type | ( | std::size_t | index | ) | const |
Gets the type of the given rank index.
Take a look at following return value for an array of type: int[2][10]
=>get_rank_type(0)
int[2][10]
=>get_rank_type(1)
int[10]
=>get_rank_type(2)
int
=> INVALIDget_rank_type(3)
- Returns
- The rank type at the given dimension
index
.
std::size_t rttr::variant_array_view::get_size | ( | ) | const |
Returns the size of the first dimension from the array.
- Returns
- The size of the array.
std::size_t rttr::variant_array_view::get_size | ( | std::size_t | index_1 | ) | const |
Returns the size of the array at the second dimension at index index_1
.
- Returns
- The size of the array.
std::size_t rttr::variant_array_view::get_size | ( | std::size_t | index_1, |
std::size_t | index_2 | ||
) | const |
Returns the size of the array at the third dimension at index index_2
, relative to the first dimension at index index_1
.
- Returns
- The size of the array.
std::size_t rttr::variant_array_view::get_size_variadic | ( | const std::vector< std::size_t > & | index_list | ) | const |
Returns the size from of the array at the specified indices in list index_list
.
The index count specify the array dimension.
- Returns
- The size of the array.
type rttr::variant_array_view::get_type | ( | ) | const |
variant rttr::variant_array_view::get_value | ( | std::size_t | index_1 | ) | const |
Returns the value of the array in the first dimension at index index_1
.
- Returns
- The value of the given array at the specified indices.
variant rttr::variant_array_view::get_value | ( | std::size_t | index_1, |
std::size_t | index_2 | ||
) | const |
Returns the value of the array in the second dimension at index index_2
, relative to the first dimension at index index_1
.
- Returns
- The value of the given array at the specified indices.
variant rttr::variant_array_view::get_value | ( | std::size_t | index_1, |
std::size_t | index_2, | ||
std::size_t | index_3 | ||
) | const |
Returns the value of the array in the third dimension at index index_3
, relative to the first dimension at index index_1
and second dimension at index index_2
.
- Returns
- The value of the given array at the specified indices.
variant rttr::variant_array_view::get_value_variadic | ( | const std::vector< std::size_t > & | index_list | ) | const |
Returns the value of the array relative to indices given in the list index_list
.
- Returns
- The value of the given array at the specified indices.
bool rttr::variant_array_view::insert_value | ( | std::size_t | index_1, |
argument | arg | ||
) |
Inserts the given argument arg
into the array, in the first dimension at index index_1
.
- Remarks
- This operation is only possible when the array is dynamic.
- Returns
- True if
arg
could be inserted, otherwise false.
bool rttr::variant_array_view::insert_value | ( | std::size_t | index_1, |
std::size_t | index_2, | ||
argument | arg | ||
) |
Inserts the given argument arg
into the array, in the second dimension at index index_2
, relative to the first dimension at index index_1
.
- Remarks
- This operation is only possible when the array is dynamic.
- Returns
- True if
arg
could be inserted, otherwise false.
bool rttr::variant_array_view::insert_value | ( | std::size_t | index_1, |
std::size_t | index_2, | ||
std::size_t | index_3, | ||
argument | arg | ||
) |
Inserts the given argument arg
into the array, in the third dimension at index index_3
, relative to the first dimension at index index_1
and the second dimension at index index_2
.
- Remarks
- This operation is only possible when the array is dynamic.
- Returns
- True if
arg
could be inserted, otherwise false.
bool rttr::variant_array_view::insert_value_variadic | ( | const std::vector< std::size_t > & | index_list, |
argument | arg | ||
) |
Inserts the given argument arg
into the array, relative to to indices given in the list index_list
.
- Remarks
- This operation is only possible when the array is dynamic.
- Returns
- True if
arg
could be inserted, otherwise false.
bool rttr::variant_array_view::is_dynamic | ( | ) | const |
Returns true if this array is dynamic, otherwise false.
When an array is dynamic, it is possible to change its size or insert and remove values from it.
- See also
- set_size(), insert_value(), remove_value()
- Returns
- A boolean flag which indicates whether this array is dynamic or not.
bool rttr::variant_array_view::is_valid | ( | ) | const |
Returns true if this variant_array_view is valid, that means the object is holding some data.
When the variant_array_view doesn't hold any data it will return false.
- Returns
- True if this array is valid, otherwise false.
|
explicit |
Convenience function to check if this variant_array_view is valid or not.
- See also
- is_valid()
- Returns
- True if this variant_array_view is valid, otherwise false.
variant_array_view& rttr::variant_array_view::operator= | ( | const variant_array_view & | other | ) |
Assigns the value of the other variant_array_view to this variant_array_view.
- Returns
- A reference to the variant_array_view with the new data.
bool rttr::variant_array_view::remove_value | ( | std::size_t | index_1 | ) |
Removes the value at index index_1
in the first dimension of the array.
- Returns
- True if the value could be removed, otherwise false.
bool rttr::variant_array_view::remove_value | ( | std::size_t | index_1, |
std::size_t | index_2 | ||
) |
Removes the value at index index_2
in the second dimension of the array relative to the first dimension at index index_1
.
- Returns
- True if the value could be removed, otherwise false.
bool rttr::variant_array_view::remove_value | ( | std::size_t | index_1, |
std::size_t | index_2, | ||
std::size_t | index_3 | ||
) |
Removes the value at index index_3
in the third dimension of the array.
relative to the first dimension at index index_1
and the second dimension at index index_2
.
- Returns
- True if the value could be removed, otherwise false.
bool rttr::variant_array_view::remove_value_variadic | ( | const std::vector< std::size_t > & | index_list | ) |
Removes the value at index index_1
in the first dimension of the array.
- Returns
- True if the value could be removed, otherwise false.
bool rttr::variant_array_view::set_size | ( | std::size_t | new_size | ) |
Sets the size of the array at the first dimension to new_size
.
- Returns
- True, when the size of the array could be changed, otherwise false.
bool rttr::variant_array_view::set_size | ( | std::size_t | new_size, |
std::size_t | index_1 | ||
) |
Sets the size of the array at the second dimension relative to the first dimension at index index_1
to new_size
.
- Returns
- True, when the size of the array could be changed, otherwise false.
bool rttr::variant_array_view::set_size | ( | std::size_t | new_size, |
std::size_t | index_1, | ||
std::size_t | index_2 | ||
) |
Sets the size of the array at the third dimension relative to the first dimension at index index_1
and the second dimension at index index_2
to new_size
.
- Returns
- True, when the size of the array could be changed, otherwise false.
bool rttr::variant_array_view::set_size_variadic | ( | std::size_t | new_size, |
const std::vector< std::size_t > & | index_list | ||
) |
Sets the size of the array at the specified indices in list index_list
.
The index count specify the array dimension.
- Returns
- True, when the size of the array could be changed, otherwise false.
bool rttr::variant_array_view::set_value | ( | argument | arg | ) |
Copies the content of the the array arg
into the underlying array.
- Returns
- True if the value could be set, otherwise false.
bool rttr::variant_array_view::set_value | ( | std::size_t | index_1, |
argument | arg | ||
) |
Set the content of the the argument arg
into the in the first dimension of the array at index index_1
.
- Returns
- True if the value could be set, otherwise false.
bool rttr::variant_array_view::set_value | ( | std::size_t | index_1, |
std::size_t | index_2, | ||
argument | arg | ||
) |
Set the content of the the argument arg
into the in the second dimension at index_2
of the array relative to the first dimension at index_1.
- Returns
- True if the value could be set, otherwise false.
bool rttr::variant_array_view::set_value | ( | std::size_t | index_1, |
std::size_t | index_2, | ||
std::size_t | index_3, | ||
argument | arg | ||
) |
Set the content of the the argument arg
into the in the third dimension at index_3
of the array relative to the first dimension at index_1
and second dimension at index_2
.
- Returns
- True if the value could be set, otherwise false.
bool rttr::variant_array_view::set_value_variadic | ( | const std::vector< std::size_t > & | index_list, |
argument | arg | ||
) |
Set the content of the the argument arg
into the array in the n-th dimension given in the list index_list
.
- Remarks
- Use this function when you want to set a value into a dimension which is bigger then three. Otherwise use the corresponding functions of set_value() .
- Returns
- True if the value could be set, otherwise false.
void rttr::variant_array_view::swap | ( | variant_array_view & | other | ) |
Swaps this variant_array_view with the other variant_array_view.
The documentation for this class was generated from the following file: