11#include <boost/spirit/home/x3.hpp>
12#include <boost/spirit/home/x3/support/ast/variant.hpp>
14#include <boost/fusion/adapted/struct/adapt_struct.hpp>
15#include <boost/fusion/include/adapt_struct.hpp>
19namespace quetzal::format::newick::ast
25using nodes = std::vector<struct node>;
60static inline std::ostream &print_subtree(
node const &
node,
const std::string &prefix, std::ostream &os)
74 for (
size_t i = 0; i < nb_children; ++i)
78 if (i < nb_children - 1)
82 os << prefix <<
"├──";
84 bool should_print_branch = nb_children > 1 && !child.children.empty();
85 auto new_prefix = prefix + (should_print_branch ?
"│\t" :
"\t");
86 os << child.distance_to_parent <<
"──" << std::quoted(child.name) <<
"\n";
87 print_subtree(child, new_prefix, os);
94 os <<
"└──" << child.distance_to_parent <<
"──" << std::quoted(child.name) <<
"\n";
95 print_subtree(child, prefix +
"\t", os);
105static inline std::ostream &operator<<(std::ostream &os, node
const &n)
107 os << std::quoted(n.name) <<
"\n";
108 return print_subtree(n,
"", os);