45 bool PrintHeaderInfo(
const std::string &in_name) {
47 if (in_name.empty()) {
48 if (!header.
Read(std::cin,
"stdin")) {
49 LOG(ERROR) <<
"fstinfo: Unable to read header from stdin";
54 istrm.open(in_name, std::ios_base::in | std::ios_base::binary);
56 LOG(ERROR) <<
"fstinfo: Unable to open " << in_name;
59 if (!header.
Read(istrm, in_name)) {
60 LOG(ERROR) <<
"fstinfo: Unable to read header from " << in_name;
64 LOG(ERROR) <<
"fstinfo: Unable to close " << in_name;
78 std::string usage =
"Prints out information about an FST.\n\n Usage: ";
80 usage +=
" [in.fst]\n";
82 SET_FLAGS(usage.c_str(), &argc, &argv,
true);
88 const std::string in_name =
89 (argc > 1 && (strcmp(argv[1],
"-") != 0)) ? argv[1] :
"";
91 if (FST_FLAGS_info_type ==
"fast") {
92 if (!PrintHeaderInfo(in_name))
return 1;
94 std::unique_ptr<FstClass> ifst(FstClass::Read(in_name));
99 LOG(ERROR) << argv[0] <<
": Unknown or unsupported arc filter type " 100 << FST_FLAGS_arc_filter;
103 s::Info(*ifst, FST_FLAGS_test_properties, arc_filter,
104 FST_FLAGS_info_type, FST_FLAGS_fst_verify);
void ShowUsage(bool long_usage=true)
int fstinfo_main(int argc, char **argv)
void PrintHeader(std::ostream &ostrm, const FstHeader &header)
#define SET_FLAGS(usage, argc, argv, rmflags)
void Info(const std::vector< std::string > &sources, const std::string &arc_type, const std::string &begin_key, const std::string &end_key, bool list_fsts)
DECLARE_bool(test_properties)
DECLARE_string(arc_filter)
bool GetArcFilterType(std::string_view str, ArcFilterType *arc_filter_type)