#include <genesis/taxonomy/taxopath.hpp>
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... | |
Taxopath & | operator= (Taxopath &&)=default |
Taxopath & | operator= (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) |
|
default |
|
default |
|
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.
|
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.
|
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.
|
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.
|
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.
|
inline |
Return an iterator to the beginning of the taxonomic elements.
Definition at line 311 of file taxopath.hpp.
|
inline |
Return a const iterator to the beginning of the taxonomic elements.
Definition at line 327 of file taxopath.hpp.
|
inline |
Clear all taxonomic elements. This results in an empty Taxopath.
Definition at line 265 of file taxopath.hpp.
|
inline |
Return the elements of the Taxopath as a vector of strings.
Definition at line 210 of file taxopath.hpp.
|
inline |
Return the elements of the Taxopath as a vector of strings.
Definition at line 202 of file taxopath.hpp.
|
inline |
Return whether the Taxopath is empty, i.e., does not contain any elements.
Definition at line 146 of file taxopath.hpp.
|
inline |
Return an iterator to the end of the taxonomic elements.
Definition at line 319 of file taxopath.hpp.
|
inline |
Return a const iterator to the end of the taxonomic elements.
Definition at line 335 of file taxopath.hpp.
|
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.
|
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.
|
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.
|
inline |
Add an element to the end of the Taxopath by moving it.
Definition at line 242 of file taxopath.hpp.
|
inline |
Add an element to the end of the Taxopath by copying it.
Definition at line 234 of file taxopath.hpp.
|
inline |
Return a reverse iterator to the reverse beginning of the taxonomic elements.
Definition at line 343 of file taxopath.hpp.
|
inline |
Return a const reverse iterator to the reverse beginning of the taxonomic elements.
Definition at line 359 of file taxopath.hpp.
|
inline |
Return a reverse iterator to the reverse end of the taxonomic elements.
Definition at line 351 of file taxopath.hpp.
|
inline |
Return a const reverse iterator to the reverse end of the taxonomic elements.
Definition at line 367 of file taxopath.hpp.
|
inline |
Return the number of elements of this Taxopath.
Definition at line 154 of file taxopath.hpp.
|
inline |
Swap the elements of two Taxopaths.
Definition at line 133 of file taxopath.hpp.
Definition at line 279 of file taxopath.hpp.
Definition at line 284 of file taxopath.hpp.
Definition at line 289 of file taxopath.hpp.
Definition at line 274 of file taxopath.hpp.
Definition at line 294 of file taxopath.hpp.
Definition at line 299 of file taxopath.hpp.
typedef std::vector< std::string >::const_iterator const_iterator |
Definition at line 92 of file taxopath.hpp.
typedef std::vector< std::string >::const_reverse_iterator const_reverse_iterator |
Definition at line 94 of file taxopath.hpp.
Definition at line 91 of file taxopath.hpp.
typedef std::vector< std::string >::reverse_iterator reverse_iterator |
Definition at line 93 of file taxopath.hpp.