A library for working with phylogenetic and population genetic data.
v0.27.0
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 serves as 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.

It furthermore offers all comparison operators (==, !=, <, <=, >, >=), which behave naturally for sorting a set of Taxopaths (akin to std::lexicographical_compare).

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

Definition at line 83 of file taxopath.hpp.

Public Member Functions

 Taxopath ()=default
 
 Taxopath (std::vector< std::string > &&elements)
 Fill constructor that uses the given strings to initialize the taxonomic elements. More...
 
 Taxopath (std::vector< std::string > const &elements)
 Fill constructor that uses the given strings to initialize the taxonomic elements. More...
 
 Taxopath (Taxopath &&)=default
 
 Taxopath (Taxopath const &)=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 & at (size_t index)
 Return the taxonomic element at a certain position. More...
 
std::string const & at (size_t index) const
 Return the taxonomic element at a certain position. More...
 
iterator begin ()
 Return an iterator to the beginning of the taxonomic elements. More...
 
const_iterator begin () const
 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 > & elements ()
 Return the elements of the Taxopath as a vector of strings. More...
 
std::vector< std::string > const & elements () const
 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 ()
 Return an iterator to the end of the taxonomic elements. More...
 
const_iterator end () const
 Return a const iterator to the end of the taxonomic elements. More...
 
Taxopathoperator= (Taxopath &&)=default
 
Taxopathoperator= (Taxopath const &)=default
 
std::string & operator[] (size_t index)
 Return the taxonomic element at a certain position. More...
 
std::string const & operator[] (size_t index) const
 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 &&value)
 Add an element to the end of the Taxopath by moving it. More...
 
void push_back (std::string const &value)
 Add an element to the end of the Taxopath by copying it. More...
 
reverse_iterator rbegin ()
 Return a reverse iterator to the reverse beginning of the taxonomic elements. More...
 
const_reverse_iterator rbegin () const
 Return a const reverse iterator to the reverse beginning of the taxonomic elements. More...
 
reverse_iterator rend ()
 Return a reverse iterator to the reverse end of the taxonomic elements. More...
 
const_reverse_iterator rend () const
 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
 

Friends

bool operator!= (Taxopath const &lhs, Taxopath const &rhs)
 
bool operator< (Taxopath const &lhs, Taxopath const &rhs)
 
bool operator<= (Taxopath const &lhs, Taxopath const &rhs)
 
bool operator== (Taxopath const &lhs, Taxopath const &rhs)
 
bool operator> (Taxopath const &lhs, Taxopath const &rhs)
 
bool operator>= (Taxopath const &lhs, Taxopath const &rhs)
 

Constructor & Destructor Documentation

◆ Taxopath() [1/5]

Taxopath ( )
default

◆ ~Taxopath()

~Taxopath ( )
default

◆ Taxopath() [2/5]

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

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 109 of file taxopath.hpp.

◆ Taxopath() [3/5]

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

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 119 of file taxopath.hpp.

◆ Taxopath() [4/5]

Taxopath ( Taxopath const &  )
default

◆ Taxopath() [5/5]

Taxopath ( Taxopath &&  )
default

Member Function Documentation

◆ assign()

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

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 226 of file taxopath.hpp.

◆ at() [1/2]

std::string& at ( size_t  index)
inline

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 174 of file taxopath.hpp.

◆ at() [2/2]

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

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 164 of file taxopath.hpp.

◆ begin() [1/2]

iterator begin ( )
inline

Return an iterator to the beginning of the taxonomic elements.

Definition at line 311 of file taxopath.hpp.

◆ begin() [2/2]

const_iterator begin ( ) const
inline

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

Definition at line 327 of file taxopath.hpp.

◆ clear()

void clear ( )
inline

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

Definition at line 265 of file taxopath.hpp.

◆ elements() [1/2]

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

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

Definition at line 210 of file taxopath.hpp.

◆ elements() [2/2]

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

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

Definition at line 202 of file taxopath.hpp.

◆ empty()

bool empty ( ) const
inline

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

Definition at line 146 of file taxopath.hpp.

◆ end() [1/2]

iterator end ( )
inline

Return an iterator to the end of the taxonomic elements.

Definition at line 319 of file taxopath.hpp.

◆ end() [2/2]

const_iterator end ( ) const
inline

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

Definition at line 335 of file taxopath.hpp.

◆ operator=() [1/2]

Taxopath& operator= ( Taxopath &&  )
default

◆ operator=() [2/2]

Taxopath& operator= ( Taxopath const &  )
default

◆ operator[]() [1/2]

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

Return the taxonomic element at a certain position.

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

Definition at line 194 of file taxopath.hpp.

◆ operator[]() [2/2]

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

Return the taxonomic element at a certain position.

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

Definition at line 184 of file taxopath.hpp.

◆ pop_back()

std::string pop_back ( )
inline

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 252 of file taxopath.hpp.

◆ push_back() [1/2]

void push_back ( std::string &&  value)
inline

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

Definition at line 242 of file taxopath.hpp.

◆ push_back() [2/2]

void push_back ( std::string const &  value)
inline

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

Definition at line 234 of file taxopath.hpp.

◆ rbegin() [1/2]

reverse_iterator rbegin ( )
inline

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

Definition at line 343 of file taxopath.hpp.

◆ rbegin() [2/2]

const_reverse_iterator rbegin ( ) const
inline

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

Definition at line 359 of file taxopath.hpp.

◆ rend() [1/2]

reverse_iterator rend ( )
inline

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

Definition at line 351 of file taxopath.hpp.

◆ rend() [2/2]

const_reverse_iterator rend ( ) const
inline

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

Definition at line 367 of file taxopath.hpp.

◆ size()

size_t size ( ) const
inline

Return the number of elements of this Taxopath.

Definition at line 154 of file taxopath.hpp.

◆ swap()

void swap ( Taxopath other)
inline

Swap the elements of two Taxopaths.

Definition at line 133 of file taxopath.hpp.

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( Taxopath const &  lhs,
Taxopath const &  rhs 
)
friend

Definition at line 279 of file taxopath.hpp.

◆ operator<

bool operator< ( Taxopath const &  lhs,
Taxopath const &  rhs 
)
friend

Definition at line 284 of file taxopath.hpp.

◆ operator<=

bool operator<= ( Taxopath const &  lhs,
Taxopath const &  rhs 
)
friend

Definition at line 289 of file taxopath.hpp.

◆ operator==

bool operator== ( Taxopath const &  lhs,
Taxopath const &  rhs 
)
friend

Definition at line 274 of file taxopath.hpp.

◆ operator>

bool operator> ( Taxopath const &  lhs,
Taxopath const &  rhs 
)
friend

Definition at line 294 of file taxopath.hpp.

◆ operator>=

bool operator>= ( Taxopath const &  lhs,
Taxopath const &  rhs 
)
friend

Definition at line 299 of file taxopath.hpp.

Member Typedef Documentation

◆ const_iterator

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

Definition at line 92 of file taxopath.hpp.

◆ const_reverse_iterator

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

Definition at line 94 of file taxopath.hpp.

◆ iterator

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

Definition at line 91 of file taxopath.hpp.

◆ reverse_iterator

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

Definition at line 93 of file taxopath.hpp.


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