3#include "util/Assert.hpp"
4#include "util/config/ConfigDefinition.hpp"
5#include "util/config/ObjectView.hpp"
6#include "util/config/ValueView.hpp"
15namespace util::config {
33 using iterator_category = std::forward_iterator_tag;
34 using pointer = T
const*;
35 using reference = T
const&;
47 if (arr_.clioConfig_.get().contains(arr_.prefix_)) {
48 ASSERT((std::is_same_v<T, ValueView>),
"Array iterator must be ValueView");
50 ASSERT((std::is_same_v<T, ObjectView>),
"Array iterator must be ObjectView");
62 if (index_ < arr_.size())
76 if (index_ < arr_.size())
89 if constexpr (std::is_same_v<T, ObjectView>) {
90 return ObjectView{arr_.prefix_, index_, arr_.clioConfig_.get()};
92 return arr_.clioConfig_.get().getValueInArray(arr_.prefix_, index_);
106 return &arr_ == &other.arr_ && index_ == other.index_;
118 return &arr_ != &other.arr_ || index_ != other.index_;
123 std::size_t index_ = 0;
131 template <
typename T>
143 template <
typename T>
153 template <
typename T>
161 [[nodiscard]] Elements<ValueView>
169 [[nodiscard]] Elements<ObjectView>
196 valueAt(std::size_t idx)
const;
208 std::reference_wrapper<ClioConfigDefinition const> clioConfig_;
231 return array_.begin<T>();
242 return array_.end<T>();
A range over the elements of an array, viewed as T (ValueView or ObjectView).
Definition ArrayView.hpp:212
ArrayIterator< T > end() const
Returns an iterator past the last element.
Definition ArrayView.hpp:240
Elements(ArrayView array)
Constructs the range over the given array.
Definition ArrayView.hpp:219
ArrayIterator< T > begin() const
Returns an iterator to the first element.
Definition ArrayView.hpp:229
ObjectView objectAt(std::size_t idx) const
Returns an ObjectView at the specified index.
Definition ArrayView.cpp:39
auto end() const
Returns an iterator to the end of the Array.
Definition ArrayView.hpp:145
auto begin() const
Returns an iterator to the beginning of the Array.
Definition ArrayView.hpp:133
size_t size() const
Returns the number of elements in the array.
Definition ArrayView.cpp:33
Elements< ObjectView > objects() const
Returns a range over the elements of an array of objects.
Definition ArrayView.hpp:256
Elements< ValueView > values() const
Returns a range over the elements of an array of values.
Definition ArrayView.hpp:250
ArrayView(std::string_view prefix, ClioConfigDefinition const &configDef)
Constructs an ArrayView with the given prefix and config definition.
Definition ArrayView.cpp:15
ValueView valueAt(std::size_t idx) const
Returns a ValueView at the specified index.
Definition ArrayView.cpp:21
All the config data will be stored and extracted from this class.
Definition ConfigDefinition.hpp:31
Provides a view into a subset of configuration data defined by a prefix.
Definition ObjectView.hpp:21
Provides view into ConfigValues that represents values in Clio Config.
Definition ValueView.hpp:27
Custom iterator class which contains config object or value underneath ArrayView.
Definition ArrayView.hpp:30
ArrayIterator & operator++()
Prefix increment operator.
Definition ArrayView.hpp:60
bool operator!=(ArrayIterator const &other) const
Inequality operator.
Definition ArrayView.hpp:116
bool operator==(ArrayIterator const &other) const
Equality operator.
Definition ArrayView.hpp:104
ArrayIterator(ArrayView const &arr, std::size_t index)
Constructs an ArrayIterator with underlying ArrayView and index value.
Definition ArrayView.hpp:45
T operator*()
Dereference operator to get a ValueView or ObjectView.
Definition ArrayView.hpp:87
ArrayIterator operator++(int)
Postfix increment operator.
Definition ArrayView.hpp:73