FST  openfst-1.6.1
OpenFst Library
compress-script.h
Go to the documentation of this file.
1 // See www.openfst.org for extensive documentation on this weighted
2 // finite-state transducer library.
3 //
4 // Declarations of 'scriptable' versions of compression operations, that is,
5 // those that can be called with FstClass-type arguments.
6 
7 #ifndef FST_EXTENSIONS_COMPRESS_COMPRESS_SCRIPT_H_
8 #define FST_EXTENSIONS_COMPRESS_COMPRESS_SCRIPT_H_
9 
10 #include <utility>
11 #include <vector>
12 
14 
15 #include <fst/log.h>
16 #include <fst/util.h>
17 #include <fst/script/arg-packs.h>
18 #include <fst/script/fst-class.h>
19 
20 namespace fst {
21 namespace script {
22 
23 typedef args::Package<const FstClass &, const string &, const bool>
25 
26 template <class Arc>
27 void Compress(CompressArgs *args) {
28  const Fst<Arc> &fst = *(args->arg1.GetFst<Arc>());
29  const string &filename = args->arg2;
30  const bool gzip = args->arg3;
31 
32  if (!fst::Compress(fst, filename, gzip)) FSTERROR() << "Compress: failed";
33 }
34 
35 void Compress(const FstClass &fst, const string &filename, const bool gzip);
36 
39 
40 template <class Arc>
42  const string &filename = args->arg1;
43  MutableFst<Arc> *fst = args->arg2->GetMutableFst<Arc>();
44  const bool gzip = args->arg3;
45 
46  if (!fst::Decompress(filename, fst, gzip))
47  FSTERROR() << "Decompress: failed";
48 }
49 
50 void Decompress(const string &filename, MutableFstClass *fst, const bool gzip);
51 
52 } // namespace script
53 } // namespace fst
54 
55 #endif // FST_EXTENSIONS_COMPRESS_COMPRESS_SCRIPT_H_
void Decompress(std::istream &strm, const string &source, MutableFst< Arc > *fst)
Definition: compress.h:824
args::Package< const string &, MutableFstClass *, const bool > DecompressArgs
#define FSTERROR()
Definition: util.h:32
args::Package< const FstClass &, const string &, const bool > CompressArgs
void Compress(const FstClass &fst, const string &filename, const bool gzip)
void Compress(const Fst< Arc > &fst, std::ostream &strm)
Definition: compress.h:776
void Decompress(const string &filename, MutableFstClass *fst, const bool gzip)