libwreport 3.38
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
11namespace wreport {
12struct Vartable;
13struct DTable;
14struct Var;
15
16namespace bulletin {
17
25struct Interpreter
26{
27 const Tables& tables;
28 std::stack<Opcodes> opcode_stack;
29
32
35
38
41
44
50
52 std::map<wreport::Varcode, uint32_t> c03_refval_overrides;
53
57
58protected:
64
65public:
66 Interpreter(const Tables& tables, const Opcodes& opcodes);
67 virtual ~Interpreter();
68
69 Interpreter(const Interpreter&) = delete;
70 Interpreter& operator=(const Interpreter&) = delete;
71
73 void run();
74
81 virtual void b_variable(Varcode code);
82
92 virtual void c_modifier(Varcode code, Opcodes& next);
93
105 virtual void r_replication(Varcode code, Varcode delayed_code, const Opcodes& ops);
106
110 virtual void r_bitmap(Varcode code, Varcode delayed_code, const Opcodes& ops);
111
124 virtual void run_r_repetition(unsigned cur, unsigned total);
125
136 virtual void run_d_expansion(Varcode code);
137
153 virtual void define_bitmap(unsigned bitmap_size);
154
158 virtual void define_variable(Varinfo info);
159
164
176
184
192
197 virtual void define_substituted_value(unsigned pos);
198
203 virtual void define_attribute(Varinfo info, unsigned pos);
204
207
213
215 static void print_c_modifier(FILE* out, Varcode code, Opcodes& nex);
216};
217
218
223class Printer : public Interpreter
224{
225protected:
232 void print_lead(Varcode code);
233
234public:
240 FILE* out;
241
248 unsigned indent;
249
251 unsigned indent_step;
252
253 Printer(const Tables& tables, const Opcodes& opcodes);
254
255 void b_variable(Varcode code) override;
256 void c_modifier(Varcode code, Opcodes& next) override;
257 void r_replication(Varcode code, Varcode delayed_code, const Opcodes& ops) override;
258 void run_d_expansion(Varcode code) override;
259 void define_variable(Varinfo info) override;
261 void define_bitmap(unsigned bitmap_size) override;
264};
265
266
267}
268}
269#endif
BUFR/CREX table D with Dxxyyy aggregate code expansions.
Definition dtable.h:15
A physical variable.
Definition var.h:25
Holds a variable information table.
Definition vartable.h:31
void define_variable_with_associated_field(Varinfo info) override
Request processing, according to info, of a data variable.
void run_d_expansion(Varcode code) override
Executes the expansion of code, which has been put on top of the opcode stack.
void define_bitmap(unsigned bitmap_size) override
Request processing of a data present bitmap.
void c_modifier(Varcode code, Opcodes &next) override
Notify of a C modifier.
unsigned indent_step
How many spaces in an indentation level.
Definition interpreter.h:251
unsigned define_bitmap_delayed_replication_factor(Varinfo info) override
Request processing of a delayed replication factor variable used to encode the size of a bitmap.
FILE * out
Output stream.
Definition interpreter.h:240
void r_replication(Varcode code, Varcode delayed_code, const Opcodes &ops) override
Handle a replicated section.
void define_variable(Varinfo info) override
Request processing, according to info, of a data variable.
void b_variable(Varcode code) override
Notify of a B variable entry.
unsigned define_associated_field_significance(Varinfo info) override
Request processing of an associated field significance variable (B31021).
void print_lead(Varcode code)
Print line lead (indentation and formatted code)
unsigned indent
Current indent level.
Definition interpreter.h:248
The bulletin namespace contains bulletin implementation details, internals and utility functions.
Definition input.h:13
String functions.
Definition benchmark.h:13
const _Varinfo * Varinfo
Varinfo reference.
Definition fwd.h:11
uint16_t Varcode
Holds the WMO variable code of a variable.
Definition fwd.h:12
Sequence of opcodes, as a slice of a Varcode vector.
Definition opcodes.h:20
Collection of BUFR/CREX tables used to work on a bulletin.
Definition tables.h:15
Definition associated_fields.h:13
Definition bitmaps.h:67
virtual void define_substituted_value(unsigned pos)
Request processing of a substituted value corresponding to position pos in the list or previous varia...
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 ...
int c_scale_change
Current value of scale change from C modifier.
Definition interpreter.h:37
virtual void r_replication(Varcode code, Varcode delayed_code, const Opcodes &ops)
Handle a replicated section.
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.
void run()
Run the interpreter.
virtual void b_variable(Varcode code)
Notify of a B variable entry.
virtual void define_raw_character_data(Varcode code)
Request processing of C05yyy raw character data.
virtual void c_modifier(Varcode code, Opcodes &next)
Notify of a C modifier.
unsigned c03_refval_override_bits
Set to the number of reference value override bits while reading the override values.
Definition interpreter.h:56
std::map< wreport::Varcode, uint32_t > c03_refval_overrides
Current reference value overrides.
Definition interpreter.h:52
int c_string_len_override
Current value of string length override from C08 modifiers (0 for no override)
Definition interpreter.h:49
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 define_bitmap(unsigned bitmap_size)
Request processing of a data present bitmap.
virtual void define_variable(Varinfo info)
Request processing, according to info, of a data variable.
static void print_c_modifier(FILE *out, Varcode code, Opcodes &nex)
Print a description of this C modifier.
virtual void r_bitmap(Varcode code, Varcode delayed_code, const Opcodes &ops)
Handle a replicated section which defines a bitmap.
AssociatedField associated_field
Current associated field state.
Definition interpreter.h:34
Bitmaps bitmaps
Bitmap iteration.
Definition interpreter.h:31
virtual void define_variable_with_associated_field(Varinfo info)
Request processing, according to info, of a data variable.
virtual void define_c03_refval_override(Varcode code)
Request processing of a new value for the reference value of the given B code.
int c_scale_ref_width_increase
Increase of scale, reference value and data width.
Definition interpreter.h:43
virtual unsigned define_associated_field_significance(Varinfo info)
Request processing of an associated field significance variable (B31021).
virtual void run_d_expansion(Varcode code)
Executes the expansion of code, which has been put on top of the opcode stack.
int c_width_change
Current value of width change from C modifier.
Definition interpreter.h:40
Varinfo get_varinfo(Varcode code)
Return a Varinfo for the given Varcode, applying all relevant C modifications that are currently acti...
virtual void run_r_repetition(unsigned cur, unsigned total)
Executes a repetition of the opcodes on top of the stack.