#include <genesis/tree/formats/newick/input_iterator.hpp>
Iterate an input stream and parse it as Newick trees.
This class allows to iterate over an input stream, iterpreting it as Newick trees, and yielding one such tree per iteration step. This is useful for processing large files without having to keep them fully in memory.
Example:
for( auto const& t : NewickInputIterator( from_file( "/path/to/trees.newick" ))) { std::cout << t.node_count() << "\n"; }
Alternatively, the following also works:
auto it = NewickInputIterator( from_file( "/path/to/trees.newick" )); while( it ) { Tree const& t = *it; std::cout << t.node_count() << "\n"; ++it; }
Use functions such as utils::from_file() and utils::from_string() to conveniently get an input source that can be used here.
See NewickReader for a description of the expected format. In order to change the reading behaviour, a NewickReader object can be handed over from which the settings are copied.
Definition at line 76 of file tree/formats/newick/input_iterator.hpp.
Public Member Functions | |
NewickInputIterator () | |
Create a default instance, with no input. More... | |
NewickInputIterator (self_type &&)=default | |
NewickInputIterator (self_type const &)=delete | |
NewickInputIterator (std::shared_ptr< utils::BaseInputSource > source) | |
Create an instance that reads from an input source, using a default NewickReader. More... | |
NewickInputIterator (std::shared_ptr< utils::BaseInputSource > source, NewickReader const &settings) | |
Create an instance that reads from an input source, using the settings of a given NewickReader. More... | |
~NewickInputIterator ()=default | |
self_type & | begin () |
Beginning of the iterator. More... | |
Tree const & | dereference () const |
self_type | end () |
End of the iterator. More... | |
void | increment () |
operator bool () const | |
Return true iff dereferencing is valid, i.e., iff there is a Tree available. More... | |
bool | operator!= (self_type const &other) const |
Tree const & | operator* () const |
self_type & | operator++ () |
Tree const * | operator-> () const |
self_type & | operator= (self_type &&)=default |
self_type & | operator= (self_type const &)=delete |
bool | operator== (self_type const &other) const |
Public Types | |
using | iterator_category = std::input_iterator_tag |
using | self_type = NewickInputIterator |
|
inline |
Create a default instance, with no input.
Definition at line 94 of file tree/formats/newick/input_iterator.hpp.
|
inlineexplicit |
Create an instance that reads from an input source, using a default NewickReader.
Definition at line 103 of file tree/formats/newick/input_iterator.hpp.
|
inline |
Create an instance that reads from an input source, using the settings of a given NewickReader.
Definition at line 119 of file tree/formats/newick/input_iterator.hpp.
|
default |
|
delete |
|
default |
|
inline |
Beginning of the iterator.
This is a bit uncommon, as the iterator provides its own begin() and end() functions. We do this to allow the easy use case that is explained above.
Definition at line 190 of file tree/formats/newick/input_iterator.hpp.
|
inline |
Definition at line 175 of file tree/formats/newick/input_iterator.hpp.
|
inline |
End of the iterator.
Beginning of the iterator. This is a bit uncommon, as the iterator provides its own begin() and end() functions. We do this to allow the easy use case that is explained above.
Definition at line 200 of file tree/formats/newick/input_iterator.hpp.
|
inline |
Definition at line 211 of file tree/formats/newick/input_iterator.hpp.
|
inlineexplicit |
Return true iff dereferencing is valid, i.e., iff there is a Tree available.
Definition at line 156 of file tree/formats/newick/input_iterator.hpp.
|
inline |
Definition at line 148 of file tree/formats/newick/input_iterator.hpp.
|
inline |
Definition at line 165 of file tree/formats/newick/input_iterator.hpp.
|
inline |
Definition at line 205 of file tree/formats/newick/input_iterator.hpp.
|
inline |
Definition at line 170 of file tree/formats/newick/input_iterator.hpp.
|
inline |
Definition at line 143 of file tree/formats/newick/input_iterator.hpp.
using iterator_category = std::input_iterator_tag |
Definition at line 85 of file tree/formats/newick/input_iterator.hpp.
using self_type = NewickInputIterator |
Definition at line 84 of file tree/formats/newick/input_iterator.hpp.