libwreport
3.29
|
Implement fast access to information about WMO variables. More...
#include <cstdint>
#include <string>
#include <wreport/fwd.h>
Go to the source code of this file.
Data Structures | |
struct | wreport::_Varinfo |
Information about a variable. More... | |
Namespaces | |
wreport | |
String functions. | |
Macros | |
#define | WR_VAR(f, x, y) ((wreport::Varcode)( ((unsigned)(f)<<14) | ((unsigned)(x)<<8) | (unsigned)(y) )) |
Create a WMO variable code from its F, X and Y components. | |
#define | WR_STRING_TO_VAR(str) |
Convert a XXYYY string to a WMO variable code. More... | |
#define | WR_VAR_F(code) (((code) >> 14) & 0x3) |
Get the F part of a WMO variable code. | |
#define | WR_VAR_X(code) ((code) >> 8 & 0x3f) |
Get the X part of a WMO variable code. | |
#define | WR_VAR_Y(code) ((code) & 0xff) |
Get the Y part of a WMO variable code. | |
#define | WR_VAR_FXY(code) WR_VAR_F(code), WR_VAR_X(code), WR_VAR_Y(code) |
Expands to WR_VAR_F(code), WR_VAR_X(code), WR_VAR_Y(code). More... | |
Enumerations | |
enum | wreport::Vartype : unsigned { Integer, Decimal, String, Binary } |
Variable type. | |
Functions | |
std::string | wreport::varcode_format (Varcode code) |
Format a varcode into a string. | |
Varcode | wreport::varcode_parse (const char *desc) |
Convert a FXXYYY string descriptor code into its short integer representation. More... | |
const char * | wreport::vartype_format (Vartype type) |
Return a string description of a Vartype. | |
Vartype | wreport::vartype_parse (const char *s) |
Return a Vartype from its string description. | |
Implement fast access to information about WMO variables.
The measured value of a physical quantity has little meaning without specifying what quantity it represents, what units are used to measure it, and how many digits are significant for the value.
This module provides access to all this metadata:
There are many B tables with slight differences used by different meteorological centre or equipment. This module allows to access different vartables using dba_vartable_create().
wreport::Vartable and wreport::Varinfo have special memory management: they are never deallocated. This is a precise design choice to speed up passing and copying wreport::Varinfo values, that are used very intensely as they accompany all the physical values processed by wreport. This behaviour should not be a cause of memory leaks, since a software would only need to access a limited amount of B tables during its lifetime.
To construct a wreport::Varcode value one needs to provide three numbers: F, X and Y.
The normal text representation of a wreport::Varcode for a WMO B table uses the format Bxxyyy.
#define WR_STRING_TO_VAR | ( | str | ) |
Convert a XXYYY string to a WMO variable code.
This is useful only in rare cases, such as when parsing tables; use descriptor_code() to parse proper entry names such as "B01003" or "D21301".
Expands to WR_VAR_F(code), WR_VAR_X(code), WR_VAR_Y(code).
This is intended as a convenient shortcut to pass a broken down varcode to functions like printf, but not much more than that. Of course it evaluates its argument multiple times.