make config iteration usefull by also returning the key (oops)

This commit is contained in:
2023-12-12 16:51:43 +01:00
parent 0b4179c039
commit 2b20c2d2a4
2 changed files with 9 additions and 3 deletions

View File

@@ -42,6 +42,7 @@ struct SimpleConfigModel : public ConfigModelI {
// iteration
template<typename Type, typename RealType = Type>
struct SimpleConstEntryIteratorImpl : public ConfigModelI::ConstEntryProxy<Type>::ConstEntryIteratorI {
using BaseType = typename ConfigModelI::ConstEntryProxy<Type>;
using BaseIteratorIType = typename ConfigModelI::ConstEntryProxy<Type>::ConstEntryIteratorI;
using MapType = std::map<std::string, RealType>;
using MapTypeIterator = typename MapType::const_iterator;
@@ -55,7 +56,7 @@ struct SimpleConfigModel : public ConfigModelI {
std::unique_ptr<BaseIteratorIType> clone(void) override { return std::make_unique<SimpleConstEntryIteratorImpl>(_self); }
bool equal(const BaseIteratorIType& other) const override { return _self == static_cast<const SimpleConstEntryIteratorImpl&>(other)._self; }
void incrementOne(void) override { ++_self; }
Type getValue(void) const override { return _self->second; }
typename BaseType::Pair getValue(void) const override { return {_self->first, _self->second}; }
// helper
static ConfigModelI::ConstEntryProxy<Type> createRange(const MapTypeIterator& begin, const MapTypeIterator& end) {