1 #ifndef WREPORT_VARINFO_H
2 #define WREPORT_VARINFO_H
65 #define WR_VAR(f, x, y) ((wreport::Varcode)( ((unsigned)(f)<<14) | ((unsigned)(x)<<8) | (unsigned)(y) ))
73 #define WR_STRING_TO_VAR(str) ((wreport::Varcode)( \
74 (( ((str)[0] - '0')*10 + ((str)[1] - '0') ) << 8) | \
75 ( ((str)[2] - '0')*100 + ((str)[3] - '0')*10 + ((str)[4] - '0') ) \
79 #define WR_VAR_F(code) (((code) >> 14) & 0x3)
82 #define WR_VAR_X(code) ((code) >> 8 & 0x3f)
85 #define WR_VAR_Y(code) ((code) & 0xff)
94 #define WR_VAR_FXY(code) WR_VAR_F(code), WR_VAR_X(code), WR_VAR_Y(code)
237 int scale=0,
unsigned len=0,
238 int bit_ref=0,
int bit_len=0);
244 int scale=0,
unsigned len=0);
253 void set_string(Varcode code,
const char* desc,
unsigned len);
262 void set_binary(Varcode code,
const char* desc,
unsigned bit_len);
Vartype vartype_parse(const char *s)
Return a Vartype from its string description.
Varcode varcode_parse(const char *desc)
Convert a FXXYYY string descriptor code into its short integer representation.
void set_bufr(Varcode code, const char *desc, const char *unit, int scale=0, unsigned len=0, int bit_ref=0, int bit_len=0)
Set all the base Varinfo fields, then call compute_range.
void compute_range()
Compute the widest ranges for imin, imax, dmin and dmax that can fit any value that can be encoded bo...
double dmax
Maximum value the field can have.
Definition: varinfo.h:182
Vartype type
Type of the value stored in the variable.
Definition: varinfo.h:141
int scale
Scale of the variable, defining its decimal precision.
Definition: varinfo.h:156
Vartype
Variable type.
Definition: varinfo.h:110
Varcode code
Variable code, as in WMO BUFR/CREX table B.
Definition: varinfo.h:138
void set_binary(Varcode code, const char *desc, unsigned bit_len)
Set all the fields to represent an opaque binary variable.
double dmin
Minimum value the field can have.
Definition: varinfo.h:179
double decode_binary(uint32_t val) const
Decode a double value from a decimal integer value using Varinfo binary encoding informations (bit_re...
uint16_t Varcode
Holds the WMO variable code of a variable.
Definition: varinfo.h:57
void set_string(Varcode code, const char *desc, unsigned len)
Set all the fields to represent a string variable.
double round_decimal(double val) const
Round val so that it only fits the significant digits given in scale.
Information about a variable.
Definition: varinfo.h:135
char desc[64]
Freeform variable description.
Definition: varinfo.h:144
int bit_ref
Binary reference value for the variable.
Definition: varinfo.h:167
std::string varcode_format(Varcode code)
Format a varcode into a string.
uint32_t encode_binary(double fval) const
Encode a double value into a positive integer value using Varinfo binary encoding informations (bit_r...
unsigned bit_len
Length in bits of the variable when encoded as an unsigned binary value.
Definition: varinfo.h:170
String functions.
Definition: benchmark.h:13
int imax
Minimum unscaled decimal integer value the field can have.
Definition: varinfo.h:176
const char * vartype_format(Vartype type)
Return a string description of a Vartype.
unsigned len
Length in digits of the variable encoded as a decimal integer.
Definition: varinfo.h:159
double decode_decimal(int val) const
Decode a double value from a decimal integer value using Varinfo decimal encoding informations (scale...
void set_crex(Varcode code, const char *desc, const char *unit, int scale=0, unsigned len=0)
Set all the base Varinfo fields, then call compute_range.
int encode_decimal(double fval) const
Encode a double value into a decimal integer value using Varinfo decimal encoding informations (scale...
const _Varinfo * Varinfo
Varinfo reference.
Definition: varinfo.h:281
int imin
Minimum unscaled decimal integer value the field can have.
Definition: varinfo.h:173
char unit[24]
Measurement unit of the variable, using the units defined in WMO BUFR/CREX table B.
Definition: varinfo.h:148