FST  openfst-1.8.2.post1
OpenFst Library
draw.h
Go to the documentation of this file.
1 // Copyright 2005-2020 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the 'License');
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an 'AS IS' BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 //
15 // See www.openfst.org for extensive documentation on this weighted
16 // finite-state transducer library.
17 
18 #ifndef FST_SCRIPT_DRAW_H_
19 #define FST_SCRIPT_DRAW_H_
20 
21 #include <ostream>
22 #include <string>
23 
24 #include <fst/script/draw-impl.h>
25 #include <fst/script/fst-class.h>
26 
27 namespace fst {
28 namespace script {
29 
30 // Note: it is safe to pass these strings as references because this struct is
31 // only used to pass them deeper in the call graph. Be sure you understand why
32 // this is so before using this struct for anything else!
33 struct FstDrawArgs {
34  const FstClass &fst;
38  const bool accep;
39  const std::string &title;
40  const float width;
41  const float height;
42  const bool portrait;
43  const bool vertical;
44  const float ranksep;
45  const float nodesep;
46  const int fontsize;
47  const int precision;
48  const std::string &float_format;
49  const bool show_weight_one;
50  std::ostream &ostrm;
51  const std::string &dest;
52 };
53 
54 template <class Arc>
55 void Draw(FstDrawArgs *args) {
56  const Fst<Arc> &fst = *args->fst.GetFst<Arc>();
57  FstDrawer<Arc> fstdrawer(fst, args->isyms, args->osyms, args->ssyms,
58  args->accep, args->title, args->width, args->height,
59  args->portrait, args->vertical, args->ranksep,
60  args->nodesep, args->fontsize, args->precision,
61  args->float_format, args->show_weight_one);
62  fstdrawer.Draw(args->ostrm, args->dest);
63 }
64 
65 void Draw(const FstClass &fst, const SymbolTable *isyms,
66  const SymbolTable *osyms, const SymbolTable *ssyms, bool accep,
67  const std::string &title, float width, float height, bool portrait,
68  bool vertical, float ranksep, float nodesep, int fontsize,
69  int precision, const std::string &float_format, bool show_weight_one,
70  std::ostream &ostrm, const std::string &dest);
71 
72 } // namespace script
73 } // namespace fst
74 
75 #endif // FST_SCRIPT_DRAW_H_
const std::string & float_format
Definition: draw.h:48
const bool accep
Definition: draw.h:38
const Fst< Arc > * GetFst() const
Definition: fst-class.h:394
const float ranksep
Definition: draw.h:44
const std::string & dest
Definition: draw.h:51
const SymbolTable * isyms
Definition: draw.h:35
const float width
Definition: draw.h:40
void Draw(FstDrawArgs *args)
Definition: draw.h:55
const FstClass & fst
Definition: draw.h:34
const std::string & title
Definition: draw.h:39
const int fontsize
Definition: draw.h:46
const bool vertical
Definition: draw.h:43
const float nodesep
Definition: draw.h:45
const bool portrait
Definition: draw.h:42
const SymbolTable * osyms
Definition: draw.h:36
const SymbolTable * ssyms
Definition: draw.h:37
const bool show_weight_one
Definition: draw.h:49
const float height
Definition: draw.h:41
const int precision
Definition: draw.h:47
std::ostream & ostrm
Definition: draw.h:50