Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef FST_SCRIPT_ENCODE_H_
00018 #define FST_SCRIPT_ENCODE_H_
00019
00020 #include <string>
00021
00022 #include <fst/script/arg-packs.h>
00023 #include <fst/script/fst-class.h>
00024 #include <fst/encode.h>
00025
00026 namespace fst {
00027 namespace script {
00028
00029 typedef args::Package<MutableFstClass*, uint32, bool,
00030 const string &> EncodeArgs;
00031
00032 template<class Arc>
00033 void Encode(EncodeArgs *args) {
00034 MutableFst<Arc> *ofst = args->arg1->GetMutableFst<Arc>();
00035 bool reuse_encoder = args->arg3;
00036 const string &coder_fname = args->arg4;
00037 uint32 flags = args->arg2;
00038
00039 EncodeMapper<Arc> *encoder = reuse_encoder
00040 ? EncodeMapper<Arc>::Read(coder_fname, ENCODE)
00041 : new EncodeMapper<Arc>(flags, ENCODE);
00042
00043 Encode(ofst, encoder);
00044 if (!args->arg3)
00045 encoder->Write(coder_fname);
00046
00047 delete encoder;
00048 }
00049
00050 void Encode(MutableFstClass *fst, uint32 flags, bool reuse_encoder,
00051 const string &coder_fname);
00052
00053 }
00054 }
00055
00056
00057
00058 #endif /// FST_SCRIPT_ENCODE_H_
00059