libwreport  3.15
interpreter.h
1 #ifndef WREPORT_BULLETIN_INTERPETER_H
2 #define WREPORT_BULLETIN_INTERPETER_H
3 
4 #include <wreport/bulletin/bitmaps.h>
5 #include <wreport/bulletin/associated_fields.h>
6 #include <wreport/opcodes.h>
7 #include <wreport/tables.h>
8 #include <memory>
9 #include <stack>
10 
11 namespace wreport {
12 struct Vartable;
13 struct DTable;
14 struct Var;
15 
16 namespace bulletin {
17 
26 {
27  const Tables& tables;
28  std::stack<Opcodes> opcode_stack;
29 
32 
35 
37  int c_scale_change = 0;
38 
40  int c_width_change = 0;
41 
44 
50 
51 protected:
57 
58 public:
59  Interpreter(const Tables& tables, const Opcodes& opcodes);
60  virtual ~Interpreter();
61 
62  Interpreter(const Interpreter&) = delete;
63  Interpreter& operator=(const Interpreter&) = delete;
64 
66  void run();
67 
74  virtual void b_variable(Varcode code);
75 
85  virtual void c_modifier(Varcode code, Opcodes& next);
86 
98  virtual void r_replication(Varcode code, Varcode delayed_code, const Opcodes& ops);
99 
103  virtual void r_bitmap(Varcode code, Varcode delayed_code, const Opcodes& ops);
104 
117  virtual void run_r_repetition(unsigned cur, unsigned total);
118 
129  virtual void run_d_expansion(Varcode code);
130 
146  virtual void define_bitmap(unsigned bitmap_size);
147 
151  virtual void define_variable(Varinfo info);
152 
157 
168  virtual unsigned define_delayed_replication_factor(Varinfo info);
169 
176  virtual unsigned define_bitmap_delayed_replication_factor(Varinfo info);
177 
184  virtual unsigned define_associated_field_significance(Varinfo info);
185 
190  virtual void define_substituted_value(unsigned pos);
191 
196  virtual void define_attribute(Varinfo info, unsigned pos);
197 
199  virtual void define_raw_character_data(Varcode code);
200 
202  static void print_c_modifier(FILE* out, Varcode code, Opcodes& nex);
203 };
204 
205 
210 class Printer : public Interpreter
211 {
212 protected:
219  void print_lead(Varcode code);
220 
221 public:
227  FILE* out;
228 
235  unsigned indent;
236 
238  unsigned indent_step;
239 
240  Printer(const Tables& tables, const Opcodes& opcodes);
241 
242  void b_variable(Varcode code) override;
243  void c_modifier(Varcode code, Opcodes& next) override;
244  void r_replication(Varcode code, Varcode delayed_code, const Opcodes& ops) override;
245  void run_d_expansion(Varcode code) override;
246  void define_variable(Varinfo info) override;
248  void define_bitmap(unsigned bitmap_size) override;
249  unsigned define_bitmap_delayed_replication_factor(Varinfo info) override;
250 };
251 
252 
253 }
254 }
255 #endif
virtual void define_variable_with_associated_field(Varinfo info)
Request processing, according to info, of a data variable.
Definition: bitmaps.h:66
virtual unsigned define_associated_field_significance(Varinfo info)
Request processing of an associated field significance variable (B31021).
virtual void b_variable(Varcode code)
Notify of a B variable entry.
virtual void r_bitmap(Varcode code, Varcode delayed_code, const Opcodes &ops)
Handle a replicated section which defines a bitmap.
virtual unsigned define_delayed_replication_factor(Varinfo info)
Request processing, according to info, of a data variabile that is significant for controlling the en...
virtual void c_modifier(Varcode code, Opcodes &next)
Notify of a C modifier.
virtual void define_attribute(Varinfo info, unsigned pos)
Request processing of an attribute encoded with info, related to the variable as position pos in the ...
virtual void run_r_repetition(unsigned cur, unsigned total)
Executes a repetition of the opcodes on top of the stack.
virtual void run_d_expansion(Varcode code)
Executes the expansion of code, which has been put on top of the opcode stack.
Collection of BUFR/CREX tables used to work on a bulletin.
Definition: tables.h:17
unsigned indent_step
How many spaces in an indentation level.
Definition: interpreter.h:238
virtual void define_bitmap(unsigned bitmap_size)
Request processing of a data present bitmap.
static void print_c_modifier(FILE *out, Varcode code, Opcodes &nex)
Print a description of this C modifier.
Interpreter that pretty-prints the opcodes using indentation to show structure.
Definition: interpreter.h:210
uint16_t Varcode
Holds the WMO variable code of a variable.
Definition: varinfo.h:57
Varinfo get_varinfo(Varcode code)
Return a Varinfo for the given Varcode, applying all relevant C modifications that are currently acti...
unsigned indent
Current indent level.
Definition: interpreter.h:235
Information about a variable.
Definition: varinfo.h:135
void run()
Run the interpreter.
Sequence of opcodes, as a slice of a Varcode vector.
Definition: opcodes.h:19
int c_width_change
Current value of width change from C modifier.
Definition: interpreter.h:40
String functions.
Definition: benchmark.h:13
Interpreter for data descriptor sections.
Definition: interpreter.h:25
Definition: associated_fields.h:12
int c_scale_change
Current value of scale change from C modifier.
Definition: interpreter.h:37
virtual void define_substituted_value(unsigned pos)
Request processing of a substituted value corresponding to position pos in the list or previous varia...
Bitmaps bitmaps
Bitmap iteration.
Definition: interpreter.h:31
FILE * out
Output stream.
Definition: interpreter.h:227
int c_string_len_override
Current value of string length override from C08 modifiers (0 for no override)
Definition: interpreter.h:49
int c_scale_ref_width_increase
Increase of scale, reference value and data width.
Definition: interpreter.h:43
virtual unsigned define_bitmap_delayed_replication_factor(Varinfo info)
Request processing of a delayed replication factor variable used to encode the size of a bitmap...
AssociatedField associated_field
Current associated field state.
Definition: interpreter.h:34
virtual void define_raw_character_data(Varcode code)
Request processing of C05yyy raw character data.
virtual void define_variable(Varinfo info)
Request processing, according to info, of a data variable.
virtual void r_replication(Varcode code, Varcode delayed_code, const Opcodes &ops)
Handle a replicated section.