libdballe 9.6
fortran/enq.h
1#ifndef DBALLE_FORTRAN_ENQ_H
2#define DBALLE_FORTRAN_ENQ_H
3
4#include <dballe/core/enq.h>
5#include <dballe/fortran/api.h>
6
7namespace dballe {
8namespace fortran {
9
10struct Enqc : public impl::Enq
11{
12 using Enq::Enq;
13 char* res;
14 unsigned res_len;
15
16 Enqc(const char* key, unsigned len, char* res, unsigned res_len)
17 : Enq(key, len), res(res), res_len(res_len)
18 {
19 }
20
21 const char* name() const override { return "enqc"; }
22
23 void set_bool(bool val) override
24 {
25 API::to_fortran(val ? "1" : "0", res, res_len);
26 missing = false;
27 }
28
29 void set_int(int val) override
30 {
31 API::to_fortran(val, res, res_len);
32 missing = false;
33 }
34
35 void set_dballe_int(int val) override
36 {
37 if (val == MISSING_INT)
38 return;
39 API::to_fortran(val, res, res_len);
40 missing = false;
41 }
42
43 void set_string(const std::string& val) override
44 {
45 API::to_fortran(val, res, res_len);
46 missing = false;
47 }
48
49 void set_ident(const Ident& ident) override
50 {
51 if (ident.is_missing())
52 return;
53 API::to_fortran(ident.get(), res, res_len);
54 missing = false;
55 }
56
57 void set_varcode(wreport::Varcode val) override
58 {
59 char buf[7];
60 dballe::format_bcode(val, buf);
61 API::to_fortran(buf, res, res_len);
62 missing = false;
63 }
64
65 void set_lat(int lat) override
66 {
67 if (lat == MISSING_INT)
68 return;
69 API::to_fortran(lat, res, res_len);
70 missing = false;
71 }
72
73 void set_lon(int lon) override
74 {
75 if (lon == MISSING_INT)
76 return;
77 API::to_fortran(lon, res, res_len);
78 missing = false;
79 }
80
81 void set_var_value(const wreport::Var& var) override
82 {
83 missing = false;
84 API::to_fortran(var.enqc(), res, res_len);
85 }
86};
87
88}
89}
90
91#endif
A station identifier, that can be any string (including the empty string) or a missing value.
Definition: types.h:748
const char * enqc() const
void format_bcode(wreport::Varcode code, char *buf)
Format the B code to its string representation.
uint16_t Varcode
Definition: fortran/enq.h:11
void set_var_value(const wreport::Var &var) override
Set the value using the value of the given variable.
Definition: fortran/enq.h:81
Class passed to key-value accessors to set values in an invoker-defined way.
Definition: core/enq.h:18