#include #include #include #include #include "common.hh" namespace param { using namespace ::args; ArgumentParser parser { "converter: feature codes -> block indices" }; HelpFlag help { parser, "help", "display this menu", {'h', "help"}, }; ValueFlag fcmap { parser, "path", "feature code map", {"fc-map"}, }; } // namespace param static void Exec() { std::ifstream fcmap_st {args::get(param::fcmap)}; Enforce(!!fcmap_st, "fcmap path is invalid"); const auto fcmap = ReadMatrix(fcmap_st); Enforce(fcmap.size() > 0, "empty fcmap"); for (auto& idxs : fcmap) { Enforce(idxs.size() > 0, "fcmap has empty item"); } size_t fcode; while (std::cin >> fcode) { Enforce(fcode < fcmap.size(), "fcode overflow"); for (const auto idx : fcmap[fcode]) { std::cout << idx << ' '; } std::cout << '\n'; } } int main(int argc, char** argv) try { param::parser.ParseCLI(argc, argv); Exec(); return EXIT_SUCCESS; } catch (const args::Help&) { std::cout << param::parser << std::endl; return EXIT_SUCCESS; } catch (const std::exception& e) { std::cerr << e.what() << std::endl; return EXIT_FAILURE; }