FST  openfst-1.8.3
OpenFst Library
draw.h
Go to the documentation of this file.
1 // Copyright 2005-2024 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/fst.h>
25 #include <fst/symbol-table.h>
26 #include <fst/script/draw-impl.h>
27 #include <fst/script/fst-class.h>
28 
29 namespace fst {
30 namespace script {
31 
32 // Note: it is safe to pass these strings as references because this struct is
33 // only used to pass them deeper in the call graph. Be sure you understand why
34 // this is so before using this struct for anything else!
35 struct FstDrawArgs {
36  const FstClass &fst;
40  const bool accep;
41  const std::string &title;
42  const float width;
43  const float height;
44  const bool portrait;
45  const bool vertical;
46  const float ranksep;
47  const float nodesep;
48  const int fontsize;
49  const int precision;
50  const std::string &float_format;
51  const bool show_weight_one;
52  std::ostream &ostrm;
53  const std::string &dest;
54 };
55 
56 template <class Arc>
57 void Draw(FstDrawArgs *args) {
58  const Fst<Arc> &fst = *args->fst.GetFst<Arc>();
59  FstDrawer<Arc> fstdrawer(fst, args->isyms, args->osyms, args->ssyms,
60  args->accep, args->title, args->width, args->height,
61  args->portrait, args->vertical, args->ranksep,
62  args->nodesep, args->fontsize, args->precision,
63  args->float_format, args->show_weight_one);
64  fstdrawer.Draw(args->ostrm, args->dest);
65 }
66 
67 void Draw(const FstClass &fst, const SymbolTable *isyms,
68  const SymbolTable *osyms, const SymbolTable *ssyms, bool accep,
69  const std::string &title, float width, float height, bool portrait,
70  bool vertical, float ranksep, float nodesep, int fontsize,
71  int precision, const std::string &float_format, bool show_weight_one,
72  std::ostream &ostrm, const std::string &dest);
73 
74 } // namespace script
75 } // namespace fst
76 
77 #endif // FST_SCRIPT_DRAW_H_
const std::string & float_format
Definition: draw.h:50
const bool accep
Definition: draw.h:40
const Fst< Arc > * GetFst() const
Definition: fst-class.h:401
const float ranksep
Definition: draw.h:46
const std::string & dest
Definition: draw.h:53
const SymbolTable * isyms
Definition: draw.h:37
const float width
Definition: draw.h:42
void Draw(FstDrawArgs *args)
Definition: draw.h:57
const FstClass & fst
Definition: draw.h:36
const std::string & title
Definition: draw.h:41
const int fontsize
Definition: draw.h:48
const bool vertical
Definition: draw.h:45
const float nodesep
Definition: draw.h:47
const bool portrait
Definition: draw.h:44
const SymbolTable * osyms
Definition: draw.h:38
const SymbolTable * ssyms
Definition: draw.h:39
const bool show_weight_one
Definition: draw.h:51
const float height
Definition: draw.h:43
const int precision
Definition: draw.h:49
std::ostream & ostrm
Definition: draw.h:52