Conversion of dumpers to C++ (#278)

ECC-1996: Dumper hierarchy: Use C++ inheritance mechanism instead of hand-crafted virtual tables
This commit is contained in:
joobog 2024-12-18 17:52:24 +01:00 committed by GitHub
parent fdb3e2a05d
commit 546c166b92
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
174 changed files with 10603 additions and 11330 deletions

View File

@ -10,6 +10,7 @@
#
include_directories(
"${CMAKE_CURRENT_SOURCE_DIR}/dumper"
"${CMAKE_CURRENT_SOURCE_DIR}/accessor"
"${CMAKE_CURRENT_SOURCE_DIR}/geo/iterator"
"${CMAKE_CURRENT_SOURCE_DIR}/geo/nearest"
@ -273,23 +274,21 @@ list( APPEND eccodes_src_files
accessor/grib_accessor_class_reference_value_error.cc
grib_memory.cc
grib_buffer.cc
grib_dumper.cc
grib_dumper_class_serialize.cc
grib_dumper_class_debug.cc
grib_dumper_class_default.cc
grib_dumper_class_bufr_encode_C.cc
grib_dumper_class_bufr_encode_filter.cc
grib_dumper_class_bufr_encode_fortran.cc
grib_dumper_class_bufr_encode_python.cc
grib_dumper_class_bufr_decode_C.cc
grib_dumper_class_bufr_decode_filter.cc
grib_dumper_class_bufr_decode_fortran.cc
grib_dumper_class_bufr_decode_python.cc
grib_dumper_class_bufr_simple.cc
grib_dumper_class_json.cc
grib_dumper_class_grib_encode_C.cc
grib_dumper_class_wmo.cc
grib_dumper_class.cc
dumper/grib_dumper_class_serialize.cc
dumper/grib_dumper_class_debug.cc
dumper/grib_dumper_class_default.cc
dumper/grib_dumper_class_bufr_encode_C.cc
dumper/grib_dumper_class_bufr_encode_filter.cc
dumper/grib_dumper_class_bufr_encode_fortran.cc
dumper/grib_dumper_class_bufr_encode_python.cc
dumper/grib_dumper_class_bufr_decode_C.cc
dumper/grib_dumper_class_bufr_decode_filter.cc
dumper/grib_dumper_class_bufr_decode_fortran.cc
dumper/grib_dumper_class_bufr_decode_python.cc
dumper/grib_dumper_class_bufr_simple.cc
dumper/grib_dumper_class_json.cc
dumper/grib_dumper_class_grib_encode_C.cc
dumper/grib_dumper_class_wmo.cc
grib_context.cc
grib_date.cc
grib_fieldset.cc
@ -368,8 +367,7 @@ list( APPEND eccodes_src_files
grib_accessor_factory.h
grib_api_internal.h
eccodes_prototypes.h
grib_dumper_class.h
grib_dumper_factory.h
grib_dumper_factory.cc
grib_iterator_factory.cc
grib_nearest_factory.cc
grib_yacc.h

View File

@ -13,7 +13,6 @@
***************************************************************************/
#include "grib_accessor.h"
#include <iostream>
// Note: A fast cut-down version of strcmp which does NOT return -1
// 0 means input strings are equal and 1 means not equal

View File

@ -4,106 +4,154 @@
* This software is licensed under the terms of the Apache Licence Version 2.0
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
*
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
* In applying this licence, ECMWF does not waive the privileges and immunities
* granted to it by virtue of its status as an intergovernmental organisation
* nor does it submit to any jurisdiction.
*/
#pragma once
#include "grib_api_internal.h"
#include "grib_value.h"
#include "dumper/grib_dumper.h"
class grib_accessor
{
namespace eccodes {
class Dumper;
}
class grib_accessor {
public:
grib_accessor() :
context_(nullptr), name_(nullptr), class_name_(nullptr), name_space_(nullptr), h_(nullptr),
creator_(nullptr), length_(0), offset_(0), parent_(nullptr), next_(nullptr), previous_(nullptr),
flags_(0), sub_section_(nullptr), dirty_(0), same_(nullptr), loop_(0), vvalue_(nullptr), set_(nullptr), parent_as_attribute_(nullptr) {}
grib_accessor()
: context_(nullptr),
name_(nullptr),
class_name_(nullptr),
name_space_(nullptr),
h_(nullptr),
creator_(nullptr),
length_(0),
offset_(0),
parent_(nullptr),
next_(nullptr),
previous_(nullptr),
flags_(0),
sub_section_(nullptr),
dirty_(0),
same_(nullptr),
loop_(0),
vvalue_(nullptr),
set_(nullptr),
parent_as_attribute_(nullptr) {}
grib_accessor(const char* name) :
context_(nullptr), name_(name), class_name_(nullptr), name_space_(nullptr), h_(nullptr),
creator_(nullptr), length_(0), offset_(0), parent_(nullptr), next_(nullptr), previous_(nullptr),
flags_(0), sub_section_(nullptr), dirty_(0), same_(nullptr), loop_(0), vvalue_(nullptr), set_(nullptr), parent_as_attribute_(nullptr) {}
virtual ~grib_accessor() {}
grib_accessor(const char *name)
: context_(nullptr),
name_(name),
class_name_(nullptr),
name_space_(nullptr),
h_(nullptr),
creator_(nullptr),
length_(0),
offset_(0),
parent_(nullptr),
next_(nullptr),
previous_(nullptr),
flags_(0),
sub_section_(nullptr),
dirty_(0),
same_(nullptr),
loop_(0),
vvalue_(nullptr),
set_(nullptr),
parent_as_attribute_(nullptr) {}
virtual ~grib_accessor() {}
virtual void init_accessor(const long, grib_arguments*) = 0;
virtual void dump(grib_dumper* f) = 0;
virtual int pack_missing() = 0;
// virtual int grib_pack_zero(grib_accessor* a) = 0;
virtual int is_missing_internal() = 0;
virtual int pack_double(const double* v, size_t* len) = 0;
virtual int pack_float(const float* v, size_t* len) = 0;
virtual int pack_expression(grib_expression* e) = 0;
virtual int pack_string(const char* v, size_t* len) = 0;
virtual int pack_string_array(const char** v, size_t* len) = 0;
virtual int pack_long(const long* v, size_t* len) = 0;
virtual int pack_bytes(const unsigned char* v, size_t* len) = 0;
virtual int unpack_bytes(unsigned char* v, size_t* len) = 0;
virtual int unpack_double_subarray(double* v, size_t start, size_t len) = 0;
virtual int unpack_double(double* v, size_t* len) = 0;
virtual int unpack_float(float* v, size_t* len) = 0;
virtual int unpack_double_element(size_t i, double* v) = 0;
virtual int unpack_float_element(size_t i, float* v) = 0;
virtual int unpack_double_element_set(const size_t* index_array, size_t len, double* val_array) = 0;
virtual int unpack_float_element_set(const size_t* index_array, size_t len, float* val_array) = 0;
virtual int unpack_string(char* v, size_t* len) = 0;
virtual int unpack_string_array(char** v, size_t* len) = 0;
virtual int unpack_long(long* v, size_t* len) = 0;
virtual long get_native_type() = 0;
virtual long get_next_position_offset() = 0;
virtual size_t string_length() = 0;
virtual long byte_offset() = 0;
virtual long byte_count() = 0;
virtual int value_count(long* count) = 0;
virtual int notify_change(grib_accessor* changed) = 0;
virtual grib_accessor* clone(grib_section* s, int* err) = 0;
virtual void update_size(size_t len) = 0;
virtual int nearest_smaller_value(double val, double* nearest) = 0;
virtual size_t preferred_size(int from_handle) = 0;
virtual grib_accessor* next_accessor() = 0;
virtual void resize(size_t new_size) = 0;
virtual void destroy(grib_context* ct) = 0;
virtual int compare_accessors(grib_accessor* a2, int compare_flags);
virtual int compare(grib_accessor*) = 0;
virtual int add_attribute(grib_accessor* attr, int nest_if_clash);
virtual grib_accessor* get_attribute_index(const char* name, int* index);
virtual int has_attributes();
virtual grib_accessor* get_attribute(const char* name);
virtual void init(const long, grib_arguments*) = 0;
virtual void post_init() = 0;
virtual grib_section* sub_section() = 0;
virtual grib_accessor* create_empty_accessor() = 0;
virtual int is_missing() = 0;
virtual long next_offset() = 0;
virtual grib_accessor* next(grib_accessor*, int) = 0;
virtual int clear() = 0;
virtual grib_accessor* make_clone(grib_section*, int*) = 0;
virtual void init_accessor(const long, grib_arguments *) = 0;
virtual void dump(eccodes::Dumper *f) = 0;
virtual int pack_missing() = 0;
// virtual int grib_pack_zero(grib_accessor* a) = 0;
virtual int is_missing_internal() = 0;
virtual int pack_double(const double *v, size_t *len) = 0;
virtual int pack_float(const float *v, size_t *len) = 0;
virtual int pack_expression(grib_expression *e) = 0;
virtual int pack_string(const char *v, size_t *len) = 0;
virtual int pack_string_array(const char **v, size_t *len) = 0;
virtual int pack_long(const long *v, size_t *len) = 0;
virtual int pack_bytes(const unsigned char *v, size_t *len) = 0;
virtual int unpack_bytes(unsigned char *v, size_t *len) = 0;
virtual int unpack_double_subarray(double *v, size_t start, size_t len) = 0;
virtual int unpack_double(double *v, size_t *len) = 0;
virtual int unpack_float(float *v, size_t *len) = 0;
virtual int unpack_double_element(size_t i, double *v) = 0;
virtual int unpack_float_element(size_t i, float *v) = 0;
virtual int unpack_double_element_set(const size_t *index_array,
size_t len,
double *val_array) = 0;
virtual int unpack_float_element_set(const size_t *index_array,
size_t len,
float *val_array) = 0;
virtual int unpack_string(char *v, size_t *len) = 0;
virtual int unpack_string_array(char **v, size_t *len) = 0;
virtual int unpack_long(long *v, size_t *len) = 0;
virtual long get_native_type() = 0;
virtual long get_next_position_offset() = 0;
virtual size_t string_length() = 0;
virtual long byte_offset() = 0;
virtual long byte_count() = 0;
virtual int value_count(long *count) = 0;
virtual int notify_change(grib_accessor *changed) = 0;
virtual grib_accessor *clone(grib_section *s, int *err) = 0;
virtual void update_size(size_t len) = 0;
virtual int nearest_smaller_value(double val, double *nearest) = 0;
virtual size_t preferred_size(int from_handle) = 0;
virtual grib_accessor *next_accessor() = 0;
virtual void resize(size_t new_size) = 0;
virtual void destroy(grib_context *ct) = 0;
virtual int compare_accessors(grib_accessor *a2, int compare_flags);
virtual int compare(grib_accessor *) = 0;
virtual int add_attribute(grib_accessor *attr, int nest_if_clash);
virtual grib_accessor *get_attribute_index(const char *name, int *index);
virtual int has_attributes();
virtual grib_accessor *get_attribute(const char *name);
virtual void init(const long, grib_arguments *) = 0;
virtual void post_init() = 0;
virtual grib_section *sub_section() = 0;
virtual grib_accessor *create_empty_accessor() = 0;
virtual int is_missing() = 0;
virtual long next_offset() = 0;
virtual grib_accessor *next(grib_accessor *, int) = 0;
virtual int clear() = 0;
virtual grib_accessor *make_clone(grib_section *, int *) = 0;
public:
// TODO(maee): make private
grib_context* context_ = nullptr;
const char* name_ = nullptr; // name of the accessor
const char* class_name_ = nullptr; // name of the class (Artifact from C version of ecCodes)
const char* name_space_ = nullptr; // namespace to which the accessor belongs
grib_handle* h_ = nullptr;
grib_action* creator_ = nullptr; // action that created the accessor
long length_ = 0; // byte length of the accessor
long offset_ = 0; // offset of the data in the buffer
grib_section* parent_ = nullptr; // section to which the accessor is attached
grib_accessor* next_ = nullptr; // next accessor in list
grib_accessor* previous_ = nullptr; // next accessor in list
unsigned long flags_ = 0; // Various flags
grib_section* sub_section_ = nullptr;
// TODO(maee): make private
grib_context *context_ = nullptr;
const char *name_ = nullptr; // name of the accessor
const char *class_name_ =
nullptr; // name of the class (Artifact from C version of ecCodes)
const char *name_space_ = nullptr; // namespace to which the accessor belongs
grib_handle *h_ = nullptr;
grib_action *creator_ = nullptr; // action that created the accessor
long length_ = 0; // byte length of the accessor
long offset_ = 0; // offset of the data in the buffer
grib_section *parent_ = nullptr; // section to which the accessor is attached
grib_accessor *next_ = nullptr; // next accessor in list
grib_accessor *previous_ = nullptr; // next accessor in list
unsigned long flags_ = 0; // Various flags
grib_section *sub_section_ = nullptr;
const char* all_names_[MAX_ACCESSOR_NAMES] = {0,}; // name of the accessor
const char* all_name_spaces_[MAX_ACCESSOR_NAMES] = {0,}; // namespace to which the accessor belongs
int dirty_ = 0;
const char *all_names_[MAX_ACCESSOR_NAMES] = {
0,
}; // name of the accessor
const char *all_name_spaces_[MAX_ACCESSOR_NAMES] = {
0,
}; // namespace to which the accessor belongs
int dirty_ = 0;
grib_accessor* same_ = nullptr; // accessors with the same name
long loop_ = 0; // used in lists
grib_virtual_value* vvalue_ = nullptr; // virtual value used when transient flag on
const char* set_ = nullptr;
grib_accessor* attributes_[MAX_ACCESSOR_ATTRIBUTES] = {0,}; // attributes are accessors
grib_accessor* parent_as_attribute_ = nullptr;
grib_accessor *same_ = nullptr; // accessors with the same name
long loop_ = 0; // used in lists
grib_virtual_value *vvalue_ =
nullptr; // virtual value used when transient flag on
const char *set_ = nullptr;
grib_accessor *attributes_[MAX_ACCESSOR_ATTRIBUTES] = {
0,
}; // attributes are accessors
grib_accessor *parent_as_attribute_ = nullptr;
};

View File

@ -31,9 +31,9 @@ size_t grib_accessor_ascii_t::string_length()
return length_;
}
void grib_accessor_ascii_t::dump(grib_dumper* dumper)
void grib_accessor_ascii_t::dump(eccodes::Dumper* dumper)
{
grib_dump_string(dumper, this, NULL);
dumper->dump_string(this, NULL);
}
long grib_accessor_ascii_t::get_native_type()

View File

@ -27,7 +27,7 @@ public:
int unpack_string(char*, size_t* len) override;
size_t string_length() override;
int value_count(long*) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
int compare(grib_accessor*) override;
};

View File

@ -67,14 +67,14 @@ long grib_accessor_bitmap_t::next_offset()
return byte_offset() + byte_count();
}
void grib_accessor_bitmap_t::dump(grib_dumper* dumper)
void grib_accessor_bitmap_t::dump(eccodes::Dumper* dumper)
{
long len = 0;
char label[1024];
value_count(&len);
snprintf(label, sizeof(label), "Bitmap of %ld values", len);
grib_dump_bytes(dumper, this, label);
dumper->dump_bytes(this, label);
}
int grib_accessor_bitmap_t::unpack_long(long* val, size_t* len)

View File

@ -24,7 +24,7 @@ public:
int unpack_string(char*, size_t* len) override;
size_t string_length() override;
long next_offset() override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
void update_size(size_t) override;
int unpack_double_element(size_t i, double* val) override;

View File

@ -39,7 +39,7 @@ int grib_accessor_blob_t::unpack_bytes(unsigned char* buffer, size_t* len)
return GRIB_SUCCESS;
}
void grib_accessor_blob_t::dump(grib_dumper* dumper)
void grib_accessor_blob_t::dump(eccodes::Dumper* dumper)
{
grib_dump_bytes(dumper, this, NULL);
dumper->dump_bytes(this, NULL);
}

View File

@ -20,6 +20,6 @@ public:
grib_accessor* create_empty_accessor() override { return new grib_accessor_blob_t{}; }
long get_native_type() override;
int unpack_bytes(unsigned char*, size_t* len) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
};

