summaryrefslogtreecommitdiff
path: root/decoder/cfg_options.h
diff options
context:
space:
mode:
Diffstat (limited to 'decoder/cfg_options.h')
-rwxr-xr-xdecoder/cfg_options.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/decoder/cfg_options.h b/decoder/cfg_options.h
new file mode 100755
index 00000000..bc7fed5f
--- /dev/null
+++ b/decoder/cfg_options.h
@@ -0,0 +1,49 @@
+#ifndef CFG_OPTIONS_H
+#define CFG_OPTIONS_H
+
+#include "hg_cfg.h"
+#include "cfg_format.h"
+#include "cfg_binarize.h"
+//#include "program_options.h"
+
+struct CFGOptions {
+ CFGFormat format;
+ CFGBinarize binarize;
+ std::string cfg_output;
+ void set_defaults() {
+ format.set_defaults();
+ binarize.set_defaults();
+ cfg_output="";
+ }
+ CFGOptions() { set_defaults(); }
+ template <class Opts> // template to support both printable_opts and boost nonprintable
+ void AddOptions(Opts *opts) {
+ opts->add_options()
+ ("cfg_output", defaulted_value(&cfg_output),"write final target CFG (before FSA rescorinn) to this file")
+ ;
+ binarize.AddOptions(opts);
+ format.AddOptions(opts);
+ }
+ void Validate() {
+ format.Validate();
+ binarize.Validate();
+ }
+ char const* description() const {
+ return "CFG output options";
+ }
+ void maybe_output(HgCFG &hgcfg) {
+ if (cfg_output.empty()) return;
+ WriteFile o(cfg_output);
+ maybe_binarize(hgcfg);
+ hgcfg.GetCFG().Print(o.get(),format);
+ }
+ void maybe_binarize(HgCFG &hgcfg) {
+ if (hgcfg.binarized) return;
+ hgcfg.GetCFG().Binarize(binarize);
+ hgcfg.binarized=true;
+ }
+
+};
+
+
+#endif