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

◆ Iterator

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

Definition at line 119 of file ConfigTree.h.

◆ iterator_category

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

123 : it_(it), tagname_(root), parent_(parent)
124 {
125 }

Member Function Documentation

◆ operator!=()

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

Definition at line 151 of file ConfigTree.h.

152 {
153 return it_ != other.it_;
154 }

References it_.

◆ operator*()

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

Definition at line 134 of file ConfigTree.h.

135 {
136 // if this iterator has been incremented since the last dereference,
137 // tell the parent_ instance that a subtree now has been parsed.
139 {
140 has_incremented_ = false;
142 }
143 return ConfigTree(it_->second, parent_, tagname_);
144 }
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(), has_incremented_, it_, BaseLib::ConfigTree::markVisited(), parent_, BaseLib::ConfigTree::TAG, and tagname_.

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

◆ operator++()

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

Definition at line 127 of file ConfigTree.h.

128 {
129 ++it_;
130 has_incremented_ = true;
131 return *this;
132 }

References has_incremented_, and it_.

◆ operator==()

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

Definition at line 146 of file ConfigTree.h.

147 {
148 return it_ == other.it_;
149 }

References it_.

Member Data Documentation

◆ has_incremented_

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

Definition at line 157 of file ConfigTree.h.

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

◆ it_

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

Definition at line 158 of file ConfigTree.h.

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

◆ parent_

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

Definition at line 162 of file ConfigTree.h.

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

◆ tagname_

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

Definition at line 161 of file ConfigTree.h.

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


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