From 947b4cd9b791b2785a0d441dfcd8cde4e4ace80f Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 6 Feb 2017 16:47:23 +0000 Subject: [PATCH] ECC-424: Allow for filtering the bufr_keys_iter flags (Future) --- examples/C/bufr_keys_iterator.c | 2 +- fortran/grib_fortran.c | 2 +- python/grib_interface.c | 2 +- src/bufr_keys_iterator.c | 3 ++- src/grib_api.h | 2 +- src/grib_api_internal.h | 2 +- src/grib_api_prototypes.h | 2 +- tests/bufr_keys_iter.c | 2 +- 8 files changed, 9 insertions(+), 8 deletions(-) diff --git a/examples/C/bufr_keys_iterator.c b/examples/C/bufr_keys_iterator.c index 9abf8e4a2..b87fbb242 100644 --- a/examples/C/bufr_keys_iterator.c +++ b/examples/C/bufr_keys_iterator.c @@ -66,7 +66,7 @@ int main(int argc,char* argv[]) CODES_CHECK(codes_set_long(h,"unpack",1),0); /* get BUFR key iterator */ - kiter=codes_bufr_keys_iterator_new(h); + kiter=codes_bufr_keys_iterator_new(h,0); if (!kiter) { printf("ERROR: Unable to create BUFR keys iterator\n"); exit(1); diff --git a/fortran/grib_fortran.c b/fortran/grib_fortran.c index f3a97391c..2c4ee7f30 100644 --- a/fortran/grib_fortran.c +++ b/fortran/grib_fortran.c @@ -1367,7 +1367,7 @@ static int _codes_f_bufr_keys_iterator_new_(int* gid,int* iterid) { return GRIB_NULL_HANDLE; } Assert(h->product_kind==PRODUCT_BUFR); - iter=codes_bufr_keys_iterator_new(h); + iter=codes_bufr_keys_iterator_new(h,0); if (iter) *iterid=push_bufr_keys_iterator(iter); else diff --git a/python/grib_interface.c b/python/grib_interface.c index a08db338c..8c7d00731 100644 --- a/python/grib_interface.c +++ b/python/grib_interface.c @@ -1031,7 +1031,7 @@ static int _codes_c_bufr_keys_iterator_new_(int* gid,int* iterid) *iterid=-1; return GRIB_NULL_HANDLE; } - iter=codes_bufr_keys_iterator_new(h); + iter=codes_bufr_keys_iterator_new(h,0); if (iter) *iterid=push_bufr_keys_iterator(iter); else diff --git a/src/bufr_keys_iterator.c b/src/bufr_keys_iterator.c index f177ce15d..a364c85d4 100644 --- a/src/bufr_keys_iterator.c +++ b/src/bufr_keys_iterator.c @@ -10,7 +10,7 @@ #include "grib_api_internal.h" -bufr_keys_iterator* codes_bufr_keys_iterator_new(grib_handle* h) +bufr_keys_iterator* codes_bufr_keys_iterator_new(grib_handle* h, unsigned long filter_flags) { bufr_keys_iterator* ki=NULL; @@ -25,6 +25,7 @@ bufr_keys_iterator* codes_bufr_keys_iterator_new(grib_handle* h) ki= (bufr_keys_iterator*)grib_context_malloc_clear(h->context,sizeof(bufr_keys_iterator)); if (!ki) return NULL; + ki->filter_flags = filter_flags; ki->handle = h; Assert(h->product_kind == PRODUCT_BUFR); ki->names = NULL; diff --git a/src/grib_api.h b/src/grib_api.h index f0f18a155..eedbdb44d 100644 --- a/src/grib_api.h +++ b/src/grib_api.h @@ -1254,7 +1254,7 @@ attributes or by the namespace they belong to. * and namespace */ grib_keys_iterator* grib_keys_iterator_new(grib_handle* h,unsigned long filter_flags, const char* name_space); -bufr_keys_iterator* codes_bufr_keys_iterator_new(grib_handle* h); +bufr_keys_iterator* codes_bufr_keys_iterator_new(grib_handle* h, unsigned long filter_flags); bufr_keys_iterator* codes_bufr_data_section_keys_iterator_new(grib_handle* h); /*! Step to the next iterator. diff --git a/src/grib_api_internal.h b/src/grib_api_internal.h index c53f186f5..400317212 100644 --- a/src/grib_api_internal.h +++ b/src/grib_api_internal.h @@ -1353,7 +1353,6 @@ struct grib_keys_iterator{ grib_handle *handle; unsigned long filter_flags; /** flags to filter out accessors */ unsigned long accessor_flags_skip; - unsigned long accessor_flags_only; grib_accessor *current; char *name_space; int at_start; @@ -1367,6 +1366,7 @@ struct grib_keys_iterator{ /* BUFR-specific keys iterator */ struct bufr_keys_iterator{ grib_handle* handle; + unsigned long filter_flags; /** flags to filter out accessors */ unsigned long accessor_flags_skip; unsigned long accessor_flags_only; grib_accessor* current; diff --git a/src/grib_api_prototypes.h b/src/grib_api_prototypes.h index 648fa8bad..be3e1e99d 100644 --- a/src/grib_api_prototypes.h +++ b/src/grib_api_prototypes.h @@ -1144,7 +1144,7 @@ int grib_keys_iterator_get_bytes(grib_keys_iterator *kiter, unsigned char *v, si int grib_keys_iterator_get_native_type(grib_keys_iterator *kiter); /* bufr_keys_iterator.c */ -bufr_keys_iterator *codes_bufr_keys_iterator_new(grib_handle *h); +bufr_keys_iterator *codes_bufr_keys_iterator_new(grib_handle *h, unsigned long filter_flags); bufr_keys_iterator *codes_bufr_data_section_keys_iterator_new(grib_handle *h); int codes_bufr_keys_iterator_rewind(bufr_keys_iterator *ki); int codes_bufr_keys_iterator_next(bufr_keys_iterator *kiter); diff --git a/tests/bufr_keys_iter.c b/tests/bufr_keys_iter.c index b8e962d85..fd34ab8fd 100644 --- a/tests/bufr_keys_iter.c +++ b/tests/bufr_keys_iter.c @@ -36,7 +36,7 @@ int main(int argc,char* argv[]) CODES_CHECK(codes_set_long(h,"unpack",1), 0); /*kiter=codes_bufr_data_section_keys_iterator_new(h);*/ - kiter = codes_bufr_keys_iterator_new(h); + kiter = codes_bufr_keys_iterator_new(h, 0); while(codes_bufr_keys_iterator_next(kiter)) { char* kname = codes_bufr_keys_iterator_get_name(kiter);