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

◆ Iterator

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

Definition at line 121 of file ConfigTree.h.

◆ iterator_category

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

125 : it_(it), tagname_(root), parent_(parent)
126 {
127 }

Member Function Documentation

◆ operator!=()

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

Definition at line 153 of file ConfigTree.h.

154 {
155 return it_ != other.it_;
156 }

References it_.

◆ operator*()

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

Definition at line 136 of file ConfigTree.h.

137 {
138 // if this iterator has been incremented since the last dereference,
139 // tell the parent_ instance that a subtree now has been parsed.
141 {
142 has_incremented_ = false;
144 }
145 return ConfigTree(it_->second, parent_, tagname_);
146 }
CountType & markVisited(std::string const &key, Attr const is_attr, bool peek_only) const

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

130 {
131 ++it_;
132 has_incremented_ = true;
133 return *this;
134 }

References has_incremented_, and it_.

◆ operator==()

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

Definition at line 148 of file ConfigTree.h.

149 {
150 return it_ == other.it_;
151 }

References it_.

Member Data Documentation

◆ has_incremented_

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

Definition at line 159 of file ConfigTree.h.

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

◆ it_

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

Definition at line 160 of file ConfigTree.h.

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

◆ parent_

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

Definition at line 164 of file ConfigTree.h.

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

◆ tagname_

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

Definition at line 163 of file ConfigTree.h.

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


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