libwreport 3.40
internals/vartable.h
1#ifndef WREPORT_INTERNALS_VARTABLE_H
2#define WREPORT_INTERNALS_VARTABLE_H
3
4#include <filesystem>
5#include <string>
6#include <wreport/fwd.h>
7#include <wreport/varinfo.h>
8#include <wreport/vartable.h>
9
10namespace wreport::vartable {
11
12struct Entry
13{
21
32 mutable Entry* alterations = nullptr;
33
34 Entry() = default;
35
39 Entry(const Entry& other, int new_scale, unsigned new_bit_len,
40 int new_bit_ref);
41
47 const Entry* get_alteration(int new_scale, unsigned new_bit_len,
48 int new_bit_ref) const;
49};
50
52class Base : public Vartable
53{
54protected:
56 std::filesystem::path m_pathname;
57
58public:
70 std::vector<Entry> entries;
71
72 explicit Base(const std::filesystem::path& pathname);
73
74 std::string pathname() const override { return m_pathname; }
75
76 std::filesystem::path path() const override { return m_pathname; }
77
78 _Varinfo* obtain(unsigned line_no, Varcode code);
79 const Entry* query_entry(Varcode code) const;
80 Varinfo query(Varcode code) const override;
81 bool contains(Varcode code) const override;
82 Varinfo query_altered(Varcode code, int new_scale, unsigned new_bit_len,
83 int new_bit_ref) const override;
84 bool iterate(std::function<bool(Varinfo)> dest) const override;
85};
86
87struct Bufr : public Base
88{
90 explicit Bufr(const std::filesystem::path& pathname);
91};
92
93struct Crex : public Base
94{
96 explicit Crex(const std::filesystem::path& pathname);
97};
98
99} // namespace wreport::vartable
100
101#endif
Holds a variable information table.
Definition vartable.h:31
Base Vartable implementation.
Definition internals/vartable.h:53
std::string pathname() const override
Return the pathname of the file from which this table has been loaded.
Definition internals/vartable.h:74
Varinfo query(Varcode code) const override
Query the Vartable.
bool contains(Varcode code) const override
Check if the code can be resolved to a varinfo.
bool iterate(std::function< bool(Varinfo)> dest) const override
Iterate the whole contents of the table.
std::vector< Entry > entries
Entries in this Vartable.
Definition internals/vartable.h:70
Varinfo query_altered(Varcode code, int new_scale, unsigned new_bit_len, int new_bit_ref) const override
Query an altered version of the vartable.
std::filesystem::path path() const override
Return the pathname of the file from which this table has been loaded.
Definition internals/vartable.h:76
std::filesystem::path m_pathname
Pathname to the file from which this vartable has been loaded.
Definition internals/vartable.h:56
uint16_t Varcode
Holds the WMO variable code of a variable.
Definition fwd.h:12
Information about a variable.
Definition varinfo.h:140
Definition internals/vartable.h:88
Bufr(const std::filesystem::path &pathname)
Create and load a BUFR B table.
Definition internals/vartable.h:94
Crex(const std::filesystem::path &pathname)
Create and load a CREX B table.
Definition internals/vartable.h:13
Entry * alterations
Altered versions of this Varinfo.
Definition internals/vartable.h:32
_Varinfo varinfo
Master Varinfo structure for this entry.
Definition internals/vartable.h:20
const Entry * get_alteration(int new_scale, unsigned new_bit_len, int new_bit_ref) const
Search for this alteration in the alteration chain.
Entry(const Entry &other, int new_scale, unsigned new_bit_len, int new_bit_ref)
Build an altered entry created for BUFR table C modifiers.
Implement fast access to information about WMO variables.