FST  openfst-1.7.9
OpenFst Library
convert.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 #ifndef FST_SCRIPT_CONVERT_H_
5 #define FST_SCRIPT_CONVERT_H_
6 
7 #include <memory>
8 #include <string>
9 #include <utility>
10 
11 #include <fst/register.h>
12 #include <fst/script/arg-packs.h>
13 #include <fst/script/fst-class.h>
14 
15 namespace fst {
16 namespace script {
17 
18 using ConvertInnerArgs = std::pair<const FstClass &, const std::string &>;
19 
21 
22 template <class Arc>
23 void Convert(ConvertArgs *args) {
24  const Fst<Arc> &fst = *std::get<0>(args->args).GetFst<Arc>();
25  const std::string &new_type = std::get<1>(args->args);
26  std::unique_ptr<Fst<Arc>> result(Convert(fst, new_type));
27  args->retval = result ? new FstClass(*result) : nullptr;
28 }
29 
30 FstClass *Convert(const FstClass &fst, const std::string &new_type);
31 
32 } // namespace script
33 } // namespace fst
34 
35 #endif // FST_SCRIPT_CONVERT_H_
std::pair< const FstClass &, const std::string & > ConvertInnerArgs
Definition: convert.h:18
void Convert(ConvertArgs *args)
Definition: convert.h:23