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)
132std::ostream& operator<<(std::ostream& out,
const Vartype& t);
248 [[deprecated(
"Use varinfo_create_bufr")]]
void
270 unsigned bit_len, uint32_t bit_ref = 0,
String functions.
Definition benchmark.h:13
Vartype vartype_parse(const char *s)
Return a Vartype from its string description.
void varinfo_delete(Varinfo &&info)
Deallocate a Varinfo created with create_bufr().
Vartype
Variable type.
Definition varinfo.h:115
std::string varcode_format(Varcode code)
Format a varcode into a string.
const char * vartype_format(Vartype type)
Return a string description of a Vartype.
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.
const _Varinfo * Varinfo
Varinfo reference.
Definition fwd.h:11
Varcode varcode_parse(const char *desc)
Convert a FXXYYY string descriptor code into its short integer representation.
uint16_t Varcode
Holds the WMO variable code of a variable.
Definition fwd.h:12
Information about a variable.
Definition varinfo.h:140
double decode_decimal(int val) const
Decode a double value from a decimal integer value using Varinfo decimal encoding informations (scale...
double round_decimal(double val) const
Round val so that it only fits the significant digits given in scale.
int imin
Minimum unscaled decimal integer value the field can have.
Definition varinfo.h:177
Varcode code
Variable code, as in WMO BUFR/CREX table B.
Definition varinfo.h:142
char unit[24]
Measurement unit of the variable, using the units defined in WMO BUFR/CREX table B.
Definition varinfo.h:152
unsigned len
Length in digits of the variable encoded as a decimal integer.
Definition varinfo.h:163
double dmin
Minimum value the field can have.
Definition varinfo.h:183
int bit_ref
Binary reference value for the variable.
Definition varinfo.h:171
int scale
Scale of the variable, defining its decimal precision.
Definition varinfo.h:160
unsigned bit_len
Length in bits of the variable when encoded as an unsigned binary value.
Definition varinfo.h:174
int imax
Minimum unscaled decimal integer value the field can have.
Definition varinfo.h:180
double decode_binary(uint32_t val) const
Decode a double value from a decimal integer value using Varinfo binary encoding informations (bit_re...
char desc[64]
Freeform variable description.
Definition varinfo.h:148
double dmax
Maximum value the field can have.
Definition varinfo.h:186
uint32_t encode_binary(double fval) const
Encode a double value into a positive integer value using Varinfo binary encoding informations (bit_r...
int encode_decimal(double fval) const
Encode a double value into a decimal integer value using Varinfo decimal encoding informations (scale...
Vartype type
Type of the value stored in the variable.
Definition varinfo.h:145
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.