View File

@ -3224,11 +3224,11 @@ int grib_accessor_bufr_data_array_t::process_elements(int flag, long onlySubset,
return err;
}
void grib_accessor_bufr_data_array_t::dump(grib_dumper* dumper)
void grib_accessor_bufr_data_array_t::dump(eccodes::Dumper* dumper)
{
// grib_accessor_bufr_data_array_t *self =(grib_accessor_bufr_data_array_t*)a;
// int err=process_elements(a,PROCESS_DECODE);
// grib_dump_section(dumper,a,self->dataKeys_ ->block);
// dumper->dump_section(a,self->dataKeys_ ->block);
return;
}

View File

@ -38,7 +38,7 @@ public:
long next_offset() override;
int value_count(long*) override;
void destroy(grib_context*) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
void accessor_bufr_data_array_set_unpackMode(int);

View File

@ -79,19 +79,19 @@ void grib_accessor_bufr_data_element_t::init(const long len, grib_arguments* par
cname_ = NULL;
}
void grib_accessor_bufr_data_element_t::dump(grib_dumper* dumper)
void grib_accessor_bufr_data_element_t::dump(eccodes::Dumper* dumper)
{
const int ntype = get_native_type();
switch (ntype) {
case GRIB_TYPE_LONG:
grib_dump_long(dumper, this, NULL);
dumper->dump_long(this, NULL);
break;
case GRIB_TYPE_DOUBLE:
grib_dump_values(dumper, this);
dumper->dump_values(this);
break;
case GRIB_TYPE_STRING:
grib_dump_string_array(dumper, this, NULL);
dumper->dump_string_array(this, NULL);
break;
}
}

