A toolkit for working with phylogenetic data.
v0.18.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Taxopath Class Reference

#include <genesis/taxonomy/taxopath.hpp>

Detailed Description

Helper class to store a taxonomic path.

We call a string of the form

Animalia;Vertebrata;Mammalia;Carnivora

a taxonomic path. Those strings are often used in taxonomic databases, and usually use semicola to separate their parts.

This class stores such a string, splitted into its single elements. Each such element can be seen as a Taxon; thus, a Taxopath can be added to a Taxonomy.

For example, the above taxonomic path would be stored as

[ "Animalia", "Vertebrata", "Mammalia", "Carnivora" ]

Each of those strings is then called a taxonomic path element.

This class is mainly an intermediate broker between a taxonomic path string and a Taxon. It is useful to transition between a Taxonomy and its string representation, for storing it in a text file or some other database format. It is also useful for looking up certain Taxa in a Taxonomy by using their taxonomic path.

See the TaxopathParser and TaxopathGenerator classes for populating a Taxopath and for turning it back into a string, respectively.

Internally, it is a thin wrapper for a vector of strings. This might be a bit overengineered for now, but offers expansion that might become necessary in the future.

Definition at line 81 of file taxopath.hpp.

Public Member Functions

 Taxopath ()=default
 
 Taxopath (std::vector< std::string > const &elements)
 Fill constructor that uses the given strings to initialize the taxonomic elements. More...
 
 Taxopath (std::vector< std::string > &&elements)
 Fill constructor that uses the given strings to initialize the taxonomic elements. More...
 
 Taxopath (Taxopath const &)=default
 
 Taxopath (Taxopath &&)=default
 
 ~Taxopath ()=default
 
void assign (std::vector< std::string > const &from)
 Replace the current elements of the Taxopath by a list of strings. More...
 
std::string const & at (size_t index) const
 Return the taxonomic element at a certain position. More...
 
std::string & at (size_t index)
 Return the taxonomic element at a certain position. More...
 
iterator begin () noexcept
 Return an iterator to the beginning of the taxonomic elements. More...
 
const_iterator begin () const noexcept
 Return a const iterator to the beginning of the taxonomic elements. More...
 
void clear ()
 Clear all taxonomic elements. This results in an empty Taxopath. More...
 
std::vector< std::string > const & elements () const
 Return the elements of the Taxopath as a vector of strings. More...
 
std::vector< std::string > & elements ()
 Return the elements of the Taxopath as a vector of strings. More...
 
bool empty () const
 Return whether the Taxopath is empty, i.e., does not contain any elements. More...
 
iterator end () noexcept
 Return an iterator to the end of the taxonomic elements. More...
 
const_iterator end () const noexcept
 Return a const iterator to the end of the taxonomic elements. More...
 
Taxopathoperator= (Taxopath const &)=default
 
Taxopathoperator= (Taxopath &&)=default
 
std::string const & operator[] (size_t index) const
 Return the taxonomic element at a certain position. More...
 
std::string & operator[] (size_t index)
 Return the taxonomic element at a certain position. More...
 
std::string pop_back ()
 Remove the last element of the Taxopath and return its value. More...
 
void push_back (std::string const &value)
 Add an element to the end of the Taxopath by copying it. More...
 
void push_back (std::string &&value)
 Add an element to the end of the Taxopath by moving it. More...
 
reverse_iterator rbegin () noexcept
 Return a reverse iterator to the reverse beginning of the taxonomic elements. More...
 
const_reverse_iterator rbegin () const noexcept
 Return a const reverse iterator to the reverse beginning of the taxonomic elements. More...
 
reverse_iterator rend () noexcept
 Return a reverse iterator to the reverse end of the taxonomic elements. More...
 
const_reverse_iterator rend () const noexcept
 Return a const reverse iterator to the reverse end of the taxonomic elements. More...
 
size_t size () const
 Return the number of elements of this Taxopath. More...
 
void swap (Taxopath &other)
 Swap the elements of two Taxopaths. More...
 

Public Types

typedef std::vector
< std::string >
::const_iterator 
const_iterator
 
typedef std::vector
< std::string >
::const_reverse_iterator 
const_reverse_iterator
 
typedef std::vector
< std::string >::iterator 
iterator
 
typedef std::vector
< std::string >
::reverse_iterator 
reverse_iterator
 

Constructor & Destructor Documentation

Taxopath ( )
default
~Taxopath ( )
default
Taxopath ( std::vector< std::string > const &  elements)
explicit

Fill constructor that uses the given strings to initialize the taxonomic elements.

The strings are copied and used as Taxopath elements in the order in which they are stored in the vector.

