6 #ifndef METALL_UTILITY_DATASTORE_LS_HPP
7 #define METALL_UTILITY_DATASTORE_LS_HPP
21 namespace datastore_ls_detail {
22 inline void aligned_show(
const std::vector<std::vector<std::string>> &buf) {
23 if (buf.empty())
return;
26 std::vector<std::size_t> col_size(buf.front().size(), 0);
27 for (
const auto &row : buf) {
28 assert(col_size.size() == row.size());
29 for (std::size_t c = 0; c < row.size(); ++c) {
30 col_size[c] = std::max(row[c].size(), col_size[c]);
37 for (std::size_t c = 0; c < col_size.size(); ++c) {
38 std::cout << std::setw(col_size[c] + 2) << buf[0][c] <<
" |";
40 std::cout << std::endl;
43 for (std::size_t c = 0; c < col_size.size(); ++c) {
44 for (std::size_t i = 0; i < col_size[c] + 4; ++i) {
48 std::cout << std::endl;
52 for (std::size_t l = 1; l < buf.size(); ++l) {
53 const auto &row = buf[l];
56 for (std::size_t c = 0; c < col_size.size(); ++c) {
57 std::cout << std::setw(col_size[c] + 2) << std::right << row[c] <<
" |";
59 std::cout << std::endl;
66 std::cout <<
"[Named Object]" << std::endl;
69 if (!accessor.good()) {
70 std::cerr <<
"Failed to open datastore" << std::endl;
74 std::vector<std::vector<std::string>> buf;
75 buf.emplace_back(std::vector<std::string>{
"Name",
"Length",
"Offset",
76 "Type-ID",
"Description"});
77 for (
const auto &
object : accessor) {
78 std::vector<std::string> row;
79 row.push_back(
object.name());
80 row.push_back(std::to_string(
object.length()));
81 row.push_back(std::to_string(
object.offset()));
82 row.push_back(std::to_string(
object.type_id()));
83 row.push_back(
object.description());
84 buf.emplace_back(std::move(row));
86 datastore_ls_detail::aligned_show(buf);
90 std::cout <<
"[Unique Object]" << std::endl;
93 if (!accessor.good()) {
94 std::cerr <<
"Failed to open datastore" << std::endl;
98 std::vector<std::vector<std::string>> buf;
99 buf.emplace_back(std::vector<std::string>{
100 "Name: typeid(T).name()",
"Length",
"Offset",
"Type-ID",
"Description"});
101 for (
const auto &
object : accessor) {
102 std::vector<std::string> row;
103 row.push_back(
object.name());
104 row.push_back(std::to_string(
object.length()));
105 row.push_back(std::to_string(
object.offset()));
106 row.push_back(std::to_string(
object.type_id()));
107 row.push_back(
object.description());
108 buf.emplace_back(std::move(row));
110 datastore_ls_detail::aligned_show(buf);
114 std::cout <<
"[Anonymous Object]" << std::endl;
116 datastore_path.c_str());
117 if (!accessor.good()) {
118 std::cerr <<
"Failed to open datastore" << std::endl;
122 std::vector<std::vector<std::string>> buf;
124 std::vector<std::string>{
"Length",
"Offset",
"Type-ID",
"Description"});
125 for (
const auto &
object : accessor) {
126 std::vector<std::string> row;
127 row.push_back(std::to_string(
object.length()));
128 row.push_back(std::to_string(
object.offset()));
129 row.push_back(std::to_string(
object.type_id()));
130 row.push_back(
object.description());
131 buf.emplace_back(std::move(row));
133 datastore_ls_detail::aligned_show(buf);