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

◆ Iterator

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

Definition at line 203 of file ConfigTree.h.

◆ iterator_category

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

Definition at line 197 of file ConfigTree.h.

◆ pointer

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

Definition at line 200 of file ConfigTree.h.

◆ reference

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

Definition at line 201 of file ConfigTree.h.

◆ value_type

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

Definition at line 198 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

Member Function Documentation

◆ operator!=()

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

Definition at line 236 of file ConfigTree.h.

237 {
238 return it_ != other.it_;
239 }

References ValueIterator(), and it_.

◆ operator*()

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

Definition at line 218 of file ConfigTree.h.

219 {
220 // if this iterator has been incremented since the last dereference,
221 // tell the parent_ instance that a setting now has been parsed.
223 {
224 has_incremented_ = false;
225 parent_.markVisited<ValueType>(tagname_, Attr::TAG, false);
226 }
227 return ConfigTree(it_->second, parent_, tagname_)
228 .getValue<ValueType>();
229 }
ConfigTree(PTree &&top_level_tree, std::string filename, Callback error_cb, Callback warning_cb)

References BaseLib::ConfigTree::ConfigTree(), has_incremented_, it_, parent_, BaseLib::ConfigTree::TAG, and tagname_.

◆ operator++()

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

Definition at line 211 of file ConfigTree.h.

212 {
213 ++it_;
214 has_incremented_ = true;
215 return *this;
216 }

References ValueIterator(), has_incremented_, and it_.

◆ operator==()

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

Definition at line 231 of file ConfigTree.h.

232 {
233 return it_ == other.it_;
234 }

References ValueIterator(), and it_.

Member Data Documentation

◆ has_incremented_

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

Definition at line 242 of file ConfigTree.h.

Referenced by operator*(), and operator++().

◆ it_

template<typename ValueType>
Iterator BaseLib::ConfigTree::ValueIterator< ValueType >::it_
private

Definition at line 243 of file ConfigTree.h.

Referenced by ValueIterator(), operator!=(), operator*(), operator++(), and operator==().

◆ parent_

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

Definition at line 245 of file ConfigTree.h.

Referenced by ValueIterator(), and operator*().

◆ tagname_

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

Definition at line 244 of file ConfigTree.h.

Referenced by ValueIterator(), and operator*().


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