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

#include <ConfigTree.h>

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

Public Types

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

◆ Iterator

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

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

199  : it_(it), tagname_(root), parent_(parent)
200  {
201  }

Member Function Documentation

◆ operator!=()

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

Definition at line 228 of file ConfigTree.h.

229  {
230  return it_ != other.it_;
231  }

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

◆ operator*()

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

Definition at line 210 of file ConfigTree.h.

211  {
212  // if this iterator has been incremented since the last dereference,
213  // tell the parent_ instance that a setting now has been parsed.
214  if (has_incremented_)
215  {
216  has_incremented_ = false;
217  parent_.markVisited<ValueType>(tagname_, Attr::TAG, false);
218  }
219  return ConfigTree(it_->second, parent_, tagname_)
220  .getValue<ValueType>();
221  }
ConfigTree(PTree const &tree, std::string filename, Callback error_cb, Callback warning_cb)
Definition: ConfigTree.cpp:34
CountType & markVisited(std::string const &key, Attr const is_attr, bool peek_only) const

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

204  {
205  ++it_;
206  has_incremented_ = true;
207  return *this;
208  }

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

224  {
225  return it_ == other.it_;
226  }

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: