20 #ifndef WREPORT_OPCODE_H
21 #define WREPORT_OPCODE_H
53 const std::vector<Varcode>&
vals;
60 Opcodes(
const std::vector<Varcode>& vals) : vals(vals), begin(0), end(vals.
size()) {}
62 Opcodes(
const std::vector<Varcode>& vals,
unsigned begin,
unsigned end)
63 : vals(vals), begin(begin), end(end) {}
85 return vals[begin + i];
112 return Opcodes(vals, begin+1, end);
118 if (begin + skip > end)
119 return Opcodes(vals, end, end);
121 return Opcodes(vals, begin + skip, end);
127 if (begin + skip > end)
128 return Opcodes(vals, end, end);
129 else if (begin + skip + len > end)
130 return Opcodes(vals, begin + skip, end);
132 return Opcodes(vals, begin + skip, begin + skip + len);
150 void print(FILE* out)
const;
Opcodes(const std::vector< Varcode > &vals, unsigned begin, unsigned end)
Sequence from begin (inclusive) to end (excluded)
Definition: opcode.h:62
virtual void c_substituted_value(Varcode code)
Notify a substituted value.
virtual void d_group_end(Varcode code)
Notify the end of a D group.
virtual void c_change_data_width(Varcode code, int change)
Notify a change of data width.
virtual void d_group_begin(Varcode code)
Notify the start of a D group.
virtual void c_char_data(Varcode code)
Notify raw character data encoded via a C modifier.
unsigned end
One-past-the-last element of the varcode sequence in Opcodes::vals.
Definition: opcode.h:57
const std::vector< Varcode > & vals
Reference to the vector with all the expanded varcodes.
Definition: opcode.h:53
virtual void b_variable(Varcode code)
Notify of a B variable entry.
void visit(opcode::Visitor &e, const DTable &dtable) const
Walk the structure of the opcodes sending events to an opcode::Visitor.
Opcodes sub(unsigned skip, unsigned len) const
Return len opcodes starting from skip.
Definition: opcode.h:125
virtual void c_substituted_value(Varcode code)
Notify a substituted value.
virtual void c_modifier(Varcode code)
Notify of a C modifier.
FILE * out
Output stream.
Definition: opcode.h:346
virtual void c_associated_field(Varcode code, Varcode sig_code, unsigned nbits)
Notify the declaration of an associated field for the next values.
virtual void d_group_begin(Varcode code)
Notify the start of a D group.
virtual void c_change_data_width(Varcode code, int change)
Notify a change of data width.
virtual void c_substituted_value_bitmap(Varcode code)
Notify a bitmap for substituted values.
virtual void d_group_end(Varcode code)
Notify the end of a D group.
virtual void c_local_descriptor(Varcode code, Varcode desc_code, unsigned nbits)
Notify the length of the following local descriptor.
unsigned indent
Current indent level.
Definition: opcode.h:362
const Vartable * btable
Table used to get variable descriptions (optional).
Definition: opcode.h:354
virtual void b_variable(Varcode code)
Notify of a B variable entry.
Holds a variable information table.
Definition: vartable.h:84
Visitor-style interface for scanning the contents of a data descriptor section.
Definition: opcode.h:167
unsigned size() const
Number of items in this opcode list.
Definition: opcode.h:89
virtual void r_replication(Varcode code, Varcode delayed_code, const Opcodes &ops)
Notify a replicated section.
Varcode head() const
First opcode in the list (0 if the list is empty)
Definition: opcode.h:95
virtual void c_local_descriptor(Varcode code, Varcode desc_code, unsigned nbits)
Notify the length of the following local descriptor.
Opcodes(const Opcodes &o)
Copy constructor.
Definition: opcode.h:65
virtual void c_quality_information_bitmap(Varcode code)
Notify a bitmap for quality information data.
Sequence of opcodes, as a slice of a Varcode vector.
Definition: opcode.h:50
D-table with Dxxyyy aggregate code expansions.
Definition: dtable.h:59
Opcodes(const std::vector< Varcode > &vals)
Sequence spanning the whole vector.
Definition: opcode.h:60
short unsigned int Varcode
Holds the WMO variable code of a variable.
Definition: varinfo.h:78
Main namespace.
Definition: buffers.h:30
Implement fast access to information about WMO variables.
virtual void c_char_data_override(Varcode code, unsigned new_length)
Notify an override of character data length.
const DTable * dtable
D table to use to expand D groups.
Definition: opcode.h:174
virtual void c_char_data(Varcode code)
Notify raw character data encoded via a C modifier.
virtual void c_substituted_value_bitmap(Varcode code)
Notify a bitmap for substituted values.
virtual void c_increase_scale_ref_width(Varcode code, int change)
Notify an increase of scale, reference value and data width.
void print(FILE *out) const
Print the contents of this opcode list.
void print_lead(Varcode code)
Print line lead (indentation and formatted code)
virtual void c_change_data_scale(Varcode code, int change)
Notify a change of data scale.
Opcodes & operator=(const Opcodes &o)
Assignment only works if the Opcodes share the same vector.
Definition: opcode.h:72
virtual void c_modifier(Varcode code)
Notify of a C modifier.
virtual void c_quality_information_bitmap(Varcode code)
Notify a bitmap for quality information data.
unsigned begin
First element of the varcode sequence in Opcodes::vals.
Definition: opcode.h:55
Varcode operator[](unsigned i) const
Return the i-th varcode in the chain.
Definition: opcode.h:80
opcode::Visitor that pretty-prints the opcodes using indentation to show structure ...
Definition: opcode.h:329
virtual void c_associated_field(Varcode code, Varcode sig_code, unsigned nbits)
Notify the declaration of an associated field for the next values.
virtual void r_replication(Varcode code, Varcode delayed_code, const Opcodes &ops)
Notify a replicated section.
Opcodes sub(unsigned skip) const
Return the opcodes from skip until the end.
Definition: opcode.h:116
virtual void c_char_data_override(Varcode code, unsigned new_length)
Notify an override of character data length.
bool empty() const
True if there are no opcodes.
Definition: opcode.h:92
virtual void c_change_data_scale(Varcode code, int change)
Notify a change of data scale.
unsigned indent_step
How many spaces in an indentation level.
Definition: opcode.h:365
Opcodes next() const
List of all opcodes after the first one.
Definition: opcode.h:107