View File

@ -31,7 +31,7 @@ public:
int unpack_string_array(char**, size_t* len) override;
int value_count(long*) override;
void destroy(grib_context*) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
int unpack_double_element(size_t i, double* val) override;
grib_accessor* make_clone(grib_section*, int*) override;

View File

@ -13,9 +13,9 @@
grib_accessor_bufr_group_t _grib_accessor_bufr_group{};
grib_accessor* grib_accessor_bufr_group = &_grib_accessor_bufr_group;
void grib_accessor_bufr_group_t::dump(grib_dumper* dumper)
void grib_accessor_bufr_group_t::dump(eccodes::Dumper* dumper)
{
grib_dump_section(dumper, this, sub_section_->block);
dumper->dump_section(this, sub_section_->block);
}
grib_accessor* grib_accessor_bufr_group_t::next(grib_accessor* a, int explore)

View File

@ -18,6 +18,6 @@ public:
grib_accessor_bufr_group_t() :
grib_accessor_variable_t() { class_name_ = "bufr_group"; }
grib_accessor* create_empty_accessor() override { return new grib_accessor_bufr_group_t{}; }
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
grib_accessor* next(grib_accessor*, int explore) override;
};

View File

@ -24,9 +24,9 @@ void grib_accessor_bufr_string_values_t::init(const long len, grib_arguments* ar
flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY;
}
void grib_accessor_bufr_string_values_t::dump(grib_dumper* dumper)
void grib_accessor_bufr_string_values_t::dump(eccodes::Dumper* dumper)
{
grib_dump_string_array(dumper, this, NULL);
dumper->dump_string_array(this, NULL);
}
grib_accessor* grib_accessor_bufr_string_values_t::get_accessor()

View File

@ -22,7 +22,7 @@ public:
int unpack_string_array(char**, size_t* len) override;
int value_count(long*) override;
void destroy(grib_context*) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
private:

View File

@ -33,9 +33,9 @@ void grib_accessor_closest_date_t::init(const long l, grib_arguments* c)
length_ = 0;
}
void grib_accessor_closest_date_t::dump(grib_dumper* dumper)
void grib_accessor_closest_date_t::dump(eccodes::Dumper* dumper)
{
grib_dump_string(dumper, this, NULL);
dumper->dump_string(this, NULL);
}
int grib_accessor_closest_date_t::unpack_long(long* val, size_t* len)

View File

@ -20,7 +20,7 @@ public:
grib_accessor* create_empty_accessor() override { return new grib_accessor_closest_date_t{}; }
int unpack_double(double* val, size_t* len) override;
int unpack_long(long* val, size_t* len) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
private:

View File

@ -101,7 +101,7 @@ int grib_accessor_codeflag_t::value_count(long* count)
return 0;
}
void grib_accessor_codeflag_t::dump(grib_dumper* dumper)
void grib_accessor_codeflag_t::dump(eccodes::Dumper* dumper)
{
long v = 0;
char flagname[1024] = {0,};
@ -113,5 +113,5 @@ void grib_accessor_codeflag_t::dump(grib_dumper* dumper)
unpack_long(&v, &llen);
grib_get_codeflag(v, flagname);
grib_dump_bits(dumper, this, flagname);
dumper->dump_bits(this, flagname);
}

View File

@ -19,7 +19,7 @@ public:
grib_accessor_unsigned_t() { class_name_ = "codeflag"; }
grib_accessor* create_empty_accessor() override { return new grib_accessor_codeflag_t{}; }
int value_count(long*) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
private:

View File

@ -506,7 +506,7 @@ int codes_codetable_check_abbreviation(const grib_handle* h, const char* key, co
return err;
}
void grib_accessor_codetable_t::dump(grib_dumper* dumper)
void grib_accessor_codetable_t::dump(eccodes::Dumper* dumper)
{
char comment[2048];
grib_codetable* table;
@ -560,7 +560,7 @@ void grib_accessor_codetable_t::dump(grib_dumper* dumper)
}
strcat(comment, ") ");
grib_dump_long(dumper, this, comment);
dumper->dump_long(this, comment);
}
int grib_accessor_codetable_t::unpack_string(char* buffer, size_t* len)

View File

@ -27,7 +27,7 @@ public:
int unpack_string(char*, size_t* len) override;
int value_count(long*) override;
void destroy(grib_context*) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
grib_codetable* codetable() const { return table_; }

View File

@ -40,9 +40,9 @@ void grib_accessor_concept_t::init(const long len, grib_arguments* args)
length_ = 0;
}
void grib_accessor_concept_t::dump(grib_dumper* dumper)
void grib_accessor_concept_t::dump(eccodes::Dumper* dumper)
{
grib_dump_string(dumper, this, NULL);
dumper->dump_string(this, NULL);
}
// See ECC-1905

View File

@ -28,7 +28,7 @@ public:
size_t string_length() override;
int value_count(long*) override;
void destroy(grib_context*) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
int compare(grib_accessor*) override;
};

View File

@ -27,9 +27,9 @@ void grib_accessor_data_apply_bitmap_t::init(const long v, grib_arguments* args)
length_ = 0;
}
void grib_accessor_data_apply_bitmap_t::dump(grib_dumper* dumper)
void grib_accessor_data_apply_bitmap_t::dump(eccodes::Dumper* dumper)
{
grib_dump_values(dumper, this);
dumper->dump_values(this);
}
int grib_accessor_data_apply_bitmap_t::value_count(long* count)

View File

