A toolkit for working with phylogenetic data.
v0.20.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
nested.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_TAXONOMY_PRINTERS_NESTED_H_
2 #define GENESIS_TAXONOMY_PRINTERS_NESTED_H_
3 
4 /*
5  Genesis - A toolkit for working with phylogenetic data.
6  Copyright (C) 2014-2018 Lucas Czech and HITS gGmbH
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 <iosfwd>
35 #include <string>
36 
37 namespace genesis {
38 namespace taxonomy {
39 
40 // =================================================================================================
41 // Forward Declarations
42 // =================================================================================================
43 
44 class Taxonomy;
45 
46 // =================================================================================================
47 // PrinterNested
48 // =================================================================================================
49 
54 {
55 public:
56 
57  // -------------------------------------------------------------------------
58  // Constructors and Rule of Five
59  // -------------------------------------------------------------------------
60 
61  PrinterNested() = default;
62  ~PrinterNested() = default;
63 
64  PrinterNested( PrinterNested const& ) = default;
65  PrinterNested( PrinterNested&& ) = default;
66 
67  PrinterNested& operator= ( PrinterNested const& ) = default;
68  PrinterNested& operator= ( PrinterNested&& ) = default;
69 
70  // -------------------------------------------------------------------------
71  // Print
72  // -------------------------------------------------------------------------
73 
74  void print(
75  std::ostream& out,
76  Taxonomy const& tax
77  ) const;
78 
79  std::string print(
80  Taxonomy const& tax
81  ) const;
82 
83  std::string operator() (
84  Taxonomy const& tax
85  ) const;
86 
87  // -------------------------------------------------------------------------
88  // Properties
89  // -------------------------------------------------------------------------
90 
91  PrinterNested& line_limit( int value );
92  int line_limit() const;
93 
94  PrinterNested& depth_limit( int value );
95  int depth_limit() const;
96 
97  PrinterNested& print_ranks( bool value );
98  bool print_ranks() const;
99 
100  PrinterNested& print_ids( bool value );
101  bool print_ids() const;
102 
103  // -------------------------------------------------------------------------
104  // Internal Functions
105  // -------------------------------------------------------------------------
106 
107 private:
108 
109  bool print_to_ostream(
110  std::ostream& out,
111  Taxonomy const& tax,
112  size_t depth,
113  size_t& lines
114  ) const;
115 
116  // -------------------------------------------------------------------------
117  // Data Members
118  // -------------------------------------------------------------------------
119 
120 private:
121 
122  int line_limit_ = -1;
123  int depth_limit_ = -1;
124  bool print_ranks_ = true;
125  bool print_ids_ = true;
126 };
127 
128 } // namespace taxonomy
129 } // namespace genesis
130 
131 #endif // include guard
void print(std::ostream &out, Taxonomy const &tax) const
Definition: nested.cpp:45
std::string operator()(Taxonomy const &tax) const
Definition: nested.cpp:61
PrinterNested & operator=(PrinterNested const &)=default
Store a Taxonomy, i.e., a nested hierarchy of Taxa.
Simple printer class for Taxonomy.
Definition: nested.hpp:53