50 std::string usage =
"Prints strings in an FST archive.\n\n Usage: ";
52 usage +=
" [in1.far in2.far ...]\n";
54 SET_FLAGS(usage.c_str(), &argc, &argv,
true);
57 std::vector<std::string> sources;
58 for (
int i = 1; i < argc; ++i) sources.push_back(argv[i]);
59 if (sources.empty()) sources.push_back(
"");
60 std::unique_ptr<FarReaderClass> reader(FarReaderClass::Open(sources));
61 if (!reader)
return 1;
65 LOG(ERROR) <<
"Unknown or unsupported FAR entry type: " 66 << FST_FLAGS_entry_type;
72 LOG(ERROR) <<
"Unknown or unsupported FAR token type: " 73 << FST_FLAGS_token_type;
78 *reader, entry_type, token_type, FST_FLAGS_begin_key,
79 FST_FLAGS_end_key, FST_FLAGS_print_key,
80 FST_FLAGS_print_weight, FST_FLAGS_symbols,
81 FST_FLAGS_initial_symbols,
82 FST_FLAGS_generate_filenames,
83 FST_FLAGS_filename_prefix,
84 FST_FLAGS_filename_suffix);
86 if (reader->Error()) {
87 FSTERROR() <<
"Error reading FAR(s)";
bool GetTokenType(std::string_view str, TokenType *token_type)
void PrintStrings(FarReaderClass &reader, const FarEntryType entry_type, const TokenType token_type, const std::string &begin_key, const std::string &end_key, bool print_key, bool print_weight, const std::string &symbols_source, bool initial_symbols, const int32_t generate_sources, const std::string &source_prefix, const std::string &source_suffix)
void ExpandArgs(int argc, char **argv, int *argcp, char ***argvp)
bool GetFarEntryType(std::string_view str, FarEntryType *entry_type)
#define SET_FLAGS(usage, argc, argv, rmflags)
DECLARE_string(filename_prefix)
int farprintstrings_main(int argc, char **argv)
DECLARE_int32(generate_filenames)