2024-10-21 12:22:35 -04:00
|
|
|
#include <filesystem>
|
|
|
|
#include <fstream>
|
2024-10-21 11:16:15 -04:00
|
|
|
#include <string>
|
|
|
|
|
2024-10-21 12:22:35 -04:00
|
|
|
#include "tree.hpp"
|
|
|
|
#include "vxheaven_parse.hpp"
|
2024-10-21 11:16:15 -04:00
|
|
|
|
2024-10-21 12:22:35 -04:00
|
|
|
int main() {
|
2024-10-21 12:27:40 -04:00
|
|
|
std::ifstream ifs("./testdata/samples.sort");
|
2024-10-21 12:22:35 -04:00
|
|
|
vxorg::VxHeavenTree tree;
|
2024-10-21 11:16:15 -04:00
|
|
|
|
2024-10-21 12:22:35 -04:00
|
|
|
vxorg::parse_into_tree(tree, ifs);
|
2024-10-21 11:16:15 -04:00
|
|
|
|
2024-10-21 12:22:35 -04:00
|
|
|
// walk the resulting tree
|
|
|
|
tree.walk([](auto* node) {
|
2024-10-21 12:38:39 -04:00
|
|
|
auto tabulation_level = node->parent_count();
|
2024-10-21 12:22:35 -04:00
|
|
|
auto& data = node->data();
|
2024-10-21 11:16:15 -04:00
|
|
|
|
2024-10-21 12:38:39 -04:00
|
|
|
if(tabulation_level != 0) {
|
|
|
|
for(auto i = 0; i < tabulation_level; ++i) {
|
|
|
|
std::printf("\t");
|
|
|
|
}
|
|
|
|
}
|
2024-10-21 11:16:15 -04:00
|
|
|
|
2024-10-21 12:22:35 -04:00
|
|
|
if(data.name.empty()) {
|
|
|
|
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);
|
2024-10-21 12:22:35 -04:00
|
|
|
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;
|
2024-10-21 11:16:15 -04:00
|
|
|
}
|