ECC-1181: Add function to determine if a BUFR key is a header key or from the data section

This commit is contained in:
Shahram Najm 2020-12-10 17:45:32 +00:00
parent 085268256b
commit 7e4d24a5ee
3 changed files with 14 additions and 1 deletions

View File

@ -1107,3 +1107,13 @@ int codes_bufr_header_get_string(codes_bufr_header* bh, const char* key, char* v
return GRIB_SUCCESS;
}
int codes_bufr_key_is_header(const grib_handle* h, const char* key, int* err)
{
grib_accessor* acc = grib_find_accessor(h, key);
if (!acc) {
*err = GRIB_NOT_FOUND;
return 0;
}
return ((acc->flags & GRIB_ACCESSOR_FLAG_BUFR_DATA) == 0);
}

View File

@ -1205,6 +1205,9 @@ int codes_is_missing(const codes_handle* h, const char* key, int* err);
/* Returns a bool i.e. 0 or 1 */
int codes_is_defined(const codes_handle* h, const char* key);
/* Returns 1 if the BUFR key is in the header and 1 if it is in the data section. The error code is an argument */
int codes_bufr_key_is_header(const codes_handle* h, const char* key, int* err);
int codes_set_missing(codes_handle* h, const char* key);
/* The truncation is the Gaussian number (or order) */
int codes_get_gaussian_latitudes(long truncation, double* latitudes);

View File

@ -1489,7 +1489,7 @@ char** codes_bufr_copy_data_return_copied_keys(grib_handle* hin, grib_handle* ho
int codes_bufr_copy_data(grib_handle* hin, grib_handle* hout);
int codes_bufr_extract_headers_malloc(grib_context* c, const char* filename, codes_bufr_header** result, int* num_messages, int strict_mode);
int codes_bufr_header_get_string(codes_bufr_header* bh, const char* key, char* val, size_t* len);
int codes_bufr_key_is_header(const grib_handle* h, const char* key, int* err);
/* string_util.c */
int strcmp_nocase(const char* s1, const char* s2);