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 200 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 205 of file ConfigTree.h.

◆ Iterator

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

Definition at line 209 of file ConfigTree.h.

◆ iterator_category

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

Definition at line 203 of file ConfigTree.h.

◆ pointer

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

Definition at line 206 of file ConfigTree.h.

◆ reference

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

Definition at line 207 of file ConfigTree.h.

◆ value_type

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

Definition at line 204 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 211 of file ConfigTree.h.

213 : it_(it), tagname_(root), parent_(parent)
214 {
215 }

Member Function Documentation

◆ operator!=()

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

Definition at line 242 of file ConfigTree.h.

243 {
244 return it_ != other.it_;
245 }

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

◆ operator*()

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

Definition at line 224 of file ConfigTree.h.

225 {
226 // if this iterator has been incremented since the last dereference,
227 // tell the parent_ instance that a setting now has been parsed.
229 {
230 has_incremented_ = false;
231 parent_.markVisited<ValueType>(tagname_, Attr::TAG, false);
232 }
233 return ConfigTree(it_->second, parent_, tagname_)
234 .getValue<ValueType>();
235 }
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)

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 217 of file ConfigTree.h.

218 {
219 ++it_;
220 has_incremented_ = true;
221 return *this;
222 }

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 237 of file ConfigTree.h.

238 {
239 return it_ == other.it_;
240 }

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: