From f4e9528f739bf268eaa728ae1983ad49869a9c65 Mon Sep 17 00:00:00 2001 From: shahramn Date: Fri, 28 Jun 2024 17:07:46 +0100 Subject: [PATCH] Formatting --- src/accessor/grib_accessor_class_g2date.cc | 19 ++++---- .../grib_accessor_class_longitudes.cc | 44 +++++++++++-------- .../grib_accessor_class_number_of_points.cc | 25 ++++++----- ...grib_accessor_class_octahedral_gaussian.cc | 20 +++++---- .../grib_accessor_class_smart_table_column.cc | 32 ++++++++------ .../grib_accessor_class_statistics.cc | 44 +++++++++++-------- ...grib_accessor_class_statistics_spectral.cc | 39 +++++++++------- src/accessor/grib_accessor_class_sum.cc | 42 ++++++++++-------- src/accessor/grib_accessor_class_time.cc | 24 +++++----- src/accessor/grib_accessor_class_to_double.cc | 41 ++++++++++------- .../grib_accessor_class_to_integer.cc | 44 ++++++++++++------- src/accessor/grib_accessor_class_to_string.cc | 33 +++++++++----- .../grib_accessor_class_transient_darray.cc | 35 +++++++++------ src/accessor/grib_accessor_class_trim.cc | 39 +++++++++------- 14 files changed, 285 insertions(+), 196 deletions(-) diff --git a/src/accessor/grib_accessor_class_g2date.cc b/src/accessor/grib_accessor_class_g2date.cc index 238da76f7..827df44df 100644 --- a/src/accessor/grib_accessor_class_g2date.cc +++ b/src/accessor/grib_accessor_class_g2date.cc @@ -11,23 +11,25 @@ #include "grib_accessor_class_g2date.h" -grib_accessor_class_g2date_t _grib_accessor_class_g2date{"g2date"}; +grib_accessor_class_g2date_t _grib_accessor_class_g2date{ "g2date" }; grib_accessor_class* grib_accessor_class_g2date = &_grib_accessor_class_g2date; -void grib_accessor_class_g2date_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_g2date_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_long_t::init(a, l, c); grib_accessor_g2date_t* self = (grib_accessor_g2date_t*)a; - int n = 0; + int n = 0; self->year = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); self->month = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); self->day = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); } -int grib_accessor_class_g2date_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_g2date_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ const grib_accessor_g2date_t* self = (grib_accessor_g2date_t*)a; - int ret = 0; + int ret = 0; long year = 0; long month = 0; long day = 0; @@ -47,11 +49,12 @@ int grib_accessor_class_g2date_t::unpack_long(grib_accessor* a, long* val, size_ return GRIB_SUCCESS; } -int grib_accessor_class_g2date_t::pack_long(grib_accessor* a, const long* val, size_t* len){ +int grib_accessor_class_g2date_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ const grib_accessor_g2date_t* self = (grib_accessor_g2date_t*)a; - int ret = GRIB_SUCCESS; - long v = val[0]; + int ret = GRIB_SUCCESS; + long v = val[0]; long year = 0; long month = 0; long day = 0; diff --git a/src/accessor/grib_accessor_class_longitudes.cc b/src/accessor/grib_accessor_class_longitudes.cc index a9ae31309..80e4e2e7b 100644 --- a/src/accessor/grib_accessor_class_longitudes.cc +++ b/src/accessor/grib_accessor_class_longitudes.cc @@ -11,13 +11,14 @@ #include "grib_accessor_class_longitudes.h" -grib_accessor_class_longitudes_t _grib_accessor_class_longitudes{"longitudes"}; +grib_accessor_class_longitudes_t _grib_accessor_class_longitudes{ "longitudes" }; grib_accessor_class* grib_accessor_class_longitudes = &_grib_accessor_class_longitudes; static int get_distinct(grib_accessor* a, double** val, long* len); int compare_doubles(const void* a, const void* b); -void grib_accessor_class_longitudes_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_longitudes_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_double_t::init(a, l, c); grib_accessor_longitudes_t* self = (grib_accessor_longitudes_t*)a; int n = 0; @@ -30,18 +31,20 @@ void grib_accessor_class_longitudes_t::init(grib_accessor* a, const long l, grib a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; } -int grib_accessor_class_longitudes_t::unpack_double(grib_accessor* a, double* val, size_t* len){ - grib_context* c = a->context; +int grib_accessor_class_longitudes_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ grib_accessor_longitudes_t* self = (grib_accessor_longitudes_t*)a; - int ret = 0; - double* v = val; - double dummyLat = 0; - size_t size = 0; - long count = 0; + + grib_context* c = a->context; + int ret = 0; + double* v = val; + double dummyLat = 0; + size_t size = 0; + long count = 0; grib_iterator* iter = NULL; self->save = 1; - ret = value_count(a, &count); + ret = value_count(a, &count); if (ret) return ret; size = count; @@ -84,11 +87,12 @@ int grib_accessor_class_longitudes_t::unpack_double(grib_accessor* a, double* va return ret; } -int grib_accessor_class_longitudes_t::value_count(grib_accessor* a, long* len){ +int grib_accessor_class_longitudes_t::value_count(grib_accessor* a, long* len) +{ grib_accessor_longitudes_t* self = (grib_accessor_longitudes_t*)a; - grib_handle* h = grib_handle_of_accessor(a); - grib_context* c = a->context; - double* val = NULL; + grib_handle* h = grib_handle_of_accessor(a); + grib_context* c = a->context; + double* val = NULL; int ret; size_t size; *len = 0; @@ -121,15 +125,16 @@ int grib_accessor_class_longitudes_t::value_count(grib_accessor* a, long* len){ return ret; } -static int get_distinct(grib_accessor* a, double** val, long* len){ +static int get_distinct(grib_accessor* a, double** val, long* len) +{ long count = 0; double prev; double* v = NULL; double* v1 = NULL; double dummyLat = 0; - int ret = 0; - size_t size = *len; - grib_context* c = a->context; + int ret = 0; + size_t size = *len; + grib_context* c = a->context; // Performance: We do not need the values to be decoded grib_iterator* iter = grib_iterator_new(grib_handle_of_accessor(a), GRIB_GEOITERATOR_NO_VALUES, &ret); @@ -177,7 +182,8 @@ static int get_distinct(grib_accessor* a, double** val, long* len){ return GRIB_SUCCESS; } -int compare_doubles(const void* a, const void* b){ +int compare_doubles(const void* a, const void* b) +{ double* arg1 = (double*)a; double* arg2 = (double*)b; if (*arg1 < *arg2) diff --git a/src/accessor/grib_accessor_class_number_of_points.cc b/src/accessor/grib_accessor_class_number_of_points.cc index c1b63f2a2..d12eabeae 100644 --- a/src/accessor/grib_accessor_class_number_of_points.cc +++ b/src/accessor/grib_accessor_class_number_of_points.cc @@ -11,34 +11,37 @@ #include "grib_accessor_class_number_of_points.h" -grib_accessor_class_number_of_points_t _grib_accessor_class_number_of_points{"number_of_points"}; +grib_accessor_class_number_of_points_t _grib_accessor_class_number_of_points{ "number_of_points" }; grib_accessor_class* grib_accessor_class_number_of_points = &_grib_accessor_class_number_of_points; -void grib_accessor_class_number_of_points_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_number_of_points_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_long_t::init(a, l, c); int n = 0; grib_handle* hand = grib_handle_of_accessor(a); grib_accessor_number_of_points_t* self = (grib_accessor_number_of_points_t*)a; - self->ni = grib_arguments_get_name(hand, c, n++); - self->nj = grib_arguments_get_name(hand, c, n++); - self->plpresent = grib_arguments_get_name(hand, c, n++); - self->pl = grib_arguments_get_name(hand, c, n++); + + self->ni = grib_arguments_get_name(hand, c, n++); + self->nj = grib_arguments_get_name(hand, c, n++); + self->plpresent = grib_arguments_get_name(hand, c, n++); + self->pl = grib_arguments_get_name(hand, c, n++); a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; a->length = 0; } -int grib_accessor_class_number_of_points_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_number_of_points_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ grib_accessor_number_of_points_t* self = (grib_accessor_number_of_points_t*)a; int ret = GRIB_SUCCESS; long ni = 0, nj = 0, plpresent = 0; - size_t plsize = 0; - long* pl = NULL; - int i = 0; - grib_context* c = a->context; + size_t plsize = 0; + long* pl = NULL; + int i = 0; + grib_context* c = a->context; grib_handle* hand = grib_handle_of_accessor(a); if ((ret = grib_get_long_internal(hand, self->ni, &ni)) != GRIB_SUCCESS) diff --git a/src/accessor/grib_accessor_class_octahedral_gaussian.cc b/src/accessor/grib_accessor_class_octahedral_gaussian.cc index 8c556e84a..eda90763f 100644 --- a/src/accessor/grib_accessor_class_octahedral_gaussian.cc +++ b/src/accessor/grib_accessor_class_octahedral_gaussian.cc @@ -11,15 +11,16 @@ #include "grib_accessor_class_octahedral_gaussian.h" -grib_accessor_class_octahedral_gaussian_t _grib_accessor_class_octahedral_gaussian{"octahedral_gaussian"}; +grib_accessor_class_octahedral_gaussian_t _grib_accessor_class_octahedral_gaussian{ "octahedral_gaussian" }; grib_accessor_class* grib_accessor_class_octahedral_gaussian = &_grib_accessor_class_octahedral_gaussian; -void grib_accessor_class_octahedral_gaussian_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_octahedral_gaussian_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_long_t::init(a, l, c); grib_accessor_octahedral_gaussian_t* self = (grib_accessor_octahedral_gaussian_t*)a; - int n = 0; - grib_handle* hand = grib_handle_of_accessor(a); + int n = 0; + grib_handle* hand = grib_handle_of_accessor(a); self->N = grib_arguments_get_name(hand, c, n++); self->Ni = grib_arguments_get_name(hand, c, n++); @@ -36,7 +37,8 @@ void grib_accessor_class_octahedral_gaussian_t::init(grib_accessor* a, const lon * -4 ..-4 All below equator * Anything else is considered not octahedral */ -static int is_pl_octahedral(const long pl[], size_t size){ +static int is_pl_octahedral(const long pl[], size_t size) +{ long i; long prev_diff = -1; for (i = 1; i < size; ++i) { @@ -69,9 +71,10 @@ static int is_pl_octahedral(const long pl[], size_t size){ return 1; /* it's octahedral */ } -int grib_accessor_class_octahedral_gaussian_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_octahedral_gaussian_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ grib_accessor_octahedral_gaussian_t* self = (grib_accessor_octahedral_gaussian_t*)a; - int ret = GRIB_SUCCESS; + int ret = GRIB_SUCCESS; long Ni; long plpresent = 0; long* pl = NULL; /* pl array */ @@ -115,6 +118,7 @@ int grib_accessor_class_octahedral_gaussian_t::unpack_long(grib_accessor* a, lon return ret; } -int grib_accessor_class_octahedral_gaussian_t::pack_long(grib_accessor* a, const long* val, size_t* len){ +int grib_accessor_class_octahedral_gaussian_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ return GRIB_NOT_IMPLEMENTED; } diff --git a/src/accessor/grib_accessor_class_smart_table_column.cc b/src/accessor/grib_accessor_class_smart_table_column.cc index 7d352471d..d9d44bc49 100644 --- a/src/accessor/grib_accessor_class_smart_table_column.cc +++ b/src/accessor/grib_accessor_class_smart_table_column.cc @@ -12,24 +12,25 @@ #include "grib_accessor_class_smart_table_column.h" #include "grib_accessor_class_smart_table.h" -grib_accessor_class_smart_table_column_t _grib_accessor_class_smart_table_column{"smart_table_column"}; +grib_accessor_class_smart_table_column_t _grib_accessor_class_smart_table_column{ "smart_table_column" }; grib_accessor_class* grib_accessor_class_smart_table_column = &_grib_accessor_class_smart_table_column; - -void grib_accessor_class_smart_table_column_t::init(grib_accessor* a, const long len, grib_arguments* params){ +void grib_accessor_class_smart_table_column_t::init(grib_accessor* a, const long len, grib_arguments* params) +{ grib_accessor_class_gen_t::init(a, len, params); int n = 0; grib_accessor_smart_table_column_t* self = (grib_accessor_smart_table_column_t*)a; self->smartTable = grib_arguments_get_name(grib_handle_of_accessor(a), params, n++); - self->index = grib_arguments_get_long(grib_handle_of_accessor(a), params, n++); + self->index = grib_arguments_get_long(grib_handle_of_accessor(a), params, n++); a->length = 0; a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; } -void grib_accessor_class_smart_table_column_t::dump(grib_accessor* a, grib_dumper* dumper){ +void grib_accessor_class_smart_table_column_t::dump(grib_accessor* a, grib_dumper* dumper) +{ int type = get_native_type(a); switch (type) { @@ -42,7 +43,8 @@ void grib_accessor_class_smart_table_column_t::dump(grib_accessor* a, grib_dumpe } } -int grib_accessor_class_smart_table_column_t::unpack_string_array(grib_accessor* a, char** buffer, size_t* len){ +int grib_accessor_class_smart_table_column_t::unpack_string_array(grib_accessor* a, char** buffer, size_t* len) +{ grib_accessor_smart_table_column_t* self = (grib_accessor_smart_table_column_t*)a; grib_accessor_smart_table_t* tableAccessor = NULL; grib_smart_table* table = NULL; @@ -96,7 +98,8 @@ int grib_accessor_class_smart_table_column_t::unpack_string_array(grib_accessor* return GRIB_SUCCESS; } -int grib_accessor_class_smart_table_column_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_smart_table_column_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ grib_accessor_smart_table_column_t* self = (grib_accessor_smart_table_column_t*)a; grib_accessor_smart_table_t* tableAccessor = NULL; grib_smart_table* table = NULL; @@ -146,21 +149,23 @@ int grib_accessor_class_smart_table_column_t::unpack_long(grib_accessor* a, long return GRIB_SUCCESS; } -int grib_accessor_class_smart_table_column_t::value_count(grib_accessor* a, long* count){ +int grib_accessor_class_smart_table_column_t::value_count(grib_accessor* a, long* count) +{ grib_accessor_smart_table_column_t* self = (grib_accessor_smart_table_column_t*)a; size_t size = 0; - int err = 0; - *count = 0; + int err = 0; + *count = 0; if (!self->smartTable) return 0; - err = grib_get_size(grib_handle_of_accessor(a), self->smartTable, &size); + err = grib_get_size(grib_handle_of_accessor(a), self->smartTable, &size); *count = size; return err; } -void grib_accessor_class_smart_table_column_t::destroy(grib_context* context, grib_accessor* a){ +void grib_accessor_class_smart_table_column_t::destroy(grib_context* context, grib_accessor* a) +{ if (a->vvalue != NULL) { grib_context_free(context, a->vvalue); a->vvalue = NULL; @@ -169,7 +174,8 @@ void grib_accessor_class_smart_table_column_t::destroy(grib_context* context, gr grib_accessor_class_gen_t::destroy(context, a); } -int grib_accessor_class_smart_table_column_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_smart_table_column_t::get_native_type(grib_accessor* a) +{ int type = GRIB_TYPE_LONG; /*printf("---------- %s flags=%ld GRIB_ACCESSOR_FLAG_STRING_TYPE=%d\n", a->name,a->flags,GRIB_ACCESSOR_FLAG_STRING_TYPE);*/ diff --git a/src/accessor/grib_accessor_class_statistics.cc b/src/accessor/grib_accessor_class_statistics.cc index 2d5cfd756..1e56f8a12 100644 --- a/src/accessor/grib_accessor_class_statistics.cc +++ b/src/accessor/grib_accessor_class_statistics.cc @@ -11,14 +11,15 @@ #include "grib_accessor_class_statistics.h" -grib_accessor_class_statistics_t _grib_accessor_class_statistics{"statistics"}; +grib_accessor_class_statistics_t _grib_accessor_class_statistics{ "statistics" }; grib_accessor_class* grib_accessor_class_statistics = &_grib_accessor_class_statistics; -void grib_accessor_class_statistics_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_statistics_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_abstract_vector_t::init(a, l, c); grib_accessor_statistics_t* self = (grib_accessor_statistics_t*)a; - int n = 0; + int n = 0; self->missing_value = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); self->values = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); @@ -27,24 +28,24 @@ void grib_accessor_class_statistics_t::init(grib_accessor* a, const long l, grib a->flags |= GRIB_ACCESSOR_FLAG_HIDDEN; self->number_of_elements = 8; - self->v = (double*)grib_context_malloc(a->context, - sizeof(double) * self->number_of_elements); + self->v = (double*)grib_context_malloc(a->context, sizeof(double) * self->number_of_elements); a->length = 0; a->dirty = 1; } -int grib_accessor_class_statistics_t::unpack_double(grib_accessor* a, double* val, size_t* len){ +int grib_accessor_class_statistics_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ grib_accessor_statistics_t* self = (grib_accessor_statistics_t*)a; int ret = 0; double* values = NULL; size_t i = 0, size = 0, real_size = 0; double max, min, avg, sd, value, skew, kurt, m2 = 0, m3 = 0, m4 = 0; - double missing = 0; + double missing = 0; long missingValuesPresent = 0; size_t number_of_missing = 0; - grib_context* c = a->context; - grib_handle* h = grib_handle_of_accessor(a); + grib_context* c = a->context; + grib_handle* h = grib_handle_of_accessor(a); if (!a->dirty) return GRIB_SUCCESS; @@ -166,19 +167,22 @@ int grib_accessor_class_statistics_t::unpack_double(grib_accessor* a, double* va return ret; } -int grib_accessor_class_statistics_t::value_count(grib_accessor* a, long* count){ +int grib_accessor_class_statistics_t::value_count(grib_accessor* a, long* count) +{ grib_accessor_statistics_t* self = (grib_accessor_statistics_t*)a; - *count = self->number_of_elements; + *count = self->number_of_elements; return 0; } -void grib_accessor_class_statistics_t::destroy(grib_context* c, grib_accessor* a){ +void grib_accessor_class_statistics_t::destroy(grib_context* c, grib_accessor* a) +{ grib_accessor_statistics_t* self = (grib_accessor_statistics_t*)a; grib_context_free(c, self->v); grib_accessor_class_abstract_vector_t::destroy(c, a); } -int grib_accessor_class_statistics_t::compare(grib_accessor* a, grib_accessor* b){ +int grib_accessor_class_statistics_t::compare(grib_accessor* a, grib_accessor* b) +{ int retval = GRIB_SUCCESS; double* aval = 0; double* bval = 0; @@ -188,11 +192,13 @@ int grib_accessor_class_statistics_t::compare(grib_accessor* a, grib_accessor* b int err = 0; long count = 0; - err = a->value_count(&count); if (err) + err = a->value_count(&count); + if (err) return err; alen = count; - err = b->value_count(&count); if (err) + err = b->value_count(&count); + if (err) return err; blen = count; @@ -205,9 +211,10 @@ int grib_accessor_class_statistics_t::compare(grib_accessor* a, grib_accessor* b b->dirty = 1; a->dirty = 1; - a->unpack_double(aval, &alen); b->unpack_double(bval, &blen); + a->unpack_double(aval, &alen); + b->unpack_double(bval, &blen); retval = GRIB_SUCCESS; - for (size_t i=0; ivalues = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); self->J = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); @@ -30,14 +31,14 @@ void grib_accessor_class_statistics_spectral_t::init(grib_accessor* a, const lon a->flags |= GRIB_ACCESSOR_FLAG_FUNCTION; self->number_of_elements = 4; - self->v = (double*)grib_context_malloc(a->context, - sizeof(double) * self->number_of_elements); + self->v = (double*)grib_context_malloc(a->context, sizeof(double) * self->number_of_elements); a->length = 0; a->dirty = 1; } -int grib_accessor_class_statistics_spectral_t::unpack_double(grib_accessor* a, double* val, size_t* len){ +int grib_accessor_class_statistics_spectral_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ grib_accessor_statistics_spectral_t* self = (grib_accessor_statistics_spectral_t*)a; int ret = 0, i = 0; double* values; @@ -85,8 +86,8 @@ int grib_accessor_class_statistics_spectral_t::unpack_double(grib_accessor* a, d return ret; } - avg = values[0]; - sd = 0; + avg = values[0]; + sd = 0; for (i = 2; i < 2 * J; i += 2) sd += values[i] * values[i]; @@ -114,19 +115,22 @@ int grib_accessor_class_statistics_spectral_t::unpack_double(grib_accessor* a, d return ret; } -int grib_accessor_class_statistics_spectral_t::value_count(grib_accessor* a, long* count){ +int grib_accessor_class_statistics_spectral_t::value_count(grib_accessor* a, long* count) +{ grib_accessor_statistics_spectral_t* self = (grib_accessor_statistics_spectral_t*)a; - *count = self->number_of_elements; + *count = self->number_of_elements; return 0; } -void grib_accessor_class_statistics_spectral_t::destroy(grib_context* c, grib_accessor* a){ +void grib_accessor_class_statistics_spectral_t::destroy(grib_context* c, grib_accessor* a) +{ grib_accessor_statistics_spectral_t* self = (grib_accessor_statistics_spectral_t*)a; grib_context_free(c, self->v); grib_accessor_class_abstract_vector_t::destroy(c, a); } -int grib_accessor_class_statistics_spectral_t::compare(grib_accessor* a, grib_accessor* b){ +int grib_accessor_class_statistics_spectral_t::compare(grib_accessor* a, grib_accessor* b) +{ int retval = GRIB_SUCCESS; double* aval = 0; double* bval = 0; @@ -136,11 +140,13 @@ int grib_accessor_class_statistics_spectral_t::compare(grib_accessor* a, grib_ac int err = 0; long count = 0; - err = a->value_count(&count); if (err) + err = a->value_count(&count); + if (err) return err; alen = count; - err = b->value_count(&count); if (err) + err = b->value_count(&count); + if (err) return err; blen = count; @@ -153,9 +159,10 @@ int grib_accessor_class_statistics_spectral_t::compare(grib_accessor* a, grib_ac b->dirty = 1; a->dirty = 1; - a->unpack_double(aval, &alen); b->unpack_double(bval, &blen); + a->unpack_double(aval, &alen); + b->unpack_double(bval, &blen); retval = GRIB_SUCCESS; - for (size_t i=0; ivalues = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); - a->length = 0; + int n = 0; + self->values = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++); + a->length = 0; a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; } -int grib_accessor_class_sum_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_sum_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ grib_accessor_sum_t* self = (grib_accessor_sum_t*)a; - int ret = 0; - size_t size = 0; - long* values = 0; - long i; - long count = 0; + int ret = 0; + size_t size = 0; + long* values = 0; + size_t i = 0; + long count = 0; ret = value_count(a, &count); if (ret) @@ -56,12 +58,13 @@ int grib_accessor_class_sum_t::unpack_long(grib_accessor* a, long* val, size_t* return GRIB_SUCCESS; } -int grib_accessor_class_sum_t::unpack_double(grib_accessor* a, double* val, size_t* len){ +int grib_accessor_class_sum_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ grib_accessor_sum_t* self = (grib_accessor_sum_t*)a; - int ret = 0; - size_t size = 0; - double* values = 0; - long i; + int ret = 0; + size_t size = 0; + double* values = 0; + size_t i = 0; long count = 0; ret = value_count(a, &count); @@ -91,10 +94,11 @@ int grib_accessor_class_sum_t::unpack_double(grib_accessor* a, double* val, size return GRIB_SUCCESS; } -int grib_accessor_class_sum_t::value_count(grib_accessor* a, long* count){ +int grib_accessor_class_sum_t::value_count(grib_accessor* a, long* count) +{ grib_accessor_sum_t* self = (grib_accessor_sum_t*)a; - size_t n = 0; - int ret = 0; + size_t n = 0; + int ret = GRIB_SUCCESS; ret = grib_get_size(grib_handle_of_accessor(a), self->values, &n); *count = n; diff --git a/src/accessor/grib_accessor_class_time.cc b/src/accessor/grib_accessor_class_time.cc index debb1a2f4..e70fc3d49 100644 --- a/src/accessor/grib_accessor_class_time.cc +++ b/src/accessor/grib_accessor_class_time.cc @@ -11,25 +11,27 @@ #include "grib_accessor_class_time.h" -grib_accessor_class_time_t _grib_accessor_class_time{"time"}; +grib_accessor_class_time_t _grib_accessor_class_time{ "time" }; grib_accessor_class* grib_accessor_class_time = &_grib_accessor_class_time; -void grib_accessor_class_time_t::init(grib_accessor* a, const long l, grib_arguments* c){ +void grib_accessor_class_time_t::init(grib_accessor* a, const long l, grib_arguments* c) +{ grib_accessor_class_long_t::init(a, l, c); grib_accessor_time_t* self = (grib_accessor_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->hour = grib_arguments_get_name(hand, c, n++); self->minute = grib_arguments_get_name(hand, c, n++); self->second = grib_arguments_get_name(hand, c, n++); } -int grib_accessor_class_time_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_time_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ const grib_accessor_time_t* self = (grib_accessor_time_t*)a; - int ret = 0; + int ret = 0; long hour = 0, minute = 0, second = 0; grib_handle* hand = grib_handle_of_accessor(a); @@ -43,7 +45,7 @@ int grib_accessor_class_time_t::unpack_long(grib_accessor* a, long* val, size_t* /* We ignore the 'seconds' in our time calculation! */ if (second != 0) { grib_context_log(a->context, GRIB_LOG_ERROR, - "Key %s (%s): Truncating time: non-zero seconds(%ld) ignored", a->name, __func__, second); + "Key %s (%s): Truncating time: non-zero seconds(%ld) ignored", a->name, __func__, second); } if (*len < 1) @@ -60,11 +62,12 @@ int grib_accessor_class_time_t::unpack_long(grib_accessor* a, long* val, size_t* return GRIB_SUCCESS; } -int grib_accessor_class_time_t::pack_long(grib_accessor* a, const long* val, size_t* len){ +int grib_accessor_class_time_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ const grib_accessor_time_t* self = (grib_accessor_time_t*)a; int ret = 0; - long v = val[0]; + long v = val[0]; grib_handle* hand = grib_handle_of_accessor(a); long hour = 0, minute = 0, second = 0; @@ -92,7 +95,8 @@ int grib_accessor_class_time_t::pack_long(grib_accessor* a, const long* val, siz return GRIB_SUCCESS; } -int grib_accessor_class_time_t::unpack_string(grib_accessor* a, char* val, size_t* len){ +int grib_accessor_class_time_t::unpack_string(grib_accessor* a, char* val, size_t* len) +{ long v = 0; size_t lsize = 1, lmin = 5; diff --git a/src/accessor/grib_accessor_class_to_double.cc b/src/accessor/grib_accessor_class_to_double.cc index 854a32ffc..2983be487 100644 --- a/src/accessor/grib_accessor_class_to_double.cc +++ b/src/accessor/grib_accessor_class_to_double.cc @@ -11,11 +11,12 @@ #include "grib_accessor_class_to_double.h" -grib_accessor_class_to_double_t _grib_accessor_class_to_double{"to_double"}; +grib_accessor_class_to_double_t _grib_accessor_class_to_double{ "to_double" }; grib_accessor_class* grib_accessor_class_to_double = &_grib_accessor_class_to_double; -void grib_accessor_class_to_double_t::init(grib_accessor* a, const long len, grib_arguments* arg){ +void grib_accessor_class_to_double_t::init(grib_accessor* a, const long len, grib_arguments* arg) +{ grib_accessor_class_gen_t::init(a, len, arg); grib_accessor_to_double_t* self = (grib_accessor_to_double_t*)a; @@ -30,9 +31,10 @@ void grib_accessor_class_to_double_t::init(grib_accessor* a, const long len, gri a->length = 0; } -int grib_accessor_class_to_double_t::value_count(grib_accessor* a, long* count){ +int grib_accessor_class_to_double_t::value_count(grib_accessor* a, long* count) +{ grib_accessor_to_double_t* self = (grib_accessor_to_double_t*)a; - size_t size = 0; + size_t size = 0; int err = grib_get_size(grib_handle_of_accessor(a), self->key, &size); *count = size; @@ -40,9 +42,10 @@ int grib_accessor_class_to_double_t::value_count(grib_accessor* a, long* count){ return err; } -size_t grib_accessor_class_to_double_t::string_length(grib_accessor* a){ +size_t grib_accessor_class_to_double_t::string_length(grib_accessor* a) +{ grib_accessor_to_double_t* self = (grib_accessor_to_double_t*)a; - size_t size = 0; + size_t size = 0; if (self->length) return self->length; @@ -51,25 +54,28 @@ size_t grib_accessor_class_to_double_t::string_length(grib_accessor* a){ return size; } -void grib_accessor_class_to_double_t::dump(grib_accessor* a, grib_dumper* dumper){ +void grib_accessor_class_to_double_t::dump(grib_accessor* a, grib_dumper* dumper) +{ grib_dump_string(dumper, a, NULL); } -int grib_accessor_class_to_double_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_to_double_t::get_native_type(grib_accessor* a) +{ return GRIB_TYPE_LONG; } -int grib_accessor_class_to_double_t::unpack_string(grib_accessor* a, char* val, size_t* len){ +int grib_accessor_class_to_double_t::unpack_string(grib_accessor* a, char* val, size_t* len) +{ grib_accessor_to_double_t* self = (grib_accessor_to_double_t*)a; int err = 0; char buff[512] = {0,}; - size_t size = 512; + size_t size = 512; size_t length = string_length(a); if (*len < length + 1) { grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%lu) for %s, it contains %ld values", - *len, a->name, a->length + 1); + *len, a->name, a->length + 1); *len = length + 1; return GRIB_ARRAY_TOO_SMALL; } @@ -89,9 +95,10 @@ int grib_accessor_class_to_double_t::unpack_string(grib_accessor* a, char* val, return err; } -int grib_accessor_class_to_double_t::unpack_long(grib_accessor* a, long* v, size_t* len){ +int grib_accessor_class_to_double_t::unpack_long(grib_accessor* a, long* v, size_t* len) +{ grib_accessor_to_double_t* self = (grib_accessor_to_double_t*)a; - char val[1024] = {0,}; + char val[1024] = {0,}; size_t l = sizeof(val); char* last = NULL; int err = a->unpack_string(val, &l); @@ -107,9 +114,10 @@ int grib_accessor_class_to_double_t::unpack_long(grib_accessor* a, long* v, size return err; } -int grib_accessor_class_to_double_t::unpack_double(grib_accessor* a, double* v, size_t* len){ +int grib_accessor_class_to_double_t::unpack_double(grib_accessor* a, double* v, size_t* len) +{ grib_accessor_to_double_t* self = (grib_accessor_to_double_t*)a; - char val[1024] = {0,}; + char val[1024] = {0,}; size_t l = sizeof(val); char* last = NULL; int err = a->unpack_string(val, &l); @@ -125,6 +133,7 @@ int grib_accessor_class_to_double_t::unpack_double(grib_accessor* a, double* v, return err; } -long grib_accessor_class_to_double_t::next_offset(grib_accessor* a){ +long grib_accessor_class_to_double_t::next_offset(grib_accessor* a) +{ return a->offset + a->length; } diff --git a/src/accessor/grib_accessor_class_to_integer.cc b/src/accessor/grib_accessor_class_to_integer.cc index bc58f31c6..a4b621b8d 100644 --- a/src/accessor/grib_accessor_class_to_integer.cc +++ b/src/accessor/grib_accessor_class_to_integer.cc @@ -11,11 +11,12 @@ #include "grib_accessor_class_to_integer.h" -grib_accessor_class_to_integer_t _grib_accessor_class_to_integer{"to_integer"}; +grib_accessor_class_to_integer_t _grib_accessor_class_to_integer{ "to_integer" }; grib_accessor_class* grib_accessor_class_to_integer = &_grib_accessor_class_to_integer; -void grib_accessor_class_to_integer_t::init(grib_accessor* a, const long len, grib_arguments* arg){ +void grib_accessor_class_to_integer_t::init(grib_accessor* a, const long len, grib_arguments* arg) +{ grib_accessor_class_gen_t::init(a, len, arg); grib_accessor_to_integer_t* self = (grib_accessor_to_integer_t*)a; @@ -27,9 +28,10 @@ void grib_accessor_class_to_integer_t::init(grib_accessor* a, const long len, gr a->length = 0; } -int grib_accessor_class_to_integer_t::value_count(grib_accessor* a, long* count){ +int grib_accessor_class_to_integer_t::value_count(grib_accessor* a, long* count) +{ grib_accessor_to_integer_t* self = (grib_accessor_to_integer_t*)a; - size_t size = 0; + size_t size = 0; int err = grib_get_size(grib_handle_of_accessor(a), self->key, &size); *count = size; @@ -37,9 +39,10 @@ int grib_accessor_class_to_integer_t::value_count(grib_accessor* a, long* count) return err; } -size_t grib_accessor_class_to_integer_t::string_length(grib_accessor* a){ +size_t grib_accessor_class_to_integer_t::string_length(grib_accessor* a) +{ grib_accessor_to_integer_t* self = (grib_accessor_to_integer_t*)a; - size_t size = 0; + size_t size = 0; if (self->length) return self->length; @@ -48,15 +51,18 @@ size_t grib_accessor_class_to_integer_t::string_length(grib_accessor* a){ return size; } -void grib_accessor_class_to_integer_t::dump(grib_accessor* a, grib_dumper* dumper){ +void grib_accessor_class_to_integer_t::dump(grib_accessor* a, grib_dumper* dumper) +{ grib_dump_long(dumper, a, NULL); } -int grib_accessor_class_to_integer_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_to_integer_t::get_native_type(grib_accessor* a) +{ return GRIB_TYPE_LONG; } -int grib_accessor_class_to_integer_t::unpack_string(grib_accessor* a, char* val, size_t* len){ +int grib_accessor_class_to_integer_t::unpack_string(grib_accessor* a, char* val, size_t* len) +{ grib_accessor_to_integer_t* self = (grib_accessor_to_integer_t*)a; int err = 0; @@ -69,7 +75,7 @@ int grib_accessor_class_to_integer_t::unpack_string(grib_accessor* a, char* val, const char* cclass_name = a->cclass->name; grib_context_log(a->context, GRIB_LOG_ERROR, "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", - cclass_name, a->name, length+1, *len); + cclass_name, a->name, length + 1, *len); *len = length + 1; return GRIB_BUFFER_TOO_SMALL; } @@ -89,21 +95,25 @@ int grib_accessor_class_to_integer_t::unpack_string(grib_accessor* a, char* val, return GRIB_SUCCESS; } -int grib_accessor_class_to_integer_t::pack_string(grib_accessor* a, const char* val, size_t* len){ +int grib_accessor_class_to_integer_t::pack_string(grib_accessor* a, const char* val, size_t* len) +{ return GRIB_NOT_IMPLEMENTED; } -int grib_accessor_class_to_integer_t::pack_long(grib_accessor* a, const long* v, size_t* len){ +int grib_accessor_class_to_integer_t::pack_long(grib_accessor* a, const long* v, size_t* len) +{ grib_context_log(a->context, GRIB_LOG_ERROR, "Should not pack %s as an integer", a->name); return GRIB_NOT_IMPLEMENTED; } -int grib_accessor_class_to_integer_t::pack_double(grib_accessor* a, const double* v, size_t* len){ +int grib_accessor_class_to_integer_t::pack_double(grib_accessor* a, const double* v, size_t* len) +{ grib_context_log(a->context, GRIB_LOG_ERROR, "Should not pack %s as a double", a->name); return GRIB_NOT_IMPLEMENTED; } -int grib_accessor_class_to_integer_t::unpack_long(grib_accessor* a, long* v, size_t* len){ +int grib_accessor_class_to_integer_t::unpack_long(grib_accessor* a, long* v, size_t* len) +{ char val[1024] = {0,}; size_t l = sizeof(val); char* last = NULL; @@ -118,7 +128,8 @@ int grib_accessor_class_to_integer_t::unpack_long(grib_accessor* a, long* v, siz return GRIB_SUCCESS; } -int grib_accessor_class_to_integer_t::unpack_double(grib_accessor* a, double* v, size_t* len){ +int grib_accessor_class_to_integer_t::unpack_double(grib_accessor* a, double* v, size_t* len) +{ size_t l = 1; long val = 0; int err = unpack_long(a, &val, &l); @@ -127,6 +138,7 @@ int grib_accessor_class_to_integer_t::unpack_double(grib_accessor* a, double* v, return err; } -long grib_accessor_class_to_integer_t::next_offset(grib_accessor* a){ +long grib_accessor_class_to_integer_t::next_offset(grib_accessor* a) +{ return a->offset + a->length; } diff --git a/src/accessor/grib_accessor_class_to_string.cc b/src/accessor/grib_accessor_class_to_string.cc index 4f1150ffb..d0fd72727 100644 --- a/src/accessor/grib_accessor_class_to_string.cc +++ b/src/accessor/grib_accessor_class_to_string.cc @@ -11,11 +11,12 @@ #include "grib_accessor_class_to_string.h" -grib_accessor_class_to_string_t _grib_accessor_class_to_string{"to_string"}; +grib_accessor_class_to_string_t _grib_accessor_class_to_string{ "to_string" }; grib_accessor_class* grib_accessor_class_to_string = &_grib_accessor_class_to_string; -void grib_accessor_class_to_string_t::init(grib_accessor* a, const long len, grib_arguments* arg){ +void grib_accessor_class_to_string_t::init(grib_accessor* a, const long len, grib_arguments* arg) +{ grib_accessor_class_gen_t::init(a, len, arg); grib_accessor_to_string_t* self = (grib_accessor_to_string_t*)a; @@ -27,9 +28,10 @@ void grib_accessor_class_to_string_t::init(grib_accessor* a, const long len, gri a->length = 0; } -int grib_accessor_class_to_string_t::value_count(grib_accessor* a, long* count){ +int grib_accessor_class_to_string_t::value_count(grib_accessor* a, long* count) +{ grib_accessor_to_string_t* self = (grib_accessor_to_string_t*)a; - size_t size = 0; + size_t size = 0; int err = grib_get_size(grib_handle_of_accessor(a), self->key, &size); *count = size; @@ -37,7 +39,8 @@ int grib_accessor_class_to_string_t::value_count(grib_accessor* a, long* count){ return err; } -size_t grib_accessor_class_to_string_t::string_length(grib_accessor* a){ +size_t grib_accessor_class_to_string_t::string_length(grib_accessor* a) +{ grib_accessor_to_string_t* self = (grib_accessor_to_string_t*)a; if (self->length) @@ -48,15 +51,18 @@ size_t grib_accessor_class_to_string_t::string_length(grib_accessor* a){ return size; } -void grib_accessor_class_to_string_t::dump(grib_accessor* a, grib_dumper* dumper){ +void grib_accessor_class_to_string_t::dump(grib_accessor* a, grib_dumper* dumper) +{ grib_dump_string(dumper, a, NULL); } -int grib_accessor_class_to_string_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_to_string_t::get_native_type(grib_accessor* a) +{ return GRIB_TYPE_STRING; } -int grib_accessor_class_to_string_t::unpack_string(grib_accessor* a, char* val, size_t* len){ +int grib_accessor_class_to_string_t::unpack_string(grib_accessor* a, char* val, size_t* len) +{ grib_accessor_to_string_t* self = (grib_accessor_to_string_t*)a; int err = 0; @@ -68,7 +74,7 @@ int grib_accessor_class_to_string_t::unpack_string(grib_accessor* a, char* val, const char* cclass_name = a->cclass->name; grib_context_log(a->context, GRIB_LOG_ERROR, "%s: Buffer too small for %s. It is %zu bytes long (len=%zu)", - cclass_name, a->name, length+1, *len); + cclass_name, a->name, length + 1, *len); *len = length + 1; return GRIB_BUFFER_TOO_SMALL; } @@ -89,7 +95,8 @@ int grib_accessor_class_to_string_t::unpack_string(grib_accessor* a, char* val, return GRIB_SUCCESS; } -int grib_accessor_class_to_string_t::unpack_long(grib_accessor* a, long* v, size_t* len){ +int grib_accessor_class_to_string_t::unpack_long(grib_accessor* a, long* v, size_t* len) +{ char val[1024] = {0,}; size_t l = sizeof(val); char* last = NULL; @@ -106,7 +113,8 @@ int grib_accessor_class_to_string_t::unpack_long(grib_accessor* a, long* v, size return err; } -int grib_accessor_class_to_string_t::unpack_double(grib_accessor* a, double* v, size_t* len){ +int grib_accessor_class_to_string_t::unpack_double(grib_accessor* a, double* v, size_t* len) +{ size_t l = 1; long val = 0; int err = unpack_long(a, &val, &l); @@ -115,6 +123,7 @@ int grib_accessor_class_to_string_t::unpack_double(grib_accessor* a, double* v, return err; } -long grib_accessor_class_to_string_t::next_offset(grib_accessor* a){ +long grib_accessor_class_to_string_t::next_offset(grib_accessor* a) +{ return a->offset + a->length; } diff --git a/src/accessor/grib_accessor_class_transient_darray.cc b/src/accessor/grib_accessor_class_transient_darray.cc index d45ec3478..71d404f0d 100644 --- a/src/accessor/grib_accessor_class_transient_darray.cc +++ b/src/accessor/grib_accessor_class_transient_darray.cc @@ -11,23 +11,26 @@ #include "grib_accessor_class_transient_darray.h" -grib_accessor_class_transient_darray_t _grib_accessor_class_transient_darray{"transient_darray"}; +grib_accessor_class_transient_darray_t _grib_accessor_class_transient_darray{ "transient_darray" }; grib_accessor_class* grib_accessor_class_transient_darray = &_grib_accessor_class_transient_darray; -void grib_accessor_class_transient_darray_t::init(grib_accessor* a, const long length, grib_arguments* args){ +void grib_accessor_class_transient_darray_t::init(grib_accessor* a, const long length, grib_arguments* args) +{ grib_accessor_class_gen_t::init(a, length, args); grib_accessor_transient_darray_t* self = (grib_accessor_transient_darray_t*)a; - self->arr = NULL; - self->type = GRIB_TYPE_DOUBLE; - a->length = 0; + self->arr = NULL; + self->type = GRIB_TYPE_DOUBLE; + a->length = 0; } -void grib_accessor_class_transient_darray_t::dump(grib_accessor* a, grib_dumper* dumper){ +void grib_accessor_class_transient_darray_t::dump(grib_accessor* a, grib_dumper* dumper) +{ grib_dump_double(dumper, a, NULL); } -int grib_accessor_class_transient_darray_t::pack_double(grib_accessor* a, const double* val, size_t* len){ +int grib_accessor_class_transient_darray_t::pack_double(grib_accessor* a, const double* val, size_t* len) +{ grib_accessor_transient_darray_t* self = (grib_accessor_transient_darray_t*)a; if (self->arr) @@ -40,7 +43,8 @@ int grib_accessor_class_transient_darray_t::pack_double(grib_accessor* a, const return GRIB_SUCCESS; } -int grib_accessor_class_transient_darray_t::pack_long(grib_accessor* a, const long* val, size_t* len){ +int grib_accessor_class_transient_darray_t::pack_long(grib_accessor* a, const long* val, size_t* len) +{ grib_accessor_transient_darray_t* self = (grib_accessor_transient_darray_t*)a; if (self->arr) @@ -53,7 +57,8 @@ int grib_accessor_class_transient_darray_t::pack_long(grib_accessor* a, const lo return GRIB_SUCCESS; } -int grib_accessor_class_transient_darray_t::unpack_double(grib_accessor* a, double* val, size_t* len){ +int grib_accessor_class_transient_darray_t::unpack_double(grib_accessor* a, double* val, size_t* len) +{ grib_accessor_transient_darray_t* self = (grib_accessor_transient_darray_t*)a; long count = 0; @@ -71,7 +76,8 @@ int grib_accessor_class_transient_darray_t::unpack_double(grib_accessor* a, doub return GRIB_SUCCESS; } -int grib_accessor_class_transient_darray_t::unpack_long(grib_accessor* a, long* val, size_t* len){ +int grib_accessor_class_transient_darray_t::unpack_long(grib_accessor* a, long* val, size_t* len) +{ grib_accessor_transient_darray_t* self = (grib_accessor_transient_darray_t*)a; long count = 0; @@ -89,14 +95,16 @@ int grib_accessor_class_transient_darray_t::unpack_long(grib_accessor* a, long* return GRIB_SUCCESS; } -void grib_accessor_class_transient_darray_t::destroy(grib_context* c, grib_accessor* a){ +void grib_accessor_class_transient_darray_t::destroy(grib_context* c, grib_accessor* a) +{ grib_accessor_transient_darray_t* self = (grib_accessor_transient_darray_t*)a; if (self->arr) grib_darray_delete(a->context, self->arr); grib_accessor_class_gen_t::destroy(c, a); } -int grib_accessor_class_transient_darray_t::value_count(grib_accessor* a, long* count){ +int grib_accessor_class_transient_darray_t::value_count(grib_accessor* a, long* count) +{ grib_accessor_transient_darray_t* self = (grib_accessor_transient_darray_t*)a; if (self->arr) *count = grib_darray_used_size(self->arr); @@ -106,7 +114,8 @@ int grib_accessor_class_transient_darray_t::value_count(grib_accessor* a, long* return 0; } -int grib_accessor_class_transient_darray_t::get_native_type(grib_accessor* a){ +int grib_accessor_class_transient_darray_t::get_native_type(grib_accessor* a) +{ const grib_accessor_transient_darray_t* self = (grib_accessor_transient_darray_t*)a; return self->type; } diff --git a/src/accessor/grib_accessor_class_trim.cc b/src/accessor/grib_accessor_class_trim.cc index a7db4f3ff..7f18a36b9 100644 --- a/src/accessor/grib_accessor_class_trim.cc +++ b/src/accessor/grib_accessor_class_trim.cc @@ -11,31 +11,33 @@ #include "grib_accessor_class_trim.h" -grib_accessor_class_trim_t _grib_accessor_class_trim{"trim"}; +grib_accessor_class_trim_t _grib_accessor_class_trim{ "trim" }; grib_accessor_class* grib_accessor_class_trim = &_grib_accessor_class_trim; -void grib_accessor_class_trim_t::init(grib_accessor* a, const long l, grib_arguments* arg){ +void grib_accessor_class_trim_t::init(grib_accessor* a, const long l, grib_arguments* arg) +{ grib_accessor_class_ascii_t::init(a, l, arg); - int n = 0; + int n = 0; grib_accessor_trim_t* self = (grib_accessor_trim_t*)a; - grib_handle* h = grib_handle_of_accessor(a); + grib_handle* h = grib_handle_of_accessor(a); - self->input = grib_arguments_get_name(h, arg, n++); - self->trim_left = grib_arguments_get_long(h, arg, n++); - self->trim_right= grib_arguments_get_long(h, arg, n++); + self->input = grib_arguments_get_name(h, arg, n++); + self->trim_left = grib_arguments_get_long(h, arg, n++); + self->trim_right = grib_arguments_get_long(h, arg, n++); DEBUG_ASSERT(self->trim_left == 0 || self->trim_left == 1); DEBUG_ASSERT(self->trim_right == 0 || self->trim_right == 1); } -int grib_accessor_class_trim_t::unpack_string(grib_accessor* a, char* val, size_t* len){ +int grib_accessor_class_trim_t::unpack_string(grib_accessor* a, char* val, size_t* len) +{ grib_accessor_trim_t* self = (grib_accessor_trim_t*)a; - int err = 0; - grib_handle* h = grib_handle_of_accessor(a); + int err = 0; + grib_handle* h = grib_handle_of_accessor(a); char input[256] = {0,}; - size_t size = sizeof(input) / sizeof(*input); - char* pInput = input; + size_t size = sizeof(input) / sizeof(*input); + char* pInput = input; err = grib_get_string(h, self->input, input, &size); if (err) return err; @@ -47,15 +49,16 @@ int grib_accessor_class_trim_t::unpack_string(grib_accessor* a, char* val, size_ return GRIB_SUCCESS; } -int grib_accessor_class_trim_t::pack_string(grib_accessor* a, const char* val, size_t* len){ +int grib_accessor_class_trim_t::pack_string(grib_accessor* a, const char* val, size_t* len) +{ char input[256] = {0,}; size_t inputLen = 256; char buf[256] = {0,}; char* pBuf = NULL; int err; - grib_handle* h = grib_handle_of_accessor(a); - grib_accessor_trim_t* self = (grib_accessor_trim_t*)a; + grib_handle* h = grib_handle_of_accessor(a); + grib_accessor_trim_t* self = (grib_accessor_trim_t*)a; grib_accessor* inputAccesstor = grib_find_accessor(h, self->input); if (!inputAccesstor) { grib_context_log(a->context, GRIB_LOG_ERROR, "Accessor for %s not found", self->input); @@ -69,8 +72,10 @@ int grib_accessor_class_trim_t::pack_string(grib_accessor* a, const char* val, s pBuf = buf; string_lrtrim(&pBuf, self->trim_left, self->trim_right); - return inputAccesstor->pack_string(pBuf, len);} + return inputAccesstor->pack_string(pBuf, len); +} -size_t grib_accessor_class_trim_t::string_length(grib_accessor* a){ +size_t grib_accessor_class_trim_t::string_length(grib_accessor* a) +{ return 1024; }