vxorg/vxorg.cpp

37 lines
814 B
C++
Raw Normal View History

#include <filesystem>
#include <fstream>
#include <string>
#include "tree.hpp"
#include "vxheaven_parse.hpp"
int main() {
2024-10-21 12:27:40 -04:00
std::ifstream ifs("./testdata/samples.sort");
vxorg::VxHeavenTree tree;
vxorg::parse_into_tree(tree, ifs);
// walk the resulting tree
tree.walk([](auto* node) {
auto tabulation_level = node->parent_count();
auto& data = node->data();
if(tabulation_level != 0) {
for(auto i = 0; i < tabulation_level; ++i) {
std::printf("\t");
}
}
2024-10-21 19:56:43 -04:00
if(node->is_root()) {
std::printf("(root)\n");
} else {
if(data.is_sample) {
2024-10-21 12:27:40 -04:00
std::string sample_name = vxorg::get_sample_name(node);
std::printf("%s (sample %s)\n", data.name.c_str(), sample_name.c_str());
} else {
std::printf("%s\n", data.name.c_str());
}
}
});
return 0;
}