@ -23,7 +23,7 @@ public:
int unpack_double(double* val, size_t* len) override;
int unpack_float(float* val, size_t* len) override;
int value_count(long*) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
int compare(grib_accessor*) override;
int unpack_double_element(size_t i, double* val) override;

View File

@ -26,9 +26,9 @@ void grib_accessor_data_apply_boustrophedonic_t::init(const long v, grib_argumen
length_ = 0;
}
void grib_accessor_data_apply_boustrophedonic_t::dump(grib_dumper* dumper)
void grib_accessor_data_apply_boustrophedonic_t::dump(eccodes::Dumper* dumper)
{
grib_dump_values(dumper, this);
dumper->dump_values(this);
}
int grib_accessor_data_apply_boustrophedonic_t::value_count(long* numberOfPoints)

View File

@ -23,7 +23,7 @@ public:
int unpack_double(double* val, size_t* len) override;
int unpack_float(float* val, size_t* len) override;
int value_count(long*) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
int unpack_double_element(size_t i, double* val) override;
int unpack_double_element_set(const size_t* index_array, size_t len, double* val_array) override;

View File

@ -31,9 +31,9 @@ void grib_accessor_data_apply_boustrophedonic_bitmap_t::init(const long v, grib_
length_ = 0;
}
void grib_accessor_data_apply_boustrophedonic_bitmap_t::dump(grib_dumper* dumper)
void grib_accessor_data_apply_boustrophedonic_bitmap_t::dump(eccodes::Dumper* dumper)
{
grib_dump_values(dumper, this);
dumper->dump_values(this);
}
int grib_accessor_data_apply_boustrophedonic_bitmap_t::value_count(long* count)

View File

@ -22,7 +22,7 @@ public:
int pack_double(const double* val, size_t* len) override;
int unpack_double(double* val, size_t* len) override;
int value_count(long*) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
int unpack_double_element(size_t i, double* val) override;
int unpack_double_element_set(const size_t* index_array, size_t len, double* val_array) override;

View File

@ -45,7 +45,7 @@ long number_of_bits(grib_handle* h, unsigned long x)
n++;
i++;
if (i >= count) {
/*grib_dump_content(h, stdout,"debug", ~0, NULL);*/
/*h->dump_content(stdout,"debug", ~0, NULL);*/
grib_context_log(h->context, GRIB_LOG_FATAL,
"grib_accessor_data_g1second_order_general_extended_packing: Number out of range: %ld", x);
}

View File

@ -24,9 +24,9 @@ void grib_accessor_data_secondary_bitmap_t::init(const long v, grib_arguments* a
length_ = 0;
}
void grib_accessor_data_secondary_bitmap_t::dump(grib_dumper* dumper)
void grib_accessor_data_secondary_bitmap_t::dump(eccodes::Dumper* dumper)
{
grib_dump_values(dumper, this);
dumper->dump_values(this);
}
int grib_accessor_data_secondary_bitmap_t::unpack_double(double* val, size_t* len)

View File

@ -20,7 +20,7 @@ public:
// grib_accessor* create_empty_accessor() override { return new grib_accessor_data_secondary_bitmap_t{}; }
long get_native_type() override;
int unpack_double(double* val, size_t* len) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
protected:

View File

@ -24,9 +24,9 @@ void grib_accessor_data_shsimple_packing_t::init(const long v, grib_arguments* a
length_ = 0;
}
void grib_accessor_data_shsimple_packing_t::dump(grib_dumper* dumper)
void grib_accessor_data_shsimple_packing_t::dump(eccodes::Dumper* dumper)
{
grib_dump_values(dumper, this);
dumper->dump_values(this);
}
int grib_accessor_data_shsimple_packing_t::pack_double(const double* val, size_t* len)

View File

@ -20,7 +20,7 @@ public:
// grib_accessor* create_empty_accessor() override { return new grib_accessor_data_shsimple_packing_t{}; }
long get_native_type() override;
int pack_double(const double* val, size_t* len) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
protected:

View File

@ -143,17 +143,17 @@ grib_trie* grib_accessor_dictionary_t::load_dictionary(int* err)
return dictionary;
}
void grib_accessor_dictionary_t::dump(grib_dumper* dumper)
void grib_accessor_dictionary_t::dump(eccodes::Dumper* dumper)
{
switch (get_native_type()) {
case GRIB_TYPE_STRING:
grib_dump_string(dumper, this, NULL);
dumper->dump_string(this, NULL);
break;
case GRIB_TYPE_LONG:
grib_dump_long(dumper, this, NULL);
dumper->dump_long(this, NULL);
break;
case GRIB_TYPE_DOUBLE:
grib_dump_double(dumper, this, NULL);
dumper->dump_double(this, NULL);
break;
}
}

View File

@ -23,7 +23,7 @@ public:
int unpack_long(long* val, size_t* len) override;
int unpack_string(char*, size_t* len) override;
int value_count(long*) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
private:

View File

@ -53,9 +53,9 @@ int grib_accessor_double_t::unpack_string(char* v, size_t* len)
return GRIB_SUCCESS;
}
void grib_accessor_double_t::dump(grib_dumper* dumper)
void grib_accessor_double_t::dump(eccodes::Dumper* dumper)
{
grib_dump_values(dumper, this);
dumper->dump_values(this);
}
int grib_accessor_double_t::compare(grib_accessor* b)

View File

@ -21,6 +21,6 @@ public:
long get_native_type() override;
int pack_missing() override;
int unpack_string(char*, size_t* len) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
int compare(grib_accessor*) override;
};

View File

@ -21,9 +21,9 @@ void grib_accessor_g1_half_byte_codeflag_t::init(const long len, grib_arguments*
flags_ |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC;
}
void grib_accessor_g1_half_byte_codeflag_t::dump(grib_dumper* dumper)
void grib_accessor_g1_half_byte_codeflag_t::dump(eccodes::Dumper* dumper)
{
grib_dump_long(dumper, this, NULL);
dumper->dump_long(this, NULL);
}
int grib_accessor_g1_half_byte_codeflag_t::unpack_long(long* val, size_t* len)

View File

@ -21,6 +21,6 @@ public:
long get_native_type() override;
int pack_long(const long* val, size_t* len) override;
int unpack_long(long* val, size_t* len) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
};

View File

@ -19,9 +19,9 @@ void grib_accessor_g1day_of_the_year_date_t::init(const long l, grib_arguments*
flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY;
}
void grib_accessor_g1day_of_the_year_date_t::dump(grib_dumper* dumper)
void grib_accessor_g1day_of_the_year_date_t::dump(eccodes::Dumper* dumper)
{
grib_dump_string(dumper, this, NULL);
dumper->dump_string(this, NULL);
}
int grib_accessor_g1day_of_the_year_date_t::unpack_string(char* val, size_t* len)

View File

@ -19,6 +19,6 @@ public:
grib_accessor_g1date_t() { class_name_ = "g1day_of_the_year_date"; }
grib_accessor* create_empty_accessor() override { return new grib_accessor_g1day_of_the_year_date_t{}; }
int unpack_string(char*, size_t* len) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
};

View File

@ -29,9 +29,9 @@ void grib_accessor_g1forecastmonth_t::init(const long l, grib_arguments* c)
}
}
void grib_accessor_g1forecastmonth_t::dump(grib_dumper* dumper)
void grib_accessor_g1forecastmonth_t::dump(eccodes::Dumper* dumper)
{
grib_dump_long(dumper, this, NULL);
dumper->dump_long(this, NULL);
}
static int calculate_fcmonth(grib_accessor* a, long verification_yearmonth, long base_date, long day, long hour, long* result)

View File

@ -20,7 +20,7 @@ public:
grib_accessor* create_empty_accessor() override { return new grib_accessor_g1forecastmonth_t{}; }
int pack_long(const long* val, size_t* len) override;
int unpack_long(long* val, size_t* len) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
private:

View File

