interpreter.h
#ifndef WREPORT_BULLETIN_INTERPETER_H
#define WREPORT_BULLETIN_INTERPETER_H
#include <wreport/bulletin/bitmaps.h>
#include <wreport/bulletin/associated_fields.h>
#include <wreport/opcodes.h>
#include <wreport/tables.h>
#include <memory>
#include <stack>
namespace wreport {
struct Vartable;
struct DTable;
struct Var;
namespace bulletin {
struct Interpreter
{
const Tables& tables;
std::stack<Opcodes> opcode_stack;
Bitmaps bitmaps;
AssociatedField associated_field;
int c_scale_change = 0;
int c_width_change = 0;
int c_scale_ref_width_increase = 0;
int c_string_len_override = 0;
std::map<wreport::Varcode, uint32_t> c03_refval_overrides;
unsigned c03_refval_override_bits = 0;
protected:
Varinfo get_varinfo(Varcode code);
public:
Interpreter(const Tables& tables, const Opcodes& opcodes);
virtual ~Interpreter();
Interpreter(const Interpreter&) = delete;
Interpreter& operator=(const Interpreter&) = delete;
void run();
virtual void b_variable(Varcode code);
virtual void c_modifier(Varcode code, Opcodes& next);
virtual void r_replication(Varcode code, Varcode delayed_code, const Opcodes& ops);
virtual void r_bitmap(Varcode code, Varcode delayed_code, const Opcodes& ops);
virtual void run_r_repetition(unsigned cur, unsigned total);
virtual void run_d_expansion(Varcode code);
virtual void define_bitmap(unsigned bitmap_size);
virtual void define_variable(Varinfo info);
virtual void define_variable_with_associated_field(Varinfo info);
virtual unsigned define_delayed_replication_factor(Varinfo info);
virtual unsigned define_bitmap_delayed_replication_factor(Varinfo info);
virtual unsigned define_associated_field_significance(Varinfo info);
virtual void define_substituted_value(unsigned pos);
virtual void define_attribute(Varinfo info, unsigned pos);
virtual void define_raw_character_data(Varcode code);
virtual void define_c03_refval_override(Varcode code);
static void print_c_modifier(FILE* out, Varcode code, Opcodes& nex);
};
class Printer : public Interpreter
{
protected:
void print_lead(Varcode code);
public:
FILE* out;
unsigned indent;
unsigned indent_step;
Printer(const Tables& tables, const Opcodes& opcodes);
void b_variable(Varcode code) override;
void c_modifier(Varcode code, Opcodes& next) override;
void r_replication(Varcode code, Varcode delayed_code, const Opcodes& ops) override;
void run_d_expansion(Varcode code) override;
void define_variable(Varinfo info) override;
void define_variable_with_associated_field(Varinfo info) override;
void define_bitmap(unsigned bitmap_size) override;
unsigned define_bitmap_delayed_replication_factor(Varinfo info) override;
unsigned define_associated_field_significance(Varinfo info) override;
};
}
}
#endif
wreport::DTable
BUFR/CREX table D with Dxxyyy aggregate code expansions.
Definition dtable.h:14
wreport::Var
A physical variable.
Definition var.h:25
wreport::Vartable
Holds a variable information table.
Definition vartable.h:30
wreport::bulletin::Printer::define_variable_with_associated_field
void define_variable_with_associated_field(Varinfo info) override
Request processing, according to info, of a data variable.
wreport::bulletin::Printer::run_d_expansion
void run_d_expansion(Varcode code) override
Executes the expansion of code, which has been put on top of the opcode stack.
wreport::bulletin::Printer::define_bitmap
void define_bitmap(unsigned bitmap_size) override
Request processing of a data present bitmap.
wreport::bulletin::Printer::c_modifier
void c_modifier(Varcode code, Opcodes &next) override
Notify of a C modifier.
wreport::bulletin::Printer::indent_step
unsigned indent_step
How many spaces in an indentation level.
Definition interpreter.h:251
wreport::bulletin::Printer::define_bitmap_delayed_replication_factor
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.
wreport::bulletin::Printer::out
FILE * out
Output stream.
Definition interpreter.h:240
wreport::bulletin::Printer::r_replication
void r_replication(Varcode code, Varcode delayed_code, const Opcodes &ops) override
Handle a replicated section.
wreport::bulletin::Printer::define_variable
void define_variable(Varinfo info) override
Request processing, according to info, of a data variable.
wreport::bulletin::Printer::b_variable
void b_variable(Varcode code) override
Notify of a B variable entry.
wreport::bulletin::Printer::define_associated_field_significance
unsigned define_associated_field_significance(Varinfo info) override
Request processing of an associated field significance variable (B31021).
wreport::bulletin::Printer::print_lead
void print_lead(Varcode code)
Print line lead (indentation and formatted code).
wreport::bulletin::Printer::indent
unsigned indent
Current indent level.
Definition interpreter.h:248
wreport::bulletin
The bulletin namespace contains bulletin implementation details, internals and utility functions.
Definition input.h:13
wreport
String functions.
Definition benchmark.h:13
wreport::Varinfo
const _Varinfo * Varinfo
Varinfo reference.
Definition fwd.h:11
wreport::Varcode
uint16_t Varcode
Holds the WMO variable code of a variable.
Definition fwd.h:12
wreport::Opcodes
Sequence of opcodes, as a slice of a Varcode vector.
Definition opcodes.h:20
wreport::Tables
Collection of BUFR/CREX tables used to work on a bulletin.
Definition tables.h:15
wreport::bulletin::AssociatedField
Definition associated_fields.h:13
wreport::bulletin::Bitmaps
Definition bitmaps.h:67
wreport::bulletin::Interpreter::define_substituted_value
virtual void define_substituted_value(unsigned pos)
Request processing of a substituted value corresponding to position pos in the list or previous varia...
wreport::bulletin::Interpreter::define_attribute
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 ...
wreport::bulletin::Interpreter::c_scale_change
int c_scale_change
Current value of scale change from C modifier.
Definition interpreter.h:37
wreport::bulletin::Interpreter::r_replication
virtual void r_replication(Varcode code, Varcode delayed_code, const Opcodes &ops)
Handle a replicated section.
wreport::bulletin::Interpreter::define_bitmap_delayed_replication_factor
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.
wreport::bulletin::Interpreter::run
void run()
Run the interpreter.
wreport::bulletin::Interpreter::b_variable
virtual void b_variable(Varcode code)
Notify of a B variable entry.
wreport::bulletin::Interpreter::define_raw_character_data
virtual void define_raw_character_data(Varcode code)
Request processing of C05yyy raw character data.
wreport::bulletin::Interpreter::c_modifier
virtual void c_modifier(Varcode code, Opcodes &next)
Notify of a C modifier.
wreport::bulletin::Interpreter::c03_refval_override_bits
unsigned c03_refval_override_bits
Set to the number of reference value override bits while reading the override values.
Definition interpreter.h:56
wreport::bulletin::Interpreter::c03_refval_overrides
std::map< wreport::Varcode, uint32_t > c03_refval_overrides
Current reference value overrides.
Definition interpreter.h:52
wreport::bulletin::Interpreter::c_string_len_override
int c_string_len_override
Current value of string length override from C08 modifiers (0 for no override).
Definition interpreter.h:49
wreport::bulletin::Interpreter::define_delayed_replication_factor
virtual unsigned define_delayed_replication_factor(Varinfo info)
Request processing, according to info, of a data variabile that is significant for controlling the en...
wreport::bulletin::Interpreter::define_bitmap
virtual void define_bitmap(unsigned bitmap_size)
Request processing of a data present bitmap.
wreport::bulletin::Interpreter::define_variable
virtual void define_variable(Varinfo info)
Request processing, according to info, of a data variable.
wreport::bulletin::Interpreter::print_c_modifier
static void print_c_modifier(FILE *out, Varcode code, Opcodes &nex)
Print a description of this C modifier.
wreport::bulletin::Interpreter::r_bitmap
virtual void r_bitmap(Varcode code, Varcode delayed_code, const Opcodes &ops)
Handle a replicated section which defines a bitmap.
wreport::bulletin::Interpreter::associated_field
AssociatedField associated_field
Current associated field state.
Definition interpreter.h:34
wreport::bulletin::Interpreter::bitmaps
Bitmaps bitmaps
Bitmap iteration.
Definition interpreter.h:31
wreport::bulletin::Interpreter::define_variable_with_associated_field
virtual void define_variable_with_associated_field(Varinfo info)
Request processing, according to info, of a data variable.
wreport::bulletin::Interpreter::define_c03_refval_override
virtual void define_c03_refval_override(Varcode code)
Request processing of a new value for the reference value of the given B code.
wreport::bulletin::Interpreter::c_scale_ref_width_increase
int c_scale_ref_width_increase
Increase of scale, reference value and data width.
Definition interpreter.h:43
wreport::bulletin::Interpreter::define_associated_field_significance
virtual unsigned define_associated_field_significance(Varinfo info)
Request processing of an associated field significance variable (B31021).
wreport::bulletin::Interpreter::run_d_expansion
virtual void run_d_expansion(Varcode code)
Executes the expansion of code, which has been put on top of the opcode stack.
wreport::bulletin::Interpreter::c_width_change
int c_width_change
Current value of width change from C modifier.
Definition interpreter.h:40
wreport::bulletin::Interpreter::get_varinfo
Varinfo get_varinfo(Varcode code)
Return a Varinfo for the given Varcode, applying all relevant C modifications that are currently acti...
wreport::bulletin::Interpreter::run_r_repetition
virtual void run_r_repetition(unsigned cur, unsigned total)
Executes a repetition of the opcodes on top of the stack.