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 = 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

◆ Iterator

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

Definition at line 114 of file ConfigTree.h.

Constructor & Destructor Documentation

◆ SubtreeIterator()

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

Definition at line 116 of file ConfigTree.h.

118  : it_(it), tagname_(root), parent_(parent)
119  {
120  }

Member Function Documentation

◆ 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_.

◆ operator*()

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

Definition at line 129 of file ConfigTree.h.

130  {
131  // if this iterator has been incremented since the last dereference,
132  // tell the parent_ instance that a subtree now has been parsed.
133  if (has_incremented_)
134  {
135  has_incremented_ = false;
137  }
138  return ConfigTree(it_->second, parent_, tagname_);
139  }
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(), 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 122 of file ConfigTree.h.

123  {
124  ++it_;
125  has_incremented_ = true;
126  return *this;
127  }

References has_incremented_, and it_.

◆ operator==()

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

Definition at line 141 of file ConfigTree.h.

142  {
143  return it_ == other.it_;
144  }

References it_.

Member Data Documentation

◆ has_incremented_

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

Definition at line 152 of file ConfigTree.h.

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

◆ it_

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

Definition at line 153 of file ConfigTree.h.

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

◆ parent_

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

Definition at line 157 of file ConfigTree.h.

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

◆ tagname_

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

Definition at line 156 of file ConfigTree.h.

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


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