@ -36,9 +36,9 @@ void grib_accessor_g1step_range_t::init(const long l, grib_arguments* c)
length_ = 0;
}
void grib_accessor_g1step_range_t::dump(grib_dumper* dumper)
void grib_accessor_g1step_range_t::dump(eccodes::Dumper* dumper)
{
grib_dump_string(dumper, this, NULL);
dumper->dump_string(this, NULL);
}
static const int u2s1[] = {

View File

@ -26,7 +26,7 @@ public:
size_t string_length() override;
int value_count(long*) override;
void destroy(grib_context*) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
protected:

View File

@ -45,9 +45,9 @@ void grib_accessor_g2end_step_t::init(const long l, grib_arguments* c)
numberOfTimeRanges_ = c->get_name(h, n++);
}
void grib_accessor_g2end_step_t::dump(grib_dumper* dumper)
void grib_accessor_g2end_step_t::dump(eccodes::Dumper* dumper)
{
grib_dump_double(dumper, this, NULL);
dumper->dump_double(this, NULL);
}
// See GRIB-488

View File

@ -24,7 +24,7 @@ public:
int unpack_double(double* val, size_t* len) override;
int unpack_long(long* val, size_t* len) override;
int unpack_string(char*, size_t* len) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
private:

View File

@ -28,9 +28,9 @@ void grib_accessor_g2step_range_t::init(const long l, grib_arguments* c)
length_ = 0;
}
// static void dump(grib_accessor* a, grib_dumper* dumper)
// static void dump(grib_accessor* a, eccodes::Dumper* dumper)
//{
// grib_dump_string(dumper, a, NULL);
// dumper->dump_string(a, NULL);
//}
int grib_accessor_g2step_range_t::unpack_string(char* val, size_t* len)

View File

