FST  openfst-1.7.2
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 <string>
11 #include <tuple>
12 
13 #include <fst/log.h>
15 #include <fst/mutable-fst.h>
16 #include <fst/util.h>
17 #include <fst/script/fst-class.h>
18 
19 namespace fst {
20 namespace script {
21 
22 typedef std::tuple<const FstClass &, const string &, const bool> CompressArgs;
23 
24 template <class Arc>
25 void Compress(CompressArgs *args) {
26  const Fst<Arc> &fst = *(std::get<0>(*args).GetFst<Arc>());
27  const string &filename = std::get<1>(*args);
28  const bool gzip = std::get<2>(*args);
29 
30  if (!fst::Compress(fst, filename, gzip)) FSTERROR() << "Compress: failed";
31 }
32 
33 void Compress(const FstClass &fst, const string &filename, const bool gzip);
34 
35 typedef std::tuple<const string &, MutableFstClass *, const bool>
37 
38 template <class Arc>
40  const string &filename = std::get<0>(*args);
41  MutableFst<Arc> *fst = std::get<1>(*args)->GetMutableFst<Arc>();
42  const bool gzip = std::get<2>(*args);
43 
44  if (!fst::Decompress(filename, fst, gzip))
45  FSTERROR() << "Decompress: failed";
46 }
47 
48 void Decompress(const string &filename, MutableFstClass *fst, const bool gzip);
49 
50 } // namespace script
51 } // namespace fst
52 
53 #endif // FST_EXTENSIONS_COMPRESS_COMPRESS_SCRIPT_H_
void Decompress(std::istream &strm, const string &source, MutableFst< Arc > *fst)
Definition: compress.h:860
#define FSTERROR()
Definition: util.h:35
std::tuple< const string &, MutableFstClass *, const bool > DecompressArgs
std::tuple< 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:812
void Decompress(const string &filename, MutableFstClass *fst, const bool gzip)