1 #ifndef WREPORT_BUFR_INPUT_H 2 #define WREPORT_BUFR_INPUT_H 5 #include <wreport/var.h> 6 #include <wreport/bulletin.h> 22 unsigned subset_count;
27 for (
unsigned i = 0; i < subset_count; ++i)
28 out.
subsets[i].store_variable_undef(info);
30 void add_same(
const Var& var)
32 for (
unsigned i = 0; i < subset_count; ++i)
35 void add_var(
unsigned subset,
Var&& var)
37 out.
subsets[subset].store_variable(var);
52 void scan_section_length(
unsigned sec_no);
68 const char* fname =
nullptr;
77 size_t start_offset = 0;
80 unsigned s4_cursor = 0;
98 Input(
const std::string& in);
107 void scan_lead_sections();
120 void scan_other_sections(
bool has_optional);
123 unsigned offset()
const {
return s4_cursor; }
126 unsigned bits_left()
const {
return (data_len - s4_cursor) * 8 + pbyte_len; }
131 return (
unsigned)data[pos];
135 inline unsigned read_byte(
unsigned section,
unsigned pos)
const 137 return (
unsigned)data[sec[section] + pos];
144 for (
unsigned i = 0; i < byte_len; ++i)
147 res |= data[pos + i];
156 inline unsigned read_number(
unsigned section,
unsigned pos,
unsigned byte_len)
const 158 return read_number(sec[section] + pos, byte_len);
169 if (s4_cursor == data_len)
170 parse_error(
"end of buffer while looking for %d bits of bit-packed data", n);
176 for (
unsigned i = 0; i < n; i++)
181 pbyte = data[s4_cursor++];
194 void debug_dump_next_bits(
const char* desc,
int count)
const;
203 void parse_error(
unsigned section,
unsigned pos,
const char* fmt, ...)
const WREPORT_THROWF_ATTRS(4, 5);
217 void check_available_data(
unsigned pos,
size_t datalen,
const char* expected);
233 void check_available_message_data(
unsigned section,
unsigned pos,
size_t datalen,
const char* expected);
249 void check_available_section_data(
unsigned section,
unsigned pos,
size_t datalen,
const char* expected);
263 void decode_compressed_number(
Var& dest, uint32_t base,
unsigned diffbits);
273 void decode_number(
Var& dest);
275 bool decode_compressed_base(
Varinfo info, uint32_t& base, uint32_t& diffbits);
281 void decode_compressed_number(
Varinfo info,
unsigned subsets, std::function<
void(
unsigned,
Var&&)> dest);
304 void decode_compressed_semantic_number(
Var& dest,
unsigned subsets);
322 bool decode_string(
unsigned bit_len,
char* str,
size_t& len);
335 void decode_string(
Var& dest);
348 void decode_string(
Var& dest,
unsigned subsets);
354 void decode_string(
Varinfo info,
unsigned subsets, std::function<
void(
unsigned,
Var&&)> dest);
367 void decode_binary(
Var& dest);
376 std::string decode_uncompressed_bitmap(
unsigned size);
391 std::string decode_compressed_bitmap(
unsigned size);
A physical variable.
Definition: var.h:23
std::vector< Subset > subsets
Decoded variables.
Definition: bulletin.h:123
Storage for the decoded data of a BUFR or CREX message.
Definition: bulletin.h:29
Information about a variable.
Definition: varinfo.h:135
String functions.
Definition: benchmark.h:13
Definition: associated_fields.h:12
#define WREPORT_THROWF_ATTRS(a, b)
Tell the compiler that a function always throws and expects printf-style arguments.
Definition: error.h:56