1 #ifndef WREPORT_VARINFO_H 2 #define WREPORT_VARINFO_H 7 #include <wreport/fwd.h> 68 #define WR_VAR(f, x, y) \ 69 (static_cast<wreport::Varcode>((static_cast<unsigned>(f) << 14) | \ 70 (static_cast<unsigned>(x) << 8) | \ 71 static_cast<unsigned>(y))) 79 #define WR_STRING_TO_VAR(str) \ 80 static_cast<wreport::Varcode>( \ 81 ((((str)[0] - '0') * 10 + ((str)[1] - '0')) << 8) | \ 82 (((str)[2] - '0') * 100 + ((str)[3] - '0') * 10 + ((str)[4] - '0'))) 85 #define WR_VAR_F(code) (((code) >> 14) & 0x3) 88 #define WR_VAR_X(code) ((code) >> 8 & 0x3f) 91 #define WR_VAR_Y(code) ((code) & 0xff) 100 #define WR_VAR_FXY(code) WR_VAR_F(code), WR_VAR_X(code), WR_VAR_Y(code) 132 std::ostream& operator<<(std::ostream& out,
const Vartype& t);
248 [[deprecated(
"Use varinfo_create_bufr")]]
void 270 unsigned bit_len, uint32_t bit_ref = 0,
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.
int encode_decimal(double fval) const
Encode a double value into a decimal integer value using Varinfo decimal encoding informations (scale...
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)
Setup this variable as a BUFR variable.
double dmax
Maximum value the field can have.
Definition: varinfo.h:186
Vartype type
Type of the value stored in the variable.
Definition: varinfo.h:145
uint32_t encode_binary(double fval) const
Encode a double value into a positive integer value using Varinfo binary encoding informations (bit_r...
int scale
Scale of the variable, defining its decimal precision.
Definition: varinfo.h:160
Vartype
Variable type.
Definition: varinfo.h:115
Varcode code
Variable code, as in WMO BUFR/CREX table B.
Definition: varinfo.h:142
const _Varinfo * Varinfo
Varinfo reference.
Definition: fwd.h:10
double dmin
Minimum value the field can have.
Definition: varinfo.h:183
uint16_t Varcode
Holds the WMO variable code of a variable.
Definition: fwd.h:12
Information about a variable.
Definition: varinfo.h:139
double decode_decimal(int val) const
Decode a double value from a decimal integer value using Varinfo decimal encoding informations (scale...
char desc[64]
Freeform variable description.
Definition: varinfo.h:148
int bit_ref
Binary reference value for the variable.
Definition: varinfo.h:171
std::string varcode_format(Varcode code)
Format a varcode into a string.
double round_decimal(double val) const
Round val so that it only fits the significant digits given in scale.
void varinfo_delete(Varinfo &&info)
Deallocate a Varinfo created with create_bufr().
unsigned bit_len
Length in bits of the variable when encoded as an unsigned binary value.
Definition: varinfo.h:174
String functions.
Definition: benchmark.h:13
double decode_binary(uint32_t val) const
Decode a double value from a decimal integer value using Varinfo binary encoding informations (bit_re...
int imax
Minimum unscaled decimal integer value the field can have.
Definition: varinfo.h:180
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:163
Varinfo varinfo_create_bufr(Varcode code, const char *desc, const char *unit, unsigned bit_len, uint32_t bit_ref=0, int scale=0)
Allocate a new Varinfo to store BUFR values.
int imin
Minimum unscaled decimal integer value the field can have.
Definition: varinfo.h:177
char unit[24]
Measurement unit of the variable, using the units defined in WMO BUFR/CREX table B.
Definition: varinfo.h:152