@ -4,15 +4,15 @@
* This software is licensed under the terms of the Apache Licence Version 2.0
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
*
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
* In applying this licence, ECMWF does not waive the privileges and immunities
* granted to it by virtue of its status as an intergovernmental organisation
* nor does it submit to any jurisdiction.
*/
#include "grib_accessor_class.h"
#include "grib_accessor_class_gen.h"
#include "grib_accessor_class.h"
#include <stdexcept>
grib_accessor_gen_t _grib_accessor_gen = grib_accessor_gen_t{};
grib_accessor* grib_accessor_gen = &_grib_accessor_gen;
@ -70,21 +70,21 @@ void grib_accessor_gen_t::init(const long len, grib_arguments* param)
}
}
void grib_accessor_gen_t::dump(grib_dumper* dumper)
void grib_accessor_gen_t::dump(eccodes::Dumper* dumper)
{
const int type = get_native_type();
switch (type) {
case GRIB_TYPE_STRING:
grib_dump_string(dumper, this, NULL);
dumper->dump_string(this, NULL);
break;
case GRIB_TYPE_DOUBLE:
grib_dump_double(dumper, this, NULL);
dumper->dump_double(this, NULL);
break;
case GRIB_TYPE_LONG:
grib_dump_long(dumper, this, NULL);
dumper->dump_long(this, NULL);
break;
default:
grib_dump_bytes(dumper, this, NULL);
dumper->dump_bytes(this, NULL);
}
}
@ -111,8 +111,11 @@ long grib_accessor_gen_t::byte_count()
long grib_accessor_gen_t::get_native_type()
{
grib_context_log(context_, GRIB_LOG_ERROR,
"Accessor %s [%s] must implement 'get_native_type'", name_, class_name_);
grib_context_log(context_,
GRIB_LOG_ERROR,
"Accessor %s [%s] must implement 'get_native_type'",
name_,
class_name_);
return GRIB_TYPE_UNDEFINED;
}
@ -124,11 +127,15 @@ long grib_accessor_gen_t::byte_offset()
int grib_accessor_gen_t::unpack_bytes(unsigned char* val, size_t* len)
{
const unsigned char* buf = grib_handle_of_accessor(this)->buffer->data;
const long length = byte_count();
const long offset = byte_offset();
const long length = byte_count();
const long offset = byte_offset();
if (*len < length) {
grib_context_log(context_, GRIB_LOG_ERROR, "Wrong size for %s, it is %ld bytes long", name_, length);
grib_context_log(context_,
GRIB_LOG_ERROR,
"Wrong size for %s, it is %ld bytes long",
name_,
length);
*len = length;
return GRIB_ARRAY_TOO_SMALL;
}
@ -163,7 +170,8 @@ int grib_accessor_gen_t::unpack_long(long* v, size_t* len)
*v = GRIB_MISSING_LONG;
else
*v = (long)val;
grib_context_log(context_, GRIB_LOG_DEBUG, "Casting double %s to long", name_);
grib_context_log(
context_, GRIB_LOG_DEBUG, "Casting double %s to long", name_);
return GRIB_SUCCESS;
}
}
@ -178,15 +186,21 @@ int grib_accessor_gen_t::unpack_long(long* v, size_t* len)
*v = strtol(val, &last, 10);
if (*last == 0) {
grib_context_log(context_, GRIB_LOG_DEBUG, "Casting string %s to long", name_);
grib_context_log(
context_, GRIB_LOG_DEBUG, "Casting string %s to long", name_);
return GRIB_SUCCESS;
}
}
}
grib_context_log(context_, GRIB_LOG_ERROR, "Cannot unpack key '%s' as long", name_);
if (grib_get_native_type(grib_handle_of_accessor(this), name_, &type) == GRIB_SUCCESS) {
grib_context_log(context_, GRIB_LOG_ERROR, "Hint: Try unpacking as %s", grib_get_type_name(type));
grib_context_log(
context_, GRIB_LOG_ERROR, "Cannot unpack key '%s' as long", name_);
if (grib_get_native_type(grib_handle_of_accessor(this), name_, &type) ==
GRIB_SUCCESS) {
grib_context_log(context_,
GRIB_LOG_ERROR,
"Hint: Try unpacking as %s",
grib_get_type_name(type));
}
return GRIB_NOT_IMPLEMENTED;
}
@ -211,10 +225,12 @@ int grib_accessor_gen_t::unpack_string(char* v, size_t* len)
size_t l = 1;
err = unpack_double(&val, &l);
if (is_overridden_[UNPACK_DOUBLE] == 1) {
if (err) return err;
if (err)
return err;
snprintf(v, 64, "%g", val);
*len = strlen(v);
grib_context_log(context_, GRIB_LOG_DEBUG, "Casting double %s to string", name_);
grib_context_log(
context_, GRIB_LOG_DEBUG, "Casting double %s to string", name_);
return GRIB_SUCCESS;
}
}
@ -224,10 +240,12 @@ int grib_accessor_gen_t::unpack_string(char* v, size_t* len)
size_t l = 1;
err = unpack_long(&val, &l);
if (is_overridden_[UNPACK_LONG] == 1) {
if (err) return err;
if (err)
return err;
snprintf(v, 64, "%ld", val);
*len = strlen(v);
grib_context_log(context_, GRIB_LOG_DEBUG, "Casting long %s to string\n", name_);
grib_context_log(
context_, GRIB_LOG_DEBUG, "Casting long %s to string\n", name_);
return GRIB_SUCCESS;
}
}
@ -258,6 +276,7 @@ int grib_accessor_gen_t::pack_expression(grib_expression* e)
int ret = 0;
grib_handle* hand = grib_handle_of_accessor(this);
// Use the native type of the expression not the accessor
switch (e->native_type(hand)) {
case GRIB_TYPE_LONG: {
@ -312,7 +331,10 @@ int grib_accessor_gen_t::pack_long(const long* v, size_t* len)
if (is_overridden_[PACK_DOUBLE]) {
double* val = (double*)grib_context_malloc(c, *len * (sizeof(double)));
if (!val) {
grib_context_log(c, GRIB_LOG_ERROR, "Unable to allocate %zu bytes", *len * (sizeof(double)));
grib_context_log(c,
GRIB_LOG_ERROR,
"Unable to allocate %zu bytes",
*len * (sizeof(double)));
return GRIB_OUT_OF_MEMORY;
}
for (size_t i = 0; i < *len; i++)
@ -324,7 +346,8 @@ int grib_accessor_gen_t::pack_long(const long* v, size_t* len)
}
}
grib_context_log(c, GRIB_LOG_ERROR, "Should not pack '%s' as an integer", name_);
grib_context_log(
c, GRIB_LOG_ERROR, "Should not pack '%s' as an integer", name_);
if (is_overridden_[PACK_STRING]) {
grib_context_log(c, GRIB_LOG_ERROR, "Try packing as a string");
}
@ -339,7 +362,8 @@ int pack_double_array_as_long(grib_accessor* a, const double* v, size_t* len)
size_t numBytes = *len * (sizeof(long));
long* lValues = (long*)grib_context_malloc(c, numBytes);
if (!lValues) {
grib_context_log(c, GRIB_LOG_ERROR, "Unable to allocate %ld bytes", numBytes);
grib_context_log(
c, GRIB_LOG_ERROR, "Unable to allocate %ld bytes", numBytes);
return GRIB_OUT_OF_MEMORY;
}
for (size_t i = 0; i < *len; i++)
@ -359,7 +383,8 @@ int grib_accessor_gen_t::pack_double(const double* v, size_t* len)
return pack_double_array_as_long(this, v, len);
}
grib_context_log(c, GRIB_LOG_ERROR, "Should not pack '%s' as a double", name_);
grib_context_log(
c, GRIB_LOG_ERROR, "Should not pack '%s' as a double", name_);
if (is_overridden_[PACK_STRING]) {
grib_context_log(c, GRIB_LOG_ERROR, "Try packing as a string");
}
@ -393,9 +418,13 @@ int grib_accessor_gen_t::pack_string(const char* v, size_t* len)
char* endPtr = NULL; /* for error handling */
double val = strtod(v, &endPtr);
if (*endPtr) {
grib_context_log(context_, GRIB_LOG_ERROR,
"%s: Invalid value (%s) for key '%s'. String cannot be converted to a double",
__func__, v, name_);
grib_context_log(context_,
GRIB_LOG_ERROR,
"%s: Invalid value (%s) for key '%s'. String cannot be "
"converted to a double",
__func__,
v,
name_);
return GRIB_WRONG_TYPE;
}
return pack_double(&val, &l);
@ -410,7 +439,8 @@ int grib_accessor_gen_t::pack_string(const char* v, size_t* len)
}
}
grib_context_log(context_, GRIB_LOG_ERROR, "Should not pack '%s' as string", name_);
grib_context_log(
context_, GRIB_LOG_ERROR, "Should not pack '%s' as string", name_);
return GRIB_NOT_IMPLEMENTED;
}
@ -418,9 +448,13 @@ int grib_accessor_gen_t::pack_bytes(const unsigned char* val, size_t* len)
{
const size_t length = *len;
if (length_ != length) {
grib_context_log(context_, GRIB_LOG_ERROR,
"pack_bytes: Wrong size (%zu) for %s. It is %ld bytes long",
length, name_, length_);
grib_context_log(
context_,
GRIB_LOG_ERROR,
"pack_bytes: Wrong size (%zu) for %s. It is %ld bytes long",
length,
name_,
length_);
return GRIB_BUFFER_TOO_SMALL;
}
grib_buffer_replace(this, val, length, 1, 1);
@ -452,8 +486,11 @@ int grib_accessor_gen_t::notify_change(grib_accessor* observed)
void grib_accessor_gen_t::update_size(size_t s)
{
grib_context_log(context_, GRIB_LOG_FATAL,
"Accessor %s [%s] must implement 'update_size'", name_, class_name_);
grib_context_log(context_,
GRIB_LOG_FATAL,
"Accessor %s [%s] must implement 'update_size'",
name_,
class_name_);
}
grib_accessor* grib_accessor_gen_t::next_accessor()
@ -500,7 +537,11 @@ int grib_accessor_gen_t::is_missing()
if (flags_ & GRIB_ACCESSOR_FLAG_TRANSIENT) {
if (vvalue_ == NULL) {
grib_context_log(context_, GRIB_LOG_ERROR, "%s internal error (flags=0x%lX)", name_, flags_);
grib_context_log(context_,
GRIB_LOG_ERROR,
"%s internal error (flags=0x%lX)",
name_,
flags_);
Assert(!"grib_accessor_gen_t::is_missing(): vvalue == NULL");
return 0;
}
@ -526,12 +567,16 @@ int grib_accessor_gen_t::unpack_double_element(size_t i, double* val)
return GRIB_NOT_IMPLEMENTED;
}
int grib_accessor_gen_t::unpack_double_element_set(const size_t* index_array, size_t len, double* val_array)
int grib_accessor_gen_t::unpack_double_element_set(const size_t* index_array,
size_t len,
double* val_array)
{
return GRIB_NOT_IMPLEMENTED;
}
int grib_accessor_gen_t::unpack_double_subarray(double* val, size_t start, size_t len)
int grib_accessor_gen_t::unpack_double_subarray(double* val,
size_t start,
size_t len)
{
return GRIB_NOT_IMPLEMENTED;
}
@ -554,9 +599,7 @@ long grib_accessor_gen_t::get_next_position_offset()
return next_offset();
}
grib_accessor_gen_t::~grib_accessor_gen_t()
{
}
grib_accessor_gen_t::~grib_accessor_gen_t() {}
void grib_accessor_gen_t::post_init()
{
@ -576,17 +619,23 @@ void grib_accessor_gen_t::resize(size_t)
}
int grib_accessor_gen_t::nearest_smaller_value(double, double*)
{
throw std::runtime_error("grib_accessor_gen_t::nearest_smaller_value not implemented");
throw std::runtime_error(
"grib_accessor_gen_t::nearest_smaller_value not implemented");
}
int grib_accessor_gen_t::unpack_float_element(size_t, float*)
{
throw std::runtime_error("grib_accessor_gen_t::unpack_float_element not implemented");
throw std::runtime_error(
"grib_accessor_gen_t::unpack_float_element not implemented");
}
int unpack_element_set(const size_t*, size_t, double*)
{
throw std::runtime_error("grib_accessor_gen_t::unpack_element_set not implemented");
throw std::runtime_error(
"grib_accessor_gen_t::unpack_element_set not implemented");
}
int grib_accessor_gen_t::unpack_float_element_set(const size_t*, size_t, float*)
int grib_accessor_gen_t::unpack_float_element_set(const size_t*,
size_t,
float*)
{
throw std::runtime_error("grib_accessor_gen_t::unpack_float_element_set not implemented");
throw std::runtime_error(
"grib_accessor_gen_t::unpack_float_element_set not implemented");
}

View File

@ -12,6 +12,7 @@
#include "grib_api_internal.h"
#include "grib_accessor.h"
#include "grib_value.h"
#include <bitset>
@ -49,7 +50,7 @@ public:
long next_offset() override;
int value_count(long*) override;
void destroy(grib_context*) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
void post_init() override;
int notify_change(grib_accessor* changed) override;

View File

@ -61,9 +61,9 @@ size_t grib_accessor_group_t::string_length()
return length_;
}
void grib_accessor_group_t::dump(grib_dumper* dumper)
void grib_accessor_group_t::dump(eccodes::Dumper* dumper)
{
grib_dump_string(dumper, this, NULL);
dumper->dump_string(this, NULL);
}
long grib_accessor_group_t::get_native_type()

View File

@ -25,7 +25,7 @@ public:
size_t string_length() override;
long next_offset() override;
int value_count(long*) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
int compare(grib_accessor*) override;

View File

