OGS
BaseLib::ConfigTree::SubtreeIterator Class Reference

Detailed Description

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

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

Definition at line 114 of file ConfigTree.h.

#include <ConfigTree.h>

Inheritance diagram for BaseLib::ConfigTree::SubtreeIterator:
[legend]
Collaboration diagram for BaseLib::ConfigTree::SubtreeIterator:
[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

 SubtreeIterator (Iterator const &it, std::string const &root, ConfigTree const &parent)
SubtreeIteratoroperator++ ()
ConfigTree operator* ()
bool operator== (SubtreeIterator const &other) const
bool operator!= (SubtreeIterator const &other) const

Protected Attributes

std::string const tagname_
ConfigTree const & parent_

Private Attributes

bool has_incremented_ = true
Iterator it_

Member Typedef Documentation

◆ difference_type

Definition at line 119 of file ConfigTree.h.

◆ Iterator

using BaseLib::ConfigTree::SubtreeIterator::Iterator = boost::property_tree::ptree::const_assoc_iterator

Definition at line 123 of file ConfigTree.h.

◆ iterator_category

Definition at line 117 of file ConfigTree.h.

◆ pointer

◆ reference

◆ value_type

Constructor & Destructor Documentation

◆ SubtreeIterator()

BaseLib::ConfigTree::SubtreeIterator::SubtreeIterator ( Iterator const & it,
std::string const & root,
ConfigTree const & parent )
inlineexplicit

Definition at line 125 of file ConfigTree.h.

127 : it_(it), tagname_(root), parent_(parent)
128 {
129 }

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

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

Member Function Documentation

◆ operator!=()

bool BaseLib::ConfigTree::SubtreeIterator::operator!= ( SubtreeIterator const & other) const
inline

Definition at line 155 of file ConfigTree.h.

156 {
157 return it_ != other.it_;
158 }

References SubtreeIterator(), and it_.

◆ operator*()

ConfigTree BaseLib::ConfigTree::SubtreeIterator::operator* ( )
inline

Definition at line 138 of file ConfigTree.h.

139 {
140 // if this iterator has been incremented since the last dereference,
141 // tell the parent_ instance that a subtree now has been parsed.
143 {
144 has_incremented_ = false;
145 parent_.markVisited(tagname_, Attr::TAG, false);
146 }
147 return ConfigTree(it_->second, parent_, tagname_);
148 }
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_.

Referenced by BaseLib::ConfigTree::ParameterIterator::operator*().

◆ operator++()

SubtreeIterator & BaseLib::ConfigTree::SubtreeIterator::operator++ ( )
inline

Definition at line 131 of file ConfigTree.h.

132 {
133 ++it_;
134 has_incremented_ = true;
135 return *this;
136 }

References SubtreeIterator(), has_incremented_, and it_.

◆ operator==()

bool BaseLib::ConfigTree::SubtreeIterator::operator== ( SubtreeIterator const & other) const
inline

Definition at line 150 of file ConfigTree.h.

151 {
152 return it_ == other.it_;
153 }

References SubtreeIterator(), and it_.

Member Data Documentation

◆ has_incremented_

bool BaseLib::ConfigTree::SubtreeIterator::has_incremented_ = true
private

Definition at line 161 of file ConfigTree.h.

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

◆ it_

Iterator BaseLib::ConfigTree::SubtreeIterator::it_
private

Definition at line 162 of file ConfigTree.h.

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

◆ parent_

ConfigTree const& BaseLib::ConfigTree::SubtreeIterator::parent_
protected

◆ tagname_

std::string const BaseLib::ConfigTree::SubtreeIterator::tagname_
protected

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