1 2// Licensed under the Apache License, Version 2.0 (the "License"); 3// you may not use this file except in compliance with the License. 4// You may obtain a copy of the License at 5// 6// http://www.apache.org/licenses/LICENSE-2.0 7// 8// Unless required by applicable law or agreed to in writing, software 9// distributed under the License is distributed on an "AS IS" BASIS, 10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11// See the License for the specific language governing permissions and 12// limitations under the License. 13// 14// Copyright 2005-2010 Google, Inc. 15// Author: jpr@google.com (Jake Ratkiewicz) 16 17#ifndef FST_SCRIPT_CONVERT_H_ 18#define FST_SCRIPT_CONVERT_H_ 19 20#include <string> 21 22#include <fst/script/arg-packs.h> 23#include <fst/script/fst-class.h> 24 25namespace fst { 26namespace script { 27 28typedef args::Package<const FstClass&, const string&> ConvertInnerArgs; 29typedef args::WithReturnValue<FstClass*, ConvertInnerArgs> ConvertArgs; 30 31template<class Arc> 32void Convert(ConvertArgs *args) { 33 const Fst<Arc> &fst = *(args->args.arg1.GetFst<Arc>()); 34 const string &new_type = args->args.arg2; 35 36 Fst<Arc> *result = Convert(fst, new_type); 37 args->retval = new FstClass(*result); 38 delete result; 39} 40 41#ifdef SWIG 42%newobject Convert; 43#endif 44FstClass *Convert(const FstClass& f, const string &new_type); 45 46} // namespace script 47} // namespace fst 48 49#endif // FST_SCRIPT_CONVERT_H_ 50