@ -23,9 +23,9 @@ void grib_accessor_hash_array_t::init(const long len, grib_arguments* args)
ha_ = NULL;
}
void grib_accessor_hash_array_t::dump(grib_dumper* dumper)
void grib_accessor_hash_array_t::dump(eccodes::Dumper* dumper)
{
grib_dump_string(dumper, this, NULL);
dumper->dump_string(this, NULL);
}
int grib_accessor_hash_array_t::pack_double(const double* val, size_t* len)

View File

@ -28,7 +28,7 @@ public:
size_t string_length() override;
int value_count(long*) override;
void destroy(grib_context*) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
int compare(grib_accessor*) override;

View File

@ -19,8 +19,8 @@ void grib_accessor_iterator_t::init(const long l, grib_arguments* args)
args_ = args;
}
void grib_accessor_iterator_t::dump(grib_dumper* dumper)
void grib_accessor_iterator_t::dump(eccodes::Dumper* dumper)
{
/* TODO: pass args */
grib_dump_label(dumper, this, NULL);
dumper->dump_label(this, NULL);
}

View File

@ -20,7 +20,7 @@ public:
grib_accessor_gen_t() { class_name_ = "iterator"; }
grib_accessor* create_empty_accessor() override { return new grib_accessor_iterator_t{}; }
void init(const long l, grib_arguments* args) override;
void dump(grib_dumper* dumper) override;
void dump(eccodes::Dumper* dumper) override;
private:
grib_arguments* args_ = nullptr;

View File

@ -48,9 +48,9 @@ void grib_accessor_julian_date_t::init(const long l, grib_arguments* c)
length_ = 0;
}
void grib_accessor_julian_date_t::dump(grib_dumper* dumper)
void grib_accessor_julian_date_t::dump(eccodes::Dumper* dumper)
{
grib_dump_string(dumper, this, NULL);
dumper->dump_string(this, NULL);
}
int grib_accessor_julian_date_t::unpack_double(double* val, size_t* len)

View File

@ -25,7 +25,7 @@ public:
int unpack_double(double* val, size_t* len) override;
int unpack_long(long* val, size_t* len) override;
int unpack_string(char*, size_t* len) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
private:

View File

@ -27,9 +27,9 @@ void grib_accessor_julian_day_t::init(const long l, grib_arguments* c)
length_ = 0;
}
void grib_accessor_julian_day_t::dump(grib_dumper* dumper)
void grib_accessor_julian_day_t::dump(eccodes::Dumper* dumper)
{
grib_dump_string(dumper, this, NULL);
dumper->dump_string(this, NULL);
}
int grib_accessor_julian_day_t::pack_long(const long* val, size_t* len)

View File

@ -22,7 +22,7 @@ public:
int pack_long(const long* val, size_t* len) override;
int unpack_double(double* val, size_t* len) override;
int unpack_long(long* val, size_t* len) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
private:

View File

@ -21,9 +21,9 @@ void grib_accessor_label_t::init(const long len, grib_arguments* arg)
length_ = 0;
}
void grib_accessor_label_t::dump(grib_dumper* dumper)
void grib_accessor_label_t::dump(eccodes::Dumper* dumper)
{
grib_dump_label(dumper, this, NULL);
dumper->dump_label(this, NULL);
}
long grib_accessor_label_t::get_native_type()

View File

@ -20,6 +20,6 @@ public:
grib_accessor* create_empty_accessor() override { return new grib_accessor_label_t{}; }
long get_native_type() override;
int unpack_string(char*, size_t* len) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
};

View File

@ -23,9 +23,9 @@ long grib_accessor_long_t::get_native_type()
return GRIB_TYPE_LONG;
}
void grib_accessor_long_t::dump(grib_dumper* dumper)
void grib_accessor_long_t::dump(eccodes::Dumper* dumper)
{
grib_dump_long(dumper, this, NULL);
dumper->dump_long(this, NULL);
}
int grib_accessor_long_t::unpack_string(char* v, size_t* len)

View File

@ -24,6 +24,6 @@ public:
int pack_string(const char*, size_t* len) override;
int unpack_double(double* val, size_t* len) override;
int unpack_string(char*, size_t* len) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
int compare(grib_accessor*) override;
};

View File

@ -30,7 +30,7 @@ void grib_accessor_lookup_t::post_init()
}
}
void grib_accessor_lookup_t::dump(grib_dumper* dumper)
void grib_accessor_lookup_t::dump(eccodes::Dumper* dumper)
{
unsigned char bytes[1024] = {0,};
char msg[1024] = {0,};
@ -50,7 +50,7 @@ void grib_accessor_lookup_t::dump(grib_dumper* dumper)
snprintf(buf, sizeof(buf), "%s %lu %ld-%ld", msg, v, (long)offset_ + loffset_, (long)llength_);
grib_dump_long(dumper, this, buf);
dumper->dump_long(this, buf);
}
int grib_accessor_lookup_t::unpack_string(char* v, size_t* len)

View File

@ -23,7 +23,7 @@ public:
int unpack_string(char*, size_t* len) override;
long byte_count() override;
long byte_offset() override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
void post_init() override;
int notify_change(grib_accessor*) override;

View File

@ -20,9 +20,9 @@ void grib_accessor_message_copy_t::init(const long length, grib_arguments* args)
length_ = 0;
}
void grib_accessor_message_copy_t::dump(grib_dumper* dumper)
void grib_accessor_message_copy_t::dump(eccodes::Dumper* dumper)
{
grib_dump_string(dumper, this, NULL);
dumper->dump_string(this, NULL);
}
long grib_accessor_message_copy_t::get_native_type()

View File

@ -22,6 +22,6 @@ public:
int unpack_string(char*, size_t* len) override;
size_t string_length() override;
long byte_count() override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
};

View File

@ -19,9 +19,9 @@ void grib_accessor_nearest_t::init(const long l, grib_arguments* args)
args_ = args;
}
void grib_accessor_nearest_t::dump(grib_dumper* dumper)
void grib_accessor_nearest_t::dump(eccodes::Dumper* dumper)
{
/* TODO: pass args */
grib_dump_label(dumper, this, NULL);
dumper->dump_label(this, NULL);
}

View File

@ -20,7 +20,7 @@ public:
grib_accessor_gen_t() { class_name_ = "nearest"; }
grib_accessor* create_empty_accessor() override { return new grib_accessor_nearest_t{}; }
void init(const long l, grib_arguments* args) override;
void dump(grib_dumper* dumper) override;
void dump(eccodes::Dumper* dumper) override;
private:
grib_arguments* args_ = nullptr;

View File

@ -39,9 +39,9 @@ size_t grib_accessor_non_alpha_t::string_length()
return length_;
}
void grib_accessor_non_alpha_t::dump(grib_dumper* dumper)
void grib_accessor_non_alpha_t::dump(eccodes::Dumper* dumper)
{
grib_dump_string(dumper, this, NULL);
dumper->dump_string(this, NULL);
}
long grib_accessor_non_alpha_t::get_native_type()

View File

@ -26,6 +26,6 @@ public:
size_t string_length() override;
long next_offset() override;
int value_count(long*) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
};

View File

@ -29,9 +29,9 @@ void grib_accessor_optimal_step_units_t::init(const long l, grib_arguments* c)
overwriteStepUnits_ = eccodes::Unit{ eccodes::Unit::Value::MISSING }.value<long>();
}
void grib_accessor_optimal_step_units_t::dump(grib_dumper* dumper)
void grib_accessor_optimal_step_units_t::dump(eccodes::Dumper* dumper)
{
grib_dump_string(dumper, this, NULL);
dumper->dump_string(this, NULL);
}
size_t grib_accessor_optimal_step_units_t::string_length()

View File

@ -26,7 +26,7 @@ public:
int unpack_long(long* val, size_t* len) override;
int unpack_string(char*, size_t* len) override;
size_t string_length() override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
private:

View File

