FST  openfst-1.7.1
OpenFst Library
draw.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_DRAW_H_
5 #define FST_SCRIPT_DRAW_H_
6 
7 #include <ostream>
8 
9 #include <fst/script/draw-impl.h>
10 #include <fst/script/fst-class.h>
11 
12 namespace fst {
13 namespace script {
14 
15 // Note: it is safe to pass these strings as references because
16 // this struct is only used to pass them deeper in the call graph.
17 // Be sure you understand why this is so before using this struct
18 // for anything else!
19 struct FstDrawerArgs {
20  const FstClass &fst;
24  const bool accep;
25  const string &title;
26  const float width;
27  const float height;
28  const bool portrait;
29  const bool vertical;
30  const float ranksep;
31  const float nodesep;
32  const int fontsize;
33  const int precision;
34  const string &float_format; // NOLINT
35  const bool show_weight_one;
36  std::ostream *ostrm;
37  const string &dest;
38 
39  FstDrawerArgs(const FstClass &fst, const SymbolTable *isyms,
40  const SymbolTable *osyms, const SymbolTable *ssyms, bool accep,
41  const string &title, float width, float height, bool portrait,
42  bool vertical, float ranksep, float nodesep, int fontsize,
43  int precision, const string &float_format,
44  bool show_weight_one, std::ostream *ostrm, const string &dest)
45  : fst(fst),
46  isyms(isyms),
47  osyms(osyms),
48  ssyms(ssyms),
49  accep(accep),
50  title(title),
51  width(width),
52  height(height),
53  portrait(portrait),
54  vertical(vertical),
55  ranksep(ranksep),
56  nodesep(nodesep),
57  fontsize(fontsize),
58  precision(precision),
59  float_format(float_format),
60  show_weight_one(show_weight_one),
61  ostrm(ostrm),
62  dest(dest) {}
63 };
64 
65 template <class Arc>
66 void DrawFst(FstDrawerArgs *args) {
67  const Fst<Arc> &fst = *(args->fst.GetFst<Arc>());
68  FstDrawer<Arc> fstdrawer(fst, args->isyms, args->osyms, args->ssyms,
69  args->accep, args->title, args->width, args->height, args->portrait,
70  args->vertical, args->ranksep, args->nodesep, args->fontsize,
71  args->precision, args->float_format, args->show_weight_one);
72  fstdrawer.Draw(args->ostrm, args->dest);
73 }
74 
75 void DrawFst(const FstClass &fst, const SymbolTable *isyms,
76  const SymbolTable *osyms, const SymbolTable *ssyms, bool accep,
77  const string &title, float width, float height, bool portrait,
78  bool vertical, float ranksep, float nodesep, int fontsize,
79  int precision, const string &float_format, bool show_weight_one,
80  std::ostream *ostrm, const string &dest);
81 
82 } // namespace script
83 } // namespace fst
84 
85 #endif // FST_SCRIPT_DRAW_H_
const string & title
Definition: draw.h:25
const int precision
Definition: draw.h:33
const Fst< Arc > * GetFst() const
Definition: fst-class.h:357
const SymbolTable * isyms
Definition: draw.h:21
const SymbolTable * ssyms
Definition: draw.h:23
const SymbolTable * osyms
Definition: draw.h:22
const float ranksep
Definition: draw.h:30
const float width
Definition: draw.h:26
FstDrawerArgs(const FstClass &fst, const SymbolTable *isyms, const SymbolTable *osyms, const SymbolTable *ssyms, bool accep, const string &title, float width, float height, bool portrait, bool vertical, float ranksep, float nodesep, int fontsize, int precision, const string &float_format, bool show_weight_one, std::ostream *ostrm, const string &dest)
Definition: draw.h:39
std::ostream * ostrm
Definition: draw.h:36
const bool show_weight_one
Definition: draw.h:35
const float height
Definition: draw.h:27
const int fontsize
Definition: draw.h:32
const bool vertical
Definition: draw.h:29
void DrawFst(FstDrawerArgs *args)
Definition: draw.h:66
void Draw(std::ostream *strm, const string &dest)
Definition: draw-impl.h:53
const string & dest
Definition: draw.h:37
const FstClass & fst
Definition: draw.h:20
const bool accep
Definition: draw.h:24
const bool portrait
Definition: draw.h:28
const string & float_format
Definition: draw.h:34
const float nodesep
Definition: draw.h:31