22#include "util/Assert.hpp"
23#include "util/newconfig/ConfigDefinition.hpp"
24#include "util/newconfig/ObjectView.hpp"
25#include "util/newconfig/ValueView.hpp"
33namespace util::config {
49 using iterator_category = std::forward_iterator_tag;
50 using pointer = T
const*;
51 using reference = T
const&;
62 if (arr_.clioConfig_.get().contains(arr_.prefix_)) {
63 ASSERT((std::is_same_v<T, ValueView>),
"Array iterator must be ValueView");
65 ASSERT((std::is_same_v<T, ObjectView>),
"Array iterator must be ObjectView");
77 if (index_ < arr_.
size())
91 if (index_ < arr_.
size())
104 if constexpr (std::is_same_v<T, ObjectView>) {
105 return ObjectView{arr_.prefix_, index_, arr_.clioConfig_.get()};
107 return arr_.clioConfig_.get().getValueInArray(arr_.prefix_, index_);
120 return &arr_ == &(other.arr_) && index_ == other.index_;
132 return &arr_ != &(other.arr_) || index_ != other.index_;
137 std::size_t index_ = 0;
145 template <
typename T>
157 template <
typename T>
188 valueAt(std::size_t idx)
const;
200 std::reference_wrapper<ClioConfigDefinition const> clioConfig_;
View for array structure for config.
Definition ArrayView.hpp:42
ObjectView objectAt(std::size_t idx) const
Returns an ObjectView at the specified index.
Definition ArrayView.cpp:54
auto end() const
Returns an iterator to the end of the Array.
Definition ArrayView.hpp:159
auto begin() const
Returns an iterator to the beginning of the Array.
Definition ArrayView.hpp:147
size_t size() const
Returns the number of elements in the array.
Definition ArrayView.cpp:48
ArrayView(std::string_view prefix, ClioConfigDefinition const &configDef)
Constructs an ArrayView with the given prefix and config definition.
Definition ArrayView.cpp:34
ValueView valueAt(std::size_t idx) const
Returns a ValueView at the specified index.
Definition ArrayView.cpp:40
All the config data will be stored and extracted from this class.
Definition ConfigDefinition.hpp:54
Provides a view into a subset of configuration data defined by a prefix.
Definition ObjectView.hpp:40
Provides view into ConfigValues that represents values in Clio Config.
Definition ValueView.hpp:46
Custom iterator class which contains config object or value underneath ArrayView.
Definition ArrayView.hpp:48
ArrayIterator & operator++()
Prefix increment operator.
Definition ArrayView.hpp:75
bool operator!=(ArrayIterator const &other) const
Inequality operator.
Definition ArrayView.hpp:130
bool operator==(ArrayIterator const &other) const
Equality operator.
Definition ArrayView.hpp:118
ArrayIterator(ArrayView const &arr, std::size_t index)
Constructs an ArrayIterator with underlying ArrayView and index value.
Definition ArrayView.hpp:60
T operator*()
Dereference operator to get a ValueView or ObjectView.
Definition ArrayView.hpp:102
ArrayIterator operator++(int)
Postfix increment operator.
Definition ArrayView.hpp:88