OGS
BaseLib::ConfigTree::ValueIterator< ValueType > Class Template Reference

Detailed Description

template<typename ValueType>
class BaseLib::ConfigTree::ValueIterator< ValueType >

A wrapper around a Boost Iterator for iterating over ranges of values.

The methods of this class tell the associated (parent) ConfigTree object when a setting has been parsed.

Definition at line 196 of file ConfigTree.h.

#include <ConfigTree.h>

Collaboration diagram for BaseLib::ConfigTree::ValueIterator< ValueType >:
[legend]

Public Types

using iterator_category = std::input_iterator_tag
 
using value_type = ConfigTree
 
using difference_type = std::ptrdiff_t
 
using pointer = ConfigTree *
 
using reference = ConfigTree &
 
using Iterator = boost::property_tree::ptree::const_assoc_iterator
 

Public Member Functions

 ValueIterator (Iterator const &it, std::string const &root, ConfigTree const &parent)
 
ValueIterator< ValueType > & operator++ ()
 
ValueType operator* ()
 
bool operator== (ValueIterator< ValueType > const &other) const
 
bool operator!= (ValueIterator< ValueType > const &other) const
 

Private Attributes

bool has_incremented_ = true
 
Iterator it_
 
std::string const tagname_
 
ConfigTree const & parent_
 

Member Typedef Documentation

◆ difference_type

template<typename ValueType >
using BaseLib::ConfigTree::ValueIterator< ValueType >::difference_type = std::ptrdiff_t

Definition at line 201 of file ConfigTree.h.

◆ Iterator

template<typename ValueType >
using BaseLib::ConfigTree::ValueIterator< ValueType >::Iterator = boost::property_tree::ptree::const_assoc_iterator

Definition at line 205 of file ConfigTree.h.

◆ iterator_category

template<typename ValueType >
using BaseLib::ConfigTree::ValueIterator< ValueType >::iterator_category = std::input_iterator_tag

Definition at line 199 of file ConfigTree.h.

◆ pointer

template<typename ValueType >
using BaseLib::ConfigTree::ValueIterator< ValueType >::pointer = ConfigTree*

Definition at line 202 of file ConfigTree.h.

◆ reference

template<typename ValueType >
using BaseLib::ConfigTree::ValueIterator< ValueType >::reference = ConfigTree&

Definition at line 203 of file ConfigTree.h.

◆ value_type

template<typename ValueType >
using BaseLib::ConfigTree::ValueIterator< ValueType >::value_type = ConfigTree

Definition at line 200 of file ConfigTree.h.

Constructor & Destructor Documentation

◆ ValueIterator()

template<typename ValueType >
BaseLib::ConfigTree::ValueIterator< ValueType >::ValueIterator ( Iterator const &  it,
std::string const &  root,
ConfigTree const &  parent 
)
inlineexplicit

Definition at line 207 of file ConfigTree.h.

209 : it_(it), tagname_(root), parent_(parent)
210 {
211 }

Member Function Documentation

◆ operator!=()

template<typename ValueType >
bool BaseLib::ConfigTree::ValueIterator< ValueType >::operator!= ( ValueIterator< ValueType > const &  other) const
inline

Definition at line 238 of file ConfigTree.h.

239 {
240 return it_ != other.it_;
241 }

References BaseLib::ConfigTree::ValueIterator< ValueType >::it_.

◆ operator*()

template<typename ValueType >
ValueType BaseLib::ConfigTree::ValueIterator< ValueType >::operator* ( )
inline

Definition at line 220 of file ConfigTree.h.

221 {
222 // if this iterator has been incremented since the last dereference,
223 // tell the parent_ instance that a setting now has been parsed.
225 {
226 has_incremented_ = false;
227 parent_.markVisited<ValueType>(tagname_, Attr::TAG, false);
228 }
229 return ConfigTree(it_->second, parent_, tagname_)
230 .getValue<ValueType>();
231 }
CountType & markVisited(std::string const &key, Attr const is_attr, bool peek_only) const
ConfigTree(PTree &&top_level_tree, std::string filename, Callback error_cb, Callback warning_cb)
Definition: ConfigTree.cpp:34

References BaseLib::ConfigTree::ConfigTree(), BaseLib::ConfigTree::ValueIterator< ValueType >::has_incremented_, BaseLib::ConfigTree::ValueIterator< ValueType >::it_, BaseLib::ConfigTree::markVisited(), BaseLib::ConfigTree::ValueIterator< ValueType >::parent_, BaseLib::ConfigTree::TAG, and BaseLib::ConfigTree::ValueIterator< ValueType >::tagname_.

◆ operator++()

template<typename ValueType >
ValueIterator< ValueType > & BaseLib::ConfigTree::ValueIterator< ValueType >::operator++ ( )
inline

Definition at line 213 of file ConfigTree.h.

214 {
215 ++it_;
216 has_incremented_ = true;
217 return *this;
218 }

References BaseLib::ConfigTree::ValueIterator< ValueType >::has_incremented_, and BaseLib::ConfigTree::ValueIterator< ValueType >::it_.

◆ operator==()

template<typename ValueType >
bool BaseLib::ConfigTree::ValueIterator< ValueType >::operator== ( ValueIterator< ValueType > const &  other) const
inline

Definition at line 233 of file ConfigTree.h.

234 {
235 return it_ == other.it_;
236 }

References BaseLib::ConfigTree::ValueIterator< ValueType >::it_.

Member Data Documentation

◆ has_incremented_

template<typename ValueType >
bool BaseLib::ConfigTree::ValueIterator< ValueType >::has_incremented_ = true
private

◆ it_

◆ parent_

template<typename ValueType >
ConfigTree const& BaseLib::ConfigTree::ValueIterator< ValueType >::parent_
private

◆ tagname_

template<typename ValueType >
std::string const BaseLib::ConfigTree::ValueIterator< ValueType >::tagname_
private

The documentation for this class was generated from the following file: