Formatting

This commit is contained in:
shahramn 2024-06-28 17:07:46 +01:00
parent 9faa8b1766
commit 0d181e6bd0
14 changed files with 285 additions and 196 deletions

View File

@ -14,7 +14,8 @@
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;
@ -24,7 +25,8 @@ void grib_accessor_class_g2date_t::init(grib_accessor* a, const long l, grib_arg
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;
@ -47,7 +49,8 @@ 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;

View File

@ -17,7 +17,8 @@ grib_accessor_class* grib_accessor_class_longitudes = &_grib_accessor_class_long
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,9 +31,11 @@ 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;
grib_context* c = a->context;
int ret = 0;
double* v = val;
double dummyLat = 0;
@ -84,7 +87,8 @@ 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;
@ -121,7 +125,8 @@ 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;
@ -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)

View File

@ -15,12 +15,14 @@ grib_accessor_class_number_of_points_t _grib_accessor_class_number_of_points{"nu
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++);
@ -30,7 +32,8 @@ void grib_accessor_class_number_of_points_t::init(grib_accessor* a, const long l
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;

View File

@ -15,7 +15,8 @@ grib_accessor_class_octahedral_gaussian_t _grib_accessor_class_octahedral_gaussi
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;
@ -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,7 +71,8 @@ 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;
long Ni;
@ -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;
}

View File

@ -16,8 +16,8 @@ grib_accessor_class_smart_table_column_t _grib_accessor_class_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;
@ -29,7 +29,8 @@ void grib_accessor_class_smart_table_column_t::init(grib_accessor* a, const long
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,7 +149,8 @@ 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;
@ -160,7 +164,8 @@ int grib_accessor_class_smart_table_column_t::value_count(grib_accessor* a, long
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);*/

View File

@ -15,7 +15,8 @@ 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;
@ -27,14 +28,14 @@ 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;
@ -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;
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,7 +211,8 @@ 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; i < alen && retval == GRIB_SUCCESS; ++i) {
if (aval[i] != bval[i]) retval = GRIB_DOUBLE_VALUE_MISMATCH;
@ -217,6 +224,7 @@ int grib_accessor_class_statistics_t::compare(grib_accessor* a, grib_accessor* b
return retval;
}
int grib_accessor_class_statistics_t::unpack_string(grib_accessor* a, char* v, size_t* len){
int grib_accessor_class_statistics_t::unpack_string(grib_accessor* a, char* v, size_t* len)
{
return GRIB_NOT_IMPLEMENTED;
}

View File

@ -15,7 +15,8 @@ grib_accessor_class_statistics_spectral_t _grib_accessor_class_statistics_spectr
grib_accessor_class* grib_accessor_class_statistics_spectral = &_grib_accessor_class_statistics_spectral;
void grib_accessor_class_statistics_spectral_t::init(grib_accessor* a, const long l, grib_arguments* c){
void grib_accessor_class_statistics_spectral_t::init(grib_accessor* a, const long l, grib_arguments* c)
{
grib_accessor_class_abstract_vector_t::init(a, l, c);
grib_accessor_statistics_spectral_t* self = (grib_accessor_statistics_spectral_t*)a;
int n = 0;
@ -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;
@ -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;
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,7 +159,8 @@ 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; i < alen && retval == GRIB_SUCCESS; ++i) {
if (aval[i] != bval[i]) retval = GRIB_DOUBLE_VALUE_MISMATCH;

View File

@ -15,7 +15,8 @@ grib_accessor_class_sum_t _grib_accessor_class_sum{"sum"};
grib_accessor_class* grib_accessor_class_sum = &_grib_accessor_class_sum;
void grib_accessor_class_sum_t::init(grib_accessor* a, const long l, grib_arguments* c){
void grib_accessor_class_sum_t::init(grib_accessor* a, const long l, grib_arguments* c)
{
grib_accessor_class_double_t::init(a, l, c);
grib_accessor_sum_t* self = (grib_accessor_sum_t*)a;
int n = 0;
@ -24,12 +25,13 @@ void grib_accessor_class_sum_t::init(grib_accessor* a, const long l, grib_argume
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;
size_t i = 0;
long count = 0;
ret = value_count(a, &count);
@ -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;
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;
int ret = GRIB_SUCCESS;
ret = grib_get_size(grib_handle_of_accessor(a), self->values, &n);
*count = n;

View File

@ -15,7 +15,8 @@ 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);
@ -26,7 +27,8 @@ void grib_accessor_class_time_t::init(grib_accessor* a, const long l, grib_argum
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;
@ -60,7 +62,8 @@ 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;
@ -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;

View File

@ -15,7 +15,8 @@ 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,7 +31,8 @@ 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;
@ -40,7 +42,8 @@ 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;
@ -51,15 +54,18 @@ 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;
@ -89,7 +95,8 @@ 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,};
size_t l = sizeof(val);
@ -107,7 +114,8 @@ 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,};
size_t l = sizeof(val);
@ -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;
}

View File

@ -15,7 +15,8 @@ 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,7 +28,8 @@ 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;
@ -37,7 +39,8 @@ 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;
@ -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;
@ -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;
}

View File

@ -15,7 +15,8 @@ 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,7 +28,8 @@ 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;
@ -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;
@ -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;
}

View File

@ -15,7 +15,8 @@ grib_accessor_class_transient_darray_t _grib_accessor_class_transient_darray{"tr
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;
@ -23,11 +24,13 @@ void grib_accessor_class_transient_darray_t::init(grib_accessor* a, const long l
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;
}

View File

@ -15,7 +15,8 @@ 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;
grib_accessor_trim_t* self = (grib_accessor_trim_t*)a;
@ -28,7 +29,8 @@ void grib_accessor_class_trim_t::init(grib_accessor* a, const long l, grib_argum
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;
@ -47,7 +49,8 @@ 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;
@ -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;
}