Definition at line 48 of file taxopath.cpp.

Taxopath ( std::vector< std::string > &&  elements)
explicit

Fill constructor that uses the given strings to initialize the taxonomic elements.

The strings are moved and used as Taxopath elements in the order in which they are stored in the vector.

Definition at line 58 of file taxopath.cpp.

Taxopath ( Taxopath const &  )
default
Taxopath ( Taxopath &&  )
default

Member Function Documentation

void assign ( std::vector< std::string > const &  from)

Replace the current elements of the Taxopath by a list of strings.

The strings are copied and used as Taxopath elements in the order in which they are stored in the vector.

Definition at line 157 of file taxopath.cpp.

std::string const & at ( size_t  index) const

Return the taxonomic element at a certain position.

The function throws if the given index is not within the size of the taxonomic elements.

Definition at line 96 of file taxopath.cpp.

std::string & at ( size_t  index)

Return the taxonomic element at a certain position.

The function throws if the given index is not within the size of the taxonomic elements.

Definition at line 106 of file taxopath.cpp.

Taxopath::iterator begin ( )
noexcept

Return an iterator to the beginning of the taxonomic elements.

Definition at line 208 of file taxopath.cpp.

Taxopath::const_iterator begin ( ) const
noexcept

Return a const iterator to the beginning of the taxonomic elements.

Definition at line 224 of file taxopath.cpp.

void clear ( )

Clear all taxonomic elements. This results in an empty Taxopath.

Definition at line 196 of file taxopath.cpp.

std::vector< std::string > const & elements ( ) const

Return the elements of the Taxopath as a vector of strings.

Definition at line 134 of file taxopath.cpp.

std::vector< std::string > & elements ( )

Return the elements of the Taxopath as a vector of strings.

Definition at line 142 of file taxopath.cpp.

bool empty ( ) const

Return whether the Taxopath is empty, i.e., does not contain any elements.

Definition at line 78 of file taxopath.cpp.

Taxopath::iterator end ( )
noexcept

Return an iterator to the end of the taxonomic elements.

Definition at line 216 of file taxopath.cpp.

Taxopath::const_iterator end ( ) const
noexcept

Return a const iterator to the end of the taxonomic elements.

Definition at line 232 of file taxopath.cpp.

Taxopath& operator= ( Taxopath const &  )
default
Taxopath& operator= ( Taxopath &&  )
default
std::string const & operator[] ( size_t  index) const

Return the taxonomic element at a certain position.

The function does not check whether the given index is valid.

Definition at line 116 of file taxopath.cpp.

std::string & operator[] ( size_t  index)

Return the taxonomic element at a certain position.

The function does not check whether the given index is valid.

Definition at line 126 of file taxopath.cpp.

std::string pop_back ( )

Remove the last element of the Taxopath and return its value.

The returned value is obtained as a copy of the last element before it is removed.

Definition at line 183 of file taxopath.cpp.

void push_back ( std::string const &  value)

Add an element to the end of the Taxopath by copying it.

Definition at line 165 of file taxopath.cpp.

void push_back ( std::string &&  value)

Add an element to the end of the Taxopath by moving it.

Definition at line 173 of file taxopath.cpp.

Taxopath::reverse_iterator rbegin ( )
noexcept

Return a reverse iterator to the reverse beginning of the taxonomic elements.

Definition at line 240 of file taxopath.cpp.

Taxopath::const_reverse_iterator rbegin ( ) const
noexcept

Return a const reverse iterator to the reverse beginning of the taxonomic elements.

Definition at line 256 of file taxopath.cpp.

Taxopath::reverse_iterator rend ( )
noexcept

Return a reverse iterator to the reverse end of the taxonomic elements.

Definition at line 248 of file taxopath.cpp.

Taxopath::const_reverse_iterator rend ( ) const
noexcept

Return a const reverse iterator to the reverse end of the taxonomic elements.

Definition at line 264 of file taxopath.cpp.

size_t size ( ) const

Return the number of elements of this Taxopath.

Definition at line 86 of file taxopath.cpp.

void swap ( Taxopath other)

Swap the elements of two Taxopaths.

Definition at line 65 of file taxopath.cpp.

Member Typedef Documentation

typedef std::vector< std::string >::const_iterator const_iterator

Definition at line 90 of file taxopath.hpp.

typedef std::vector< std::string >::const_reverse_iterator const_reverse_iterator

Definition at line 92 of file taxopath.hpp.

typedef std::vector< std::string >::iterator iterator

Definition at line 89 of file taxopath.hpp.

typedef std::vector< std::string >::reverse_iterator reverse_iterator

Definition at line 91 of file taxopath.hpp.


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