3#include "util/Assert.hpp"
4#include "util/config/ConfigDefinition.hpp"
5#include "util/config/ObjectView.hpp"
6#include "util/config/ValueView.hpp"
14namespace util::config {
30 using iterator_category = std::forward_iterator_tag;
31 using pointer = T
const*;
32 using reference = T
const&;
43 if (arr_.clioConfig_.get().contains(arr_.prefix_)) {
44 ASSERT((std::is_same_v<T, ValueView>),
"Array iterator must be ValueView");
46 ASSERT((std::is_same_v<T, ObjectView>),
"Array iterator must be ObjectView");
58 if (index_ < arr_.size())
72 if (index_ < arr_.size())
85 if constexpr (std::is_same_v<T, ObjectView>) {
86 return ObjectView{arr_.prefix_, index_, arr_.clioConfig_.get()};
88 return arr_.clioConfig_.get().getValueInArray(arr_.prefix_, index_);
102 return &arr_ == &(other.arr_) && index_ == other.index_;
114 return &arr_ != &(other.arr_) || index_ != other.index_;
119 std::size_t index_ = 0;
127 template <
typename T>
139 template <
typename T>
170 valueAt(std::size_t idx)
const;
182 std::reference_wrapper<ClioConfigDefinition const> clioConfig_;
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:141
auto begin() const
Returns an iterator to the beginning of the Array.
Definition ArrayView.hpp:129
size_t size() const
Returns the number of elements in the array.
Definition ArrayView.cpp:33
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:29
ArrayIterator & operator++()
Prefix increment operator.
Definition ArrayView.hpp:56
bool operator!=(ArrayIterator const &other) const
Inequality operator.
Definition ArrayView.hpp:112
bool operator==(ArrayIterator const &other) const
Equality operator.
Definition ArrayView.hpp:100
ArrayIterator(ArrayView const &arr, std::size_t index)
Constructs an ArrayIterator with underlying ArrayView and index value.
Definition ArrayView.hpp:41
T operator*()
Dereference operator to get a ValueView or ObjectView.
Definition ArrayView.hpp:83
ArrayIterator operator++(int)
Postfix increment operator.
Definition ArrayView.hpp:69