From 22bd62c27647d85759c9f531a874992c99c222b3 Mon Sep 17 00:00:00 2001 From: shahramn Date: Fri, 10 May 2024 16:53:58 +0100 Subject: [PATCH] Cosmetics --- src/accessor/grib_accessor_class_bitmap.cc | 2 +- src/accessor/grib_accessor_class_blob.cc | 17 +- .../grib_accessor_class_bufr_data_element.cc | 169 ++++++++++-------- .../grib_accessor_class_bufr_string_values.cc | 33 ++-- .../grib_accessor_class_codetable_title.cc | 21 ++- .../grib_accessor_class_codetable_units.cc | 13 +- .../grib_accessor_class_count_file.cc | 8 +- .../grib_accessor_class_count_total.cc | 8 +- src/accessor/grib_accessor_class_dirty.cc | 17 +- src/accessor/grib_accessor_class_evaluate.cc | 16 +- src/accessor/grib_accessor_class_mars_step.cc | 49 +++-- ...grib_accessor_class_step_human_readable.cc | 3 +- .../grib_accessor_class_step_in_units.cc | 28 +-- ...b_accessor_class_unexpanded_descriptors.cc | 52 +++--- .../grib_accessor_class_unpack_bufr_values.cc | 73 +++++--- src/accessor/grib_accessor_class_unsigned.cc | 32 ++-- .../grib_accessor_class_unsigned_bits.cc | 62 ++++--- .../grib_accessor_class_validity_date.cc | 24 +-- .../grib_accessor_class_validity_time.cc | 31 ++-- src/accessor/grib_accessor_class_values.cc | 30 ++-- src/accessor/grib_accessor_class_vector.cc | 17 +- src/accessor/grib_accessor_class_when.cc | 14 +- 22 files changed, 425 insertions(+), 294 deletions(-) diff --git a/src/accessor/grib_accessor_class_bitmap.cc b/src/accessor/grib_accessor_class_bitmap.cc index 505871a3a..05d9db3bf 100644 --- a/src/accessor/grib_accessor_class_bitmap.cc +++ b/src/accessor/grib_accessor_class_bitmap.cc @@ -104,7 +104,7 @@ int grib_accessor_class_bitmap_t::unpack_long(grib_accessor* a, long* val, size_ } template -int unpack(grib_accessor* a, T* val, size_t* len) +static int unpack(grib_accessor* a, T* val, size_t* len) { static_assert(std::is_floating_point::value, "Requires floating points numbers"); long pos = a->offset * 8; diff --git a/src/accessor/grib_accessor_class_blob.cc b/src/accessor/grib_accessor_class_blob.cc index ca7b21f24..4629de93a 100644 --- a/src/accessor/grib_accessor_class_blob.cc +++ b/src/accessor/grib_accessor_class_blob.cc @@ -11,21 +11,25 @@ #include "grib_accessor_class_blob.h" -grib_accessor_class_blob_t _grib_accessor_class_blob{"blob"}; +grib_accessor_class_blob_t _grib_accessor_class_blob{ "blob" }; grib_accessor_class* grib_accessor_class_blob = &_grib_accessor_class_blob; -void grib_accessor_class_blob_t::init(grib_accessor* a, const long len, grib_arguments* arg){ +void grib_accessor_class_blob_t::init(grib_accessor* a, const long len, grib_arguments* arg) +{ grib_accessor_class_gen_t::init(a, len, arg); - grib_get_long_internal(grib_handle_of_accessor(a), grib_arguments_get_name(a->parent->h, arg, 0), &a->length); + grib_get_long_internal(grib_handle_of_accessor(a), + grib_arguments_get_name(a->parent->h, arg, 0), &a->length); Assert(a->length >= 0); } -int grib_accessor_class_blob_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_blob_t::get_native_type(grib_accessor* a) +{ return GRIB_TYPE_BYTES; } -int grib_accessor_class_blob_t::unpack_bytes(grib_accessor* a, unsigned char* buffer, size_t* len){ +int grib_accessor_class_blob_t::unpack_bytes(grib_accessor* a, unsigned char* buffer, size_t* len) +{ if (*len < (size_t)a->length) { *len = a->length; return GRIB_ARRAY_TOO_SMALL; @@ -37,6 +41,7 @@ int grib_accessor_class_blob_t::unpack_bytes(grib_accessor* a, unsigned char* bu return GRIB_SUCCESS; } -void grib_accessor_class_blob_t::dump(grib_accessor* a, grib_dumper* dumper){ +void grib_accessor_class_blob_t::dump(grib_accessor* a, grib_dumper* dumper) +{ grib_dump_bytes(dumper, a, NULL); } diff --git a/src/accessor/grib_accessor_class_bufr_data_element.cc b/src/accessor/grib_accessor_class_bufr_data_element.cc index e2c9eafbe..8d483b96d 100644 --- a/src/accessor/grib_accessor_class_bufr_data_element.cc +++ b/src/accessor/grib_accessor_class_bufr_data_element.cc @@ -10,7 +10,7 @@ #include "grib_accessor_class_bufr_data_element.h" -grib_accessor_class_bufr_data_element_t _grib_accessor_class_bufr_data_element{"bufr_data_element"}; +grib_accessor_class_bufr_data_element_t _grib_accessor_class_bufr_data_element{ "bufr_data_element" }; grib_accessor_class* grib_accessor_class_bufr_data_element = &_grib_accessor_class_bufr_data_element; grib_accessor* grib_accessor_class_bufr_data_element_t::make_clone(grib_accessor* a, grib_section* s, int* err) @@ -21,7 +21,9 @@ grib_accessor* grib_accessor_class_bufr_data_element_t::make_clone(grib_accessor grib_accessor_bufr_data_element_t* self; char* copied_name = NULL; int i; - grib_action creator = {0,}; + grib_action creator = { + 0, + }; creator.op = (char*)"bufr_data_element"; creator.name_space = (char*)""; creator.set = 0; @@ -64,67 +66,69 @@ grib_accessor* grib_accessor_class_bufr_data_element_t::make_clone(grib_accessor void accessor_bufr_data_element_set_index(grib_accessor* a, long index) { grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; - self->index = index; + self->index = index; } void accessor_bufr_data_element_set_type(grib_accessor* a, int type) { grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; - self->type = type; + self->type = type; } void accessor_bufr_data_element_set_numberOfSubsets(grib_accessor* a, long numberOfSubsets) { grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; - self->numberOfSubsets = numberOfSubsets; + self->numberOfSubsets = numberOfSubsets; } void accessor_bufr_data_element_set_subsetNumber(grib_accessor* a, long subsetNumber) { grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; - self->subsetNumber = subsetNumber; + self->subsetNumber = subsetNumber; } void accessor_bufr_data_element_set_compressedData(grib_accessor* a, int compressedData) { grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; - self->compressedData = compressedData; + self->compressedData = compressedData; } void accessor_bufr_data_element_set_descriptors(grib_accessor* a, bufr_descriptors_array* descriptors) { grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; - self->descriptors = descriptors; + self->descriptors = descriptors; } void accessor_bufr_data_element_set_numericValues(grib_accessor* a, grib_vdarray* numericValues) { grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; - self->numericValues = numericValues; + self->numericValues = numericValues; } void accessor_bufr_data_element_set_stringValues(grib_accessor* a, grib_vsarray* stringValues) { grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; - self->stringValues = stringValues; + self->stringValues = stringValues; } void accessor_bufr_data_element_set_elementsDescriptorsIndex(grib_accessor* a, grib_viarray* elementsDescriptorsIndex) { grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; - self->elementsDescriptorsIndex = elementsDescriptorsIndex; + self->elementsDescriptorsIndex = elementsDescriptorsIndex; } -void grib_accessor_class_bufr_data_element_t::init(grib_accessor* a, const long len, grib_arguments* params){ +void grib_accessor_class_bufr_data_element_t::init(grib_accessor* a, const long len, grib_arguments* params) +{ grib_accessor_class_gen_t::init(a, len, params); grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; - a->length = 0; + a->length = 0; a->flags |= GRIB_ACCESSOR_FLAG_BUFR_DATA; /* a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; */ self->cname = NULL; } -void grib_accessor_class_bufr_data_element_t::dump(grib_accessor* a, grib_dumper* dumper){ +void grib_accessor_class_bufr_data_element_t::dump(grib_accessor* a, grib_dumper* dumper) +{ int type = get_native_type(a); switch (type) { @@ -140,7 +144,8 @@ void grib_accessor_class_bufr_data_element_t::dump(grib_accessor* a, grib_dumper } } -int grib_accessor_class_bufr_data_element_t::unpack_string_array(grib_accessor* a, char** val, size_t* len){ +int grib_accessor_class_bufr_data_element_t::unpack_string_array(grib_accessor* a, char** val, size_t* len) +{ grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; int ret = 0, idx = 0; @@ -160,7 +165,7 @@ int grib_accessor_class_bufr_data_element_t::unpack_string_array(grib_accessor* else { DEBUG_ASSERT(self->subsetNumber < self->numericValues->n); DEBUG_ASSERT(self->index < self->numericValues->v[self->subsetNumber]->n); - idx = (int)self->numericValues->v[self->subsetNumber]->v[self->index] / 1000 - 1; + idx = (int)self->numericValues->v[self->subsetNumber]->v[self->index] / 1000 - 1; val[0] = grib_context_strdup(c, self->stringValues->v[idx]->v[0]); *len = 1; } @@ -168,12 +173,13 @@ int grib_accessor_class_bufr_data_element_t::unpack_string_array(grib_accessor* return ret; } -int grib_accessor_class_bufr_data_element_t::pack_string_array(grib_accessor* a, const char** v, size_t* len){ +int grib_accessor_class_bufr_data_element_t::pack_string_array(grib_accessor* a, const char** v, size_t* len) +{ grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; int ret = GRIB_SUCCESS, idx = 0; - size_t i = 0; - char* s = NULL; + size_t i = 0; + char* s = NULL; grib_context* c = a->context; if (self->compressedData) { @@ -192,31 +198,32 @@ int grib_accessor_class_bufr_data_element_t::pack_string_array(grib_accessor* a, } } else { - //ECC-1623 + // ECC-1623 if (*len != (size_t)self->numberOfSubsets) { grib_context_log(c, GRIB_LOG_ERROR, - "Number of values mismatch for '%s': %zu strings provided but expected %ld (=number of subsets)", - a->name, *len, self->numberOfSubsets); + "Number of values mismatch for '%s': %zu strings provided but expected %ld (=number of subsets)", + a->name, *len, self->numberOfSubsets); return GRIB_WRONG_ARRAY_SIZE; } for (i = 0; i < *len; i++) { - //idx = (int)self->numericValues->v[self->subsetNumber]->v[self->index] / 1000 - 1; - idx = (int)self->numericValues->v[i]->v[self->index] / 1000 - 1; + // idx = (int)self->numericValues->v[self->subsetNumber]->v[self->index] / 1000 - 1; + idx = (int)self->numericValues->v[i]->v[self->index] / 1000 - 1; self->stringValues->v[idx]->v[0] = strdup(v[i]); } - *len=1; + *len = 1; } return ret; } -int grib_accessor_class_bufr_data_element_t::unpack_string(grib_accessor* a, char* val, size_t* len){ +int grib_accessor_class_bufr_data_element_t::unpack_string(grib_accessor* a, char* val, size_t* len) +{ grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; - char* str = NULL; - char* p = 0; - size_t slen = 0; - double dval = 0; - size_t dlen = 1; + char* str = NULL; + char* p = 0; + size_t slen = 0; + double dval = 0; + size_t dlen = 1; int idx = 0, err = 0; grib_context* c = a->context; @@ -278,11 +285,12 @@ int grib_accessor_class_bufr_data_element_t::unpack_string(grib_accessor* a, cha return GRIB_SUCCESS; } -int grib_accessor_class_bufr_data_element_t::pack_string(grib_accessor* a, const char* val, size_t* len){ +int grib_accessor_class_bufr_data_element_t::pack_string(grib_accessor* a, const char* val, size_t* len) +{ grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; int ret = GRIB_SUCCESS, idx = 0; - char* s = NULL; + char* s = NULL; grib_context* c = a->context; if (self->compressedData) { @@ -294,15 +302,16 @@ int grib_accessor_class_bufr_data_element_t::pack_string(grib_accessor* a, const grib_sarray_delete_content(c, self->stringValues->v[idx]); /* ECC-1172 */ grib_sarray_delete(c, self->stringValues->v[idx]); self->stringValues->v[idx] = grib_sarray_new(c, 1, 1); - s = grib_context_strdup(c, val); + s = grib_context_strdup(c, val); grib_sarray_push(c, self->stringValues->v[idx], s); return ret; } -int grib_accessor_class_bufr_data_element_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_bufr_data_element_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; - int ret = GRIB_SUCCESS; + int ret = GRIB_SUCCESS; long count = 0, i = 0; value_count(a, &count); @@ -328,9 +337,10 @@ int grib_accessor_class_bufr_data_element_t::unpack_long(grib_accessor* a, long* return ret; } -int grib_accessor_class_bufr_data_element_t::unpack_double(grib_accessor* a, double* val, size_t* len){ +int grib_accessor_class_bufr_data_element_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; - int ret = GRIB_SUCCESS; + int ret = GRIB_SUCCESS; long count = 0, i = 0; value_count(a, &count); @@ -356,9 +366,10 @@ int grib_accessor_class_bufr_data_element_t::unpack_double(grib_accessor* a, dou return ret; } -int grib_accessor_class_bufr_data_element_t::pack_double(grib_accessor* a, const double* val, size_t* len){ +int grib_accessor_class_bufr_data_element_t::pack_double(grib_accessor* a, const double* val, size_t* len) +{ grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; - int ret = GRIB_SUCCESS; + int ret = GRIB_SUCCESS; size_t count = 1, i = 0; grib_context* c = a->context; @@ -379,15 +390,16 @@ int grib_accessor_class_bufr_data_element_t::pack_double(grib_accessor* a, const } else { self->numericValues->v[self->subsetNumber]->v[self->index] = val[0]; - *len = 1; + *len = 1; } return ret; } -int grib_accessor_class_bufr_data_element_t::pack_long(grib_accessor* a, const long* val, size_t* len){ +int grib_accessor_class_bufr_data_element_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; - int ret = 0; + int ret = 0; size_t count = 1, i = 0; grib_context* c = a->context; @@ -408,15 +420,16 @@ int grib_accessor_class_bufr_data_element_t::pack_long(grib_accessor* a, const l } else { self->numericValues->v[self->subsetNumber]->v[self->index] = val[0] == GRIB_MISSING_LONG ? GRIB_MISSING_DOUBLE : val[0]; - *len = 1; + *len = 1; } return ret; } -int grib_accessor_class_bufr_data_element_t::value_count(grib_accessor* a, long* count){ +int grib_accessor_class_bufr_data_element_t::value_count(grib_accessor* a, long* count) +{ int ret = 0, type = 0, idx = 0; - size_t size = 0; + size_t size = 0; grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; if (!self->compressedData) { @@ -440,11 +453,12 @@ int grib_accessor_class_bufr_data_element_t::value_count(grib_accessor* a, long* return ret; } -int grib_accessor_class_bufr_data_element_t::unpack_double_element(grib_accessor* a, size_t idx, double* val){ +int grib_accessor_class_bufr_data_element_t::unpack_double_element(grib_accessor* a, size_t idx, double* val) +{ /* ECC-415 */ grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; - int ret = GRIB_SUCCESS; - long count = 0; + int ret = GRIB_SUCCESS; + long count = 0; value_count(a, &count); if (idx >= (size_t)count) { @@ -460,9 +474,10 @@ int grib_accessor_class_bufr_data_element_t::unpack_double_element(grib_accessor return ret; } -int grib_accessor_class_bufr_data_element_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_bufr_data_element_t::get_native_type(grib_accessor* a) +{ grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; - int ret = GRIB_TYPE_DOUBLE; + int ret = GRIB_TYPE_DOUBLE; DEBUG_ASSERT(self); switch (self->type) { case BUFR_DESCRIPTOR_TYPE_STRING: @@ -485,9 +500,10 @@ int grib_accessor_class_bufr_data_element_t::get_native_type(grib_accessor* a){ return ret; } -void grib_accessor_class_bufr_data_element_t::destroy(grib_context* ct, grib_accessor* a){ +void grib_accessor_class_bufr_data_element_t::destroy(grib_context* ct, grib_accessor* a) +{ grib_accessor_bufr_data_element_t* self = (grib_accessor_bufr_data_element_t*)a; - int i = 0; + int i = 0; if (self->cname) grib_context_free(ct, self->cname); /* ECC-765 */ while (i < MAX_ACCESSOR_ATTRIBUTES && a->attributes[i]) { @@ -502,7 +518,8 @@ void grib_accessor_class_bufr_data_element_t::destroy(grib_context* ct, grib_acc #define MAX_STRING_SIZE 4096 /* Return 1 if BUFR element(s) is/are missing, 0 otherwise. In case of decoding errors, also return 0 */ -int grib_accessor_class_bufr_data_element_t::is_missing(grib_accessor* a){ +int grib_accessor_class_bufr_data_element_t::is_missing(grib_accessor* a) +{ const int ktype = get_native_type(a); int err = 0, result = 1; /* default: assume all are missing */ long count = 0; @@ -511,15 +528,17 @@ int grib_accessor_class_bufr_data_element_t::is_missing(grib_accessor* a){ if (ktype == GRIB_TYPE_LONG) { long* values = NULL; - long value = 0; + long value = 0; value_count(a, &count); size = size2 = count; if (size > 1) { values = (long*)grib_context_malloc_clear(c, sizeof(long) * size); - err = a->unpack_long(values, &size2); } + err = a->unpack_long(values, &size2); + } else { - err = a->unpack_long(&value, &size2); } + err = a->unpack_long(&value, &size2); + } if (err) return 0; /* TODO: no way of propagating the error up */ Assert(size2 == size); if (size > 1) { @@ -530,21 +549,24 @@ int grib_accessor_class_bufr_data_element_t::is_missing(grib_accessor* a){ } } grib_context_free(c, values); - } else { + } + else { result = grib_is_missing_long(a, value); } } else if (ktype == GRIB_TYPE_DOUBLE) { - double value = 0; + double value = 0; double* values = NULL; value_count(a, &count); size = size2 = count; if (size > 1) { values = (double*)grib_context_malloc_clear(c, sizeof(double) * size); - err = a->unpack_double(values, &size2); } + err = a->unpack_double(values, &size2); + } else { - err = a->unpack_double(&value, &size2); } + err = a->unpack_double(&value, &size2); + } if (err) return 0; /* TODO: no way of propagating the error up */ Assert(size2 == size); if (size > 1) { @@ -566,19 +588,23 @@ int grib_accessor_class_bufr_data_element_t::is_missing(grib_accessor* a){ size = count; if (size > 1) { values = (char**)grib_context_malloc_clear(a->context, size * sizeof(char*)); - err = a->unpack_string_array(values, &size); if (err) return 0; /* TODO: no way of propagating the error up */ + err = a->unpack_string_array(values, &size); + if (err) return 0; /* TODO: no way of propagating the error up */ for (i = 0; i < size; i++) { if (!grib_is_missing_string(a, (unsigned char*)values[i], size)) { result = 0; break; } } - for (i = 0; i < size; i++) grib_context_free(c, values[i]); + for (i = 0; i < size; i++) + grib_context_free(c, values[i]); grib_context_free(c, values); - } else { + } + else { char value[MAX_STRING_SIZE] = {0,}; /* See ECC-710 */ size = MAX_STRING_SIZE; - err = a->unpack_string(value, &size); if (err) return 0; /* TODO: no way of propagating the error up */ + err = a->unpack_string(value, &size); + if (err) return 0; /* TODO: no way of propagating the error up */ result = grib_is_missing_string(a, (unsigned char*)value, size); } } @@ -588,10 +614,11 @@ int grib_accessor_class_bufr_data_element_t::is_missing(grib_accessor* a){ return result; } -int grib_accessor_class_bufr_data_element_t::pack_missing(grib_accessor* a){ - int ktype = GRIB_TYPE_UNDEFINED; - int err = 0; - size_t size = 1; +int grib_accessor_class_bufr_data_element_t::pack_missing(grib_accessor* a) +{ + int ktype = GRIB_TYPE_UNDEFINED; + int err = 0; + size_t size = 1; const int can_be_missing = (a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING); if (!can_be_missing) return GRIB_VALUE_CANNOT_BE_MISSING; @@ -599,11 +626,11 @@ int grib_accessor_class_bufr_data_element_t::pack_missing(grib_accessor* a){ ktype = get_native_type(a); if (ktype == GRIB_TYPE_LONG) { long missing = GRIB_MISSING_LONG; - err = pack_long(a, &missing, &size); + err = pack_long(a, &missing, &size); } else if (ktype == GRIB_TYPE_DOUBLE) { double missing = GRIB_MISSING_DOUBLE; - err = pack_double(a, &missing, &size); + err = pack_double(a, &missing, &size); } else if (ktype == GRIB_TYPE_STRING) { err = pack_string(a, "", &size); diff --git a/src/accessor/grib_accessor_class_bufr_string_values.cc b/src/accessor/grib_accessor_class_bufr_string_values.cc index eb76f6fb9..31e616b6f 100644 --- a/src/accessor/grib_accessor_class_bufr_string_values.cc +++ b/src/accessor/grib_accessor_class_bufr_string_values.cc @@ -12,21 +12,23 @@ #include "grib_accessor_class_bufr_string_values.h" #include "grib_accessor_class_bufr_data_array.h" -grib_accessor_class_bufr_string_values_t _grib_accessor_class_bufr_string_values{"bufr_string_values"}; +grib_accessor_class_bufr_string_values_t _grib_accessor_class_bufr_string_values{ "bufr_string_values" }; grib_accessor_class* grib_accessor_class_bufr_string_values = &_grib_accessor_class_bufr_string_values; -void grib_accessor_class_bufr_string_values_t::init(grib_accessor* a, const long len, grib_arguments* args){ +void grib_accessor_class_bufr_string_values_t::init(grib_accessor* a, const long len, grib_arguments* args) +{ grib_accessor_class_ascii_t::init(a, len, args); grib_accessor_bufr_string_values_t* self = (grib_accessor_bufr_string_values_t*)a; - int n = 0; - self->dataAccessorName = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->dataAccessor = NULL; - a->length = 0; + int n = 0; + self->dataAccessorName = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->dataAccessor = NULL; + a->length = 0; a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; } -void grib_accessor_class_bufr_string_values_t::dump(grib_accessor* a, grib_dumper* dumper){ +void grib_accessor_class_bufr_string_values_t::dump(grib_accessor* a, grib_dumper* dumper) +{ grib_dump_string_array(dumper, a, NULL); } @@ -39,11 +41,12 @@ static grib_accessor* get_accessor(grib_accessor* a) return self->dataAccessor; } -int grib_accessor_class_bufr_string_values_t::unpack_string_array(grib_accessor* a, char** buffer, size_t* len){ +int grib_accessor_class_bufr_string_values_t::unpack_string_array(grib_accessor* a, char** buffer, size_t* len) +{ grib_accessor* data = 0; grib_context* c = a->context; grib_vsarray* stringValues = NULL; - size_t l = 0, tl; + size_t l = 0, tl; size_t i, j, n = 0; char** b = buffer; @@ -72,14 +75,18 @@ int grib_accessor_class_bufr_string_values_t::unpack_string_array(grib_accessor* return GRIB_SUCCESS; } -int grib_accessor_class_bufr_string_values_t::unpack_string(grib_accessor* a, char* val, size_t* len){ +int grib_accessor_class_bufr_string_values_t::unpack_string(grib_accessor* a, char* val, size_t* len) +{ return GRIB_NOT_IMPLEMENTED; } -int grib_accessor_class_bufr_string_values_t::value_count(grib_accessor* a, long* rlen){ +int grib_accessor_class_bufr_string_values_t::value_count(grib_accessor* a, long* rlen) +{ grib_accessor* descriptors = get_accessor(a); - return descriptors->value_count(rlen);} + return descriptors->value_count(rlen); +} -void grib_accessor_class_bufr_string_values_t::destroy(grib_context* c, grib_accessor* a){ +void grib_accessor_class_bufr_string_values_t::destroy(grib_context* c, grib_accessor* a) +{ grib_accessor_class_ascii_t::destroy(c, a); } diff --git a/src/accessor/grib_accessor_class_codetable_title.cc b/src/accessor/grib_accessor_class_codetable_title.cc index d124ee75f..2bcdfd215 100644 --- a/src/accessor/grib_accessor_class_codetable_title.cc +++ b/src/accessor/grib_accessor_class_codetable_title.cc @@ -12,31 +12,34 @@ #include "grib_accessor_class_codetable_title.h" #include "grib_accessor_class_codetable.h" -grib_accessor_class_codetable_title_t _grib_accessor_class_codetable_title{"codetable_title"}; +grib_accessor_class_codetable_title_t _grib_accessor_class_codetable_title{ "codetable_title" }; grib_accessor_class* grib_accessor_class_codetable_title = &_grib_accessor_class_codetable_title; -void grib_accessor_class_codetable_title_t::init(grib_accessor* a, const long len, grib_arguments* params){ +void grib_accessor_class_codetable_title_t::init(grib_accessor* a, const long len, grib_arguments* params) +{ grib_accessor_class_gen_t::init(a, len, params); grib_accessor_codetable_title_t* self = (grib_accessor_codetable_title_t*)a; - int n = 0; - self->codetable = grib_arguments_get_name(grib_handle_of_accessor(a), params, n++); - a->length = 0; + int n = 0; + self->codetable = grib_arguments_get_name(grib_handle_of_accessor(a), params, n++); + a->length = 0; a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; } -int grib_accessor_class_codetable_title_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_codetable_title_t::get_native_type(grib_accessor* a) +{ return GRIB_TYPE_STRING; } -int grib_accessor_class_codetable_title_t::unpack_string(grib_accessor* a, char* buffer, size_t* len){ +int grib_accessor_class_codetable_title_t::unpack_string(grib_accessor* a, char* buffer, size_t* len) +{ grib_accessor_codetable_title_t* self = (grib_accessor_codetable_title_t*)a; - grib_codetable* table = NULL; + grib_codetable* table = NULL; size_t size = 1; long value; int err = GRIB_SUCCESS; char tmp[1024]; - size_t l = 1024; + size_t l = 1024; grib_accessor_codetable_t* ca = (grib_accessor_codetable_t*)grib_find_accessor(grib_handle_of_accessor(a), self->codetable); if ((err = ((grib_accessor*)ca)->unpack_long(&value, &size)) != GRIB_SUCCESS) diff --git a/src/accessor/grib_accessor_class_codetable_units.cc b/src/accessor/grib_accessor_class_codetable_units.cc index 2e7ccda61..cc91ae2e2 100644 --- a/src/accessor/grib_accessor_class_codetable_units.cc +++ b/src/accessor/grib_accessor_class_codetable_units.cc @@ -12,10 +12,11 @@ #include "grib_accessor_class_codetable_units.h" #include "grib_accessor_class_codetable.h" -grib_accessor_class_codetable_units_t _grib_accessor_class_codetable_units{"codetable_units"}; +grib_accessor_class_codetable_units_t _grib_accessor_class_codetable_units{ "codetable_units" }; grib_accessor_class* grib_accessor_class_codetable_units = &_grib_accessor_class_codetable_units; -void grib_accessor_class_codetable_units_t::init(grib_accessor* a, const long len, grib_arguments* params){ +void grib_accessor_class_codetable_units_t::init(grib_accessor* a, const long len, grib_arguments* params) +{ grib_accessor_class_gen_t::init(a, len, params); grib_accessor_codetable_units_t* self = (grib_accessor_codetable_units_t*)a; @@ -25,13 +26,15 @@ void grib_accessor_class_codetable_units_t::init(grib_accessor* a, const long le a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; } -int grib_accessor_class_codetable_units_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_codetable_units_t::get_native_type(grib_accessor* a) +{ return GRIB_TYPE_STRING; } -int grib_accessor_class_codetable_units_t::unpack_string(grib_accessor* a, char* buffer, size_t* len){ +int grib_accessor_class_codetable_units_t::unpack_string(grib_accessor* a, char* buffer, size_t* len) +{ grib_accessor_codetable_units_t* self = (grib_accessor_codetable_units_t*)a; - grib_codetable* table = NULL; + grib_codetable* table = NULL; size_t size = 1; long value; diff --git a/src/accessor/grib_accessor_class_count_file.cc b/src/accessor/grib_accessor_class_count_file.cc index a347e49ff..268ba8051 100644 --- a/src/accessor/grib_accessor_class_count_file.cc +++ b/src/accessor/grib_accessor_class_count_file.cc @@ -11,17 +11,19 @@ #include "grib_accessor_class_count_file.h" -grib_accessor_class_count_file_t _grib_accessor_class_count_file{"count_file"}; +grib_accessor_class_count_file_t _grib_accessor_class_count_file{ "count_file" }; grib_accessor_class* grib_accessor_class_count_file = &_grib_accessor_class_count_file; -void grib_accessor_class_count_file_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_count_file_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_long_t::init(a, l, c); a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; a->length = 0; } -int grib_accessor_class_count_file_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_count_file_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ *val = grib_context_get_handle_file_count(a->context); *len = 1; return 0; diff --git a/src/accessor/grib_accessor_class_count_total.cc b/src/accessor/grib_accessor_class_count_total.cc index 561a8743d..dc708b4b6 100644 --- a/src/accessor/grib_accessor_class_count_total.cc +++ b/src/accessor/grib_accessor_class_count_total.cc @@ -11,17 +11,19 @@ #include "grib_accessor_class_count_total.h" -grib_accessor_class_count_total_t _grib_accessor_class_count_total{"count_total"}; +grib_accessor_class_count_total_t _grib_accessor_class_count_total{ "count_total" }; grib_accessor_class* grib_accessor_class_count_total = &_grib_accessor_class_count_total; -void grib_accessor_class_count_total_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_count_total_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_long_t::init(a, l, c); a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; a->length = 0; } -int grib_accessor_class_count_total_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_count_total_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ *val = grib_context_get_handle_total_count(a->context); *len = 1; return 0; diff --git a/src/accessor/grib_accessor_class_dirty.cc b/src/accessor/grib_accessor_class_dirty.cc index 39df7e450..73f11c9d7 100644 --- a/src/accessor/grib_accessor_class_dirty.cc +++ b/src/accessor/grib_accessor_class_dirty.cc @@ -11,22 +11,24 @@ #include "grib_accessor_class_dirty.h" -grib_accessor_class_dirty_t _grib_accessor_class_dirty{"dirty"}; +grib_accessor_class_dirty_t _grib_accessor_class_dirty{ "dirty" }; grib_accessor_class* grib_accessor_class_dirty = &_grib_accessor_class_dirty; -void grib_accessor_class_dirty_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_dirty_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_long_t::init(a, l, c); grib_accessor_dirty_t* self = (grib_accessor_dirty_t*)a; - self->accessor = grib_arguments_get_name(grib_handle_of_accessor(a), c, 0); + self->accessor = grib_arguments_get_name(grib_handle_of_accessor(a), c, 0); a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; a->length = 0; } -int grib_accessor_class_dirty_t::pack_long(grib_accessor* a, const long* val, size_t* len){ +int grib_accessor_class_dirty_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ grib_accessor_dirty_t* self = (grib_accessor_dirty_t*)a; - grib_accessor* x = grib_find_accessor(grib_handle_of_accessor(a), self->accessor); + grib_accessor* x = grib_find_accessor(grib_handle_of_accessor(a), self->accessor); if (x) x->dirty = *val; @@ -34,9 +36,10 @@ int grib_accessor_class_dirty_t::pack_long(grib_accessor* a, const long* val, si return GRIB_SUCCESS; } -int grib_accessor_class_dirty_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_dirty_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ grib_accessor_dirty_t* self = (grib_accessor_dirty_t*)a; - grib_accessor* x = grib_find_accessor(grib_handle_of_accessor(a), self->accessor); + grib_accessor* x = grib_find_accessor(grib_handle_of_accessor(a), self->accessor); if (x) x->dirty = 1; diff --git a/src/accessor/grib_accessor_class_evaluate.cc b/src/accessor/grib_accessor_class_evaluate.cc index efed99598..0312107a4 100644 --- a/src/accessor/grib_accessor_class_evaluate.cc +++ b/src/accessor/grib_accessor_class_evaluate.cc @@ -11,23 +11,25 @@ #include "grib_accessor_class_evaluate.h" -grib_accessor_class_evaluate_t _grib_accessor_class_evaluate{"evaluate"}; +grib_accessor_class_evaluate_t _grib_accessor_class_evaluate{ "evaluate" }; grib_accessor_class* grib_accessor_class_evaluate = &_grib_accessor_class_evaluate; -void grib_accessor_class_evaluate_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_evaluate_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_long_t::init(a, l, c); grib_accessor_evaluate_t* self = (grib_accessor_evaluate_t*)a; - self->arg = c; + self->arg = c; a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; } -int grib_accessor_class_evaluate_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_evaluate_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ grib_accessor_evaluate_t* self = (grib_accessor_evaluate_t*)a; - grib_expression* e = grib_arguments_get_expression(grib_handle_of_accessor(a), self->arg, 0); + grib_expression* e = grib_arguments_get_expression(grib_handle_of_accessor(a), self->arg, 0); - int ret = grib_expression_evaluate_long(grib_handle_of_accessor(a), e, val); - *len = 1; + int ret = grib_expression_evaluate_long(grib_handle_of_accessor(a), e, val); + *len = 1; return ret; } diff --git a/src/accessor/grib_accessor_class_mars_step.cc b/src/accessor/grib_accessor_class_mars_step.cc index 34d245998..8fd9f9dfa 100644 --- a/src/accessor/grib_accessor_class_mars_step.cc +++ b/src/accessor/grib_accessor_class_mars_step.cc @@ -11,25 +11,27 @@ #include "grib_accessor_class_mars_step.h" -grib_accessor_class_mars_step_t _grib_accessor_class_mars_step{"mars_step"}; +grib_accessor_class_mars_step_t _grib_accessor_class_mars_step{ "mars_step" }; grib_accessor_class* grib_accessor_class_mars_step = &_grib_accessor_class_mars_step; -void grib_accessor_class_mars_step_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_mars_step_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_ascii_t::init(a, l, c); - int n = 0; + int n = 0; grib_accessor_mars_step_t* self = (grib_accessor_mars_step_t*)a; - self->stepRange = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - self->stepType = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->stepRange = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + self->stepType = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); } -int grib_accessor_class_mars_step_t::pack_string(grib_accessor* a, const char* val, size_t* len){ +int grib_accessor_class_mars_step_t::pack_string(grib_accessor* a, const char* val, size_t* len) +{ char stepType[100]; size_t stepTypeLen = 100; char buf[100] = {0,}; int ret; grib_accessor_mars_step_t* self = (grib_accessor_mars_step_t*)a; - grib_accessor* stepRangeAcc = grib_find_accessor(grib_handle_of_accessor(a), self->stepRange); + grib_accessor* stepRangeAcc = grib_find_accessor(grib_handle_of_accessor(a), self->stepRange); if (!stepRangeAcc) { grib_context_log(a->context, GRIB_LOG_ERROR, "%s not found", self->stepRange); @@ -44,17 +46,20 @@ int grib_accessor_class_mars_step_t::pack_string(grib_accessor* a, const char* v else snprintf(buf, sizeof(buf), "0-%s", val); - return stepRangeAcc->pack_string(buf, len);} + return stepRangeAcc->pack_string(buf, len); +} -int grib_accessor_class_mars_step_t::unpack_string(grib_accessor* a, char* val, size_t* len){ - int ret = 0; +int grib_accessor_class_mars_step_t::unpack_string(grib_accessor* a, char* val, size_t* len) +{ grib_accessor_mars_step_t* self = (grib_accessor_mars_step_t*)a; - char buf[100] = {0,}; + + int ret = 0; + char buf[100] = {0,}; char* p = NULL; size_t buflen = 100; long step; grib_accessor* stepRangeAcc = grib_find_accessor(grib_handle_of_accessor(a), self->stepRange); - const char* cclass_name = a->cclass->name; + const char* cclass_name = a->cclass->name; if (!stepRangeAcc) { grib_context_log(a->context, GRIB_LOG_ERROR, "%s: %s not found", cclass_name, self->stepRange); @@ -83,7 +88,8 @@ int grib_accessor_class_mars_step_t::unpack_string(grib_accessor* a, char* val, return ret; } -int grib_accessor_class_mars_step_t::pack_long(grib_accessor* a, const long* val, size_t* len){ +int grib_accessor_class_mars_step_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ char buff[100] = {0,}; size_t bufflen = 100; @@ -92,24 +98,29 @@ int grib_accessor_class_mars_step_t::pack_long(grib_accessor* a, const long* val return pack_string(a, buff, &bufflen); } -int grib_accessor_class_mars_step_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_mars_step_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ grib_accessor_mars_step_t* self = (grib_accessor_mars_step_t*)a; - grib_accessor* stepRangeAcc = grib_find_accessor(grib_handle_of_accessor(a), self->stepRange); + grib_accessor* stepRangeAcc = grib_find_accessor(grib_handle_of_accessor(a), self->stepRange); if (!stepRangeAcc) return GRIB_NOT_FOUND; - return stepRangeAcc->unpack_long(val, len);} + return stepRangeAcc->unpack_long(val, len); +} -int grib_accessor_class_mars_step_t::value_count(grib_accessor* a, long* count){ +int grib_accessor_class_mars_step_t::value_count(grib_accessor* a, long* count) +{ *count = 1; return 0; } -size_t grib_accessor_class_mars_step_t::string_length(grib_accessor* a){ +size_t grib_accessor_class_mars_step_t::string_length(grib_accessor* a) +{ return 16; } -int grib_accessor_class_mars_step_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_mars_step_t::get_native_type(grib_accessor* a) +{ return GRIB_TYPE_LONG; } diff --git a/src/accessor/grib_accessor_class_step_human_readable.cc b/src/accessor/grib_accessor_class_step_human_readable.cc index 929733705..18dec9c14 100644 --- a/src/accessor/grib_accessor_class_step_human_readable.cc +++ b/src/accessor/grib_accessor_class_step_human_readable.cc @@ -69,9 +69,10 @@ static int get_step_human_readable(grib_handle* h, char* result, size_t* length) int grib_accessor_class_step_human_readable_t::unpack_string(grib_accessor* a, char* buffer, size_t* len) { grib_accessor_step_human_readable_t* self = (grib_accessor_step_human_readable_t*)a; + grib_handle* h = grib_handle_of_accessor(a); long stepUnits = 0; - int err = 0; + int err = 0; /* Save the current value of stepUnits */ err = grib_get_long_internal(h, self->stepUnits, &stepUnits); diff --git a/src/accessor/grib_accessor_class_step_in_units.cc b/src/accessor/grib_accessor_class_step_in_units.cc index 3bbdba009..52086d700 100644 --- a/src/accessor/grib_accessor_class_step_in_units.cc +++ b/src/accessor/grib_accessor_class_step_in_units.cc @@ -17,8 +17,8 @@ grib_accessor_class_step_in_units_t _grib_accessor_class_step_in_units{"step_in_units"}; grib_accessor_class* grib_accessor_class_step_in_units = &_grib_accessor_class_step_in_units; - -void grib_accessor_class_step_in_units_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_step_in_units_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_long_t::init(a, l, c); grib_accessor_step_in_units_t* self = (grib_accessor_step_in_units_t*)a; grib_handle* hand = grib_handle_of_accessor(a); @@ -31,11 +31,13 @@ void grib_accessor_class_step_in_units_t::init(grib_accessor* a, const long l, g self->time_range_value = grib_arguments_get_name(hand, c, n++); } -void grib_accessor_class_step_in_units_t::dump(grib_accessor* a, grib_dumper* dumper){ +void grib_accessor_class_step_in_units_t::dump(grib_accessor* a, grib_dumper* dumper) +{ grib_dump_double(dumper, a, NULL); } -int grib_accessor_class_step_in_units_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_step_in_units_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ const grib_accessor_step_in_units_t* self = (grib_accessor_step_in_units_t*)a; int err = 0; long forecast_time_value, forecast_time_unit, step_units; @@ -65,7 +67,8 @@ int grib_accessor_class_step_in_units_t::unpack_long(grib_accessor* a, long* val return GRIB_SUCCESS; } -int grib_accessor_class_step_in_units_t::unpack_double(grib_accessor* a, double * val, size_t* len){ +int grib_accessor_class_step_in_units_t::unpack_double(grib_accessor* a, double * val, size_t* len) +{ const grib_accessor_step_in_units_t* self = (grib_accessor_step_in_units_t*)a; int err = 0; long forecast_time_value, forecast_time_unit, step_units; @@ -94,7 +97,8 @@ int grib_accessor_class_step_in_units_t::unpack_double(grib_accessor* a, double return GRIB_SUCCESS; } -int pack_long_new_(grib_accessor* a, const long start_step_value, const long start_step_unit, const long force_step_units){ +int pack_long_new_(grib_accessor* a, const long start_step_value, const long start_step_unit, const long force_step_units) +{ const grib_accessor_step_in_units_t* self = (grib_accessor_step_in_units_t*)a; grib_handle* h = grib_handle_of_accessor(a); int err = 0; @@ -143,7 +147,8 @@ int pack_long_new_(grib_accessor* a, const long start_step_value, const long sta return GRIB_SUCCESS; } -int grib_accessor_class_step_in_units_t::pack_long(grib_accessor* a, const long* val, size_t* len){ +int grib_accessor_class_step_in_units_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ grib_handle* h = grib_handle_of_accessor(a); int ret = GRIB_SUCCESS; @@ -174,7 +179,8 @@ int grib_accessor_class_step_in_units_t::pack_long(grib_accessor* a, const long* return ret; } -int grib_accessor_class_step_in_units_t::pack_string(grib_accessor* a, const char* val, size_t* len){ +int grib_accessor_class_step_in_units_t::pack_string(grib_accessor* a, const char* val, size_t* len) +{ grib_handle* h = grib_handle_of_accessor(a); //long force_step_units = eccodes::Unit(eccodes::Unit::Value::MISSING).value(); int ret = GRIB_SUCCESS; @@ -195,7 +201,8 @@ int grib_accessor_class_step_in_units_t::pack_string(grib_accessor* a, const cha return GRIB_SUCCESS; } -int grib_accessor_class_step_in_units_t::unpack_string(grib_accessor* a, char* val, size_t* len){ +int grib_accessor_class_step_in_units_t::unpack_string(grib_accessor* a, char* val, size_t* len) +{ const grib_accessor_step_in_units_t* self = (grib_accessor_step_in_units_t*)a; grib_handle* h = grib_handle_of_accessor(a); int ret = GRIB_SUCCESS; @@ -238,7 +245,8 @@ int grib_accessor_class_step_in_units_t::unpack_string(grib_accessor* a, char* v return GRIB_SUCCESS; } -int grib_accessor_class_step_in_units_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_step_in_units_t::get_native_type(grib_accessor* a) +{ grib_handle* h = grib_handle_of_accessor(a); const int show_units_for_hours = a->context->grib_hourly_steps_with_units; diff --git a/src/accessor/grib_accessor_class_unexpanded_descriptors.cc b/src/accessor/grib_accessor_class_unexpanded_descriptors.cc index f430b4864..5c9402360 100644 --- a/src/accessor/grib_accessor_class_unexpanded_descriptors.cc +++ b/src/accessor/grib_accessor_class_unexpanded_descriptors.cc @@ -11,25 +11,28 @@ #include "grib_accessor_class_unexpanded_descriptors.h" -grib_accessor_class_unexpanded_descriptors_t _grib_accessor_class_unexpanded_descriptors{"unexpanded_descriptors"}; +grib_accessor_class_unexpanded_descriptors_t _grib_accessor_class_unexpanded_descriptors{ "unexpanded_descriptors" }; grib_accessor_class* grib_accessor_class_unexpanded_descriptors = &_grib_accessor_class_unexpanded_descriptors; -void grib_accessor_class_unexpanded_descriptors_t::init(grib_accessor* a, const long len, grib_arguments* args){ +void grib_accessor_class_unexpanded_descriptors_t::init(grib_accessor* a, const long len, grib_arguments* args) +{ grib_accessor_class_long_t::init(a, len, args); grib_accessor_unexpanded_descriptors_t* self = (grib_accessor_unexpanded_descriptors_t*)a; - int n = 0; - grib_handle* hand = grib_handle_of_accessor(a); - self->unexpandedDescriptorsEncoded = grib_find_accessor(hand, grib_arguments_get_name(hand, args, n++)); - self->createNewData = grib_arguments_get_name(hand, args, n++); - a->length = 0; + + int n = 0; + grib_handle* hand = grib_handle_of_accessor(a); + self->unexpandedDescriptorsEncoded = grib_find_accessor(hand, grib_arguments_get_name(hand, args, n++)); + self->createNewData = grib_arguments_get_name(hand, args, n++); + a->length = 0; } -int grib_accessor_class_unexpanded_descriptors_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_unexpanded_descriptors_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ grib_accessor_unexpanded_descriptors_t* self = (grib_accessor_unexpanded_descriptors_t*)a; - int ret = 0; - long pos = 0; - long rlen = 0; + int ret = 0; + long pos = 0; + long rlen = 0; long f, x, y; long* v = val; long i; @@ -64,10 +67,11 @@ int grib_accessor_class_unexpanded_descriptors_t::unpack_long(grib_accessor* a, return GRIB_SUCCESS; } -int grib_accessor_class_unexpanded_descriptors_t::pack_long(grib_accessor* a, const long* val, size_t* len){ +int grib_accessor_class_unexpanded_descriptors_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ grib_accessor_unexpanded_descriptors_t* self = (grib_accessor_unexpanded_descriptors_t*)a; - int ret = 0; - long pos = 0; + int ret = 0; + long pos = 0; unsigned long f, x, y; unsigned char* buf = NULL; grib_accessor* expanded = NULL; @@ -90,7 +94,8 @@ int grib_accessor_class_unexpanded_descriptors_t::pack_long(grib_accessor* a, co grib_encode_unsigned_longb(buf, y, &pos, 8); } - self->unexpandedDescriptorsEncoded->pack_bytes(buf, &buflen); grib_context_free(hand->context, buf); + self->unexpandedDescriptorsEncoded->pack_bytes(buf, &buflen); + grib_context_free(hand->context, buf); if (createNewData == 0) return ret; @@ -110,23 +115,28 @@ int grib_accessor_class_unexpanded_descriptors_t::pack_long(grib_accessor* a, co return ret; } -int grib_accessor_class_unexpanded_descriptors_t::value_count(grib_accessor* a, long* numberOfUnexpandedDescriptors){ +int grib_accessor_class_unexpanded_descriptors_t::value_count(grib_accessor* a, long* numberOfUnexpandedDescriptors) +{ grib_accessor_unexpanded_descriptors_t* self = (grib_accessor_unexpanded_descriptors_t*)a; - long n = 0; + long n = 0; - self->unexpandedDescriptorsEncoded->value_count(&n); *numberOfUnexpandedDescriptors = n / 2; + self->unexpandedDescriptorsEncoded->value_count(&n); + *numberOfUnexpandedDescriptors = n / 2; return 0; } -long grib_accessor_class_unexpanded_descriptors_t::byte_offset(grib_accessor* a){ +long grib_accessor_class_unexpanded_descriptors_t::byte_offset(grib_accessor* a) +{ return a->offset; } -void grib_accessor_class_unexpanded_descriptors_t::update_size(grib_accessor* a, size_t s){ +void grib_accessor_class_unexpanded_descriptors_t::update_size(grib_accessor* a, size_t s) +{ a->length = s; } -long grib_accessor_class_unexpanded_descriptors_t::next_offset(grib_accessor* a){ +long grib_accessor_class_unexpanded_descriptors_t::next_offset(grib_accessor* a) +{ return a->byte_offset() + a->length; } diff --git a/src/accessor/grib_accessor_class_unpack_bufr_values.cc b/src/accessor/grib_accessor_class_unpack_bufr_values.cc index 9942a64a8..3497bbbe2 100644 --- a/src/accessor/grib_accessor_class_unpack_bufr_values.cc +++ b/src/accessor/grib_accessor_class_unpack_bufr_values.cc @@ -12,58 +12,71 @@ #include "grib_accessor_class_unpack_bufr_values.h" #include "grib_accessor_class_bufr_data_array.h" -grib_accessor_class_unpack_bufr_values_t _grib_accessor_class_unpack_bufr_values{"unpack_bufr_values"}; +grib_accessor_class_unpack_bufr_values_t _grib_accessor_class_unpack_bufr_values{ "unpack_bufr_values" }; grib_accessor_class* grib_accessor_class_unpack_bufr_values = &_grib_accessor_class_unpack_bufr_values; -void grib_accessor_class_unpack_bufr_values_t::init(grib_accessor* a, const long len, grib_arguments* params){ +void grib_accessor_class_unpack_bufr_values_t::init(grib_accessor* a, const long len, grib_arguments* params) +{ grib_accessor_class_gen_t::init(a, len, params); char* key; grib_accessor_unpack_bufr_values_t* self = (grib_accessor_unpack_bufr_values_t*)a; - key = (char*)grib_arguments_get_name(grib_handle_of_accessor(a), params, 0); - self->data_accessor = grib_find_accessor(grib_handle_of_accessor(a), key); + key = (char*)grib_arguments_get_name(grib_handle_of_accessor(a), params, 0); + self->data_accessor = grib_find_accessor(grib_handle_of_accessor(a), key); a->length = 0; } -void grib_accessor_class_unpack_bufr_values_t::dump(grib_accessor* a, grib_dumper* dumper){ +void grib_accessor_class_unpack_bufr_values_t::dump(grib_accessor* a, grib_dumper* dumper) +{ } -int grib_accessor_class_unpack_bufr_values_t::unpack_string_array(grib_accessor* a, char** buffer, size_t* len){ +int grib_accessor_class_unpack_bufr_values_t::unpack_string_array(grib_accessor* a, char** buffer, size_t* len) +{ grib_accessor_unpack_bufr_values_t* self = (grib_accessor_unpack_bufr_values_t*)a; - grib_accessor* data = (grib_accessor*)self->data_accessor; + grib_accessor* data = (grib_accessor*)self->data_accessor; - return data->unpack_double(0, 0);} + return data->unpack_double(0, 0); +} -int grib_accessor_class_unpack_bufr_values_t::unpack_string(grib_accessor* a, char* buffer, size_t* len){ +int grib_accessor_class_unpack_bufr_values_t::unpack_string(grib_accessor* a, char* buffer, size_t* len) +{ grib_accessor_unpack_bufr_values_t* self = (grib_accessor_unpack_bufr_values_t*)a; - grib_accessor* data = (grib_accessor*)self->data_accessor; + grib_accessor* data = (grib_accessor*)self->data_accessor; strcpy(buffer, "0"); - *len=1; + *len = 1; - return data->unpack_double(0, 0);} + return data->unpack_double(0, 0); +} -int grib_accessor_class_unpack_bufr_values_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_unpack_bufr_values_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ grib_accessor_unpack_bufr_values_t* self = (grib_accessor_unpack_bufr_values_t*)a; - grib_accessor* data = (grib_accessor*)self->data_accessor; + grib_accessor* data = (grib_accessor*)self->data_accessor; - return data->unpack_double(0, 0);} + return data->unpack_double(0, 0); +} -int grib_accessor_class_unpack_bufr_values_t::unpack_double(grib_accessor* a, double* val, size_t* len){ +int grib_accessor_class_unpack_bufr_values_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ grib_accessor_unpack_bufr_values_t* self = (grib_accessor_unpack_bufr_values_t*)a; - grib_accessor* data = (grib_accessor*)self->data_accessor; + grib_accessor* data = (grib_accessor*)self->data_accessor; - return data->unpack_double(0, 0);} + return data->unpack_double(0, 0); +} -int grib_accessor_class_unpack_bufr_values_t::value_count(grib_accessor* a, long* count){ +int grib_accessor_class_unpack_bufr_values_t::value_count(grib_accessor* a, long* count) +{ *count = 1; return 0; } -void grib_accessor_class_unpack_bufr_values_t::destroy(grib_context* context, grib_accessor* a){ +void grib_accessor_class_unpack_bufr_values_t::destroy(grib_context* context, grib_accessor* a) +{ grib_accessor_class_gen_t::destroy(context, a); } -int grib_accessor_class_unpack_bufr_values_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_unpack_bufr_values_t::get_native_type(grib_accessor* a) +{ return GRIB_TYPE_LONG; } @@ -75,10 +88,11 @@ int grib_accessor_class_unpack_bufr_values_t::get_native_type(grib_accessor* a){ // return "unknown proc flag"; // } -int grib_accessor_class_unpack_bufr_values_t::pack_long(grib_accessor* a, const long* val, size_t* len){ - int unpackMode = CODES_BUFR_UNPACK_STRUCTURE; +int grib_accessor_class_unpack_bufr_values_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ + int unpackMode = CODES_BUFR_UNPACK_STRUCTURE; grib_accessor_unpack_bufr_values_t* self = (grib_accessor_unpack_bufr_values_t*)a; - grib_accessor* data = (grib_accessor*)self->data_accessor; + grib_accessor* data = (grib_accessor*)self->data_accessor; if (*val == 2) unpackMode = CODES_BUFR_UNPACK_FLAT; @@ -87,10 +101,13 @@ int grib_accessor_class_unpack_bufr_values_t::pack_long(grib_accessor* a, const accessor_bufr_data_array_set_unpackMode(data, unpackMode); - return data->unpack_double(0, 0);} + return data->unpack_double(0, 0); +} -int grib_accessor_class_unpack_bufr_values_t::pack_double(grib_accessor* a, const double* val, size_t* len){ +int grib_accessor_class_unpack_bufr_values_t::pack_double(grib_accessor* a, const double* val, size_t* len) +{ grib_accessor_unpack_bufr_values_t* self = (grib_accessor_unpack_bufr_values_t*)a; - grib_accessor* data = (grib_accessor*)self->data_accessor; + grib_accessor* data = (grib_accessor*)self->data_accessor; - return data->unpack_double(0, 0);} + return data->unpack_double(0, 0); +} diff --git a/src/accessor/grib_accessor_class_unsigned.cc b/src/accessor/grib_accessor_class_unsigned.cc index 0a60e809c..8093e3a6a 100644 --- a/src/accessor/grib_accessor_class_unsigned.cc +++ b/src/accessor/grib_accessor_class_unsigned.cc @@ -19,8 +19,8 @@ void grib_accessor_class_unsigned_t::init(grib_accessor* a, const long len, grib { grib_accessor_class_long_t::init(a, len, arg); grib_accessor_unsigned_t* self = (grib_accessor_unsigned_t*)a; - self->arg = arg; - self->nbytes = len; + self->arg = arg; + self->nbytes = len; if (a->flags & GRIB_ACCESSOR_FLAG_TRANSIENT) { a->length = 0; @@ -67,10 +67,10 @@ int value_is_missing(long val) int pack_long_unsigned_helper(grib_accessor* a, const long* val, size_t* len, int check) { grib_accessor_unsigned_t* self = (grib_accessor_unsigned_t*)a; - int ret = 0; - long off = 0; - long rlen = 0; - int err = 0; + int ret = 0; + long off = 0; + long rlen = 0; + int err = 0; size_t buflen = 0; unsigned char* buf = NULL; @@ -114,7 +114,7 @@ int pack_long_unsigned_helper(grib_accessor* a, const long* val, size_t* len, in if (check) { if (val[0] < 0) { grib_context_log(a->context, GRIB_LOG_ERROR, - "Key \"%s\": Trying to encode a negative value of %ld for key of type unsigned", a->name, val[0]); + "Key \"%s\": Trying to encode a negative value of %ld for key of type unsigned", a->name, val[0]); return GRIB_ENCODING_ERROR; } /* See GRIB-23 and GRIB-262 */ @@ -124,8 +124,8 @@ int pack_long_unsigned_helper(grib_accessor* a, const long* val, size_t* len, in unsigned long maxval = (1UL << nbits) - 1; if (maxval > 0 && v > maxval) { /* See ECC-1002 */ grib_context_log(a->context, GRIB_LOG_ERROR, - "Key \"%s\": Trying to encode value of %ld but the maximum allowable value is %lu (number of bits=%ld)", - a->name, v, maxval, nbits); + "Key \"%s\": Trying to encode value of %ld but the maximum allowable value is %lu (number of bits=%ld)", + a->name, v, maxval, nbits); return GRIB_ENCODING_ERROR; } } @@ -164,13 +164,13 @@ int pack_long_unsigned_helper(grib_accessor* a, const long* val, size_t* len, in int grib_accessor_class_unsigned_t::unpack_long(grib_accessor* a, long* val, size_t* len) { grib_accessor_unsigned_t* self = (grib_accessor_unsigned_t*)a; - long rlen = 0; - unsigned long i = 0; - unsigned long missing = 0; - long count = 0; - int err = 0; - long pos = a->offset * 8; - grib_handle* hand = grib_handle_of_accessor(a); + long rlen = 0; + unsigned long i = 0; + unsigned long missing = 0; + long count = 0; + int err = 0; + long pos = a->offset * 8; + grib_handle* hand = grib_handle_of_accessor(a); err = a->value_count(&count); if (err) diff --git a/src/accessor/grib_accessor_class_unsigned_bits.cc b/src/accessor/grib_accessor_class_unsigned_bits.cc index 40088c17d..44873938a 100644 --- a/src/accessor/grib_accessor_class_unsigned_bits.cc +++ b/src/accessor/grib_accessor_class_unsigned_bits.cc @@ -11,12 +11,12 @@ #include "grib_accessor_class_unsigned_bits.h" -grib_accessor_class_unsigned_bits_t _grib_accessor_class_unsigned_bits{"unsigned_bits"}; +grib_accessor_class_unsigned_bits_t _grib_accessor_class_unsigned_bits{ "unsigned_bits" }; grib_accessor_class* grib_accessor_class_unsigned_bits = &_grib_accessor_class_unsigned_bits; - -static long compute_byte_count(grib_accessor* a){ +static long compute_byte_count(grib_accessor* a) +{ grib_accessor_unsigned_bits_t* self = (grib_accessor_unsigned_bits_t*)a; long numberOfBits; long numberOfElements; @@ -40,21 +40,23 @@ static long compute_byte_count(grib_accessor* a){ } -void grib_accessor_class_unsigned_bits_t::init(grib_accessor* a, const long len, grib_arguments* args){ +void grib_accessor_class_unsigned_bits_t::init(grib_accessor* a, const long len, grib_arguments* args) +{ grib_accessor_class_long_t::init(a, len, args); grib_accessor_unsigned_bits_t* self = (grib_accessor_unsigned_bits_t*)a; - int n = 0; - self->numberOfBits = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - self->numberOfElements = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); - a->length = compute_byte_count(a); + int n = 0; + self->numberOfBits = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + self->numberOfElements = grib_arguments_get_name(grib_handle_of_accessor(a), args, n++); + a->length = compute_byte_count(a); } -int grib_accessor_class_unsigned_bits_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_unsigned_bits_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ grib_accessor_unsigned_bits_t* self = (grib_accessor_unsigned_bits_t*)a; - int ret = 0; - long pos = a->offset * 8; - long rlen = 0; - long numberOfBits = 0; + int ret = 0; + long pos = a->offset * 8; + long rlen = 0; + long numberOfBits = 0; ret = value_count(a, &rlen); if (ret) @@ -84,16 +86,17 @@ int grib_accessor_class_unsigned_bits_t::unpack_long(grib_accessor* a, long* val return GRIB_SUCCESS; } -int grib_accessor_class_unsigned_bits_t::pack_long(grib_accessor* a, const long* val, size_t* len){ +int grib_accessor_class_unsigned_bits_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ grib_accessor_unsigned_bits_t* self = (grib_accessor_unsigned_bits_t*)a; - int ret = 0; - long off = 0; - long numberOfBits = 0; - size_t buflen = 0; - unsigned char* buf = NULL; - unsigned long i = 0; - long rlen = 0; - ret = value_count(a, &rlen); + int ret = 0; + long off = 0; + long numberOfBits = 0; + size_t buflen = 0; + unsigned char* buf = NULL; + unsigned long i = 0; + long rlen = 0; + ret = value_count(a, &rlen); if (ret) return ret; /* @@ -128,11 +131,13 @@ int grib_accessor_class_unsigned_bits_t::pack_long(grib_accessor* a, const long* return ret; } -long grib_accessor_class_unsigned_bits_t::byte_count(grib_accessor* a){ +long grib_accessor_class_unsigned_bits_t::byte_count(grib_accessor* a) +{ return a->length; } -int grib_accessor_class_unsigned_bits_t::value_count(grib_accessor* a, long* numberOfElements){ +int grib_accessor_class_unsigned_bits_t::value_count(grib_accessor* a, long* numberOfElements) +{ grib_accessor_unsigned_bits_t* self = (grib_accessor_unsigned_bits_t*)a; int ret; *numberOfElements = 0; @@ -146,14 +151,17 @@ int grib_accessor_class_unsigned_bits_t::value_count(grib_accessor* a, long* num return ret; } -long grib_accessor_class_unsigned_bits_t::byte_offset(grib_accessor* a){ +long grib_accessor_class_unsigned_bits_t::byte_offset(grib_accessor* a) +{ return a->offset; } -void grib_accessor_class_unsigned_bits_t::update_size(grib_accessor* a, size_t s){ +void grib_accessor_class_unsigned_bits_t::update_size(grib_accessor* a, size_t s) +{ a->length = s; } -long grib_accessor_class_unsigned_bits_t::next_offset(grib_accessor* a){ +long grib_accessor_class_unsigned_bits_t::next_offset(grib_accessor* a) +{ return a->byte_offset() + a->length; } diff --git a/src/accessor/grib_accessor_class_validity_date.cc b/src/accessor/grib_accessor_class_validity_date.cc index 19c26bf48..331c4ec82 100644 --- a/src/accessor/grib_accessor_class_validity_date.cc +++ b/src/accessor/grib_accessor_class_validity_date.cc @@ -12,14 +12,15 @@ #include "grib_accessor_class_validity_date.h" #include "shared_functions.h" -grib_accessor_class_validity_date_t _grib_accessor_class_validity_date{"validity_date"}; +grib_accessor_class_validity_date_t _grib_accessor_class_validity_date{ "validity_date" }; grib_accessor_class* grib_accessor_class_validity_date = &_grib_accessor_class_validity_date; -void grib_accessor_class_validity_date_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_validity_date_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_long_t::init(a, l, c); grib_accessor_validity_date_t* self = (grib_accessor_validity_date_t*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int n = 0; + grib_handle* hand = grib_handle_of_accessor(a); + int n = 0; self->date = grib_arguments_get_name(hand, c, n++); self->time = grib_arguments_get_name(hand, c, n++); @@ -32,14 +33,15 @@ void grib_accessor_class_validity_date_t::init(grib_accessor* a, const long l, g a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; } -int grib_accessor_class_validity_date_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_validity_date_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ grib_accessor_validity_date_t* self = (grib_accessor_validity_date_t*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int ret = 0; - long date = 0; - long time = 0; - long step = 0; - long stepUnits = 0; + grib_handle* hand = grib_handle_of_accessor(a); + int ret = 0; + long date = 0; + long time = 0; + long step = 0; + long stepUnits = 0; long hours = 0, minutes = 0, step_mins = 0, tmp, tmp_hrs; if (self->year) { diff --git a/src/accessor/grib_accessor_class_validity_time.cc b/src/accessor/grib_accessor_class_validity_time.cc index 9cbc445cb..350a19e92 100644 --- a/src/accessor/grib_accessor_class_validity_time.cc +++ b/src/accessor/grib_accessor_class_validity_time.cc @@ -12,15 +12,16 @@ #include "grib_accessor_class_validity_time.h" #include "shared_functions.h" -grib_accessor_class_validity_time_t _grib_accessor_class_validity_time{"validity_time"}; +grib_accessor_class_validity_time_t _grib_accessor_class_validity_time{ "validity_time" }; grib_accessor_class* grib_accessor_class_validity_time = &_grib_accessor_class_validity_time; -void grib_accessor_class_validity_time_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_validity_time_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_long_t::init(a, l, c); grib_accessor_validity_time_t* self = (grib_accessor_validity_time_t*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int n = 0; + grib_handle* hand = grib_handle_of_accessor(a); + int n = 0; self->date = grib_arguments_get_name(hand, c, n++); self->time = grib_arguments_get_name(hand, c, n++); @@ -32,14 +33,15 @@ void grib_accessor_class_validity_time_t::init(grib_accessor* a, const long l, g a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; } -int grib_accessor_class_validity_time_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_validity_time_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ grib_accessor_validity_time_t* self = (grib_accessor_validity_time_t*)a; - grib_handle* hand = grib_handle_of_accessor(a); - int ret = 0; - long date = 0; - long time = 0; - long step = 0; - long stepUnits = 0; + grib_handle* hand = grib_handle_of_accessor(a); + int ret = 0; + long date = 0; + long time = 0; + long step = 0; + long stepUnits = 0; long hours = 0, minutes = 0, step_mins = 0, tmp, tmp_hrs, tmp_mins; if (self->hours) { @@ -92,9 +94,10 @@ int grib_accessor_class_validity_time_t::unpack_long(grib_accessor* a, long* val return GRIB_SUCCESS; } -int grib_accessor_class_validity_time_t::unpack_string(grib_accessor* a, char* val, size_t* len){ - int err = 0; - long v = 0; +int grib_accessor_class_validity_time_t::unpack_string(grib_accessor* a, char* val, size_t* len) +{ + int err = 0; + long v = 0; size_t lsize = 1, lmin = 5; err = unpack_long(a, &v, &lsize); diff --git a/src/accessor/grib_accessor_class_values.cc b/src/accessor/grib_accessor_class_values.cc index 5aa172a05..cd2107559 100644 --- a/src/accessor/grib_accessor_class_values.cc +++ b/src/accessor/grib_accessor_class_values.cc @@ -14,7 +14,8 @@ grib_accessor_class_values_t _grib_accessor_class_values{"values"}; grib_accessor_class* grib_accessor_class_values = &_grib_accessor_class_values; -long init_length(grib_accessor* a){ +long init_length(grib_accessor* a) +{ grib_accessor_values_t* self = (grib_accessor_values_t*)a; int ret = 0; @@ -46,7 +47,8 @@ long init_length(grib_accessor* a){ return seclen - (offsetdata - offsetsection); } -void grib_accessor_class_values_t::init(grib_accessor* a, const long v, grib_arguments* params){ +void grib_accessor_class_values_t::init(grib_accessor* a, const long v, grib_arguments* params) +{ grib_accessor_class_gen_t::init(a, v, params); grib_accessor_values_t* self = (grib_accessor_values_t*)a; self->carg = 0; @@ -60,34 +62,41 @@ void grib_accessor_class_values_t::init(grib_accessor* a, const long v, grib_arg /* Assert(a->length>=0); */ } -int grib_accessor_class_values_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_values_t::get_native_type(grib_accessor* a) +{ return GRIB_TYPE_DOUBLE; } -void grib_accessor_class_values_t::dump(grib_accessor* a, grib_dumper* dumper){ +void grib_accessor_class_values_t::dump(grib_accessor* a, grib_dumper* dumper) +{ grib_dump_values(dumper, a); } -long grib_accessor_class_values_t::byte_count(grib_accessor* a){ +long grib_accessor_class_values_t::byte_count(grib_accessor* a) +{ grib_context_log(a->context, GRIB_LOG_DEBUG, "byte_count of %s = %ld", a->name, a->length); return a->length; } -long grib_accessor_class_values_t::byte_offset(grib_accessor* a){ +long grib_accessor_class_values_t::byte_offset(grib_accessor* a) +{ return a->offset; } -long grib_accessor_class_values_t::next_offset(grib_accessor* a){ +long grib_accessor_class_values_t::next_offset(grib_accessor* a) +{ return a->offset + a->length; } -void grib_accessor_class_values_t::update_size(grib_accessor* a, size_t s){ +void grib_accessor_class_values_t::update_size(grib_accessor* a, size_t s) +{ grib_context_log(a->context, GRIB_LOG_DEBUG, "updating size of %s old %ld new %ld", a->name, a->length, s); a->length = s; Assert(a->length >= 0); } -int grib_accessor_class_values_t::compare(grib_accessor* a, grib_accessor* b){ +int grib_accessor_class_values_t::compare(grib_accessor* a, grib_accessor* b) +{ int retval = 0; double* aval = 0; double* bval = 0; @@ -123,7 +132,8 @@ int grib_accessor_class_values_t::compare(grib_accessor* a, grib_accessor* b){ return retval; } -int grib_accessor_class_values_t::pack_long(grib_accessor* a, const long* val, size_t* len){ +int grib_accessor_class_values_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ grib_accessor_values_t* self = (grib_accessor_values_t*)a; double* dval = (double*)grib_context_malloc(a->context, *len * sizeof(double)); diff --git a/src/accessor/grib_accessor_class_vector.cc b/src/accessor/grib_accessor_class_vector.cc index bd0185d73..f08809f6f 100644 --- a/src/accessor/grib_accessor_class_vector.cc +++ b/src/accessor/grib_accessor_class_vector.cc @@ -12,14 +12,15 @@ #include "grib_accessor_class_vector.h" #include "grib_accessor_class_abstract_vector.h" -grib_accessor_class_vector_t _grib_accessor_class_vector{"vector"}; +grib_accessor_class_vector_t _grib_accessor_class_vector{ "vector" }; grib_accessor_class* grib_accessor_class_vector = &_grib_accessor_class_vector; -void grib_accessor_class_vector_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_vector_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_abstract_vector_t::init(a, l, c); grib_accessor_vector_t* self = (grib_accessor_vector_t*)a; - int n = 0; + int n = 0; self->vector = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); self->index = grib_arguments_get_long(grib_handle_of_accessor(a), c, n++); @@ -28,12 +29,13 @@ void grib_accessor_class_vector_t::init(grib_accessor* a, const long l, grib_arg a->length = 0; } -int grib_accessor_class_vector_t::unpack_double(grib_accessor* a, double* val, size_t* len){ +int grib_accessor_class_vector_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ int err = 0; size_t size = 0; double* stat; - grib_accessor_vector_t* self = (grib_accessor_vector_t*)a; - grib_accessor* va = (grib_accessor*)grib_find_accessor(grib_handle_of_accessor(a), self->vector); + grib_accessor_vector_t* self = (grib_accessor_vector_t*)a; + grib_accessor* va = (grib_accessor*)grib_find_accessor(grib_handle_of_accessor(a), self->vector); grib_accessor_abstract_vector_t* v = (grib_accessor_abstract_vector_t*)va; Assert(self->index >= 0); @@ -46,7 +48,8 @@ int grib_accessor_class_vector_t::unpack_double(grib_accessor* a, double* val, s if (va->dirty) { grib_get_size(grib_handle_of_accessor(a), self->vector, &size); stat = (double*)grib_context_malloc_clear(a->context, sizeof(double) * size); - err = va->unpack_double(stat, &size); grib_context_free(a->context, stat); + err = va->unpack_double(stat, &size); + grib_context_free(a->context, stat); if (err) return err; } diff --git a/src/accessor/grib_accessor_class_when.cc b/src/accessor/grib_accessor_class_when.cc index 2ab2652f0..48db76803 100644 --- a/src/accessor/grib_accessor_class_when.cc +++ b/src/accessor/grib_accessor_class_when.cc @@ -11,25 +11,29 @@ #include "grib_accessor_class_when.h" -grib_accessor_class_when_t _grib_accessor_class_when{"when"}; +grib_accessor_class_when_t _grib_accessor_class_when{ "when" }; grib_accessor_class* grib_accessor_class_when = &_grib_accessor_class_when; -void grib_accessor_class_when_t::init(grib_accessor* a, const long len, grib_arguments* arg){ +void grib_accessor_class_when_t::init(grib_accessor* a, const long len, grib_arguments* arg) +{ grib_accessor_class_gen_t::init(a, len, arg); a->length = 0; a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; } -void grib_accessor_class_when_t::dump(grib_accessor* a, grib_dumper* dumper){ +void grib_accessor_class_when_t::dump(grib_accessor* a, grib_dumper* dumper) +{ /* grib_dump_when(dumper,a,NULL); */ } -int grib_accessor_class_when_t::notify_change(grib_accessor* a, grib_accessor* changed){ +int grib_accessor_class_when_t::notify_change(grib_accessor* a, grib_accessor* changed) +{ return grib_action_notify_change(a->creator, a, changed); } -int grib_accessor_class_when_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_when_t::get_native_type(grib_accessor* a) +{ return GRIB_TYPE_UNDEFINED; }