wreport::_Varinfo Struct Reference

Information about a variable. More...

`#include <varinfo.h>`

## Public Member Functions

int | encode_decimal (double fval) const
| Encode a double value into 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.
uint32_t | encode_binary (double fval) const
| Encode a double value into a positive integer value using Varinfo binary encoding informations (bit_ref and scale).
double | decode_decimal (int val) const
| Decode a double value from a decimal integer value using Varinfo decimal encoding informations (scale).
double | decode_binary (uint32_t val) const
| Decode a double value from a decimal integer value using Varinfo binary encoding informations (bit_ref and 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)
| Set all the base Varinfo fields, then call compute_range.
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.
void | set_string (Varcode code, const char *desc, unsigned len)
| Set all the fields to represent a string variable.
void | set_binary (Varcode code, const char *desc, unsigned bit_len)
| Set all the fields to represent an opaque binary variable.
void | compute_range ()
| Compute the widest ranges for imin, imax, dmin and dmax that can fit any value that can be encoded both with (scale, len) and with (scale, bit_ref, bit_len).

## Data Fields

Varcode | code
| Variable code, as in WMO BUFR/CREX table B.
Vartype | type
| Type of the value stored in the variable.
char | desc [64]
| Freeform variable description.
char | unit [24]
| Measurement unit of the variable, using the units defined in WMO BUFR/CREX table B.
int | scale
| Scale of the variable, defining its decimal precision.
unsigned | len
| Length in digits of the variable encoded as a decimal integer.
int | bit_ref
| Binary reference value for the variable.
unsigned | bit_len
| Length in bits of the variable when encoded as an unsigned binary value.
int | imin
| Minimum unscaled decimal integer value the field can have.
int | imax
| Minimum unscaled decimal integer value the field can have.
double | dmin
| Minimum value the field can have.
double | dmax
| Maximum value the field can have.

## Detailed Description

Information about a variable.

The normal value of a variable is considered expressed in unit

## Member Function Documentation

## decode_binary()

double wreport::_Varinfo::decode_binary | ( | uint32_t | val | ) | const

Decode a double value from a decimal integer value using Varinfo binary encoding informations (bit_ref and scale).

Parameters

  val | Value to decode

Returns
  The decoded double value

## decode_decimal()

double wreport::_Varinfo::decode_decimal | ( | int | val | ) | const

Decode a double value from a decimal integer value using Varinfo decimal encoding informations (scale).

Parameters

  val | Value to decode

Returns
  The decoded double value

## encode_binary()

uint32_t wreport::_Varinfo::encode_binary | ( | double | fval | ) | const

Encode a double value into a positive integer value using Varinfo binary encoding informations (bit_ref and scale).

Parameters

  fval | Value to encode

Returns
  The double value encoded as an unsigned integer

## encode_decimal()

int wreport::_Varinfo::encode_decimal | ( | double | fval | ) | const

Encode a double value into a decimal integer value using Varinfo decimal encoding informations (scale).

Parameters

  fval | Value to encode

Returns
  The double value encoded as an integer

## set_binary()

void wreport::_Varinfo::set_binary | ( | Varcode | code,
|  | const char * | desc,
|  | unsigned | bit_len )

Set all the fields to represent an opaque binary variable.

Parameters

  code | the variable code
  desc | the variable description
  bit_len | the variable length in bits

References bit_len, code, and desc.

## set_string()

void wreport::_Varinfo::set_string | ( | Varcode | code,
|  | const char * | desc,
|  | unsigned | len )

Set all the fields to represent a string variable.

Parameters

  code | the variable code
  desc | the variable description
  len | the maximum string length

References code, desc, and len.

## Field Documentation

## bit_ref

int wreport::_Varinfo::bit_ref

Binary reference value for the variable.

The value of the variable can be encoded as an unsigned binary value by computing value * exp10(scale) + bit_ref.

Referenced by set_bufr().

## scale

int wreport::_Varinfo::scale

Scale of the variable, defining its decimal precision.

The value of the variable can be encoded as a decimal integer by computing value * exp10(scale).

Referenced by set_bufr(), and set_crex().

The documentation for this struct was generated from the following file:

- varinfo.h