@ -23,7 +23,7 @@ void grib_accessor_pack_bufr_values_t::init(const long len, grib_arguments* para
length_ = 0;
}
void grib_accessor_pack_bufr_values_t::dump(grib_dumper* dumper)
void grib_accessor_pack_bufr_values_t::dump(eccodes::Dumper* dumper)
{
}

View File

@ -27,7 +27,7 @@ public:
int unpack_string_array(char**, size_t* len) override;
int value_count(long*) override;
void destroy(grib_context*) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
private:

View File

@ -35,7 +35,7 @@ void grib_accessor_padto_t::init(const long len, grib_arguments* arg)
length_ = preferred_size(1);
}
void grib_accessor_padto_t::dump(grib_dumper* dumper)
void grib_accessor_padto_t::dump(eccodes::Dumper* dumper)
{
/*grib_dump_string(dumper,a,NULL);*/
/*dumper->dump_string(a,NULL);*/
}

View File

@ -18,7 +18,7 @@ public:
grib_accessor_padto_t() :
grib_accessor_padding_t() { class_name_ = "padto"; }
grib_accessor* create_empty_accessor() override { return new grib_accessor_padto_t{}; }
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
size_t preferred_size(int) override;

View File

@ -28,9 +28,9 @@ long grib_accessor_position_t::get_native_type()
return GRIB_TYPE_LONG;
}
void grib_accessor_position_t::dump(grib_dumper* dumper)
void grib_accessor_position_t::dump(eccodes::Dumper* dumper)
{
grib_dump_long(dumper, this, NULL);
dumper->dump_long(this, NULL);
}
int grib_accessor_position_t::unpack_long(long* val, size_t* len)

View File

@ -21,6 +21,6 @@ public:
grib_accessor* create_empty_accessor() override { return new grib_accessor_position_t{}; }
long get_native_type() override;
int unpack_long(long* val, size_t* len) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
};

View File

@ -24,7 +24,7 @@ void grib_accessor_round_t::destroy(grib_context* c)
grib_accessor_evaluate_t::destroy(c);
}
void grib_accessor_round_t::dump(grib_dumper* dumper)
void grib_accessor_round_t::dump(eccodes::Dumper* dumper)
{
grib_accessor_evaluate_t::dump(dumper);
}

View File

@ -22,5 +22,5 @@ public:
int unpack_string(char*, size_t* len) override;
void init(const long, grib_arguments*) override;
void destroy(grib_context*) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
};

View File

@ -21,9 +21,9 @@ void grib_accessor_section_t::init(const long len, grib_arguments* arg)
flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY;
}
void grib_accessor_section_t::dump(grib_dumper* dumper)
void grib_accessor_section_t::dump(eccodes::Dumper* dumper)
{
grib_dump_section(dumper, this, sub_section_->block);
dumper->dump_section(this, sub_section_->block);
}
long grib_accessor_section_t::byte_count()

View File

@ -22,7 +22,7 @@ public:
long byte_count() override;
long next_offset() override;
void destroy(grib_context*) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
void update_size(size_t) override;
grib_section* sub_section() override;

View File

@ -23,9 +23,9 @@ void grib_accessor_section_length_t::init(const long len, grib_arguments* arg)
Assert(length_ >= 0);
}
void grib_accessor_section_length_t::dump(grib_dumper* dumper)
void grib_accessor_section_length_t::dump(eccodes::Dumper* dumper)
{
grib_dump_long(dumper, this, NULL);
dumper->dump_long(this, NULL);
}
int grib_accessor_section_length_t::value_count(long* c)

View File

@ -19,6 +19,6 @@ public:
grib_accessor_unsigned_t() { class_name_ = "section_length"; }
grib_accessor* create_empty_accessor() override { return new grib_accessor_section_length_t{}; }
int value_count(long*) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
};

View File

@ -19,9 +19,9 @@ void grib_accessor_sexagesimal2decimal_t::init(const long len, grib_arguments* a
flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY;
}
void grib_accessor_sexagesimal2decimal_t::dump(grib_dumper* dumper)
void grib_accessor_sexagesimal2decimal_t::dump(eccodes::Dumper* dumper)
{
grib_dump_double(dumper, this, NULL);
dumper->dump_double(this, NULL);
}
long grib_accessor_sexagesimal2decimal_t::get_native_type()

View File

@ -20,6 +20,6 @@ public:
grib_accessor* create_empty_accessor() override { return new grib_accessor_sexagesimal2decimal_t{}; }
long get_native_type() override;
int unpack_string(char*, size_t* len) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
};

View File

@ -27,14 +27,14 @@ void grib_accessor_signed_t::init(const long len, grib_arguments* arg)
Assert(length_ >= 0);
}
void grib_accessor_signed_t::dump(grib_dumper* dumper)
void grib_accessor_signed_t::dump(eccodes::Dumper* dumper)
{
long rlen = 0;
value_count(&rlen);
if (rlen == 1)
grib_dump_long(dumper, this, NULL);
dumper->dump_long(this, NULL);
else
grib_dump_values(dumper, this);
dumper->dump_values(this);
}
static const long ones[] = {

View File

@ -25,7 +25,7 @@ public:
long byte_offset() override;
long next_offset() override;
int value_count(long*) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
void update_size(size_t) override;

View File

@ -277,9 +277,9 @@ void grib_smart_table_delete(grib_context* c)
}
}
void grib_accessor_smart_table_t::dump(grib_dumper* dumper)
void grib_accessor_smart_table_t::dump(eccodes::Dumper* dumper)
{
grib_dump_long(dumper, this, NULL);
dumper->dump_long(this, NULL);
}
int grib_accessor_smart_table_t::unpack_string(char* buffer, size_t* len)

View File

@ -24,7 +24,7 @@ public:
int unpack_string(char*, size_t* len) override;
int value_count(long*) override;
void destroy(grib_context*) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
grib_smart_table* smarttable() const { return table_; }

View File

@ -26,16 +26,16 @@ void grib_accessor_smart_table_column_t::init(const long len, grib_arguments* pa
flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY;
}
void grib_accessor_smart_table_column_t::dump(grib_dumper* dumper)
void grib_accessor_smart_table_column_t::dump(eccodes::Dumper* dumper)
{
int type = get_native_type();
switch (type) {
case GRIB_TYPE_LONG:
grib_dump_long(dumper, this, NULL);
dumper->dump_long(this, NULL);
break;
case GRIB_TYPE_STRING:
grib_dump_string_array(dumper, this, NULL);
dumper->dump_string_array(this, NULL);
break;
}
}

View File

@ -23,7 +23,7 @@ public:
int unpack_string_array(char**, size_t* len) override;
int value_count(long*) override;
void destroy(grib_context*) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
private:

View File

@ -28,9 +28,9 @@ void grib_accessor_step_in_units_t::init(const long l, grib_arguments* c)
time_range_value_ = c->get_name(hand, n++);
}
void grib_accessor_step_in_units_t::dump(grib_dumper* dumper)
void grib_accessor_step_in_units_t::dump(eccodes::Dumper* dumper)
{
grib_dump_double(dumper, this, NULL);
dumper->dump_double(this, NULL);
}
int grib_accessor_step_in_units_t::unpack_long(long* val, size_t* len)

View File

@ -24,7 +24,7 @@ public:
int unpack_double(double* val, size_t* len) override;
int unpack_long(long* val, size_t* len) override;
int unpack_string(char*, size_t* len) override;
void dump(grib_dumper*) override;
void dump(eccodes::Dumper*) override;
void init(const long, grib_arguments*) override;
private:

View File

@ -50,9 +50,9 @@ size_t grib_accessor_to_double_t::string_length()
return size;
}
void grib_accessor_to_double_t::dump(grib_dumper* dumper)
void grib_accessor_to_double_t::dump(eccodes::Dumper* dumper)
{
grib_dump_string(dumper, this, NULL);
dumper->dump_string(this, NULL);
}
long grib_accessor_to_double_t::get_native_type()

Some files were not shown because too many files have changed in this diff Show More