A toolkit for working with phylogenetic data.
v0.19.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
taxopath_generator.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_TAXONOMY_FORMATS_TAXOPATH_GENERATOR_H_
2 #define GENESIS_TAXONOMY_FORMATS_TAXOPATH_GENERATOR_H_
3 
4 /*
5  Genesis - A toolkit for working with phylogenetic data.
6  Copyright (C) 2014-2017 Lucas Czech
7 
8  This program is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program. If not, see <http://www.gnu.org/licenses/>.
20 
21  Contact:
22  Lucas Czech <lucas.czech@h-its.org>
23  Exelixis Lab, Heidelberg Institute for Theoretical Studies
24  Schloss-Wolfsbrunnenweg 35, D-69118 Heidelberg, Germany
25 */
26 
34 #include <string>
35 #include <vector>
36 
37 namespace genesis {
38 namespace taxonomy {
39 
40 // =================================================================================================
41 // Forward Declarations
42 // =================================================================================================
43 
44 class Taxon;
45 class Taxopath;
46 
47 // =================================================================================================
48 // Taxopath Generator
49 // =================================================================================================
50 
75 {
76 public:
77 
78  // -------------------------------------------------------------------------
79  // Constructors and Rule of Five
80  // -------------------------------------------------------------------------
81 
82  TaxopathGenerator() = default;
83  ~TaxopathGenerator() = default;
84 
85  TaxopathGenerator( TaxopathGenerator const& ) = default;
86  TaxopathGenerator( TaxopathGenerator&& ) = default;
87 
88  TaxopathGenerator& operator= ( TaxopathGenerator const& ) = default;
90 
91  // -------------------------------------------------------------------------
92  // Generating
93  // -------------------------------------------------------------------------
94 
95  std::string to_string( Taxopath const& taxopath ) const;
96  std::string operator() ( Taxopath const& taxopath ) const;
97 
98  std::string to_string( Taxon const& taxon ) const;
99  std::string operator() ( Taxon const& taxon ) const;
100 
101  // -------------------------------------------------------------------------
102  // Properties
103  // -------------------------------------------------------------------------
104 
105  TaxopathGenerator& delimiter( std::string const& value );
106  std::string delimiter() const;
107 
109  bool trim_nested_duplicates() const;
110 
111  TaxopathGenerator& append_delimiter( bool value );
112  bool append_delimiter() const;
113 
114  // -------------------------------------------------------------------------
115  // Data Members
116  // -------------------------------------------------------------------------
117 
118 private:
119 
120  std::string delimiter_ = ";";
121  bool trim_nested_duplicates_ = false;
122  bool append_delimiter_ = false;
123 
124 };
125 
126 } // namespace taxonomy
127 } // namespace genesis
128 
129 #endif // include guard
Helper class to generate a taxonomic path string from a Taxopath object or a Taxon.
bool append_delimiter() const
Return whether currently a delimiter is appended to the taxonomic path string.
bool trim_nested_duplicates() const
Return the currently set value whether to trim nested duplicates of taxa names.
std::string delimiter() const
Return the currelty set value used to join the taxonomic path string elements.
std::string operator()(Taxopath const &taxopath) const
Shortcut function alias for to_string( Taxopath ).
Store a Taxon, i.e., an element in a Taxonomy, with its name, rank and sub-taxa.
Definition: taxon.hpp:76
Helper class to store a taxonomic path.
Definition: taxopath.hpp:81
std::string to_string(Taxopath const &taxopath) const
Return a string representation of a Taxopath.
TaxopathGenerator & operator=(TaxopathGenerator const &)=default