diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8a5dcd280..ff92ba3bb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -310,22 +310,27 @@ list( APPEND eccodes_src_files grib_dependency.cc grib_value.cc grib_errors.cc - grib_expression_class_binop.cc - grib_expression_class_logical_and.cc - grib_expression_class_logical_or.cc - grib_expression_class_is_in_dict.cc - grib_expression_class_true.cc - grib_expression_class_string_compare.cc - grib_expression_class_unop.cc - grib_expression_class_functor.cc - grib_expression_class_accessor.cc - grib_expression_class_is_in_list.cc - grib_expression_class_is_integer.cc - grib_expression_class_length.cc - grib_expression_class_long.cc - grib_expression_class_double.cc - grib_expression_class_string.cc - grib_expression_class_sub_string.cc + + expression/grib_arguments.cc + + expression/grib_expression.cc + expression/grib_expression_class_binop.cc + expression/grib_expression_class_logical_and.cc + expression/grib_expression_class_logical_or.cc + expression/grib_expression_class_is_in_dict.cc + expression/grib_expression_class_true.cc + expression/grib_expression_class_string_compare.cc + expression/grib_expression_class_unop.cc + expression/grib_expression_class_functor.cc + expression/grib_expression_class_accessor.cc + expression/grib_expression_class_is_in_list.cc + expression/grib_expression_class_is_integer.cc + expression/grib_expression_class_length.cc + expression/grib_expression_class_long.cc + expression/grib_expression_class_double.cc + expression/grib_expression_class_string.cc + expression/grib_expression_class_sub_string.cc + geo_nearest/grib_nearest.cc geo_nearest/grib_nearest_class_gen.cc geo_nearest/grib_nearest_class_healpix.cc @@ -337,6 +342,7 @@ list( APPEND eccodes_src_files geo_nearest/grib_nearest_class_reduced.cc geo_nearest/grib_nearest_class_regular.cc geo_nearest/grib_nearest_class_space_view.cc + geo_iterator/grib_iterator.cc geo_iterator/grib_iterator_class_gaussian.cc geo_iterator/grib_iterator_class_gaussian_reduced.cc @@ -351,7 +357,7 @@ list( APPEND eccodes_src_files geo_iterator/grib_iterator_class_regular.cc geo_iterator/grib_iterator_class_space_view.cc geo_iterator/grib_iterator_class_unstructured.cc - grib_expression.cc + codes_util.cc grib_util.cc bufr_util.cc diff --git a/src/accessor/grib_accessor_class_bit.cc b/src/accessor/grib_accessor_class_bit.cc index 0bd9ffbf6..28ae01874 100644 --- a/src/accessor/grib_accessor_class_bit.cc +++ b/src/accessor/grib_accessor_class_bit.cc @@ -17,8 +17,8 @@ void grib_accessor_bit_t::init(const long len, grib_arguments* arg) { grib_accessor_long_t::init(len, arg); length_ = 0; - owner_ = grib_arguments_get_name(grib_handle_of_accessor(this), arg, 0); - bit_index_ = grib_arguments_get_long(grib_handle_of_accessor(this), arg, 1); + owner_ = arg->get_name(grib_handle_of_accessor(this), 0); + bit_index_ = arg->get_long(grib_handle_of_accessor(this), 1); } int grib_accessor_bit_t::unpack_long(long* val, size_t* len) diff --git a/src/accessor/grib_accessor_class_bitmap.cc b/src/accessor/grib_accessor_class_bitmap.cc index 206a9f918..dd8c9ae2b 100644 --- a/src/accessor/grib_accessor_class_bitmap.cc +++ b/src/accessor/grib_accessor_class_bitmap.cc @@ -54,10 +54,10 @@ void grib_accessor_bitmap_t::init(const long len, grib_arguments* arg) grib_handle* hand = grib_handle_of_accessor(this); int n = 0; - tableReference_ = grib_arguments_get_name(hand, arg, n++); - missing_value_ = grib_arguments_get_name(hand, arg, n++); - offsetbsec_ = grib_arguments_get_name(hand, arg, n++); - sLength_ = grib_arguments_get_name(hand, arg, n++); + tableReference_ = arg->get_name(hand, n++); + missing_value_ = arg->get_name(hand, n++); + offsetbsec_ = arg->get_name(hand, n++); + sLength_ = arg->get_name(hand, n++); compute_size(); } diff --git a/src/accessor/grib_accessor_class_bits.cc b/src/accessor/grib_accessor_class_bits.cc index d34e5f401..b03255af3 100644 --- a/src/accessor/grib_accessor_class_bits.cc +++ b/src/accessor/grib_accessor_class_bits.cc @@ -23,12 +23,12 @@ void grib_accessor_bits_t::init(const long l, grib_arguments* c) int n = 0; referenceValue_ = 0; - argument_ = grib_arguments_get_name(hand, c, n++); - start_ = grib_arguments_get_long(hand, c, n++); - len_ = grib_arguments_get_long(hand, c, n++); - e = grib_arguments_get_expression(hand, c, n++); + argument_ = c->get_name(hand, n++); + start_ = c->get_long(hand, n++); + len_ = c->get_long(hand, n++); + e = c->get_expression(hand, n++); if (e) { - grib_expression_evaluate_double(hand, e, &(referenceValue_)); + e->evaluate_double(hand, &(referenceValue_)); referenceValuePresent_ = 1; } else { @@ -36,7 +36,7 @@ void grib_accessor_bits_t::init(const long l, grib_arguments* c) } scale_ = 1; if (referenceValuePresent_) { - scale_ = grib_arguments_get_double(hand, c, n++); + scale_ = c->get_double(hand, n++); } Assert(len_ <= sizeof(long) * 8); diff --git a/src/accessor/grib_accessor_class_bits_per_value.cc b/src/accessor/grib_accessor_class_bits_per_value.cc index 0023bbcc0..bd5e8d6bb 100644 --- a/src/accessor/grib_accessor_class_bits_per_value.cc +++ b/src/accessor/grib_accessor_class_bits_per_value.cc @@ -17,8 +17,8 @@ void grib_accessor_bits_per_value_t::init(const long l, grib_arguments* args) { grib_accessor_long_t::init(l, args); int n = 0; - values_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++); - bits_per_value_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++); + values_ = args->get_name(grib_handle_of_accessor(this), n++); + bits_per_value_ = args->get_name(grib_handle_of_accessor(this), n++); flags_ |= GRIB_ACCESSOR_FLAG_FUNCTION; length_ = 0; } diff --git a/src/accessor/grib_accessor_class_blob.cc b/src/accessor/grib_accessor_class_blob.cc index cf7d86ae8..972d73e7a 100644 --- a/src/accessor/grib_accessor_class_blob.cc +++ b/src/accessor/grib_accessor_class_blob.cc @@ -17,7 +17,7 @@ void grib_accessor_blob_t::init(const long len, grib_arguments* arg) { grib_accessor_gen_t::init(len, arg); grib_get_long_internal(grib_handle_of_accessor(this), - grib_arguments_get_name(parent_->h, arg, 0), &length_); + arg->get_name(parent_->h, 0), &length_); Assert(length_ >= 0); } diff --git a/src/accessor/grib_accessor_class_budgdate.cc b/src/accessor/grib_accessor_class_budgdate.cc index 3b44f62a4..8488b1af4 100644 --- a/src/accessor/grib_accessor_class_budgdate.cc +++ b/src/accessor/grib_accessor_class_budgdate.cc @@ -18,9 +18,9 @@ void grib_accessor_budgdate_t::init(const long l, grib_arguments* c) grib_accessor_long_t::init(l, c); int n = 0; - year_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - month_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - day_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); + year_ = c->get_name(grib_handle_of_accessor(this), n++); + month_ = c->get_name(grib_handle_of_accessor(this), n++); + day_ = c->get_name(grib_handle_of_accessor(this), n++); } int grib_accessor_budgdate_t::unpack_long(long* val, size_t* len) diff --git a/src/accessor/grib_accessor_class_bufr_data_array.cc b/src/accessor/grib_accessor_class_bufr_data_array.cc index 1bf0af02f..1f4f077ba 100644 --- a/src/accessor/grib_accessor_class_bufr_data_array.cc +++ b/src/accessor/grib_accessor_class_bufr_data_array.cc @@ -195,13 +195,13 @@ void grib_accessor_bufr_data_array_t::init(const long v, grib_arguments* params) tempStrings_ = NULL; - bufrDataEncodedName_ = grib_arguments_get_name(grib_handle_of_accessor(this), params, n++); - numberOfSubsetsName_ = grib_arguments_get_name(grib_handle_of_accessor(this), params, n++); - expandedDescriptorsName_ = grib_arguments_get_name(grib_handle_of_accessor(this), params, n++); - flagsName_ = grib_arguments_get_name(grib_handle_of_accessor(this), params, n++); - elementsDescriptorsIndexName_ = grib_arguments_get_name(grib_handle_of_accessor(this), params, n++); - compressedDataName_ = grib_arguments_get_name(grib_handle_of_accessor(this), params, n++); - dataKeysName = grib_arguments_get_name(grib_handle_of_accessor(this), params, n++); + bufrDataEncodedName_ = params->get_name(grib_handle_of_accessor(this), n++); + numberOfSubsetsName_ = params->get_name(grib_handle_of_accessor(this), n++); + expandedDescriptorsName_ = params->get_name(grib_handle_of_accessor(this), n++); + flagsName_ = params->get_name(grib_handle_of_accessor(this), n++); + elementsDescriptorsIndexName_ = params->get_name(grib_handle_of_accessor(this), n++); + compressedDataName_ = params->get_name(grib_handle_of_accessor(this), n++); + dataKeysName = params->get_name(grib_handle_of_accessor(this), n++); dataKeysAcc = grib_find_accessor(grib_handle_of_accessor(this), dataKeysName); dataKeys_ = dataKeysAcc->parent_; diff --git a/src/accessor/grib_accessor_class_bufr_elements_table.cc b/src/accessor/grib_accessor_class_bufr_elements_table.cc index 73d631303..233dfc118 100644 --- a/src/accessor/grib_accessor_class_bufr_elements_table.cc +++ b/src/accessor/grib_accessor_class_bufr_elements_table.cc @@ -47,9 +47,9 @@ void grib_accessor_bufr_elements_table_t::init(const long len, grib_arguments* p grib_accessor_gen_t::init(len, params); int n = 0; - dictionary_ = grib_arguments_get_string(grib_handle_of_accessor(this), params, n++); - masterDir_ = grib_arguments_get_name(grib_handle_of_accessor(this), params, n++); - localDir_ = grib_arguments_get_name(grib_handle_of_accessor(this), params, n++); + dictionary_ = params->get_string(grib_handle_of_accessor(this), n++); + masterDir_ = params->get_name(grib_handle_of_accessor(this), n++); + localDir_ = params->get_name(grib_handle_of_accessor(this), n++); length_ = 0; flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; diff --git a/src/accessor/grib_accessor_class_bufr_extract_area_subsets.cc b/src/accessor/grib_accessor_class_bufr_extract_area_subsets.cc index e6d9185c8..0ac88d0d0 100644 --- a/src/accessor/grib_accessor_class_bufr_extract_area_subsets.cc +++ b/src/accessor/grib_accessor_class_bufr_extract_area_subsets.cc @@ -20,16 +20,16 @@ void grib_accessor_bufr_extract_area_subsets_t::init(const long len, grib_argume int n = 0; length_ = 0; - doExtractSubsets_ = grib_arguments_get_name(h, arg, n++); - numberOfSubsets_ = grib_arguments_get_name(h, arg, n++); - extractSubsetList_ = grib_arguments_get_name(h, arg, n++); - extractAreaWestLongitude_ = grib_arguments_get_name(h, arg, n++); - extractAreaEastLongitude_ = grib_arguments_get_name(h, arg, n++); - extractAreaNorthLatitude_ = grib_arguments_get_name(h, arg, n++); - extractAreaSouthLatitude_ = grib_arguments_get_name(h, arg, n++); - extractAreaLongitudeRank_ = grib_arguments_get_name(h, arg, n++); - extractAreaLatitudeRank_ = grib_arguments_get_name(h, arg, n++); - extractedAreaNumberOfSubsets_ = grib_arguments_get_name(h, arg, n++); + doExtractSubsets_ = arg->get_name(h, n++); + numberOfSubsets_ = arg->get_name(h, n++); + extractSubsetList_ = arg->get_name(h, n++); + extractAreaWestLongitude_ = arg->get_name(h, n++); + extractAreaEastLongitude_ = arg->get_name(h, n++); + extractAreaNorthLatitude_ = arg->get_name(h, n++); + extractAreaSouthLatitude_ = arg->get_name(h, n++); + extractAreaLongitudeRank_ = arg->get_name(h, n++); + extractAreaLatitudeRank_ = arg->get_name(h, n++); + extractedAreaNumberOfSubsets_ = arg->get_name(h, n++); flags_ |= GRIB_ACCESSOR_FLAG_FUNCTION; } diff --git a/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.cc b/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.cc index 9b5df9995..a696ed2b1 100644 --- a/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.cc +++ b/src/accessor/grib_accessor_class_bufr_extract_datetime_subsets.cc @@ -19,9 +19,9 @@ void grib_accessor_bufr_extract_datetime_subsets_t::init(const long len, grib_ar int n = 0; length_ = 0; - doExtractSubsets_ = grib_arguments_get_name(grib_handle_of_accessor(this), arg, n++); - numberOfSubsets_ = grib_arguments_get_name(grib_handle_of_accessor(this), arg, n++); - extractSubsetList_ = grib_arguments_get_name(grib_handle_of_accessor(this), arg, n++); + doExtractSubsets_ = arg->get_name(grib_handle_of_accessor(this), n++); + numberOfSubsets_ = arg->get_name(grib_handle_of_accessor(this), n++); + extractSubsetList_ = arg->get_name(grib_handle_of_accessor(this), n++); flags_ |= GRIB_ACCESSOR_FLAG_FUNCTION; } diff --git a/src/accessor/grib_accessor_class_bufr_extract_subsets.cc b/src/accessor/grib_accessor_class_bufr_extract_subsets.cc index afa289026..60ffa3490 100644 --- a/src/accessor/grib_accessor_class_bufr_extract_subsets.cc +++ b/src/accessor/grib_accessor_class_bufr_extract_subsets.cc @@ -29,8 +29,8 @@ void grib_accessor_bufr_extract_subsets_t::init(const long len, grib_arguments* int n = 0; length_ = 0; - numericValues_ = grib_arguments_get_name(grib_handle_of_accessor(this), arg, n++); - pack_ = grib_arguments_get_name(grib_handle_of_accessor(this), arg, n++); + numericValues_ = arg->get_name(grib_handle_of_accessor(this), n++); + pack_ = arg->get_name(grib_handle_of_accessor(this), n++); flags_ |= GRIB_ACCESSOR_FLAG_FUNCTION; numericValuesAccessor_ = NULL; diff --git a/src/accessor/grib_accessor_class_bufr_simple_thinning.cc b/src/accessor/grib_accessor_class_bufr_simple_thinning.cc index 42d6641fe..b2a3aa69c 100644 --- a/src/accessor/grib_accessor_class_bufr_simple_thinning.cc +++ b/src/accessor/grib_accessor_class_bufr_simple_thinning.cc @@ -20,12 +20,12 @@ void grib_accessor_bufr_simple_thinning_t::init(const long len, grib_arguments* int n = 0; length_ = 0; - doExtractSubsets_ = grib_arguments_get_name(h, arg, n++); - numberOfSubsets_ = grib_arguments_get_name(h, arg, n++); - extractSubsetList_ = grib_arguments_get_name(h, arg, n++); - simpleThinningStart_ = grib_arguments_get_name(h, arg, n++); - simpleThinningMissingRadius_ = grib_arguments_get_name(h, arg, n++); - simpleThinningSkip_ = grib_arguments_get_name(h, arg, n++); + doExtractSubsets_ = arg->get_name(h, n++); + numberOfSubsets_ = arg->get_name(h, n++); + extractSubsetList_ = arg->get_name(h, n++); + simpleThinningStart_ = arg->get_name(h, n++); + simpleThinningMissingRadius_ = arg->get_name(h, n++); + simpleThinningSkip_ = arg->get_name(h, n++); flags_ |= GRIB_ACCESSOR_FLAG_FUNCTION; } diff --git a/src/accessor/grib_accessor_class_bufr_string_values.cc b/src/accessor/grib_accessor_class_bufr_string_values.cc index e95f43a59..50b963083 100644 --- a/src/accessor/grib_accessor_class_bufr_string_values.cc +++ b/src/accessor/grib_accessor_class_bufr_string_values.cc @@ -18,7 +18,7 @@ void grib_accessor_bufr_string_values_t::init(const long len, grib_arguments* ar { grib_accessor_ascii_t::init(len, args); int n = 0; - dataAccessorName_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++); + dataAccessorName_ = args->get_name(grib_handle_of_accessor(this), n++); dataAccessor_ = NULL; length_ = 0; flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; diff --git a/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.cc b/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.cc index 1b769121a..a6e6dbe3e 100644 --- a/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.cc +++ b/src/accessor/grib_accessor_class_bufrdc_expanded_descriptors.cc @@ -17,7 +17,7 @@ void grib_accessor_bufrdc_expanded_descriptors_t::init(const long len, grib_argu { grib_accessor_long_t::init(len, args); int n = 0; - expandedDescriptors_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++); + expandedDescriptors_ = args->get_name(grib_handle_of_accessor(this), n++); expandedDescriptorsAccessor_ = 0; length_ = 0; flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; diff --git a/src/accessor/grib_accessor_class_cf_var_name.cc b/src/accessor/grib_accessor_class_cf_var_name.cc index 8685e1dfb..072a3ba49 100644 --- a/src/accessor/grib_accessor_class_cf_var_name.cc +++ b/src/accessor/grib_accessor_class_cf_var_name.cc @@ -17,7 +17,7 @@ void grib_accessor_cf_var_name_t::init(const long l, grib_arguments* arg) { grib_accessor_ascii_t::init(l, arg); grib_handle* h = grib_handle_of_accessor(this); - defaultKey_ = grib_arguments_get_name(h, arg, 0); + defaultKey_ = arg->get_name(h, 0); } int grib_accessor_cf_var_name_t::unpack_string(char* val, size_t* len) diff --git a/src/accessor/grib_accessor_class_change_alternative_row_scanning.cc b/src/accessor/grib_accessor_class_change_alternative_row_scanning.cc index 67bb0eca8..92709f07f 100644 --- a/src/accessor/grib_accessor_class_change_alternative_row_scanning.cc +++ b/src/accessor/grib_accessor_class_change_alternative_row_scanning.cc @@ -18,10 +18,10 @@ void grib_accessor_change_alternative_row_scanning_t::init(const long len, grib_ grib_accessor_gen_t::init(len, args); int n = 0; - values_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++); - Ni_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++); - Nj_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++); - alternativeRowScanning_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++); + values_ = args->get_name(grib_handle_of_accessor(this), n++); + Ni_ = args->get_name(grib_handle_of_accessor(this), n++); + Nj_ = args->get_name(grib_handle_of_accessor(this), n++); + alternativeRowScanning_ = args->get_name(grib_handle_of_accessor(this), n++); flags_ |= GRIB_ACCESSOR_FLAG_FUNCTION; length_ = 0; diff --git a/src/accessor/grib_accessor_class_change_scanning_direction.cc b/src/accessor/grib_accessor_class_change_scanning_direction.cc index f85d80674..c6446562e 100644 --- a/src/accessor/grib_accessor_class_change_scanning_direction.cc +++ b/src/accessor/grib_accessor_class_change_scanning_direction.cc @@ -19,14 +19,14 @@ void grib_accessor_change_scanning_direction_t::init(const long len, grib_argume grib_handle* h = grib_handle_of_accessor(this); int n = 0; - values_ = grib_arguments_get_name(h, args, n++); - Ni_ = grib_arguments_get_name(h, args, n++); - Nj_ = grib_arguments_get_name(h, args, n++); - i_scans_negatively_ = grib_arguments_get_name(h, args, n++); - j_scans_positively_ = grib_arguments_get_name(h, args, n++); - first_ = grib_arguments_get_name(h, args, n++); - last_ = grib_arguments_get_name(h, args, n++); - axis_ = grib_arguments_get_name(h, args, n++); + values_ = args->get_name(h, n++); + Ni_ = args->get_name(h, n++); + Nj_ = args->get_name(h, n++); + i_scans_negatively_ = args->get_name(h, n++); + j_scans_positively_ = args->get_name(h, n++); + first_ = args->get_name(h, n++); + last_ = args->get_name(h, n++); + axis_ = args->get_name(h, n++); flags_ |= GRIB_ACCESSOR_FLAG_FUNCTION; length_ = 0; diff --git a/src/accessor/grib_accessor_class_check_internal_version.cc b/src/accessor/grib_accessor_class_check_internal_version.cc index 86aec25f3..ef16d6176 100644 --- a/src/accessor/grib_accessor_class_check_internal_version.cc +++ b/src/accessor/grib_accessor_class_check_internal_version.cc @@ -25,7 +25,7 @@ void grib_accessor_check_internal_version_t::init(const long l, grib_arguments* int err = 0; long defs_file_version = 0; grib_handle* h = grib_handle_of_accessor(this); - const char* s_defn_version = grib_arguments_get_name(h, args, 0); + const char* s_defn_version = args->get_name(h, 0); Assert(s_defn_version); err = grib_get_long_internal(h, s_defn_version, &defs_file_version); diff --git a/src/accessor/grib_accessor_class_closest_date.cc b/src/accessor/grib_accessor_class_closest_date.cc index 46db8c1f3..37d8dd001 100644 --- a/src/accessor/grib_accessor_class_closest_date.cc +++ b/src/accessor/grib_accessor_class_closest_date.cc @@ -20,15 +20,15 @@ void grib_accessor_closest_date_t::init(const long l, grib_arguments* c) grib_handle* h = grib_handle_of_accessor(this); int n = 0; - dateLocal_ = grib_arguments_get_name(h, c, n++); - timeLocal_ = grib_arguments_get_name(h, c, n++); - numForecasts_ = grib_arguments_get_name(h, c, n++); - year_ = grib_arguments_get_name(h, c, n++); - month_ = grib_arguments_get_name(h, c, n++); - day_ = grib_arguments_get_name(h, c, n++); - hour_ = grib_arguments_get_name(h, c, n++); - minute_ = grib_arguments_get_name(h, c, n++); - second_ = grib_arguments_get_name(h, c, n++); + dateLocal_ = c->get_name(h, n++); + timeLocal_ = c->get_name(h, n++); + numForecasts_ = c->get_name(h, n++); + year_ = c->get_name(h, n++); + month_ = c->get_name(h, n++); + day_ = c->get_name(h, n++); + hour_ = c->get_name(h, n++); + minute_ = c->get_name(h, n++); + second_ = c->get_name(h, n++); length_ = 0; } diff --git a/src/accessor/grib_accessor_class_codeflag.cc b/src/accessor/grib_accessor_class_codeflag.cc index 07435e6c4..bd44d1de1 100644 --- a/src/accessor/grib_accessor_class_codeflag.cc +++ b/src/accessor/grib_accessor_class_codeflag.cc @@ -17,7 +17,7 @@ void grib_accessor_codeflag_t::init(const long len, grib_arguments* param) { grib_accessor_unsigned_t::init(len, param); length_ = len; - tablename_ = grib_arguments_get_string(grib_handle_of_accessor(this), param, 0); + tablename_ = param->get_string(grib_handle_of_accessor(this), 0); Assert(length_ >= 0); } diff --git a/src/accessor/grib_accessor_class_codetable.cc b/src/accessor/grib_accessor_class_codetable.cc index af9fce6fd..53f3dcb71 100644 --- a/src/accessor/grib_accessor_class_codetable.cc +++ b/src/accessor/grib_accessor_class_codetable.cc @@ -61,19 +61,19 @@ void grib_accessor_codetable_t::init(const long len, grib_arguments* params) * its length as an identifier not an integer. This identifier is * added to the argument list (at the beginning) */ - new_len = grib_arguments_get_long(hand, params, n++); + new_len = params->get_long(hand, n++); if (new_len <= 0) { grib_context_log(context_, GRIB_LOG_FATAL, "%s: codetable length must be a positive integer", name_); } nbytes_ = new_len; } - tablename_ = grib_arguments_get_string(hand, params, n++); + tablename_ = params->get_string(hand, n++); if (tablename_ == NULL) { grib_context_log(context_, GRIB_LOG_FATAL, "%s: codetable table is invalid", name_); } - masterDir_ = grib_arguments_get_name(hand, params, n++); /* can be NULL */ - localDir_ = grib_arguments_get_name(hand, params, n++); /* can be NULL */ + masterDir_ = params->get_name(hand, n++); /* can be NULL */ + localDir_ = params->get_name(hand, n++); /* can be NULL */ /*if (flags_ & GRIB_ACCESSOR_FLAG_STRING_TYPE) printf("-------- %s type string (%ld)\n",a->name,flags_ );*/ @@ -97,22 +97,22 @@ void grib_accessor_codetable_t::init(const long len, grib_arguments* params) int ret = 0; double d; char tmp[1024]; - grib_expression* expression = grib_arguments_get_expression(hand, act->default_value, 0); - int type = grib_expression_native_type(hand, expression); + grib_expression* expression = act->default_value->get_expression(hand, 0); + int type = expression->native_type(hand); switch (type) { case GRIB_TYPE_DOUBLE: - grib_expression_evaluate_double(hand, expression, &d); + expression->evaluate_double(hand, &d); pack_double(&d, &s_len); break; case GRIB_TYPE_LONG: - grib_expression_evaluate_long(grib_handle_of_accessor(this), expression, &l); + expression->evaluate_long(grib_handle_of_accessor(this), &l); pack_long(&l, &s_len); break; default: s_len = sizeof(tmp); - p = grib_expression_evaluate_string(grib_handle_of_accessor(this), expression, tmp, &s_len, &ret); + p = expression->evaluate_string(grib_handle_of_accessor(this), tmp, &s_len, &ret); if (ret != GRIB_SUCCESS) { grib_context_log(context_, GRIB_LOG_FATAL, "Unable to evaluate %s as string", name_); @@ -683,22 +683,22 @@ int grib_accessor_codetable_t::pack_string(const char* buffer, size_t* len) int ret = 0; double d = 0; char tmp[1024] = {0,}; - grib_expression* expression = grib_arguments_get_expression(grib_handle_of_accessor(this), act->default_value, 0); - int type = grib_expression_native_type(grib_handle_of_accessor(this), expression); + grib_expression* expression = act->default_value->get_expression(grib_handle_of_accessor(this), 0); + int type = expression->native_type(grib_handle_of_accessor(this)); switch (type) { case GRIB_TYPE_DOUBLE: - grib_expression_evaluate_double(grib_handle_of_accessor(this), expression, &d); + expression->evaluate_double(grib_handle_of_accessor(this), &d); pack_double(&d, &s_len); break; case GRIB_TYPE_LONG: - grib_expression_evaluate_long(grib_handle_of_accessor(this), expression, &l); + expression->evaluate_long(grib_handle_of_accessor(this), &l); pack_long(&l, &s_len); break; default: s_len = sizeof(tmp); - p = grib_expression_evaluate_string(grib_handle_of_accessor(this), expression, tmp, &s_len, &ret); + p = expression->evaluate_string(grib_handle_of_accessor(this), tmp, &s_len, &ret); if (ret != GRIB_SUCCESS) { grib_context_log(context_, GRIB_LOG_ERROR, "%s: Unable to evaluate default value of %s as string expression", __func__, name_); @@ -735,19 +735,19 @@ int grib_accessor_codetable_t::pack_expression(grib_expression* e) size_t len = 1; grib_handle* hand = grib_handle_of_accessor(this); - if (strcmp(e->cclass->name, "long") == 0) { - grib_expression_evaluate_long(hand, e, &lval); /* TODO: check return value */ + if (strcmp(e->class_name(), "long") == 0) { + e->evaluate_long(hand, &lval); /* TODO: check return value */ // if (hand->context->debug) printf("ECCODES DEBUG grib_accessor_codetable::pack_expression %s %ld\n", name_ ,lval); ret = pack_long(&lval, &len); } else { char tmp[1024]; len = sizeof(tmp); - cval = grib_expression_evaluate_string(hand, e, tmp, &len, &ret); + cval = e->evaluate_string(hand, tmp, &len, &ret); if (ret != GRIB_SUCCESS) { grib_context_log(context_, GRIB_LOG_ERROR, "grib_accessor_codetable.%s: Unable to evaluate string %s to be set in %s", - __func__, grib_expression_get_name(e), name_); + __func__, e->get_name(), name_); return ret; } len = strlen(cval) + 1; diff --git a/src/accessor/grib_accessor_class_codetable_title.cc b/src/accessor/grib_accessor_class_codetable_title.cc index 6e247ad1b..480bca7d9 100644 --- a/src/accessor/grib_accessor_class_codetable_title.cc +++ b/src/accessor/grib_accessor_class_codetable_title.cc @@ -18,7 +18,7 @@ void grib_accessor_codetable_title_t::init(const long len, grib_arguments* param { grib_accessor_gen_t::init(len, params); int n = 0; - codetable_ = grib_arguments_get_name(grib_handle_of_accessor(this), params, n++); + codetable_ = params->get_name(grib_handle_of_accessor(this), n++); length_ = 0; flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; } diff --git a/src/accessor/grib_accessor_class_codetable_units.cc b/src/accessor/grib_accessor_class_codetable_units.cc index 279de14f6..120aa885c 100644 --- a/src/accessor/grib_accessor_class_codetable_units.cc +++ b/src/accessor/grib_accessor_class_codetable_units.cc @@ -19,7 +19,7 @@ void grib_accessor_codetable_units_t::init(const long len, grib_arguments* param grib_accessor_gen_t::init(len, params); int n = 0; - codetable_ = grib_arguments_get_name(grib_handle_of_accessor(this), params, n++); + codetable_ = params->get_name(grib_handle_of_accessor(this), n++); length_ = 0; flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; } diff --git a/src/accessor/grib_accessor_class_concept.cc b/src/accessor/grib_accessor_class_concept.cc index 68b7f9694..c2be42de5 100644 --- a/src/accessor/grib_accessor_class_concept.cc +++ b/src/accessor/grib_accessor_class_concept.cc @@ -72,11 +72,11 @@ static int concept_condition_expression_true( long lres = 0; int ok = FALSE; // Boolean int err = 0; - const int type = grib_expression_native_type(h, c->expression); + const int type = c->expression->native_type(h); switch (type) { case GRIB_TYPE_LONG: - grib_expression_evaluate_long(h, c->expression, &lres); + c->expression->evaluate_long(h, &lres); // Use memoization for the most common type (integer keys) ok = (grib_get_long_memoize(h, c->name, &lval, memo) == GRIB_SUCCESS) && (lval == lres); @@ -86,7 +86,7 @@ static int concept_condition_expression_true( case GRIB_TYPE_DOUBLE: { double dval; double dres = 0.0; - grib_expression_evaluate_double(h, c->expression, &dres); + c->expression->evaluate_double(h, &dres); ok = (grib_get_double(h, c->name, &dval) == GRIB_SUCCESS) && (dval == dres); break; @@ -100,7 +100,7 @@ static int concept_condition_expression_true( size_t size = sizeof(tmp); ok = (grib_get_string(h, c->name, buf, &len) == GRIB_SUCCESS) && - ((cval = grib_expression_evaluate_string(h, c->expression, tmp, &size, &err)) != NULL) && + ((cval = c->expression->evaluate_string(h, tmp, &size, &err)) != NULL) && (err == 0) && (grib_inline_strcmp(buf, cval) == 0); break; } @@ -203,19 +203,19 @@ static int concept_conditions_expression_apply(grib_handle* h, grib_concept_cond Assert(count < 1024); values[count].name = e->name; - values[count].type = grib_expression_native_type(h, e->expression); + values[count].type = e->expression->native_type(h); switch (values[count].type) { case GRIB_TYPE_LONG: - grib_expression_evaluate_long(h, e->expression, &lres); + e->expression->evaluate_long(h, &lres); values[count].long_value = lres; break; case GRIB_TYPE_DOUBLE: - grib_expression_evaluate_double(h, e->expression, &dres); + e->expression->evaluate_double(h, &dres); values[count].double_value = dres; break; case GRIB_TYPE_STRING: size = sizeof(sa->v[count]); - values[count].string_value = grib_expression_evaluate_string(h, e->expression, sa->v[count], &size, &err); + values[count].string_value = e->expression->evaluate_string(h, sa->v[count], &size, &err); break; default: return GRIB_NOT_IMPLEMENTED; diff --git a/src/accessor/grib_accessor_class_count_missing.cc b/src/accessor/grib_accessor_class_count_missing.cc index 372f6540d..6c0792c2e 100644 --- a/src/accessor/grib_accessor_class_count_missing.cc +++ b/src/accessor/grib_accessor_class_count_missing.cc @@ -39,10 +39,10 @@ void grib_accessor_count_missing_t::init(const long len, grib_arguments* arg) grib_handle* h = grib_handle_of_accessor(this); length_ = 0; flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; - bitmap_ = grib_arguments_get_name(h, arg, n++); - unusedBitsInBitmap_ = grib_arguments_get_name(h, arg, n++); - numberOfDataPoints_ = grib_arguments_get_name(h, arg, n++); - missingValueManagementUsed_ = grib_arguments_get_name(h, arg, n++); /* Can be NULL */ + bitmap_ = arg->get_name(h, n++); + unusedBitsInBitmap_ = arg->get_name(h, n++); + numberOfDataPoints_ = arg->get_name(h, n++); + missingValueManagementUsed_ = arg->get_name(h, n++); /* Can be NULL */ } static const int used[] = { 0, 1, 3, 7, 15, 31, 63, 127, 255 }; diff --git a/src/accessor/grib_accessor_class_data_apply_bitmap.cc b/src/accessor/grib_accessor_class_data_apply_bitmap.cc index 10b138782..b83c9a7f4 100644 --- a/src/accessor/grib_accessor_class_data_apply_bitmap.cc +++ b/src/accessor/grib_accessor_class_data_apply_bitmap.cc @@ -18,12 +18,12 @@ void grib_accessor_data_apply_bitmap_t::init(const long v, grib_arguments* args) grib_accessor_gen_t::init(v, args); int n = 0; - coded_values_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++); - bitmap_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++); - missing_value_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++); - binary_scale_factor_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++); - number_of_data_points_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++); - number_of_values_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++); + coded_values_ = args->get_name(grib_handle_of_accessor(this), n++); + bitmap_ = args->get_name(grib_handle_of_accessor(this), n++); + missing_value_ = args->get_name(grib_handle_of_accessor(this), n++); + binary_scale_factor_ = args->get_name(grib_handle_of_accessor(this), n++); + number_of_data_points_ = args->get_name(grib_handle_of_accessor(this), n++); + number_of_values_ = args->get_name(grib_handle_of_accessor(this), n++); length_ = 0; } diff --git a/src/accessor/grib_accessor_class_data_apply_boustrophedonic.cc b/src/accessor/grib_accessor_class_data_apply_boustrophedonic.cc index a711969f4..5a4588247 100644 --- a/src/accessor/grib_accessor_class_data_apply_boustrophedonic.cc +++ b/src/accessor/grib_accessor_class_data_apply_boustrophedonic.cc @@ -18,11 +18,11 @@ void grib_accessor_data_apply_boustrophedonic_t::init(const long v, grib_argumen grib_accessor_gen_t::init(v, args); int n = 0; - values_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++); - numberOfRows_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++); - numberOfColumns_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++); - numberOfPoints_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++); - pl_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++); + values_ = args->get_name(grib_handle_of_accessor(this), n++); + numberOfRows_ = args->get_name(grib_handle_of_accessor(this), n++); + numberOfColumns_ = args->get_name(grib_handle_of_accessor(this), n++); + numberOfPoints_ = args->get_name(grib_handle_of_accessor(this), n++); + pl_ = args->get_name(grib_handle_of_accessor(this), n++); length_ = 0; } diff --git a/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.cc b/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.cc index a0783f98b..cdc717bd6 100644 --- a/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.cc +++ b/src/accessor/grib_accessor_class_data_apply_boustrophedonic_bitmap.cc @@ -19,14 +19,14 @@ void grib_accessor_data_apply_boustrophedonic_bitmap_t::init(const long v, grib_ int n = 0; grib_handle* gh = grib_handle_of_accessor(this); - coded_values_ = grib_arguments_get_name(gh, args, n++); - bitmap_ = grib_arguments_get_name(gh, args, n++); - missing_value_ = grib_arguments_get_name(gh, args, n++); - binary_scale_factor_ = grib_arguments_get_name(gh, args, n++); + coded_values_ = args->get_name(gh, n++); + bitmap_ = args->get_name(gh, n++); + missing_value_ = args->get_name(gh, n++); + binary_scale_factor_ = args->get_name(gh, n++); - numberOfRows_ = grib_arguments_get_name(gh, args, n++); - numberOfColumns_ = grib_arguments_get_name(gh, args, n++); - numberOfPoints_ = grib_arguments_get_name(gh, args, n++); + numberOfRows_ = args->get_name(gh, n++); + numberOfColumns_ = args->get_name(gh, n++); + numberOfPoints_ = args->get_name(gh, n++); length_ = 0; } diff --git a/src/accessor/grib_accessor_class_data_ccsds_packing.cc b/src/accessor/grib_accessor_class_data_ccsds_packing.cc index 99fbd2dc3..01b826343 100644 --- a/src/accessor/grib_accessor_class_data_ccsds_packing.cc +++ b/src/accessor/grib_accessor_class_data_ccsds_packing.cc @@ -25,16 +25,16 @@ void grib_accessor_data_ccsds_packing_t::init(const long v, grib_arguments* args grib_accessor_values_t::init(v, args); grib_handle* h = grib_handle_of_accessor(this); - number_of_values_ = grib_arguments_get_name(h, args, carg_++); - reference_value_ = grib_arguments_get_name(h, args, carg_++); - binary_scale_factor_ = grib_arguments_get_name(h, args, carg_++); - decimal_scale_factor_ = grib_arguments_get_name(h, args, carg_++); - optimize_scaling_factor_ = grib_arguments_get_name(h, args, carg_++); - bits_per_value_ = grib_arguments_get_name(h, args, carg_++); - number_of_data_points_ = grib_arguments_get_name(h, args, carg_++); - ccsds_flags_ = grib_arguments_get_name(h, args, carg_++); - ccsds_block_size_ = grib_arguments_get_name(h, args, carg_++); - ccsds_rsi_ = grib_arguments_get_name(h, args, carg_++); + number_of_values_ = args->get_name(h, carg_++); + reference_value_ = args->get_name(h, carg_++); + binary_scale_factor_ = args->get_name(h, carg_++); + decimal_scale_factor_ = args->get_name(h, carg_++); + optimize_scaling_factor_ = args->get_name(h, carg_++); + bits_per_value_ = args->get_name(h, carg_++); + number_of_data_points_ = args->get_name(h, carg_++); + ccsds_flags_ = args->get_name(h, carg_++); + ccsds_block_size_ = args->get_name(h, carg_++); + ccsds_rsi_ = args->get_name(h, carg_++); flags_ |= GRIB_ACCESSOR_FLAG_DATA; } diff --git a/src/accessor/grib_accessor_class_data_complex_packing.cc b/src/accessor/grib_accessor_class_data_complex_packing.cc index 1b33fef30..b48b6179c 100644 --- a/src/accessor/grib_accessor_class_data_complex_packing.cc +++ b/src/accessor/grib_accessor_class_data_complex_packing.cc @@ -18,16 +18,16 @@ void grib_accessor_data_complex_packing_t::init(const long v, grib_arguments* ar grib_accessor_data_simple_packing_t::init(v, args); grib_handle* gh = grib_handle_of_accessor(this); - GRIBEX_sh_bug_present_ = grib_arguments_get_name(gh, args, carg_++); - ieee_floats_ = grib_arguments_get_name(gh, args, carg_++); - laplacianOperatorIsSet_ = grib_arguments_get_name(gh, args, carg_++); - laplacianOperator_ = grib_arguments_get_name(gh, args, carg_++); - sub_j_ = grib_arguments_get_name(gh, args, carg_++); - sub_k_ = grib_arguments_get_name(gh, args, carg_++); - sub_m_ = grib_arguments_get_name(gh, args, carg_++); - pen_j_ = grib_arguments_get_name(gh, args, carg_++); - pen_k_ = grib_arguments_get_name(gh, args, carg_++); - pen_m_ = grib_arguments_get_name(gh, args, carg_++); + GRIBEX_sh_bug_present_ = args->get_name(gh, carg_++); + ieee_floats_ = args->get_name(gh, carg_++); + laplacianOperatorIsSet_ = args->get_name(gh, carg_++); + laplacianOperator_ = args->get_name(gh, carg_++); + sub_j_ = args->get_name(gh, carg_++); + sub_k_ = args->get_name(gh, carg_++); + sub_m_ = args->get_name(gh, carg_++); + pen_j_ = args->get_name(gh, carg_++); + pen_k_ = args->get_name(gh, carg_++); + pen_m_ = args->get_name(gh, carg_++); flags_ |= GRIB_ACCESSOR_FLAG_DATA; } diff --git a/src/accessor/grib_accessor_class_data_dummy_field.cc b/src/accessor/grib_accessor_class_data_dummy_field.cc index 590fd9138..ee6b6a380 100644 --- a/src/accessor/grib_accessor_class_data_dummy_field.cc +++ b/src/accessor/grib_accessor_class_data_dummy_field.cc @@ -16,9 +16,9 @@ grib_accessor* grib_accessor_data_dummy_field = &_grib_accessor_data_dummy_field void grib_accessor_data_dummy_field_t::init(const long v, grib_arguments* args) { grib_accessor_data_g1simple_packing_t::init(v, args); - missing_value_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, carg_++); - numberOfPoints_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, carg_++); - bitmap_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, carg_++); + missing_value_ = args->get_name(grib_handle_of_accessor(this), carg_++); + numberOfPoints_ = args->get_name(grib_handle_of_accessor(this), carg_++); + bitmap_ = args->get_name(grib_handle_of_accessor(this), carg_++); } int grib_accessor_data_dummy_field_t::unpack_double(double* val, size_t* len) diff --git a/src/accessor/grib_accessor_class_data_g1complex_packing.cc b/src/accessor/grib_accessor_class_data_g1complex_packing.cc index c7795e5f1..7f0deff36 100644 --- a/src/accessor/grib_accessor_class_data_g1complex_packing.cc +++ b/src/accessor/grib_accessor_class_data_g1complex_packing.cc @@ -16,11 +16,11 @@ grib_accessor* grib_accessor_data_g1complex_packing = &_grib_accessor_data_g1com void grib_accessor_data_g1complex_packing_t::init(const long v, grib_arguments* args) { grib_accessor_data_complex_packing_t::init(v, args); - half_byte_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, carg_++); - N_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, carg_++); - packingType_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, carg_++); - ieee_packing_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, carg_++); - precision_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, carg_++); + half_byte_ = args->get_name(grib_handle_of_accessor(this), carg_++); + N_ = args->get_name(grib_handle_of_accessor(this), carg_++); + packingType_ = args->get_name(grib_handle_of_accessor(this), carg_++); + ieee_packing_ = args->get_name(grib_handle_of_accessor(this), carg_++); + precision_ = args->get_name(grib_handle_of_accessor(this), carg_++); edition_ = 1; flags_ |= GRIB_ACCESSOR_FLAG_DATA; } diff --git a/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.cc b/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.cc index 0d7cd7e45..91ea14f52 100644 --- a/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.cc +++ b/src/accessor/grib_accessor_class_data_g1second_order_constant_width_packing.cc @@ -19,22 +19,22 @@ void grib_accessor_data_g1second_order_constant_width_packing_t::init(const long grib_accessor_data_simple_packing_t::init(v, args); grib_handle* hand = grib_handle_of_accessor(this); - half_byte_ = grib_arguments_get_name(hand, args, carg_++); - packingType_ = grib_arguments_get_name(hand, args, carg_++); - ieee_packing_ = grib_arguments_get_name(hand, args, carg_++); - precision_ = grib_arguments_get_name(hand, args, carg_++); - widthOfFirstOrderValues_ = grib_arguments_get_name(hand, args, carg_++); - N1_ = grib_arguments_get_name(hand, args, carg_++); - N2_ = grib_arguments_get_name(hand, args, carg_++); - numberOfGroups_ = grib_arguments_get_name(hand, args, carg_++); - numberOfSecondOrderPackedValues_ = grib_arguments_get_name(hand, args, carg_++); - extraValues_ = grib_arguments_get_name(hand, args, carg_++); - Ni_ = grib_arguments_get_name(hand, args, carg_++); - Nj_ = grib_arguments_get_name(hand, args, carg_++); - pl_ = grib_arguments_get_name(hand, args, carg_++); - jPointsAreConsecutive_ = grib_arguments_get_name(hand, args, carg_++); - bitmap_ = grib_arguments_get_name(hand, args, carg_++); - groupWidth_ = grib_arguments_get_name(hand, args, carg_++); + half_byte_ = args->get_name(hand, carg_++); + packingType_ = args->get_name(hand, carg_++); + ieee_packing_ = args->get_name(hand, carg_++); + precision_ = args->get_name(hand, carg_++); + widthOfFirstOrderValues_ = args->get_name(hand, carg_++); + N1_ = args->get_name(hand, carg_++); + N2_ = args->get_name(hand, carg_++); + numberOfGroups_ = args->get_name(hand, carg_++); + numberOfSecondOrderPackedValues_ = args->get_name(hand, carg_++); + extraValues_ = args->get_name(hand, carg_++); + Ni_ = args->get_name(hand, carg_++); + Nj_ = args->get_name(hand, carg_++); + pl_ = args->get_name(hand, carg_++); + jPointsAreConsecutive_ = args->get_name(hand, carg_++); + bitmap_ = args->get_name(hand, carg_++); + groupWidth_ = args->get_name(hand, carg_++); edition_ = 1; flags_ |= GRIB_ACCESSOR_FLAG_DATA; } diff --git a/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc b/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc index 166be66de..eab5bdfcf 100644 --- a/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc +++ b/src/accessor/grib_accessor_class_data_g1second_order_general_extended_packing.cc @@ -58,28 +58,28 @@ void grib_accessor_data_g1second_order_general_extended_packing_t::init(const lo grib_accessor_data_simple_packing_t::init(v, args); grib_handle* handle = grib_handle_of_accessor(this); - half_byte_ = grib_arguments_get_name(handle, args, carg_++); - packingType_ = grib_arguments_get_name(handle, args, carg_++); - ieee_packing_ = grib_arguments_get_name(handle, args, carg_++); - precision_ = grib_arguments_get_name(handle, args, carg_++); - widthOfFirstOrderValues_ = grib_arguments_get_name(handle, args, carg_++); - firstOrderValues_ = grib_arguments_get_name(handle, args, carg_++); - N1_ = grib_arguments_get_name(handle, args, carg_++); - N2_ = grib_arguments_get_name(handle, args, carg_++); - numberOfGroups_ = grib_arguments_get_name(handle, args, carg_++); - codedNumberOfGroups_ = grib_arguments_get_name(handle, args, carg_++); - numberOfSecondOrderPackedValues_ = grib_arguments_get_name(handle, args, carg_++); - extraValues_ = grib_arguments_get_name(handle, args, carg_++); - groupWidths_ = grib_arguments_get_name(handle, args, carg_++); - widthOfWidths_ = grib_arguments_get_name(handle, args, carg_++); - groupLengths_ = grib_arguments_get_name(handle, args, carg_++); - widthOfLengths_ = grib_arguments_get_name(handle, args, carg_++); - NL_ = grib_arguments_get_name(handle, args, carg_++); - SPD_ = grib_arguments_get_name(handle, args, carg_++); - widthOfSPD_ = grib_arguments_get_name(handle, args, carg_++); - orderOfSPD_ = grib_arguments_get_name(handle, args, carg_++); - numberOfPoints_ = grib_arguments_get_name(handle, args, carg_++); - dataFlag_ = grib_arguments_get_name(handle, args, carg_++); + half_byte_ = args->get_name(handle, carg_++); + packingType_ = args->get_name(handle, carg_++); + ieee_packing_ = args->get_name(handle, carg_++); + precision_ = args->get_name(handle, carg_++); + widthOfFirstOrderValues_ = args->get_name(handle, carg_++); + firstOrderValues_ = args->get_name(handle, carg_++); + N1_ = args->get_name(handle, carg_++); + N2_ = args->get_name(handle, carg_++); + numberOfGroups_ = args->get_name(handle, carg_++); + codedNumberOfGroups_ = args->get_name(handle, carg_++); + numberOfSecondOrderPackedValues_ = args->get_name(handle, carg_++); + extraValues_ = args->get_name(handle, carg_++); + groupWidths_ = args->get_name(handle, carg_++); + widthOfWidths_ = args->get_name(handle, carg_++); + groupLengths_ = args->get_name(handle, carg_++); + widthOfLengths_ = args->get_name(handle, carg_++); + NL_ = args->get_name(handle, carg_++); + SPD_ = args->get_name(handle, carg_++); + widthOfSPD_ = args->get_name(handle, carg_++); + orderOfSPD_ = args->get_name(handle, carg_++); + numberOfPoints_ = args->get_name(handle, carg_++); + dataFlag_ = args->get_name(handle, carg_++); edition_ = 1; dirty_ = 1; dvalues_ = NULL; diff --git a/src/accessor/grib_accessor_class_data_g1second_order_general_packing.cc b/src/accessor/grib_accessor_class_data_g1second_order_general_packing.cc index ac9622b64..89a95529e 100644 --- a/src/accessor/grib_accessor_class_data_g1second_order_general_packing.cc +++ b/src/accessor/grib_accessor_class_data_g1second_order_general_packing.cc @@ -18,22 +18,22 @@ void grib_accessor_data_g1second_order_general_packing_t::init(const long v, gri grib_accessor_data_simple_packing_t::init(v, args); grib_handle* hand = grib_handle_of_accessor(this); - half_byte_ = grib_arguments_get_name(hand, args, carg_++); - packingType_ = grib_arguments_get_name(hand, args, carg_++); - ieee_packing_ = grib_arguments_get_name(hand, args, carg_++); - precision_ = grib_arguments_get_name(hand, args, carg_++); - widthOfFirstOrderValues_ = grib_arguments_get_name(hand, args, carg_++); - N1_ = grib_arguments_get_name(hand, args, carg_++); - N2_ = grib_arguments_get_name(hand, args, carg_++); - numberOfGroups_ = grib_arguments_get_name(hand, args, carg_++); - numberOfSecondOrderPackedValues_ = grib_arguments_get_name(hand, args, carg_++); - extraValues_ = grib_arguments_get_name(hand, args, carg_++); - Ni_ = grib_arguments_get_name(hand, args, carg_++); - Nj_ = grib_arguments_get_name(hand, args, carg_++); - pl_ = grib_arguments_get_name(hand, args, carg_++); - jPointsAreConsecutive_ = grib_arguments_get_name(hand, args, carg_++); - bitmap_ = grib_arguments_get_name(hand, args, carg_++); - groupWidths_ = grib_arguments_get_name(hand, args, carg_++); + half_byte_ = args->get_name(hand, carg_++); + packingType_ = args->get_name(hand, carg_++); + ieee_packing_ = args->get_name(hand, carg_++); + precision_ = args->get_name(hand, carg_++); + widthOfFirstOrderValues_ = args->get_name(hand, carg_++); + N1_ = args->get_name(hand, carg_++); + N2_ = args->get_name(hand, carg_++); + numberOfGroups_ = args->get_name(hand, carg_++); + numberOfSecondOrderPackedValues_ = args->get_name(hand, carg_++); + extraValues_ = args->get_name(hand, carg_++); + Ni_ = args->get_name(hand, carg_++); + Nj_ = args->get_name(hand, carg_++); + pl_ = args->get_name(hand, carg_++); + jPointsAreConsecutive_ = args->get_name(hand, carg_++); + bitmap_ = args->get_name(hand, carg_++); + groupWidths_ = args->get_name(hand, carg_++); edition_ = 1; flags_ |= GRIB_ACCESSOR_FLAG_DATA; } diff --git a/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.cc b/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.cc index 49c8550c2..b749f58fa 100644 --- a/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.cc +++ b/src/accessor/grib_accessor_class_data_g1second_order_row_by_row_packing.cc @@ -18,22 +18,22 @@ void grib_accessor_data_g1second_order_row_by_row_packing_t::init(const long v, grib_accessor_data_simple_packing_t::init(v, args); grib_handle* gh = grib_handle_of_accessor(this); - half_byte_ = grib_arguments_get_name(gh, args, carg_++); - packingType_ = grib_arguments_get_name(gh, args, carg_++); - ieee_packing_ = grib_arguments_get_name(gh, args, carg_++); - precision_ = grib_arguments_get_name(gh, args, carg_++); - widthOfFirstOrderValues_ = grib_arguments_get_name(gh, args, carg_++); - N1_ = grib_arguments_get_name(gh, args, carg_++); - N2_ = grib_arguments_get_name(gh, args, carg_++); - numberOfGroups_ = grib_arguments_get_name(gh, args, carg_++); - numberOfSecondOrderPackedValues_ = grib_arguments_get_name(gh, args, carg_++); - extraValues_ = grib_arguments_get_name(gh, args, carg_++); - Ni_ = grib_arguments_get_name(gh, args, carg_++); - Nj_ = grib_arguments_get_name(gh, args, carg_++); - pl_ = grib_arguments_get_name(gh, args, carg_++); - jPointsAreConsecutive_ = grib_arguments_get_name(gh, args, carg_++); - groupWidths_ = grib_arguments_get_name(gh, args, carg_++); - bitmap_ = grib_arguments_get_name(gh, args, carg_++); + half_byte_ = args->get_name(gh, carg_++); + packingType_ = args->get_name(gh, carg_++); + ieee_packing_ = args->get_name(gh, carg_++); + precision_ = args->get_name(gh, carg_++); + widthOfFirstOrderValues_ = args->get_name(gh, carg_++); + N1_ = args->get_name(gh, carg_++); + N2_ = args->get_name(gh, carg_++); + numberOfGroups_ = args->get_name(gh, carg_++); + numberOfSecondOrderPackedValues_ = args->get_name(gh, carg_++); + extraValues_ = args->get_name(gh, carg_++); + Ni_ = args->get_name(gh, carg_++); + Nj_ = args->get_name(gh, carg_++); + pl_ = args->get_name(gh, carg_++); + jPointsAreConsecutive_ = args->get_name(gh, carg_++); + groupWidths_ = args->get_name(gh, carg_++); + bitmap_ = args->get_name(gh, carg_++); edition_ = 1; flags_ |= GRIB_ACCESSOR_FLAG_DATA; } diff --git a/src/accessor/grib_accessor_class_data_g1secondary_bitmap.cc b/src/accessor/grib_accessor_class_data_g1secondary_bitmap.cc index 289c403ca..7bd009775 100644 --- a/src/accessor/grib_accessor_class_data_g1secondary_bitmap.cc +++ b/src/accessor/grib_accessor_class_data_g1secondary_bitmap.cc @@ -16,7 +16,7 @@ grib_accessor* grib_accessor_data_g1secondary_bitmap = &_grib_accessor_data_g1se void grib_accessor_data_g1secondary_bitmap_t::init(const long v, grib_arguments* args) { grib_accessor_data_secondary_bitmap_t::init(v, args); - number_of_ones_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, 4); + number_of_ones_ = args->get_name(grib_handle_of_accessor(this), 4); } int grib_accessor_data_g1secondary_bitmap_t::value_count(long* count) diff --git a/src/accessor/grib_accessor_class_data_g1simple_packing.cc b/src/accessor/grib_accessor_class_data_g1simple_packing.cc index 2f0b64134..4ebc9ca12 100644 --- a/src/accessor/grib_accessor_class_data_g1simple_packing.cc +++ b/src/accessor/grib_accessor_class_data_g1simple_packing.cc @@ -18,10 +18,10 @@ void grib_accessor_data_g1simple_packing_t::init(const long v, grib_arguments* a { grib_accessor_data_simple_packing_t::init(v, args); - half_byte_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, carg_++); - packingType_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, carg_++); - ieee_packing_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, carg_++); - precision_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, carg_++); + half_byte_ = args->get_name(grib_handle_of_accessor(this), carg_++); + packingType_ = args->get_name(grib_handle_of_accessor(this), carg_++); + ieee_packing_ = args->get_name(grib_handle_of_accessor(this), carg_++); + precision_ = args->get_name(grib_handle_of_accessor(this), carg_++); edition_ = 1; flags_ |= GRIB_ACCESSOR_FLAG_DATA; } diff --git a/src/accessor/grib_accessor_class_data_g22order_packing.cc b/src/accessor/grib_accessor_class_data_g22order_packing.cc index 2e33a0b50..c6d50bbae 100644 --- a/src/accessor/grib_accessor_class_data_g22order_packing.cc +++ b/src/accessor/grib_accessor_class_data_g22order_packing.cc @@ -18,28 +18,28 @@ void grib_accessor_data_g22order_packing_t::init(const long v, grib_arguments* a grib_accessor_values_t::init(v, args); grib_handle* gh = grib_handle_of_accessor(this); - numberOfValues_ = grib_arguments_get_name(gh, args, carg_++); - bits_per_value_ = grib_arguments_get_name(gh, args, carg_++); - reference_value_ = grib_arguments_get_name(gh, args, carg_++); - binary_scale_factor_ = grib_arguments_get_name(gh, args, carg_++); - decimal_scale_factor_ = grib_arguments_get_name(gh, args, carg_++); - optimize_scale_factor_ = grib_arguments_get_name(gh, args, carg_++); + numberOfValues_ = args->get_name(gh, carg_++); + bits_per_value_ = args->get_name(gh, carg_++); + reference_value_ = args->get_name(gh, carg_++); + binary_scale_factor_ = args->get_name(gh, carg_++); + decimal_scale_factor_ = args->get_name(gh, carg_++); + optimize_scale_factor_ = args->get_name(gh, carg_++); - typeOfOriginalFieldValues_ = grib_arguments_get_name(gh, args, carg_++); - groupSplittingMethodUsed_ = grib_arguments_get_name(gh, args, carg_++); - missingValueManagementUsed_ = grib_arguments_get_name(gh, args, carg_++); - primaryMissingValueSubstitute_ = grib_arguments_get_name(gh, args, carg_++); - secondaryMissingValueSubstitute_ = grib_arguments_get_name(gh, args, carg_++); - numberOfGroupsOfDataValues_ = grib_arguments_get_name(gh, args, carg_++); - referenceForGroupWidths_ = grib_arguments_get_name(gh, args, carg_++); - numberOfBitsUsedForTheGroupWidths_ = grib_arguments_get_name(gh, args, carg_++); - referenceForGroupLengths_ = grib_arguments_get_name(gh, args, carg_++); - lengthIncrementForTheGroupLengths_ = grib_arguments_get_name(gh, args, carg_++); - trueLengthOfLastGroup_ = grib_arguments_get_name(gh, args, carg_++); - numberOfBitsUsedForTheScaledGroupLengths_ = grib_arguments_get_name(gh, args, carg_++); + typeOfOriginalFieldValues_ = args->get_name(gh, carg_++); + groupSplittingMethodUsed_ = args->get_name(gh, carg_++); + missingValueManagementUsed_ = args->get_name(gh, carg_++); + primaryMissingValueSubstitute_ = args->get_name(gh, carg_++); + secondaryMissingValueSubstitute_ = args->get_name(gh, carg_++); + numberOfGroupsOfDataValues_ = args->get_name(gh, carg_++); + referenceForGroupWidths_ = args->get_name(gh, carg_++); + numberOfBitsUsedForTheGroupWidths_ = args->get_name(gh, carg_++); + referenceForGroupLengths_ = args->get_name(gh, carg_++); + lengthIncrementForTheGroupLengths_ = args->get_name(gh, carg_++); + trueLengthOfLastGroup_ = args->get_name(gh, carg_++); + numberOfBitsUsedForTheScaledGroupLengths_ = args->get_name(gh, carg_++); - orderOfSpatialDifferencing_ = grib_arguments_get_name(gh, args, carg_++); - numberOfOctetsExtraDescriptors_ = grib_arguments_get_name(gh, args, carg_++); + orderOfSpatialDifferencing_ = args->get_name(gh, carg_++); + numberOfOctetsExtraDescriptors_ = args->get_name(gh, carg_++); flags_ |= GRIB_ACCESSOR_FLAG_DATA; } diff --git a/src/accessor/grib_accessor_class_data_g2bifourier_packing.cc b/src/accessor/grib_accessor_class_data_g2bifourier_packing.cc index 0126e83e8..eee26fb16 100644 --- a/src/accessor/grib_accessor_class_data_g2bifourier_packing.cc +++ b/src/accessor/grib_accessor_class_data_g2bifourier_packing.cc @@ -20,19 +20,19 @@ void grib_accessor_data_g2bifourier_packing_t::init(const long v, grib_arguments grib_accessor_data_simple_packing_t::init(v, args); grib_handle* gh = grib_handle_of_accessor(this); - ieee_floats_ = grib_arguments_get_name(gh, args, carg_++); - laplacianOperatorIsSet_ = grib_arguments_get_name(gh, args, carg_++); - laplacianOperator_ = grib_arguments_get_name(gh, args, carg_++); - biFourierTruncationType_ = grib_arguments_get_name(gh, args, carg_++); - sub_i_ = grib_arguments_get_name(gh, args, carg_++); - sub_j_ = grib_arguments_get_name(gh, args, carg_++); - bif_i_ = grib_arguments_get_name(gh, args, carg_++); - bif_j_ = grib_arguments_get_name(gh, args, carg_++); - biFourierSubTruncationType_ = grib_arguments_get_name(gh, args, carg_++); - biFourierDoNotPackAxes_ = grib_arguments_get_name(gh, args, carg_++); - biFourierMakeTemplate_ = grib_arguments_get_name(gh, args, carg_++); - totalNumberOfValuesInUnpackedSubset_ = grib_arguments_get_name(gh, args, carg_++); - /*numberOfValues = grib_arguments_get_name(gh,args,carg_ ++);*/ + ieee_floats_ = args->get_name(gh, carg_++); + laplacianOperatorIsSet_ = args->get_name(gh, carg_++); + laplacianOperator_ = args->get_name(gh, carg_++); + biFourierTruncationType_ = args->get_name(gh, carg_++); + sub_i_ = args->get_name(gh, carg_++); + sub_j_ = args->get_name(gh, carg_++); + bif_i_ = args->get_name(gh, carg_++); + bif_j_ = args->get_name(gh, carg_++); + biFourierSubTruncationType_ = args->get_name(gh, carg_++); + biFourierDoNotPackAxes_ = args->get_name(gh, carg_++); + biFourierMakeTemplate_ = args->get_name(gh, carg_++); + totalNumberOfValuesInUnpackedSubset_ = args->get_name(gh, carg_++); + /*numberOfValues = args->get_name(gh, carg_++);*/ flags_ |= GRIB_ACCESSOR_FLAG_DATA; dirty_ = 1; diff --git a/src/accessor/grib_accessor_class_data_g2complex_packing.cc b/src/accessor/grib_accessor_class_data_g2complex_packing.cc index 7b50a410d..acf3aa908 100644 --- a/src/accessor/grib_accessor_class_data_g2complex_packing.cc +++ b/src/accessor/grib_accessor_class_data_g2complex_packing.cc @@ -16,7 +16,7 @@ grib_accessor* grib_accessor_data_g2complex_packing = &_grib_accessor_data_g2com void grib_accessor_data_g2complex_packing_t::init(const long v, grib_arguments* args) { grib_accessor_data_complex_packing_t::init(v, args); - numberOfValues_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, carg_++); + numberOfValues_ = args->get_name(grib_handle_of_accessor(this), carg_++); edition_ = 2; flags_ |= GRIB_ACCESSOR_FLAG_DATA; diff --git a/src/accessor/grib_accessor_class_data_g2secondary_bitmap.cc b/src/accessor/grib_accessor_class_data_g2secondary_bitmap.cc index e12c570c6..519a15557 100644 --- a/src/accessor/grib_accessor_class_data_g2secondary_bitmap.cc +++ b/src/accessor/grib_accessor_class_data_g2secondary_bitmap.cc @@ -16,7 +16,7 @@ grib_accessor* grib_accessor_data_g2secondary_bitmap = &_grib_accessor_data_g2se void grib_accessor_data_g2secondary_bitmap_t::init(const long v, grib_arguments* args) { grib_accessor_data_secondary_bitmap_t::init(v, args); - number_of_values_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, 4); + number_of_values_ = args->get_name(grib_handle_of_accessor(this), 4); } int grib_accessor_data_g2secondary_bitmap_t::value_count(long* len) diff --git a/src/accessor/grib_accessor_class_data_g2shsimple_packing.cc b/src/accessor/grib_accessor_class_data_g2shsimple_packing.cc index 9e90ef67e..0ee6040db 100644 --- a/src/accessor/grib_accessor_class_data_g2shsimple_packing.cc +++ b/src/accessor/grib_accessor_class_data_g2shsimple_packing.cc @@ -17,8 +17,8 @@ void grib_accessor_data_g2shsimple_packing_t::init(const long v, grib_arguments* { grib_accessor_data_shsimple_packing_t::init(v, args); - numberOfValues_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, 2); - numberOfDataPoints_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, 3); + numberOfValues_ = args->get_name(grib_handle_of_accessor(this), 2); + numberOfDataPoints_ = args->get_name(grib_handle_of_accessor(this), 3); flags_ |= GRIB_ACCESSOR_FLAG_DATA; } diff --git a/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc b/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc index 77370bb3d..a6a083046 100644 --- a/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc +++ b/src/accessor/grib_accessor_class_data_g2simple_packing_with_preprocessing.cc @@ -18,8 +18,8 @@ grib_accessor* grib_accessor_data_g2simple_packing_with_preprocessing = &_grib_a void grib_accessor_data_g2simple_packing_with_preprocessing_t::init(const long v, grib_arguments* args) { grib_accessor_data_g2simple_packing_t::init(v, args); - pre_processing_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, carg_++); - pre_processing_parameter_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, carg_++); + pre_processing_ = args->get_name(grib_handle_of_accessor(this), carg_++); + pre_processing_parameter_ = args->get_name(grib_handle_of_accessor(this), carg_++); flags_ |= GRIB_ACCESSOR_FLAG_DATA; } diff --git a/src/accessor/grib_accessor_class_data_jpeg2000_packing.cc b/src/accessor/grib_accessor_class_data_jpeg2000_packing.cc index 55bf9ea8a..46bee7a76 100644 --- a/src/accessor/grib_accessor_class_data_jpeg2000_packing.cc +++ b/src/accessor/grib_accessor_class_data_jpeg2000_packing.cc @@ -25,13 +25,13 @@ void grib_accessor_data_jpeg2000_packing_t::init(const long v, grib_arguments* a grib_handle* hand = grib_handle_of_accessor(this); jpeg_lib_ = 0; - type_of_compression_used_ = grib_arguments_get_name(hand, args, carg_++); - target_compression_ratio_ = grib_arguments_get_name(hand, args, carg_++); - ni_ = grib_arguments_get_name(hand, args, carg_++); - nj_ = grib_arguments_get_name(hand, args, carg_++); - list_defining_points_ = grib_arguments_get_name(hand, args, carg_++); - number_of_data_points_ = grib_arguments_get_name(hand, args, carg_++); - scanning_mode_ = grib_arguments_get_name(hand, args, carg_++); + type_of_compression_used_ = args->get_name(hand, carg_++); + target_compression_ratio_ = args->get_name(hand, carg_++); + ni_ = args->get_name(hand, carg_++); + nj_ = args->get_name(hand, carg_++); + list_defining_points_ = args->get_name(hand, carg_++); + number_of_data_points_ = args->get_name(hand, carg_++); + scanning_mode_ = args->get_name(hand, carg_++); edition_ = 2; flags_ |= GRIB_ACCESSOR_FLAG_DATA; diff --git a/src/accessor/grib_accessor_class_data_png_packing.cc b/src/accessor/grib_accessor_class_data_png_packing.cc index ad024215b..13d032431 100644 --- a/src/accessor/grib_accessor_class_data_png_packing.cc +++ b/src/accessor/grib_accessor_class_data_png_packing.cc @@ -21,16 +21,16 @@ void grib_accessor_data_png_packing_t::init(const long v, grib_arguments* args) grib_accessor_values_t::init(v, args); grib_handle* h = grib_handle_of_accessor(this); - number_of_values_ = grib_arguments_get_name(h, args, carg_++); - reference_value_ = grib_arguments_get_name(h, args, carg_++); - binary_scale_factor_ = grib_arguments_get_name(h, args, carg_++); - decimal_scale_factor_ = grib_arguments_get_name(h, args, carg_++); - bits_per_value_ = grib_arguments_get_name(h, args, carg_++); - ni_ = grib_arguments_get_name(h, args, carg_++); - nj_ = grib_arguments_get_name(h, args, carg_++); - list_defining_points_ = grib_arguments_get_name(h, args, carg_++); - number_of_data_points_ = grib_arguments_get_name(h, args, carg_++); - scanning_mode_ = grib_arguments_get_name(h, args, carg_++); + number_of_values_ = args->get_name(h, carg_++); + reference_value_ = args->get_name(h, carg_++); + binary_scale_factor_ = args->get_name(h, carg_++); + decimal_scale_factor_ = args->get_name(h, carg_++); + bits_per_value_ = args->get_name(h, carg_++); + ni_ = args->get_name(h, carg_++); + nj_ = args->get_name(h, carg_++); + list_defining_points_ = args->get_name(h, carg_++); + number_of_data_points_ = args->get_name(h, carg_++); + scanning_mode_ = args->get_name(h, carg_++); flags_ |= GRIB_ACCESSOR_FLAG_DATA; } diff --git a/src/accessor/grib_accessor_class_data_raw_packing.cc b/src/accessor/grib_accessor_class_data_raw_packing.cc index 916029045..4da85f02e 100644 --- a/src/accessor/grib_accessor_class_data_raw_packing.cc +++ b/src/accessor/grib_accessor_class_data_raw_packing.cc @@ -18,8 +18,8 @@ void grib_accessor_data_raw_packing_t::init(const long v, grib_arguments* args) { grib_accessor_values_t::init(v, args); - number_of_values_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, carg_++); - precision_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, carg_++); + number_of_values_ = args->get_name(grib_handle_of_accessor(this), carg_++); + precision_ = args->get_name(grib_handle_of_accessor(this), carg_++); flags_ |= GRIB_ACCESSOR_FLAG_DATA; } diff --git a/src/accessor/grib_accessor_class_data_run_length_packing.cc b/src/accessor/grib_accessor_class_data_run_length_packing.cc index 6f550ce29..5d7afe336 100644 --- a/src/accessor/grib_accessor_class_data_run_length_packing.cc +++ b/src/accessor/grib_accessor_class_data_run_length_packing.cc @@ -18,12 +18,12 @@ void grib_accessor_data_run_length_packing_t::init(const long v, grib_arguments* { grib_accessor_values_t::init(v, args); grib_handle* gh = grib_handle_of_accessor(this); - number_of_values_ = grib_arguments_get_name(gh, args, carg_++); - bits_per_value_ = grib_arguments_get_name(gh, args, carg_++); - max_level_value_ = grib_arguments_get_name(gh, args, carg_++); - number_of_level_values_ = grib_arguments_get_name(gh, args, carg_++); - decimal_scale_factor_ = grib_arguments_get_name(gh, args, carg_++); - level_values_ = grib_arguments_get_name(gh, args, carg_++); + number_of_values_ = args->get_name(gh, carg_++); + bits_per_value_ = args->get_name(gh, carg_++); + max_level_value_ = args->get_name(gh, carg_++); + number_of_level_values_ = args->get_name(gh, carg_++); + decimal_scale_factor_ = args->get_name(gh, carg_++); + level_values_ = args->get_name(gh, carg_++); flags_ |= GRIB_ACCESSOR_FLAG_DATA; } diff --git a/src/accessor/grib_accessor_class_data_secondary_bitmap.cc b/src/accessor/grib_accessor_class_data_secondary_bitmap.cc index 705ca6c80..16f99c19d 100644 --- a/src/accessor/grib_accessor_class_data_secondary_bitmap.cc +++ b/src/accessor/grib_accessor_class_data_secondary_bitmap.cc @@ -16,10 +16,10 @@ grib_accessor* grib_accessor_data_secondary_bitmap = &_grib_accessor_data_second void grib_accessor_data_secondary_bitmap_t::init(const long v, grib_arguments* args) { grib_accessor_gen_t::init(v, args); - primary_bitmap_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, 0); - secondary_bitmap_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, 1); - missing_value_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, 2); - expand_by_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, 3); + primary_bitmap_ = args->get_name(grib_handle_of_accessor(this), 0); + secondary_bitmap_ = args->get_name(grib_handle_of_accessor(this), 1); + missing_value_ = args->get_name(grib_handle_of_accessor(this), 2); + expand_by_ = args->get_name(grib_handle_of_accessor(this), 3); length_ = 0; } diff --git a/src/accessor/grib_accessor_class_data_sh_packed.cc b/src/accessor/grib_accessor_class_data_sh_packed.cc index e753b7d07..4d5656a4f 100644 --- a/src/accessor/grib_accessor_class_data_sh_packed.cc +++ b/src/accessor/grib_accessor_class_data_sh_packed.cc @@ -22,16 +22,16 @@ void grib_accessor_data_sh_packed_t::init(const long v, grib_arguments* args) grib_accessor_data_simple_packing_t::init(v, args); grib_handle* hand = grib_handle_of_accessor(this); - GRIBEX_sh_bug_present_ = grib_arguments_get_name(hand, args, carg_++); - ieee_floats_ = grib_arguments_get_name(hand, args, carg_++); - laplacianOperatorIsSet_ = grib_arguments_get_name(hand, args, carg_++); - laplacianOperator_ = grib_arguments_get_name(hand, args, carg_++); - sub_j_ = grib_arguments_get_name(hand, args, carg_++); - sub_k_ = grib_arguments_get_name(hand, args, carg_++); - sub_m_ = grib_arguments_get_name(hand, args, carg_++); - pen_j_ = grib_arguments_get_name(hand, args, carg_++); - pen_k_ = grib_arguments_get_name(hand, args, carg_++); - pen_m_ = grib_arguments_get_name(hand, args, carg_++); + GRIBEX_sh_bug_present_ = args->get_name(hand, carg_++); + ieee_floats_ = args->get_name(hand, carg_++); + laplacianOperatorIsSet_ = args->get_name(hand, carg_++); + laplacianOperator_ = args->get_name(hand, carg_++); + sub_j_ = args->get_name(hand, carg_++); + sub_k_ = args->get_name(hand, carg_++); + sub_m_ = args->get_name(hand, carg_++); + pen_j_ = args->get_name(hand, carg_++); + pen_k_ = args->get_name(hand, carg_++); + pen_m_ = args->get_name(hand, carg_++); flags_ |= GRIB_ACCESSOR_FLAG_DATA; length_ = 0; diff --git a/src/accessor/grib_accessor_class_data_sh_unpacked.cc b/src/accessor/grib_accessor_class_data_sh_unpacked.cc index 6ff72c1b3..dddf88083 100644 --- a/src/accessor/grib_accessor_class_data_sh_unpacked.cc +++ b/src/accessor/grib_accessor_class_data_sh_unpacked.cc @@ -22,16 +22,16 @@ void grib_accessor_data_sh_unpacked_t::init(const long v, grib_arguments* args) grib_accessor_data_simple_packing_t::init(v, args); grib_handle* hand = grib_handle_of_accessor(this); - GRIBEX_sh_bug_present_ = grib_arguments_get_name(hand, args, carg_++); - ieee_floats_ = grib_arguments_get_name(hand, args, carg_++); - laplacianOperatorIsSet_ = grib_arguments_get_name(hand, args, carg_++); - laplacianOperator_ = grib_arguments_get_name(hand, args, carg_++); - sub_j_ = grib_arguments_get_name(hand, args, carg_++); - sub_k_ = grib_arguments_get_name(hand, args, carg_++); - sub_m_ = grib_arguments_get_name(hand, args, carg_++); - pen_j_ = grib_arguments_get_name(hand, args, carg_++); - pen_k_ = grib_arguments_get_name(hand, args, carg_++); - pen_m_ = grib_arguments_get_name(hand, args, carg_++); + GRIBEX_sh_bug_present_ = args->get_name(hand, carg_++); + ieee_floats_ = args->get_name(hand, carg_++); + laplacianOperatorIsSet_ = args->get_name(hand, carg_++); + laplacianOperator_ = args->get_name(hand, carg_++); + sub_j_ = args->get_name(hand, carg_++); + sub_k_ = args->get_name(hand, carg_++); + sub_m_ = args->get_name(hand, carg_++); + pen_j_ = args->get_name(hand, carg_++); + pen_k_ = args->get_name(hand, carg_++); + pen_m_ = args->get_name(hand, carg_++); flags_ |= GRIB_ACCESSOR_FLAG_DATA; length_ = 0; diff --git a/src/accessor/grib_accessor_class_data_shsimple_packing.cc b/src/accessor/grib_accessor_class_data_shsimple_packing.cc index ae909b6c2..210a39ad1 100644 --- a/src/accessor/grib_accessor_class_data_shsimple_packing.cc +++ b/src/accessor/grib_accessor_class_data_shsimple_packing.cc @@ -17,8 +17,8 @@ void grib_accessor_data_shsimple_packing_t::init(const long v, grib_arguments* a { grib_accessor_gen_t::init(v, args); - coded_values_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, 0); - real_part_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, 1); + coded_values_ = args->get_name(grib_handle_of_accessor(this), 0); + real_part_ = args->get_name(grib_handle_of_accessor(this), 1); flags_ |= GRIB_ACCESSOR_FLAG_DATA; length_ = 0; diff --git a/src/accessor/grib_accessor_class_data_simple_packing.cc b/src/accessor/grib_accessor_class_data_simple_packing.cc index 355067b25..87c0cbcca 100644 --- a/src/accessor/grib_accessor_class_data_simple_packing.cc +++ b/src/accessor/grib_accessor_class_data_simple_packing.cc @@ -21,15 +21,15 @@ void grib_accessor_data_simple_packing_t::init(const long v, grib_arguments* arg { grib_accessor_values_t::init(v, args); grib_handle* gh = grib_handle_of_accessor(this); - units_factor_ = grib_arguments_get_name(gh, args, carg_++); - units_bias_ = grib_arguments_get_name(gh, args, carg_++); - changing_precision_ = grib_arguments_get_name(gh, args, carg_++); - number_of_values_ = grib_arguments_get_name(gh, args, carg_++); - bits_per_value_ = grib_arguments_get_name(gh, args, carg_++); - reference_value_ = grib_arguments_get_name(gh, args, carg_++); - binary_scale_factor_ = grib_arguments_get_name(gh, args, carg_++); - decimal_scale_factor_ = grib_arguments_get_name(gh, args, carg_++); - optimize_scaling_factor_ = grib_arguments_get_name(gh, args, carg_++); + units_factor_ = args->get_name(gh, carg_++); + units_bias_ = args->get_name(gh, carg_++); + changing_precision_ = args->get_name(gh, carg_++); + number_of_values_ = args->get_name(gh, carg_++); + bits_per_value_ = args->get_name(gh, carg_++); + reference_value_ = args->get_name(gh, carg_++); + binary_scale_factor_ = args->get_name(gh, carg_++); + decimal_scale_factor_ = args->get_name(gh, carg_++); + optimize_scaling_factor_ = args->get_name(gh, carg_++); flags_ |= GRIB_ACCESSOR_FLAG_DATA; dirty_ = 1; } diff --git a/src/accessor/grib_accessor_class_decimal_precision.cc b/src/accessor/grib_accessor_class_decimal_precision.cc index cff70e669..6652279e7 100644 --- a/src/accessor/grib_accessor_class_decimal_precision.cc +++ b/src/accessor/grib_accessor_class_decimal_precision.cc @@ -18,10 +18,10 @@ void grib_accessor_decimal_precision_t::init(const long l, grib_arguments* args) grib_accessor_long_t::init(l, args); int n = 0; - bits_per_value_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++); - decimal_scale_factor_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++); - changing_precision_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++); - values_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++); + bits_per_value_ = args->get_name(grib_handle_of_accessor(this), n++); + decimal_scale_factor_ = args->get_name(grib_handle_of_accessor(this), n++); + changing_precision_ = args->get_name(grib_handle_of_accessor(this), n++); + values_ = args->get_name(grib_handle_of_accessor(this), n++); flags_ |= GRIB_ACCESSOR_FLAG_FUNCTION; length_ = 0; diff --git a/src/accessor/grib_accessor_class_dictionary.cc b/src/accessor/grib_accessor_class_dictionary.cc index 04086c416..1b56a5555 100644 --- a/src/accessor/grib_accessor_class_dictionary.cc +++ b/src/accessor/grib_accessor_class_dictionary.cc @@ -18,11 +18,11 @@ void grib_accessor_dictionary_t::init(const long len, grib_arguments* params) grib_accessor_gen_t::init(len, params); int n = 0; - dictionary_ = grib_arguments_get_string(grib_handle_of_accessor(this), params, n++); - key_ = grib_arguments_get_name(grib_handle_of_accessor(this), params, n++); - column_ = grib_arguments_get_long(grib_handle_of_accessor(this), params, n++); - masterDir_ = grib_arguments_get_name(grib_handle_of_accessor(this), params, n++); - localDir_ = grib_arguments_get_name(grib_handle_of_accessor(this), params, n++); + dictionary_ = params->get_string(grib_handle_of_accessor(this), n++); + key_ = params->get_name(grib_handle_of_accessor(this), n++); + column_ = params->get_long(grib_handle_of_accessor(this), n++); + masterDir_ = params->get_name(grib_handle_of_accessor(this), n++); + localDir_ = params->get_name(grib_handle_of_accessor(this), n++); length_ = 0; flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; diff --git a/src/accessor/grib_accessor_class_dirty.cc b/src/accessor/grib_accessor_class_dirty.cc index f743957f3..5d5fdc843 100644 --- a/src/accessor/grib_accessor_class_dirty.cc +++ b/src/accessor/grib_accessor_class_dirty.cc @@ -16,7 +16,7 @@ grib_accessor* grib_accessor_dirty = &_grib_accessor_dirty; void grib_accessor_dirty_t::init(const long l, grib_arguments* c) { grib_accessor_long_t::init(l, c); - accessor_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, 0); + accessor_ = c->get_name(grib_handle_of_accessor(this), 0); flags_ |= GRIB_ACCESSOR_FLAG_FUNCTION; flags_ |= GRIB_ACCESSOR_FLAG_HIDDEN; length_ = 0; diff --git a/src/accessor/grib_accessor_class_divdouble.cc b/src/accessor/grib_accessor_class_divdouble.cc index f590ca3a9..a280f041e 100644 --- a/src/accessor/grib_accessor_class_divdouble.cc +++ b/src/accessor/grib_accessor_class_divdouble.cc @@ -18,8 +18,8 @@ void grib_accessor_divdouble_t::init(const long l, grib_arguments* c) grib_accessor_double_t::init(l, c); int n = 0; - val_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - divisor_ = grib_arguments_get_double(grib_handle_of_accessor(this), c, n++); + val_ = c->get_name(grib_handle_of_accessor(this), n++); + divisor_ = c->get_double(grib_handle_of_accessor(this), n++); } int grib_accessor_divdouble_t::unpack_double(double* val, size_t* len) diff --git a/src/accessor/grib_accessor_class_element.cc b/src/accessor/grib_accessor_class_element.cc index 0889a6eb2..7e53b6a00 100644 --- a/src/accessor/grib_accessor_class_element.cc +++ b/src/accessor/grib_accessor_class_element.cc @@ -19,8 +19,8 @@ void grib_accessor_element_t::init(const long l, grib_arguments* c) grib_handle* hand = grib_handle_of_accessor(this); int n = 0; - array_ = grib_arguments_get_name(hand, c, n++); - element_ = grib_arguments_get_long(hand, c, n++); + array_ = c->get_name(hand, n++); + element_ = c->get_long(hand, n++); } static int check_element_index(const char* func, const char* array_name, long index, size_t size) diff --git a/src/accessor/grib_accessor_class_evaluate.cc b/src/accessor/grib_accessor_class_evaluate.cc index 9cca2b034..1e583cd11 100644 --- a/src/accessor/grib_accessor_class_evaluate.cc +++ b/src/accessor/grib_accessor_class_evaluate.cc @@ -23,9 +23,9 @@ void grib_accessor_evaluate_t::init(const long l, grib_arguments* c) int grib_accessor_evaluate_t::unpack_long(long* val, size_t* len) { grib_handle* h = grib_handle_of_accessor(this); - grib_expression* e = grib_arguments_get_expression(h, arg_, 0); + grib_expression* e = arg_->get_expression(h, 0); - int ret = grib_expression_evaluate_long(h, e, val); + int ret = e->evaluate_long(h, val); *len = 1; return ret; diff --git a/src/accessor/grib_accessor_class_expanded_descriptors.cc b/src/accessor/grib_accessor_class_expanded_descriptors.cc index c2f7518a1..7fe9b3e3a 100644 --- a/src/accessor/grib_accessor_class_expanded_descriptors.cc +++ b/src/accessor/grib_accessor_class_expanded_descriptors.cc @@ -34,17 +34,17 @@ void grib_accessor_expanded_descriptors_t::init(const long len, grib_arguments* grib_accessor_long_t::init(len, args); int n = 0; grib_handle* hand = grib_handle_of_accessor(this); - tablesAccessorName_ = grib_arguments_get_name(hand, args, n++); - expandedName_ = grib_arguments_get_name(hand, args, n++); - rank_ = grib_arguments_get_long(hand, args, n++); + tablesAccessorName_ = args->get_name(hand, n++); + expandedName_ = args->get_name(hand, n++); + rank_ = args->get_long(hand, n++); if (rank_ != 0) { expandedAccessor_ = dynamic_cast(grib_find_accessor(hand, expandedName_)); } else { expandedAccessor_ = 0; } - unexpandedDescriptors_ = grib_arguments_get_name(hand, args, n++); - sequence_ = grib_arguments_get_name(hand, args, n++); + unexpandedDescriptors_ = args->get_name(hand, n++); + sequence_ = args->get_name(hand, n++); do_expand_ = 1; expanded_ = 0; length_ = 0; diff --git a/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.cc b/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.cc index dfe77afcf..ae58d5463 100644 --- a/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.cc +++ b/src/accessor/grib_accessor_class_from_scale_factor_scaled_value.cc @@ -20,8 +20,8 @@ void grib_accessor_from_scale_factor_scaled_value_t::init(const long l, grib_arg int n = 0; grib_handle* hand = grib_handle_of_accessor(this); - scaleFactor_ = grib_arguments_get_name(hand, c, n++); - scaledValue_ = grib_arguments_get_name(hand, c, n++); // Can be scalar or array + scaleFactor_ = c->get_name(hand, n++); + scaledValue_ = c->get_name(hand, n++); // Can be scalar or array // ECC-979: Allow user to encode // flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; diff --git a/src/accessor/grib_accessor_class_g1_message_length.cc b/src/accessor/grib_accessor_class_g1_message_length.cc index d09f1dd0a..160db8cab 100644 --- a/src/accessor/grib_accessor_class_g1_message_length.cc +++ b/src/accessor/grib_accessor_class_g1_message_length.cc @@ -16,7 +16,7 @@ grib_accessor* grib_accessor_g1_message_length = &_grib_accessor_g1_message_leng void grib_accessor_g1_message_length_t::init(const long len, grib_arguments* args) { grib_accessor_section_length_t::init(len, args); - sec4_length_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, 0); + sec4_length_ = args->get_name(grib_handle_of_accessor(this), 0); } int grib_get_g1_message_size(grib_handle* h, grib_accessor* tl, grib_accessor* s4, diff --git a/src/accessor/grib_accessor_class_g1_section4_length.cc b/src/accessor/grib_accessor_class_g1_section4_length.cc index 0387b9fc8..fde6f8c5d 100644 --- a/src/accessor/grib_accessor_class_g1_section4_length.cc +++ b/src/accessor/grib_accessor_class_g1_section4_length.cc @@ -16,7 +16,7 @@ grib_accessor* grib_accessor_g1_section4_length = &_grib_accessor_g1_section4_le void grib_accessor_g1_section4_length_t::init(const long len, grib_arguments* args) { grib_accessor_section_length_t::init(len, args); - total_length_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, 0); + total_length_ = args->get_name(grib_handle_of_accessor(this), 0); } int grib_accessor_g1_section4_length_t::pack_long(const long* val, size_t* len) diff --git a/src/accessor/grib_accessor_class_g1bitmap.cc b/src/accessor/grib_accessor_class_g1bitmap.cc index 6c9e6461f..e11d26728 100644 --- a/src/accessor/grib_accessor_class_g1bitmap.cc +++ b/src/accessor/grib_accessor_class_g1bitmap.cc @@ -16,7 +16,7 @@ grib_accessor* grib_accessor_g1bitmap = &_grib_accessor_g1bitmap; void grib_accessor_g1bitmap_t::init(const long len, grib_arguments* arg) { grib_accessor_bitmap_t::init(len, arg); - unusedBits_ = grib_arguments_get_name(grib_handle_of_accessor(this), arg, 4); + unusedBits_ = arg->get_name(grib_handle_of_accessor(this), 4); } int grib_accessor_g1bitmap_t::pack_double(const double* val, size_t* len) diff --git a/src/accessor/grib_accessor_class_g1date.cc b/src/accessor/grib_accessor_class_g1date.cc index 167265361..15d05722a 100644 --- a/src/accessor/grib_accessor_class_g1date.cc +++ b/src/accessor/grib_accessor_class_g1date.cc @@ -19,10 +19,10 @@ void grib_accessor_g1date_t::init(const long l, grib_arguments* c) grib_handle* hand = grib_handle_of_accessor(this); int n = 0; - century_ = grib_arguments_get_name(hand, c, n++); - year_ = grib_arguments_get_name(hand, c, n++); - month_ = grib_arguments_get_name(hand, c, n++); - day_ = grib_arguments_get_name(hand, c, n++); + century_ = c->get_name(hand, n++); + year_ = c->get_name(hand, n++); + month_ = c->get_name(hand, n++); + day_ = c->get_name(hand, n++); } int grib_accessor_g1date_t::unpack_long(long* val, size_t* len) diff --git a/src/accessor/grib_accessor_class_g1end_of_interval_monthly.cc b/src/accessor/grib_accessor_class_g1end_of_interval_monthly.cc index 43f7dbbb4..acb5f020b 100644 --- a/src/accessor/grib_accessor_class_g1end_of_interval_monthly.cc +++ b/src/accessor/grib_accessor_class_g1end_of_interval_monthly.cc @@ -18,7 +18,7 @@ void grib_accessor_g1end_of_interval_monthly_t::init(const long l, grib_argument grib_accessor_abstract_vector_t::init(l, c); int n = 0; - verifyingMonth_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); + verifyingMonth_ = c->get_name(grib_handle_of_accessor(this), n++); flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; flags_ |= GRIB_ACCESSOR_FLAG_FUNCTION; flags_ |= GRIB_ACCESSOR_FLAG_HIDDEN; diff --git a/src/accessor/grib_accessor_class_g1forecastmonth.cc b/src/accessor/grib_accessor_class_g1forecastmonth.cc index 6f9e00a64..43f71f0c1 100644 --- a/src/accessor/grib_accessor_class_g1forecastmonth.cc +++ b/src/accessor/grib_accessor_class_g1forecastmonth.cc @@ -18,14 +18,14 @@ void grib_accessor_g1forecastmonth_t::init(const long l, grib_arguments* c) grib_accessor_long_t::init(l, c); grib_handle* h = grib_handle_of_accessor(this); int n = 0; - const int count = grib_arguments_get_count(c); + const int count = c->get_count(); if (count == 6) { /* GRIB1 case -- this needs to be refactored */ - verification_yearmonth_ = grib_arguments_get_name(h, c, n++); - base_date_ = grib_arguments_get_name(h, c, n++); - day_ = grib_arguments_get_name(h, c, n++); - hour_ = grib_arguments_get_name(h, c, n++); - fcmonth_ = grib_arguments_get_name(h, c, n++); - check_ = grib_arguments_get_name(h, c, n++); + verification_yearmonth_ = c->get_name(h, n++); + base_date_ = c->get_name(h, n++); + day_ = c->get_name(h, n++); + hour_ = c->get_name(h, n++); + fcmonth_ = c->get_name(h, n++); + check_ = c->get_name(h, n++); } } diff --git a/src/accessor/grib_accessor_class_g1monthlydate.cc b/src/accessor/grib_accessor_class_g1monthlydate.cc index 851f27988..602442bbb 100644 --- a/src/accessor/grib_accessor_class_g1monthlydate.cc +++ b/src/accessor/grib_accessor_class_g1monthlydate.cc @@ -18,7 +18,7 @@ void grib_accessor_g1monthlydate_t::init(const long l, grib_arguments* c) grib_accessor_long_t::init(l, c); int n = 0; - date_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); + date_ = c->get_name(grib_handle_of_accessor(this), n++); flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; } diff --git a/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.cc b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.cc index e77e85bd1..c7697ecdf 100644 --- a/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.cc +++ b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_complex.cc @@ -17,14 +17,14 @@ void grib_accessor_g1number_of_coded_values_sh_complex_t::init(const long l, gri { grib_accessor_long_t::init(l, c); int n = 0; - bitsPerValue_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - offsetBeforeData_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - offsetAfterData_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - unusedBits_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - numberOfValues_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - JS_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - KS_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - MS_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); + bitsPerValue_ = c->get_name(grib_handle_of_accessor(this), n++); + offsetBeforeData_ = c->get_name(grib_handle_of_accessor(this), n++); + offsetAfterData_ = c->get_name(grib_handle_of_accessor(this), n++); + unusedBits_ = c->get_name(grib_handle_of_accessor(this), n++); + numberOfValues_ = c->get_name(grib_handle_of_accessor(this), n++); + JS_ = c->get_name(grib_handle_of_accessor(this), n++); + KS_ = c->get_name(grib_handle_of_accessor(this), n++); + MS_ = c->get_name(grib_handle_of_accessor(this), n++); flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; flags_ |= GRIB_ACCESSOR_FLAG_FUNCTION; length_ = 0; diff --git a/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.cc b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.cc index 8821f6020..2667ed88b 100644 --- a/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.cc +++ b/src/accessor/grib_accessor_class_g1number_of_coded_values_sh_simple.cc @@ -17,11 +17,11 @@ void grib_accessor_g1number_of_coded_values_sh_simple_t::init(const long l, grib { grib_accessor_long_t::init(l, c); int n = 0; - bitsPerValue_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - offsetBeforeData_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - offsetAfterData_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - unusedBits_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - numberOfValues_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); + bitsPerValue_ = c->get_name(grib_handle_of_accessor(this), n++); + offsetBeforeData_ = c->get_name(grib_handle_of_accessor(this), n++); + offsetAfterData_ = c->get_name(grib_handle_of_accessor(this), n++); + unusedBits_ = c->get_name(grib_handle_of_accessor(this), n++); + numberOfValues_ = c->get_name(grib_handle_of_accessor(this), n++); flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; flags_ |= GRIB_ACCESSOR_FLAG_FUNCTION; length_ = 0; diff --git a/src/accessor/grib_accessor_class_g1step_range.cc b/src/accessor/grib_accessor_class_g1step_range.cc index ce82f455f..ab1824fd5 100644 --- a/src/accessor/grib_accessor_class_g1step_range.cc +++ b/src/accessor/grib_accessor_class_g1step_range.cc @@ -18,13 +18,13 @@ void grib_accessor_g1step_range_t::init(const long l, grib_arguments* c) grib_accessor_abstract_long_vector_t::init(l, c); grib_handle* h = grib_handle_of_accessor(this); int n = 0; - p1_ = grib_arguments_get_name(h, c, n++); - p2_ = grib_arguments_get_name(h, c, n++); - timeRangeIndicator_ = grib_arguments_get_name(h, c, n++); - unit_ = grib_arguments_get_name(h, c, n++); - step_unit_ = grib_arguments_get_name(h, c, n++); - stepType_ = grib_arguments_get_name(h, c, n++); - patch_fp_precip_ = grib_arguments_get_name(h, c, n++); + p1_ = c->get_name(h, n++); + p2_ = c->get_name(h, n++); + timeRangeIndicator_ = c->get_name(h, n++); + unit_ = c->get_name(h, n++); + step_unit_ = c->get_name(h, n++); + stepType_ = c->get_name(h, n++); + patch_fp_precip_ = c->get_name(h, n++); error_on_units_ = 1; number_of_elements_ = 2; diff --git a/src/accessor/grib_accessor_class_g1verificationdate.cc b/src/accessor/grib_accessor_class_g1verificationdate.cc index 9cfa720d6..de0217414 100644 --- a/src/accessor/grib_accessor_class_g1verificationdate.cc +++ b/src/accessor/grib_accessor_class_g1verificationdate.cc @@ -18,9 +18,9 @@ void grib_accessor_g1verificationdate_t::init(const long l, grib_arguments* c) grib_accessor_long_t::init(l, c); int n = 0; - date_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - time_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - step_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); + date_ = c->get_name(grib_handle_of_accessor(this), n++); + time_ = c->get_name(grib_handle_of_accessor(this), n++); + step_ = c->get_name(grib_handle_of_accessor(this), n++); flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; } diff --git a/src/accessor/grib_accessor_class_g2_aerosol.cc b/src/accessor/grib_accessor_class_g2_aerosol.cc index 641e4e125..4f0ad1c20 100644 --- a/src/accessor/grib_accessor_class_g2_aerosol.cc +++ b/src/accessor/grib_accessor_class_g2_aerosol.cc @@ -19,9 +19,9 @@ void grib_accessor_g2_aerosol_t::init(const long l, grib_arguments* c) grib_handle* hand = grib_handle_of_accessor(this); int n = 0; - productDefinitionTemplateNumber_ = grib_arguments_get_name(hand, c, n++); - stepType_ = grib_arguments_get_name(hand, c, n++); - optical_ = grib_arguments_get_long(hand, c, n++); + productDefinitionTemplateNumber_ = c->get_name(hand, n++); + stepType_ = c->get_name(hand, n++); + optical_ = c->get_long(hand, n++); } int grib_accessor_g2_aerosol_t::unpack_long(long* val, size_t* len) diff --git a/src/accessor/grib_accessor_class_g2_chemical.cc b/src/accessor/grib_accessor_class_g2_chemical.cc index c86240aa9..87cdbdb09 100644 --- a/src/accessor/grib_accessor_class_g2_chemical.cc +++ b/src/accessor/grib_accessor_class_g2_chemical.cc @@ -28,9 +28,9 @@ void grib_accessor_g2_chemical_t::init(const long l, grib_arguments* c) grib_handle* hand = grib_handle_of_accessor(this); int n = 0; - productDefinitionTemplateNumber_ = grib_arguments_get_name(hand, c, n++); - stepType_ = grib_arguments_get_name(hand, c, n++); - chemical_type_ = grib_arguments_get_long(hand, c, n++); + productDefinitionTemplateNumber_ = c->get_name(hand, n++); + stepType_ = c->get_name(hand, n++); + chemical_type_ = c->get_long(hand, n++); } int grib_accessor_g2_chemical_t::unpack_long(long* val, size_t* len) diff --git a/src/accessor/grib_accessor_class_g2_eps.cc b/src/accessor/grib_accessor_class_g2_eps.cc index 31c4bf6b9..2311dc7a1 100644 --- a/src/accessor/grib_accessor_class_g2_eps.cc +++ b/src/accessor/grib_accessor_class_g2_eps.cc @@ -18,11 +18,11 @@ void grib_accessor_g2_eps_t::init(const long l, grib_arguments* c) grib_accessor_unsigned_t::init(l, c); int n = 0; - productDefinitionTemplateNumber_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - type_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - stream_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - stepType_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - derivedForecast_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); + productDefinitionTemplateNumber_ = c->get_name(grib_handle_of_accessor(this), n++); + type_ = c->get_name(grib_handle_of_accessor(this), n++); + stream_ = c->get_name(grib_handle_of_accessor(this), n++); + stepType_ = c->get_name(grib_handle_of_accessor(this), n++); + derivedForecast_ = c->get_name(grib_handle_of_accessor(this), n++); } int grib_accessor_g2_eps_t::unpack_long(long* val, size_t* len) diff --git a/src/accessor/grib_accessor_class_g2_mars_labeling.cc b/src/accessor/grib_accessor_class_g2_mars_labeling.cc index 2ec962251..0991f4d35 100644 --- a/src/accessor/grib_accessor_class_g2_mars_labeling.cc +++ b/src/accessor/grib_accessor_class_g2_mars_labeling.cc @@ -19,16 +19,16 @@ void grib_accessor_g2_mars_labeling_t::init(const long l, grib_arguments* c) int n = 0; grib_handle* hand = grib_handle_of_accessor(this); - index_ = grib_arguments_get_long(hand, c, n++); - the_class_ = grib_arguments_get_name(hand, c, n++); - type_ = grib_arguments_get_name(hand, c, n++); - stream_ = grib_arguments_get_name(hand, c, n++); - expver_ = grib_arguments_get_name(hand, c, n++); - typeOfProcessedData_ = grib_arguments_get_name(hand, c, n++); - productDefinitionTemplateNumber_ = grib_arguments_get_name(hand, c, n++); - stepType_ = grib_arguments_get_name(hand, c, n++); - derivedForecast_ = grib_arguments_get_name(hand, c, n++); - typeOfGeneratingProcess_ = grib_arguments_get_name(hand, c, n++); + index_ = c->get_long(hand, n++); + the_class_ = c->get_name(hand, n++); + type_ = c->get_name(hand, n++); + stream_ = c->get_name(hand, n++); + expver_ = c->get_name(hand, n++); + typeOfProcessedData_ = c->get_name(hand, n++); + productDefinitionTemplateNumber_ = c->get_name(hand, n++); + stepType_ = c->get_name(hand, n++); + derivedForecast_ = c->get_name(hand, n++); + typeOfGeneratingProcess_ = c->get_name(hand, n++); } int grib_accessor_g2_mars_labeling_t::unpack_long(long* val, size_t* len) diff --git a/src/accessor/grib_accessor_class_g2bitmap.cc b/src/accessor/grib_accessor_class_g2bitmap.cc index 6a5486981..08f47fe6d 100644 --- a/src/accessor/grib_accessor_class_g2bitmap.cc +++ b/src/accessor/grib_accessor_class_g2bitmap.cc @@ -17,7 +17,7 @@ void grib_accessor_g2bitmap_t::init(const long len, grib_arguments* arg) { grib_accessor_bitmap_t::init(len, arg); - numberOfValues_ = grib_arguments_get_name(grib_handle_of_accessor(this), arg, 4); + numberOfValues_ = arg->get_name(grib_handle_of_accessor(this), 4); } // For speed use a local static function diff --git a/src/accessor/grib_accessor_class_g2bitmap_present.cc b/src/accessor/grib_accessor_class_g2bitmap_present.cc index 47c91d330..a7257bfe5 100644 --- a/src/accessor/grib_accessor_class_g2bitmap_present.cc +++ b/src/accessor/grib_accessor_class_g2bitmap_present.cc @@ -17,7 +17,7 @@ void grib_accessor_g2bitmap_present_t::init(const long l, grib_arguments* c) { grib_accessor_long_t::init(l, c); int n = 0; - bitmapIndicator_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); + bitmapIndicator_ = c->get_name(grib_handle_of_accessor(this), n++); length_ = 0; } diff --git a/src/accessor/grib_accessor_class_g2date.cc b/src/accessor/grib_accessor_class_g2date.cc index 4728811c7..8a5ce4f71 100644 --- a/src/accessor/grib_accessor_class_g2date.cc +++ b/src/accessor/grib_accessor_class_g2date.cc @@ -18,9 +18,9 @@ void grib_accessor_g2date_t::init(const long l, grib_arguments* c) grib_accessor_long_t::init(l, c); int n = 0; - year_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - month_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - day_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); + year_ = c->get_name(grib_handle_of_accessor(this), n++); + month_ = c->get_name(grib_handle_of_accessor(this), n++); + day_ = c->get_name(grib_handle_of_accessor(this), n++); } int grib_accessor_g2date_t::unpack_long(long* val, size_t* len) diff --git a/src/accessor/grib_accessor_class_g2end_step.cc b/src/accessor/grib_accessor_class_g2end_step.cc index 576553c00..5f9cf19c2 100644 --- a/src/accessor/grib_accessor_class_g2end_step.cc +++ b/src/accessor/grib_accessor_class_g2end_step.cc @@ -22,27 +22,27 @@ void grib_accessor_g2end_step_t::init(const long l, grib_arguments* c) int n = 0; grib_handle* h = grib_handle_of_accessor(this); - start_step_value_ = grib_arguments_get_name(h, c, n++); - step_units_ = grib_arguments_get_name(h, c, n++); + start_step_value_ = c->get_name(h, n++); + step_units_ = c->get_name(h, n++); - year_ = grib_arguments_get_name(h, c, n++); - month_ = grib_arguments_get_name(h, c, n++); - day_ = grib_arguments_get_name(h, c, n++); - hour_ = grib_arguments_get_name(h, c, n++); - minute_ = grib_arguments_get_name(h, c, n++); - second_ = grib_arguments_get_name(h, c, n++); + year_ = c->get_name(h, n++); + month_ = c->get_name(h, n++); + day_ = c->get_name(h, n++); + hour_ = c->get_name(h, n++); + minute_ = c->get_name(h, n++); + second_ = c->get_name(h, n++); - year_of_end_of_interval_ = grib_arguments_get_name(h, c, n++); - month_of_end_of_interval_ = grib_arguments_get_name(h, c, n++); - day_of_end_of_interval_ = grib_arguments_get_name(h, c, n++); - hour_of_end_of_interval_ = grib_arguments_get_name(h, c, n++); - minute_of_end_of_interval_ = grib_arguments_get_name(h, c, n++); - second_of_end_of_interval_ = grib_arguments_get_name(h, c, n++); + year_of_end_of_interval_ = c->get_name(h, n++); + month_of_end_of_interval_ = c->get_name(h, n++); + day_of_end_of_interval_ = c->get_name(h, n++); + hour_of_end_of_interval_ = c->get_name(h, n++); + minute_of_end_of_interval_ = c->get_name(h, n++); + second_of_end_of_interval_ = c->get_name(h, n++); - time_range_unit_ = grib_arguments_get_name(h, c, n++); - time_range_value_ = grib_arguments_get_name(h, c, n++); - typeOfTimeIncrement_ = grib_arguments_get_name(h, c, n++); - numberOfTimeRanges_ = grib_arguments_get_name(h, c, n++); + time_range_unit_ = c->get_name(h, n++); + time_range_value_ = c->get_name(h, n++); + typeOfTimeIncrement_ = c->get_name(h, n++); + numberOfTimeRanges_ = c->get_name(h, n++); } void grib_accessor_g2end_step_t::dump(grib_dumper* dumper) diff --git a/src/accessor/grib_accessor_class_g2grid.cc b/src/accessor/grib_accessor_class_g2grid.cc index 6dddc5a3f..725ace107 100644 --- a/src/accessor/grib_accessor_class_g2grid.cc +++ b/src/accessor/grib_accessor_class_g2grid.cc @@ -19,14 +19,14 @@ void grib_accessor_g2grid_t::init(const long l, grib_arguments* c) grib_handle* hand = grib_handle_of_accessor(this); int n = 0; - latitude_first_ = grib_arguments_get_name(hand, c, n++); - longitude_first_ = grib_arguments_get_name(hand, c, n++); - latitude_last_ = grib_arguments_get_name(hand, c, n++); - longitude_last_ = grib_arguments_get_name(hand, c, n++); - i_increment_ = grib_arguments_get_name(hand, c, n++); - j_increment_ = grib_arguments_get_name(hand, c, n++); - basic_angle_ = grib_arguments_get_name(hand, c, n++); - sub_division_ = grib_arguments_get_name(hand, c, n++); + latitude_first_ = c->get_name(hand, n++); + longitude_first_ = c->get_name(hand, n++); + latitude_last_ = c->get_name(hand, n++); + longitude_last_ = c->get_name(hand, n++); + i_increment_ = c->get_name(hand, n++); + j_increment_ = c->get_name(hand, n++); + basic_angle_ = c->get_name(hand, n++); + sub_division_ = c->get_name(hand, n++); flags_ |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC | GRIB_ACCESSOR_FLAG_READ_ONLY; } diff --git a/src/accessor/grib_accessor_class_g2latlon.cc b/src/accessor/grib_accessor_class_g2latlon.cc index 14ba5f5c5..6a4e0e4e2 100644 --- a/src/accessor/grib_accessor_class_g2latlon.cc +++ b/src/accessor/grib_accessor_class_g2latlon.cc @@ -19,9 +19,9 @@ void grib_accessor_g2latlon_t::init(const long l, grib_arguments* c) grib_accessor_double_t::init(l, c); int n = 0; - grid_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - index_ = grib_arguments_get_long(grib_handle_of_accessor(this), c, n++); - given_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); + grid_ = c->get_name(grib_handle_of_accessor(this), n++); + index_ = c->get_long(grib_handle_of_accessor(this), n++); + given_ = c->get_name(grib_handle_of_accessor(this), n++); } int grib_accessor_g2latlon_t::unpack_double(double* val, size_t* len) diff --git a/src/accessor/grib_accessor_class_g2level.cc b/src/accessor/grib_accessor_class_g2level.cc index 05dd07b26..84767bf12 100644 --- a/src/accessor/grib_accessor_class_g2level.cc +++ b/src/accessor/grib_accessor_class_g2level.cc @@ -19,10 +19,10 @@ void grib_accessor_g2level_t::init(const long l, grib_arguments* c) grib_handle* hand = grib_handle_of_accessor(this); int n = 0; - type_first_ = grib_arguments_get_name(hand, c, n++); - scale_first_ = grib_arguments_get_name(hand, c, n++); - value_first_ = grib_arguments_get_name(hand, c, n++); - pressure_units_ = grib_arguments_get_name(hand, c, n++); + type_first_ = c->get_name(hand, n++); + scale_first_ = c->get_name(hand, n++); + value_first_ = c->get_name(hand, n++); + pressure_units_ = c->get_name(hand, n++); // See ECC-1644 flags_ |= GRIB_ACCESSOR_FLAG_COPY_IF_CHANGING_EDITION; diff --git a/src/accessor/grib_accessor_class_g2lon.cc b/src/accessor/grib_accessor_class_g2lon.cc index 63b6d8e6a..23a17eeef 100644 --- a/src/accessor/grib_accessor_class_g2lon.cc +++ b/src/accessor/grib_accessor_class_g2lon.cc @@ -19,7 +19,7 @@ void grib_accessor_g2lon_t::init(const long l, grib_arguments* c) grib_accessor_double_t::init(l, c); int n = 0; - longitude_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); + longitude_ = c->get_name(grib_handle_of_accessor(this), n++); } int grib_accessor_g2lon_t::unpack_double(double* val, size_t* len) diff --git a/src/accessor/grib_accessor_class_g2step_range.cc b/src/accessor/grib_accessor_class_g2step_range.cc index adf08b7d1..c51a3efbd 100644 --- a/src/accessor/grib_accessor_class_g2step_range.cc +++ b/src/accessor/grib_accessor_class_g2step_range.cc @@ -22,8 +22,8 @@ void grib_accessor_g2step_range_t::init(const long l, grib_arguments* c) int n = 0; - start_step_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - end_step_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); + start_step_ = c->get_name(grib_handle_of_accessor(this), n++); + end_step_ = c->get_name(grib_handle_of_accessor(this), n++); length_ = 0; } diff --git a/src/accessor/grib_accessor_class_gaussian_grid_name.cc b/src/accessor/grib_accessor_class_gaussian_grid_name.cc index f8a34e06f..c8eed586f 100644 --- a/src/accessor/grib_accessor_class_gaussian_grid_name.cc +++ b/src/accessor/grib_accessor_class_gaussian_grid_name.cc @@ -18,9 +18,9 @@ void grib_accessor_gaussian_grid_name_t::init(const long len, grib_arguments* ar grib_accessor_gen_t::init(len, arg); int n = 0; - N_ = grib_arguments_get_name(parent_->h, arg, n++); - Ni_ = grib_arguments_get_name(parent_->h, arg, n++); - isOctahedral_ = grib_arguments_get_name(parent_->h, arg, n++); + N_ = arg->get_name(parent_->h, n++); + Ni_ = arg->get_name(parent_->h, n++); + isOctahedral_ = arg->get_name(parent_->h, n++); length_ = 0; flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; flags_ |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; diff --git a/src/accessor/grib_accessor_class_gds_is_present.cc b/src/accessor/grib_accessor_class_gds_is_present.cc index 36a2c154c..99efbb3b6 100644 --- a/src/accessor/grib_accessor_class_gds_is_present.cc +++ b/src/accessor/grib_accessor_class_gds_is_present.cc @@ -18,10 +18,10 @@ void grib_accessor_gds_is_present_t::init(const long l, grib_arguments* c) grib_accessor_long_t::init(l, c); int n = 0; grib_handle* h = grib_handle_of_accessor(this); - gds_present_ = grib_arguments_get_name(h, c, n++); - grid_definition_ = grib_arguments_get_name(h, c, n++); - bitmap_present_ = grib_arguments_get_name(h, c, n++); - values_ = grib_arguments_get_name(h, c, n++); + gds_present_ = c->get_name(h, n++); + grid_definition_ = c->get_name(h, n++); + bitmap_present_ = c->get_name(h, n++); + values_ = c->get_name(h, n++); flags_ |= GRIB_ACCESSOR_FLAG_FUNCTION; flags_ |= GRIB_ACCESSOR_FLAG_HIDDEN; diff --git a/src/accessor/grib_accessor_class_gds_not_present_bitmap.cc b/src/accessor/grib_accessor_class_gds_not_present_bitmap.cc index f42438b97..974f2f23b 100644 --- a/src/accessor/grib_accessor_class_gds_not_present_bitmap.cc +++ b/src/accessor/grib_accessor_class_gds_not_present_bitmap.cc @@ -19,11 +19,11 @@ void grib_accessor_gds_not_present_bitmap_t::init(const long v, grib_arguments* int n = 0; grib_handle* hand = grib_handle_of_accessor(this); - missing_value_ = grib_arguments_get_name(hand, args, n++); - number_of_values_ = grib_arguments_get_name(hand, args, n++); - number_of_points_ = grib_arguments_get_name(hand, args, n++); - latitude_of_first_point_ = grib_arguments_get_name(hand, args, n++); - ni_ = grib_arguments_get_name(hand, args, n++); + missing_value_ = args->get_name(hand, n++); + number_of_values_ = args->get_name(hand, n++); + number_of_points_ = args->get_name(hand, n++); + latitude_of_first_point_ = args->get_name(hand, n++); + ni_ = args->get_name(hand, n++); length_ = 0; } diff --git a/src/accessor/grib_accessor_class_gen.cc b/src/accessor/grib_accessor_class_gen.cc index 167e48764..87df8e981 100644 --- a/src/accessor/grib_accessor_class_gen.cc +++ b/src/accessor/grib_accessor_class_gen.cc @@ -37,24 +37,24 @@ void grib_accessor_gen_t::init(const long len, grib_arguments* param) int ret = 0; double d; char tmp[1024]; - grib_expression* expression = grib_arguments_get_expression(grib_handle_of_accessor(this), act->default_value, 0); - int type = grib_expression_native_type(grib_handle_of_accessor(this), expression); + grib_expression* expression = act->default_value->get_expression(grib_handle_of_accessor(this), 0); + int type = expression->native_type(grib_handle_of_accessor(this)); switch (type) { // TODO(maee): add single-precision case case GRIB_TYPE_DOUBLE: - grib_expression_evaluate_double(grib_handle_of_accessor(this), expression, &d); + expression->evaluate_double(grib_handle_of_accessor(this), &d); pack_double(&d, &s_len); break; case GRIB_TYPE_LONG: - grib_expression_evaluate_long(grib_handle_of_accessor(this), expression, &l); + expression->evaluate_long(grib_handle_of_accessor(this), &l); pack_long(&l, &s_len); break; default: s_len = sizeof(tmp); - p = grib_expression_evaluate_string(grib_handle_of_accessor(this), expression, tmp, &s_len, &ret); + p = expression->evaluate_string(grib_handle_of_accessor(this), tmp, &s_len, &ret); if (ret != GRIB_SUCCESS) { grib_context_log(context_, GRIB_LOG_ERROR, "Unable to evaluate %s as string", name_); Assert(0); @@ -259,13 +259,13 @@ int grib_accessor_gen_t::pack_expression(grib_expression* e) grib_handle* hand = grib_handle_of_accessor(this); // Use the native type of the expression not the accessor - switch (grib_expression_native_type(hand, e)) { + switch (e->native_type(hand)) { case GRIB_TYPE_LONG: { len = 1; - ret = grib_expression_evaluate_long(hand, e, &lval); + ret = e->evaluate_long(hand, &lval); if (ret != GRIB_SUCCESS) { grib_context_log(context_, GRIB_LOG_ERROR, "Unable to set %s as long (from %s)", - name_, e->cclass->name); + name_, e->class_name()); return ret; } /*if (hand->context->debug) @@ -275,10 +275,10 @@ int grib_accessor_gen_t::pack_expression(grib_expression* e) case GRIB_TYPE_DOUBLE: { len = 1; - ret = grib_expression_evaluate_double(hand, e, &dval); + ret = e->evaluate_double(hand, &dval); if (ret != GRIB_SUCCESS) { grib_context_log(context_, GRIB_LOG_ERROR, "Unable to set %s as double (from %s)", - name_, e->cclass->name); + name_, e->class_name()); return ret; } /*if (hand->context->debug) @@ -289,10 +289,10 @@ int grib_accessor_gen_t::pack_expression(grib_expression* e) case GRIB_TYPE_STRING: { char tmp[1024]; len = sizeof(tmp); - cval = grib_expression_evaluate_string(hand, e, tmp, &len, &ret); + cval = e->evaluate_string(hand, tmp, &len, &ret); if (ret != GRIB_SUCCESS) { grib_context_log(context_, GRIB_LOG_ERROR, "Unable to set %s as string (from %s)", - name_, e->cclass->name); + name_, e->class_name()); return ret; } len = strlen(cval); diff --git a/src/accessor/grib_accessor_class_getenv.cc b/src/accessor/grib_accessor_class_getenv.cc index 7fea4feb2..2bc3eee3a 100644 --- a/src/accessor/grib_accessor_class_getenv.cc +++ b/src/accessor/grib_accessor_class_getenv.cc @@ -18,8 +18,8 @@ void grib_accessor_getenv_t::init(const long l, grib_arguments* args) grib_accessor_ascii_t::init(l, args); static char undefined[] = "undefined"; - envvar_ = grib_arguments_get_string(grib_handle_of_accessor(this), args, 0); - default_value_ = grib_arguments_get_string(grib_handle_of_accessor(this), args, 1); + envvar_ = args->get_string(grib_handle_of_accessor(this), 0); + default_value_ = args->get_string(grib_handle_of_accessor(this), 1); if (!default_value_) default_value_ = undefined; value_ = 0; diff --git a/src/accessor/grib_accessor_class_global_gaussian.cc b/src/accessor/grib_accessor_class_global_gaussian.cc index 55511c7e8..48a93771c 100644 --- a/src/accessor/grib_accessor_class_global_gaussian.cc +++ b/src/accessor/grib_accessor_class_global_gaussian.cc @@ -19,17 +19,17 @@ void grib_accessor_global_gaussian_t::init(const long l, grib_arguments* c) int n = 0; grib_handle* h = grib_handle_of_accessor(this); - N_ = grib_arguments_get_name(h, c, n++); - Ni_ = grib_arguments_get_name(h, c, n++); - di_ = grib_arguments_get_name(h, c, n++); - latfirst_ = grib_arguments_get_name(h, c, n++); - lonfirst_ = grib_arguments_get_name(h, c, n++); - latlast_ = grib_arguments_get_name(h, c, n++); - lonlast_ = grib_arguments_get_name(h, c, n++); - plpresent_ = grib_arguments_get_name(h, c, n++); - pl_ = grib_arguments_get_name(h, c, n++); - basic_angle_ = grib_arguments_get_name(h, c, n++); - subdivision_ = grib_arguments_get_name(h, c, n++); + N_ = c->get_name(h, n++); + Ni_ = c->get_name(h, n++); + di_ = c->get_name(h, n++); + latfirst_ = c->get_name(h, n++); + lonfirst_ = c->get_name(h, n++); + latlast_ = c->get_name(h, n++); + lonlast_ = c->get_name(h, n++); + plpresent_ = c->get_name(h, n++); + pl_ = c->get_name(h, n++); + basic_angle_ = c->get_name(h, n++); + subdivision_ = c->get_name(h, n++); } int grib_accessor_global_gaussian_t::unpack_long(long* val, size_t* len) diff --git a/src/accessor/grib_accessor_class_group.cc b/src/accessor/grib_accessor_class_group.cc index 2b98e6b46..b011faef0 100644 --- a/src/accessor/grib_accessor_class_group.cc +++ b/src/accessor/grib_accessor_class_group.cc @@ -20,7 +20,7 @@ void grib_accessor_group_t::init(const long len, grib_arguments* arg) size_t i = 0; unsigned char* v; - const char* s = grib_arguments_get_string(grib_handle_of_accessor(this), arg, 0); + const char* s = arg ? arg->get_string(grib_handle_of_accessor(this), 0) : nullptr; if (s && strlen(s) > 1) { grib_context_log(context_, GRIB_LOG_WARNING, diff --git a/src/accessor/grib_accessor_class_gts_header.cc b/src/accessor/grib_accessor_class_gts_header.cc index 591e6e783..a240bc63b 100644 --- a/src/accessor/grib_accessor_class_gts_header.cc +++ b/src/accessor/grib_accessor_class_gts_header.cc @@ -16,10 +16,8 @@ grib_accessor* grib_accessor_gts_header = &_grib_accessor_gts_header; void grib_accessor_gts_header_t::init(const long l, grib_arguments* c) { grib_accessor_ascii_t::init(l, c); - gts_offset_ = -1; - gts_length_ = -1; - gts_offset_ = grib_arguments_get_long(grib_handle_of_accessor(this), c, 0); - gts_length_ = grib_arguments_get_long(grib_handle_of_accessor(this), c, 1); + gts_offset_ = c ? c->get_long(grib_handle_of_accessor(this), 0) : 0; + gts_length_ = c ? c->get_long(grib_handle_of_accessor(this), 1) : 0; flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; } diff --git a/src/accessor/grib_accessor_class_ibmfloat.cc b/src/accessor/grib_accessor_class_ibmfloat.cc index e0d087f3c..3d74576c5 100644 --- a/src/accessor/grib_accessor_class_ibmfloat.cc +++ b/src/accessor/grib_accessor_class_ibmfloat.cc @@ -102,7 +102,7 @@ int grib_accessor_ibmfloat_t::pack_double(const double* val, size_t* len) for (i = 0; i < rlen; i++) { grib_encode_unsigned_longb(buf, grib_ibm_to_long(val[i]), &off, 32); } - ret = grib_set_long_internal(grib_handle_of_accessor(this), grib_arguments_get_name(parent_->h, arg_, 0), rlen); + ret = grib_set_long_internal(grib_handle_of_accessor(this), arg_->get_name(parent_->h, 0), rlen); if (ret == GRIB_SUCCESS) grib_buffer_replace(this, buf, buflen, 1, 1); @@ -128,7 +128,7 @@ int grib_accessor_ibmfloat_t::value_count(long* len) *len = 1; return 0; } - return grib_get_long_internal(grib_handle_of_accessor(this), grib_arguments_get_name(parent_->h, arg_, 0), len); + return grib_get_long_internal(grib_handle_of_accessor(this), arg_->get_name(parent_->h, 0), len); } long grib_accessor_ibmfloat_t::byte_offset() diff --git a/src/accessor/grib_accessor_class_ieeefloat.cc b/src/accessor/grib_accessor_class_ieeefloat.cc index dc242b72a..31e7cd164 100644 --- a/src/accessor/grib_accessor_class_ieeefloat.cc +++ b/src/accessor/grib_accessor_class_ieeefloat.cc @@ -32,7 +32,7 @@ int grib_accessor_ieeefloat_t::value_count(long* len) *len = 1; return 0; } - return grib_get_long_internal(grib_handle_of_accessor(this), grib_arguments_get_name(parent_->h, arg_, 0), len); + return grib_get_long_internal(grib_handle_of_accessor(this), arg_->get_name(parent_->h, 0), len); } int grib_accessor_ieeefloat_t::pack_double(const double* val, size_t* len) @@ -68,7 +68,7 @@ int grib_accessor_ieeefloat_t::pack_double(const double* val, size_t* len) for (i = 0; i < rlen; i++) { grib_encode_unsigned_longb(buf, grib_ieee_to_long(val[i]), &off, 32); } - ret = grib_set_long_internal(grib_handle_of_accessor(this), grib_arguments_get_name(parent_->h, arg_, 0), rlen); + ret = grib_set_long_internal(grib_handle_of_accessor(this), arg_->get_name(parent_->h, 0), rlen); if (ret == GRIB_SUCCESS) grib_buffer_replace(this, buf, buflen, 1, 1); diff --git a/src/accessor/grib_accessor_class_ifs_param.cc b/src/accessor/grib_accessor_class_ifs_param.cc index a1ba7aef3..ce7b952e1 100644 --- a/src/accessor/grib_accessor_class_ifs_param.cc +++ b/src/accessor/grib_accessor_class_ifs_param.cc @@ -18,8 +18,8 @@ void grib_accessor_ifs_param_t::init(const long l, grib_arguments* c) grib_accessor_gen_t::init(l, c); int n = 0; - paramId_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - type_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); + paramId_ = c->get_name(grib_handle_of_accessor(this), n++); + type_ = c->get_name(grib_handle_of_accessor(this), n++); } int grib_accessor_ifs_param_t::unpack_long(long* val, size_t* len) diff --git a/src/accessor/grib_accessor_class_julian_date.cc b/src/accessor/grib_accessor_class_julian_date.cc index 4f7e430d2..bc060f094 100644 --- a/src/accessor/grib_accessor_class_julian_date.cc +++ b/src/accessor/grib_accessor_class_julian_date.cc @@ -19,10 +19,10 @@ void grib_accessor_julian_date_t::init(const long l, grib_arguments* c) int n = 0; grib_handle* h = grib_handle_of_accessor(this); - year_ = grib_arguments_get_name(h, c, n++); - month_ = grib_arguments_get_name(h, c, n++); + year_ = c->get_name(h, n++); + month_ = c->get_name(h, n++); - day_ = grib_arguments_get_name(h, c, n++); + day_ = c->get_name(h, n++); if (day_ == NULL) { hour_ = 0; minute_ = 0; @@ -35,9 +35,9 @@ void grib_accessor_julian_date_t::init(const long l, grib_arguments* c) else { ymd_ = 0; hms_ = 0; - hour_ = grib_arguments_get_name(h, c, n++); - minute_ = grib_arguments_get_name(h, c, n++); - second_ = grib_arguments_get_name(h, c, n++); + hour_ = c->get_name(h, n++); + minute_ = c->get_name(h, n++); + second_ = c->get_name(h, n++); } sep_[0] = ' '; sep_[1] = 0; @@ -312,10 +312,10 @@ int grib_accessor_julian_date_t::pack_expression(grib_expression* e) int ret = 0; grib_handle* hand = grib_handle_of_accessor(this); - switch (grib_expression_native_type(hand, e)) { + switch (e->native_type(hand)) { case GRIB_TYPE_LONG: { len = 1; - ret = grib_expression_evaluate_long(hand, e, &lval); + ret = e->evaluate_long(hand, &lval); if (ret != GRIB_SUCCESS) { grib_context_log(context_, GRIB_LOG_ERROR, "Unable to set %s as long", name_); return ret; @@ -327,7 +327,7 @@ int grib_accessor_julian_date_t::pack_expression(grib_expression* e) case GRIB_TYPE_DOUBLE: { len = 1; - ret = grib_expression_evaluate_double(hand, e, &dval); + ret = e->evaluate_double(hand, &dval); /*if (hand->context->debug) printf("ECCODES DEBUG grib_accessor_gen::pack_expression %s %g\n", name_ , dval);*/ return pack_double(&dval, &len); @@ -336,7 +336,7 @@ int grib_accessor_julian_date_t::pack_expression(grib_expression* e) case GRIB_TYPE_STRING: { char tmp[1024]; len = sizeof(tmp); - cval = grib_expression_evaluate_string(hand, e, tmp, &len, &ret); + cval = e->evaluate_string(hand, tmp, &len, &ret); if (ret != GRIB_SUCCESS) { grib_context_log(context_, GRIB_LOG_ERROR, "Unable to set %s as string", name_); return ret; diff --git a/src/accessor/grib_accessor_class_julian_day.cc b/src/accessor/grib_accessor_class_julian_day.cc index 7b22252a0..1ed2cbb73 100644 --- a/src/accessor/grib_accessor_class_julian_day.cc +++ b/src/accessor/grib_accessor_class_julian_day.cc @@ -19,10 +19,10 @@ void grib_accessor_julian_day_t::init(const long l, grib_arguments* c) int n = 0; grib_handle* h = grib_handle_of_accessor(this); - date_ = grib_arguments_get_name(h, c, n++); - hour_ = grib_arguments_get_name(h, c, n++); - minute_ = grib_arguments_get_name(h, c, n++); - second_ = grib_arguments_get_name(h, c, n++); + date_ = c->get_name(h, n++); + hour_ = c->get_name(h, n++); + minute_ = c->get_name(h, n++); + second_ = c->get_name(h, n++); length_ = 0; } diff --git a/src/accessor/grib_accessor_class_latitudes.cc b/src/accessor/grib_accessor_class_latitudes.cc index 49976c844..be627bb3c 100644 --- a/src/accessor/grib_accessor_class_latitudes.cc +++ b/src/accessor/grib_accessor_class_latitudes.cc @@ -48,8 +48,8 @@ void grib_accessor_latitudes_t::init(const long l, grib_arguments* c) grib_accessor_double_t::init(l, c); int n = 0; - values_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - distinct_ = grib_arguments_get_long(grib_handle_of_accessor(this), c, n++); + values_ = c->get_name(grib_handle_of_accessor(this), n++); + distinct_ = c->get_long(grib_handle_of_accessor(this), n++); save_ = 0; flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; diff --git a/src/accessor/grib_accessor_class_latlon_increment.cc b/src/accessor/grib_accessor_class_latlon_increment.cc index ead5d04da..3beed4bae 100644 --- a/src/accessor/grib_accessor_class_latlon_increment.cc +++ b/src/accessor/grib_accessor_class_latlon_increment.cc @@ -19,15 +19,15 @@ void grib_accessor_latlon_increment_t::init(const long l, grib_arguments* c) int n = 0; grib_handle* hand = grib_handle_of_accessor(this); - directionIncrementGiven_ = grib_arguments_get_name(hand, c, n++); - directionIncrement_ = grib_arguments_get_name(hand, c, n++); - scansPositively_ = grib_arguments_get_name(hand, c, n++); - first_ = grib_arguments_get_name(hand, c, n++); - last_ = grib_arguments_get_name(hand, c, n++); - numberOfPoints_ = grib_arguments_get_name(hand, c, n++); - angleMultiplier_ = grib_arguments_get_name(hand, c, n++); - angleDivisor_ = grib_arguments_get_name(hand, c, n++); - isLongitude_ = grib_arguments_get_long(hand, c, n++); + directionIncrementGiven_ = c->get_name(hand, n++); + directionIncrement_ = c->get_name(hand, n++); + scansPositively_ = c->get_name(hand, n++); + first_ = c->get_name(hand, n++); + last_ = c->get_name(hand, n++); + numberOfPoints_ = c->get_name(hand, n++); + angleMultiplier_ = c->get_name(hand, n++); + angleDivisor_ = c->get_name(hand, n++); + isLongitude_ = c->get_long(hand, n++); } int grib_accessor_latlon_increment_t::unpack_double(double* val, size_t* len) diff --git a/src/accessor/grib_accessor_class_latlonvalues.cc b/src/accessor/grib_accessor_class_latlonvalues.cc index 5dd250272..8e0b15331 100644 --- a/src/accessor/grib_accessor_class_latlonvalues.cc +++ b/src/accessor/grib_accessor_class_latlonvalues.cc @@ -19,7 +19,7 @@ void grib_accessor_latlonvalues_t::init(const long l, grib_arguments* c) grib_accessor_double_t::init(l, c); int n = 0; - values_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); + values_ = c->get_name(grib_handle_of_accessor(this), n++); flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; } diff --git a/src/accessor/grib_accessor_class_local_definition.cc b/src/accessor/grib_accessor_class_local_definition.cc index 6f3d8a3a7..0dc4e3641 100644 --- a/src/accessor/grib_accessor_class_local_definition.cc +++ b/src/accessor/grib_accessor_class_local_definition.cc @@ -19,15 +19,15 @@ void grib_accessor_local_definition_t::init(const long l, grib_arguments* c) grib_handle* hand = grib_handle_of_accessor(this); int n = 0; - grib2LocalSectionNumber_ = grib_arguments_get_name(hand, c, n++); - productDefinitionTemplateNumber_ = grib_arguments_get_name(hand, c, n++); - productDefinitionTemplateNumberInternal_ = grib_arguments_get_name(hand, c, n++); - type_ = grib_arguments_get_name(hand, c, n++); - stream_ = grib_arguments_get_name(hand, c, n++); - the_class_ = grib_arguments_get_name(hand, c, n++); - eps_ = grib_arguments_get_name(hand, c, n++); - stepType_ = grib_arguments_get_name(hand, c, n++); - derivedForecast_ = grib_arguments_get_name(hand, c, n++); + grib2LocalSectionNumber_ = c->get_name(hand, n++); + productDefinitionTemplateNumber_ = c->get_name(hand, n++); + productDefinitionTemplateNumberInternal_ = c->get_name(hand, n++); + type_ = c->get_name(hand, n++); + stream_ = c->get_name(hand, n++); + the_class_ = c->get_name(hand, n++); + eps_ = c->get_name(hand, n++); + stepType_ = c->get_name(hand, n++); + derivedForecast_ = c->get_name(hand, n++); } int grib_accessor_local_definition_t::unpack_long(long* val, size_t* len) diff --git a/src/accessor/grib_accessor_class_long_vector.cc b/src/accessor/grib_accessor_class_long_vector.cc index d8c004e90..1d746e185 100644 --- a/src/accessor/grib_accessor_class_long_vector.cc +++ b/src/accessor/grib_accessor_class_long_vector.cc @@ -21,11 +21,11 @@ void grib_accessor_long_vector_t::init(const long l, grib_arguments* c) grib_accessor_abstract_long_vector_t* v = NULL; int n = 0; - vector_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); + vector_ = c->get_name(grib_handle_of_accessor(this), n++); va = (grib_accessor*)grib_find_accessor(grib_handle_of_accessor(this), vector_); v = (grib_accessor_abstract_long_vector_t*)va; - index_ = grib_arguments_get_long(grib_handle_of_accessor(this), c, n++); + index_ = c->get_long(grib_handle_of_accessor(this), n++); /* check index_ on init and never change it */ Assert(index_ < v->number_of_elements_ && index_ >= 0); diff --git a/src/accessor/grib_accessor_class_longitudes.cc b/src/accessor/grib_accessor_class_longitudes.cc index b262079c1..a73d65879 100644 --- a/src/accessor/grib_accessor_class_longitudes.cc +++ b/src/accessor/grib_accessor_class_longitudes.cc @@ -19,8 +19,8 @@ void grib_accessor_longitudes_t::init(const long l, grib_arguments* c) grib_accessor_double_t::init(l, c); int n = 0; - values_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - distinct_ = grib_arguments_get_long(grib_handle_of_accessor(this), c, n++); + values_ = c->get_name(grib_handle_of_accessor(this), n++); + distinct_ = c->get_long(grib_handle_of_accessor(this), n++); save_ = 0; lons_ = 0; diff --git a/src/accessor/grib_accessor_class_lookup.cc b/src/accessor/grib_accessor_class_lookup.cc index 0ec0c62e1..dcc9d3061 100644 --- a/src/accessor/grib_accessor_class_lookup.cc +++ b/src/accessor/grib_accessor_class_lookup.cc @@ -18,9 +18,9 @@ void grib_accessor_lookup_t::init(const long len, grib_arguments* arg) grib_accessor_long_t::init(len, arg); length_ = 0; llength_ = len; - loffset_ = grib_arguments_get_long(grib_handle_of_accessor(this), arg, 0); + loffset_ = arg->get_long(grib_handle_of_accessor(this), 0); flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; - real_name_ = grib_arguments_get_expression(grib_handle_of_accessor(this), arg, 1); + real_name_ = arg->get_expression(grib_handle_of_accessor(this), 1); } void grib_accessor_lookup_t::post_init() diff --git a/src/accessor/grib_accessor_class_mars_param.cc b/src/accessor/grib_accessor_class_mars_param.cc index b9b0d2c2c..4c2e3f422 100644 --- a/src/accessor/grib_accessor_class_mars_param.cc +++ b/src/accessor/grib_accessor_class_mars_param.cc @@ -17,9 +17,9 @@ void grib_accessor_mars_param_t::init(const long l, grib_arguments* c) { grib_accessor_ascii_t::init(l, c); int n = 0; - paramId_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - table_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - param_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); + paramId_ = c->get_name(grib_handle_of_accessor(this), n++); + table_ = c->get_name(grib_handle_of_accessor(this), n++); + param_ = c->get_name(grib_handle_of_accessor(this), n++); } // For an implementation of pack_string, see diff --git a/src/accessor/grib_accessor_class_mars_step.cc b/src/accessor/grib_accessor_class_mars_step.cc index d7fa6902d..10b695339 100644 --- a/src/accessor/grib_accessor_class_mars_step.cc +++ b/src/accessor/grib_accessor_class_mars_step.cc @@ -17,8 +17,8 @@ void grib_accessor_mars_step_t::init(const long l, grib_arguments* c) { grib_accessor_ascii_t::init(l, c); int n = 0; - stepRange_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - stepType_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); + stepRange_ = c->get_name(grib_handle_of_accessor(this), n++); + stepType_ = c->get_name(grib_handle_of_accessor(this), n++); } int grib_accessor_mars_step_t::pack_string(const char* val, size_t* len) diff --git a/src/accessor/grib_accessor_class_md5.cc b/src/accessor/grib_accessor_class_md5.cc index 8099f5f6f..c5549cd51 100644 --- a/src/accessor/grib_accessor_class_md5.cc +++ b/src/accessor/grib_accessor_class_md5.cc @@ -22,10 +22,10 @@ void grib_accessor_md5_t::init(const long len, grib_arguments* arg) grib_string_list* current = 0; grib_context* context = context_; - offset_key_ = grib_arguments_get_name(grib_handle_of_accessor(this), arg, n++); - length_key_ = grib_arguments_get_expression(grib_handle_of_accessor(this), arg, n++); + offset_key_ = arg->get_name(grib_handle_of_accessor(this), n++); + length_key_ = arg->get_expression(grib_handle_of_accessor(this), n++); blocklist_ = NULL; - while ((b = (char*)grib_arguments_get_name(grib_handle_of_accessor(this), arg, n++)) != NULL) { + while ((b = (char*)arg->get_name(grib_handle_of_accessor(this), n++)) != NULL) { if (!blocklist_) { blocklist_ = (grib_string_list*)grib_context_malloc_clear(context, sizeof(grib_string_list)); blocklist_->value = grib_context_strdup(context, b); @@ -97,7 +97,7 @@ int grib_accessor_md5_t::unpack_string(char* v, size_t* len) if ((ret = grib_get_long_internal(grib_handle_of_accessor(this), offset_key_, &offset)) != GRIB_SUCCESS) return ret; - if ((ret = grib_expression_evaluate_long(grib_handle_of_accessor(this), length_key_, &length)) != GRIB_SUCCESS) + if ((ret = length_key_->evaluate_long(grib_handle_of_accessor(this), &length)) != GRIB_SUCCESS) return ret; mess = (unsigned char*)grib_context_malloc(context_, length); memcpy(mess, grib_handle_of_accessor(this)->buffer->data + offset, length); diff --git a/src/accessor/grib_accessor_class_multdouble.cc b/src/accessor/grib_accessor_class_multdouble.cc index f610cbfc5..af29a8444 100644 --- a/src/accessor/grib_accessor_class_multdouble.cc +++ b/src/accessor/grib_accessor_class_multdouble.cc @@ -18,8 +18,8 @@ void grib_accessor_multdouble_t::init(const long l, grib_arguments* c) grib_accessor_double_t::init(l, c); int n = 0; - val_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - multiplier_ = grib_arguments_get_double(grib_handle_of_accessor(this), c, n++); + val_ = c->get_name(grib_handle_of_accessor(this), n++); + multiplier_ = c->get_double(grib_handle_of_accessor(this), n++); } int grib_accessor_multdouble_t::unpack_double(double* val, size_t* len) diff --git a/src/accessor/grib_accessor_class_number_of_coded_values.cc b/src/accessor/grib_accessor_class_number_of_coded_values.cc index 4ca9d4c2b..6e05b3c3e 100644 --- a/src/accessor/grib_accessor_class_number_of_coded_values.cc +++ b/src/accessor/grib_accessor_class_number_of_coded_values.cc @@ -19,11 +19,11 @@ void grib_accessor_number_of_coded_values_t::init(const long l, grib_arguments* grib_handle* h = grib_handle_of_accessor(this); int n = 0; - bitsPerValue_ = grib_arguments_get_name(h, c, n++); - offsetBeforeData_ = grib_arguments_get_name(h, c, n++); - offsetAfterData_ = grib_arguments_get_name(h, c, n++); - unusedBits_ = grib_arguments_get_name(h, c, n++); - numberOfValues_ = grib_arguments_get_name(h, c, n++); + bitsPerValue_ = c->get_name(h, n++); + offsetBeforeData_ = c->get_name(h, n++); + offsetAfterData_ = c->get_name(h, n++); + unusedBits_ = c->get_name(h, n++); + numberOfValues_ = c->get_name(h, n++); flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; flags_ |= GRIB_ACCESSOR_FLAG_FUNCTION; length_ = 0; diff --git a/src/accessor/grib_accessor_class_number_of_points.cc b/src/accessor/grib_accessor_class_number_of_points.cc index 3fae3d9f0..bd812b08a 100644 --- a/src/accessor/grib_accessor_class_number_of_points.cc +++ b/src/accessor/grib_accessor_class_number_of_points.cc @@ -19,10 +19,10 @@ void grib_accessor_number_of_points_t::init(const long l, grib_arguments* c) int n = 0; grib_handle* hand = grib_handle_of_accessor(this); - ni_ = grib_arguments_get_name(hand, c, n++); - nj_ = grib_arguments_get_name(hand, c, n++); - plpresent_ = grib_arguments_get_name(hand, c, n++); - pl_ = grib_arguments_get_name(hand, c, n++); + ni_ = c->get_name(hand, n++); + nj_ = c->get_name(hand, n++); + plpresent_ = c->get_name(hand, n++); + pl_ = c->get_name(hand, n++); flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; flags_ |= GRIB_ACCESSOR_FLAG_FUNCTION; length_ = 0; diff --git a/src/accessor/grib_accessor_class_number_of_points_gaussian.cc b/src/accessor/grib_accessor_class_number_of_points_gaussian.cc index 73a5e17a6..4cdd5676d 100644 --- a/src/accessor/grib_accessor_class_number_of_points_gaussian.cc +++ b/src/accessor/grib_accessor_class_number_of_points_gaussian.cc @@ -21,16 +21,16 @@ void grib_accessor_number_of_points_gaussian_t::init(const long l, grib_argument int n = 0; grib_handle* h = grib_handle_of_accessor(this); - ni_ = grib_arguments_get_name(h, c, n++); - nj_ = grib_arguments_get_name(h, c, n++); - plpresent_ = grib_arguments_get_name(h, c, n++); - pl_ = grib_arguments_get_name(h, c, n++); - order_ = grib_arguments_get_name(h, c, n++); - lat_first_ = grib_arguments_get_name(h, c, n++); - lon_first_ = grib_arguments_get_name(h, c, n++); - lat_last_ = grib_arguments_get_name(h, c, n++); - lon_last_ = grib_arguments_get_name(h, c, n++); - support_legacy_ = grib_arguments_get_name(h, c, n++); + ni_ = c->get_name(h, n++); + nj_ = c->get_name(h, n++); + plpresent_ = c->get_name(h, n++); + pl_ = c->get_name(h, n++); + order_ = c->get_name(h, n++); + lat_first_ = c->get_name(h, n++); + lon_first_ = c->get_name(h, n++); + lat_last_ = c->get_name(h, n++); + lon_last_ = c->get_name(h, n++); + support_legacy_ = c->get_name(h, n++); flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; flags_ |= GRIB_ACCESSOR_FLAG_FUNCTION; length_ = 0; diff --git a/src/accessor/grib_accessor_class_number_of_values.cc b/src/accessor/grib_accessor_class_number_of_values.cc index 6456d3ffe..ea553bf75 100644 --- a/src/accessor/grib_accessor_class_number_of_values.cc +++ b/src/accessor/grib_accessor_class_number_of_values.cc @@ -19,12 +19,12 @@ void grib_accessor_number_of_values_t::init(const long l, grib_arguments* c) int n = 0; grib_handle* hand = grib_handle_of_accessor(this); - values_ = grib_arguments_get_name(hand, c, n++); - bitsPerValue_ = grib_arguments_get_name(hand, c, n++); - numberOfPoints_ = grib_arguments_get_name(hand, c, n++); - bitmapPresent_ = grib_arguments_get_name(hand, c, n++); - bitmap_ = grib_arguments_get_name(hand, c, n++); - numberOfCodedValues_ = grib_arguments_get_name(hand, c, n++); + values_ = c->get_name(hand, n++); + bitsPerValue_ = c->get_name(hand, n++); + numberOfPoints_ = c->get_name(hand, n++); + bitmapPresent_ = c->get_name(hand, n++); + bitmap_ = c->get_name(hand, n++); + numberOfCodedValues_ = c->get_name(hand, n++); flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; length_ = 0; diff --git a/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.cc b/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.cc index e76eb4197..63a2ad963 100644 --- a/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.cc +++ b/src/accessor/grib_accessor_class_number_of_values_data_raw_packing.cc @@ -18,8 +18,8 @@ void grib_accessor_number_of_values_data_raw_packing_t::init(const long v, grib_ grib_accessor_gen_t::init(v, args); int n = 0; - values_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++); - precision_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++); + values_ = args->get_name(grib_handle_of_accessor(this), n++); + precision_ = args->get_name(grib_handle_of_accessor(this), n++); flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; length_ = 0; } diff --git a/src/accessor/grib_accessor_class_octahedral_gaussian.cc b/src/accessor/grib_accessor_class_octahedral_gaussian.cc index bffe8b1b0..e3f9e2527 100644 --- a/src/accessor/grib_accessor_class_octahedral_gaussian.cc +++ b/src/accessor/grib_accessor_class_octahedral_gaussian.cc @@ -19,10 +19,10 @@ void grib_accessor_octahedral_gaussian_t::init(const long l, grib_arguments* c) int n = 0; grib_handle* hand = grib_handle_of_accessor(this); - N_ = grib_arguments_get_name(hand, c, n++); - Ni_ = grib_arguments_get_name(hand, c, n++); - plpresent_ = grib_arguments_get_name(hand, c, n++); - pl_ = grib_arguments_get_name(hand, c, n++); + N_ = c->get_name(hand, n++); + Ni_ = c->get_name(hand, n++); + plpresent_ = c->get_name(hand, n++); + pl_ = c->get_name(hand, n++); } /* Returns 1 (=true) if input pl array is Octahedral, 0 otherwise. diff --git a/src/accessor/grib_accessor_class_octet_number.cc b/src/accessor/grib_accessor_class_octet_number.cc index e54117420..b5159065d 100644 --- a/src/accessor/grib_accessor_class_octet_number.cc +++ b/src/accessor/grib_accessor_class_octet_number.cc @@ -18,8 +18,8 @@ void grib_accessor_octet_number_t::init(const long l, grib_arguments* c) grib_accessor_long_t::init(l, c); int n = 0; - left_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - right_ = grib_arguments_get_long(grib_handle_of_accessor(this), c, n++); + left_ = c->get_name(grib_handle_of_accessor(this), n++); + right_ = c->get_long(grib_handle_of_accessor(this), n++); length_ = 0; } diff --git a/src/accessor/grib_accessor_class_offset_values.cc b/src/accessor/grib_accessor_class_offset_values.cc index a2f94d8c5..390fb8ba1 100644 --- a/src/accessor/grib_accessor_class_offset_values.cc +++ b/src/accessor/grib_accessor_class_offset_values.cc @@ -17,8 +17,8 @@ void grib_accessor_offset_values_t::init(const long l, grib_arguments* args) { grib_accessor_double_t::init(l, args); int n = 0; - values_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++); - missingValue_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++); + values_ = args->get_name(grib_handle_of_accessor(this), n++); + missingValue_ = args->get_name(grib_handle_of_accessor(this), n++); flags_ |= GRIB_ACCESSOR_FLAG_FUNCTION; length_ = 0; } diff --git a/src/accessor/grib_accessor_class_optimal_step_units.cc b/src/accessor/grib_accessor_class_optimal_step_units.cc index feeb90a2a..a38d5ff82 100644 --- a/src/accessor/grib_accessor_class_optimal_step_units.cc +++ b/src/accessor/grib_accessor_class_optimal_step_units.cc @@ -21,10 +21,10 @@ void grib_accessor_optimal_step_units_t::init(const long l, grib_arguments* c) grib_handle* hand = grib_handle_of_accessor(this); int n = 0; - forecast_time_value_ = grib_arguments_get_name(hand, c, n++); - forecast_time_unit_ = grib_arguments_get_name(hand, c, n++); - time_range_value_ = grib_arguments_get_name(hand, c, n++); - time_range_unit_ = grib_arguments_get_name(hand, c, n++); + forecast_time_value_ = c->get_name(hand, n++); + forecast_time_unit_ = c->get_name(hand, n++); + time_range_value_ = c->get_name(hand, n++); + time_range_unit_ = c->get_name(hand, n++); length_ = 0; overwriteStepUnits_ = eccodes::Unit{ eccodes::Unit::Value::MISSING }.value(); } @@ -47,18 +47,18 @@ int grib_accessor_optimal_step_units_t::pack_expression(grib_expression* e) size_t len = 1; grib_handle* hand = grib_handle_of_accessor(this); - if (strcmp(e->cclass->name, "long") == 0) { - grib_expression_evaluate_long(hand, e, &lval); /* TODO: check return value */ + if (strcmp(e->class_name(), "long") == 0) { + e->evaluate_long(hand, &lval); /* TODO: check return value */ ret = pack_long(&lval, &len); } else { char tmp[1024]; len = sizeof(tmp); - cval = grib_expression_evaluate_string(hand, e, tmp, &len, &ret); + cval = e->evaluate_string(hand, tmp, &len, &ret); if (ret != GRIB_SUCCESS) { grib_context_log(context_, GRIB_LOG_ERROR, "%s.%s: Unable to evaluate string %s to be set in %s", - class_name_, __func__, grib_expression_get_name(e), name_); + class_name_, __func__, e->get_name(), name_); return ret; } len = strlen(cval) + 1; diff --git a/src/accessor/grib_accessor_class_pack_bufr_values.cc b/src/accessor/grib_accessor_class_pack_bufr_values.cc index a80d9735f..95c64dc63 100644 --- a/src/accessor/grib_accessor_class_pack_bufr_values.cc +++ b/src/accessor/grib_accessor_class_pack_bufr_values.cc @@ -17,7 +17,7 @@ void grib_accessor_pack_bufr_values_t::init(const long len, grib_arguments* para { grib_accessor_gen_t::init(len, params); char* key; - key = (char*)grib_arguments_get_name(grib_handle_of_accessor(this), params, 0); + key = (char*)params->get_name(grib_handle_of_accessor(this), 0); data_accessor_ = grib_find_accessor(grib_handle_of_accessor(this), key); length_ = 0; diff --git a/src/accessor/grib_accessor_class_packing_type.cc b/src/accessor/grib_accessor_class_packing_type.cc index 1abc8d5ef..92c13a239 100644 --- a/src/accessor/grib_accessor_class_packing_type.cc +++ b/src/accessor/grib_accessor_class_packing_type.cc @@ -17,8 +17,8 @@ void grib_accessor_packing_type_t::init(const long l, grib_arguments* args) { grib_accessor_gen_t::init(l, args); int n = 0; - values_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++); - packing_type_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++); + values_ = args->get_name(grib_handle_of_accessor(this), n++); + packing_type_ = args->get_name(grib_handle_of_accessor(this), n++); flags_ |= GRIB_ACCESSOR_FLAG_FUNCTION; length_ = 0; } diff --git a/src/accessor/grib_accessor_class_pad.cc b/src/accessor/grib_accessor_class_pad.cc index dbc151288..ca896644d 100644 --- a/src/accessor/grib_accessor_class_pad.cc +++ b/src/accessor/grib_accessor_class_pad.cc @@ -17,7 +17,7 @@ void grib_accessor_pad_t::init(const long len, grib_arguments* arg) { grib_accessor_padding_t::init(len, arg); - expression_ = grib_arguments_get_expression(grib_handle_of_accessor(this), arg, 0); + expression_ = arg->get_expression(grib_handle_of_accessor(this), 0); length_ = preferred_size(1); } @@ -25,7 +25,7 @@ size_t grib_accessor_pad_t::preferred_size(int from_handle) { long length = 0; - grib_expression_evaluate_long(grib_handle_of_accessor(this), expression_, &length); + expression_->evaluate_long(grib_handle_of_accessor(this), &length); return length > 0 ? length : 0; } diff --git a/src/accessor/grib_accessor_class_padto.cc b/src/accessor/grib_accessor_class_padto.cc index 2f496e640..f276b37ce 100644 --- a/src/accessor/grib_accessor_class_padto.cc +++ b/src/accessor/grib_accessor_class_padto.cc @@ -18,7 +18,7 @@ size_t grib_accessor_padto_t::preferred_size(int from_handle) long length = 0; long theEnd; - grib_expression_evaluate_long(grib_handle_of_accessor(this), expression_, &theEnd); + expression_->evaluate_long(grib_handle_of_accessor(this), &theEnd); length = theEnd - offset_; @@ -31,7 +31,7 @@ void grib_accessor_padto_t::init(const long len, grib_arguments* arg) { grib_accessor_padding_t::init(len, arg); - expression_ = grib_arguments_get_expression(grib_handle_of_accessor(this), arg, 0); + expression_ = arg->get_expression(grib_handle_of_accessor(this), 0); length_ = preferred_size(1); } diff --git a/src/accessor/grib_accessor_class_padtoeven.cc b/src/accessor/grib_accessor_class_padtoeven.cc index af1865173..872f6c5e4 100644 --- a/src/accessor/grib_accessor_class_padtoeven.cc +++ b/src/accessor/grib_accessor_class_padtoeven.cc @@ -39,8 +39,8 @@ void grib_accessor_padtoeven_t::init(const long len, grib_arguments* args) { grib_accessor_padding_t::init(len, args); - section_offset_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, 0); - section_length_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, 1); + section_offset_ = args->get_name(grib_handle_of_accessor(this), 0); + section_length_ = args->get_name(grib_handle_of_accessor(this), 1); length_ = preferred_size(1); } diff --git a/src/accessor/grib_accessor_class_padtomultiple.cc b/src/accessor/grib_accessor_class_padtomultiple.cc index 0888c526c..effcdc45c 100644 --- a/src/accessor/grib_accessor_class_padtomultiple.cc +++ b/src/accessor/grib_accessor_class_padtomultiple.cc @@ -19,8 +19,8 @@ size_t grib_accessor_padtomultiple_t::preferred_size(int from_handle) long begin = 0; long multiple = 0; - grib_expression_evaluate_long(grib_handle_of_accessor(this), begin_, &begin); - grib_expression_evaluate_long(grib_handle_of_accessor(this), multiple_, &multiple); + begin_->evaluate_long(grib_handle_of_accessor(this), &begin); + multiple_->evaluate_long(grib_handle_of_accessor(this), &multiple); padding = offset_ - begin; padding = ((padding + multiple - 1) / multiple) * multiple - padding; @@ -32,7 +32,7 @@ void grib_accessor_padtomultiple_t::init(const long len, grib_arguments* arg) { grib_accessor_padding_t::init(len, arg); - begin_ = grib_arguments_get_expression(grib_handle_of_accessor(this), arg, 0); - multiple_ = grib_arguments_get_expression(grib_handle_of_accessor(this), arg, 1); + begin_ = arg->get_expression(grib_handle_of_accessor(this), 0); + multiple_ = arg->get_expression(grib_handle_of_accessor(this), 1); length_ = preferred_size(1); } diff --git a/src/accessor/grib_accessor_class_proj_string.cc b/src/accessor/grib_accessor_class_proj_string.cc index b42da8c45..5973f7ac1 100644 --- a/src/accessor/grib_accessor_class_proj_string.cc +++ b/src/accessor/grib_accessor_class_proj_string.cc @@ -18,8 +18,8 @@ void grib_accessor_proj_string_t::init(const long len, grib_arguments* arg) grib_accessor_gen_t::init(len, arg); grib_handle* h = grib_handle_of_accessor(this); - grid_type_ = grib_arguments_get_name(h, arg, 0); - endpoint_ = grib_arguments_get_long(h, arg, 1); + grid_type_ = arg->get_name(h, 0); + endpoint_ = arg->get_long(h, 1); length_ = 0; flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; flags_ |= GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC; diff --git a/src/accessor/grib_accessor_class_raw.cc b/src/accessor/grib_accessor_class_raw.cc index 2196bd668..b27a83b43 100644 --- a/src/accessor/grib_accessor_class_raw.cc +++ b/src/accessor/grib_accessor_class_raw.cc @@ -23,11 +23,11 @@ void grib_accessor_raw_t::init(const long len, grib_arguments* arg) grib_handle* hand = grib_handle_of_accessor(this); length_ = 0; - totalLength_ = grib_arguments_get_name(hand, arg, n++); - sectionLength_ = grib_arguments_get_name(hand, arg, n++); + totalLength_ = arg->get_name(hand, n++); + sectionLength_ = arg->get_name(hand, n++); - e = grib_arguments_get_expression(hand, arg, n++); - err = grib_expression_evaluate_long(hand, e, &(relativeOffset_)); + e = arg->get_expression(hand, n++); + err = e->evaluate_long(hand, &(relativeOffset_)); if (err) grib_context_log(hand->context, GRIB_LOG_ERROR, "Unable to evaluate relativeOffset"); diff --git a/src/accessor/grib_accessor_class_rdbtime_guess_date.cc b/src/accessor/grib_accessor_class_rdbtime_guess_date.cc index 55c545eec..90ea3dc78 100644 --- a/src/accessor/grib_accessor_class_rdbtime_guess_date.cc +++ b/src/accessor/grib_accessor_class_rdbtime_guess_date.cc @@ -19,11 +19,11 @@ void grib_accessor_rdbtime_guess_date_t::init(const long l, grib_arguments* c) grib_accessor_long_t::init(l, c); int n = 0; - typicalYear_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - typicalMonth_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - typicalDay_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - rdbDay_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - yearOrMonth_ = grib_arguments_get_long(grib_handle_of_accessor(this), c, n++); + typicalYear_ = c->get_name(grib_handle_of_accessor(this), n++); + typicalMonth_ = c->get_name(grib_handle_of_accessor(this), n++); + typicalDay_ = c->get_name(grib_handle_of_accessor(this), n++); + rdbDay_ = c->get_name(grib_handle_of_accessor(this), n++); + yearOrMonth_ = c->get_long(grib_handle_of_accessor(this), n++); /* flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; */ } diff --git a/src/accessor/grib_accessor_class_reference_value_error.cc b/src/accessor/grib_accessor_class_reference_value_error.cc index 923b9e95b..8b444f9c8 100644 --- a/src/accessor/grib_accessor_class_reference_value_error.cc +++ b/src/accessor/grib_accessor_class_reference_value_error.cc @@ -19,8 +19,8 @@ void grib_accessor_reference_value_error_t::init(const long l, grib_arguments* c grib_accessor_double_t::init(l, c); int n = 0; - referenceValue_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - floatType_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); + referenceValue_ = c->get_name(grib_handle_of_accessor(this), n++); + floatType_ = c->get_name(grib_handle_of_accessor(this), n++); flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; length_ = 0; diff --git a/src/accessor/grib_accessor_class_round.cc b/src/accessor/grib_accessor_class_round.cc index 80b0f601d..f141a94a7 100644 --- a/src/accessor/grib_accessor_class_round.cc +++ b/src/accessor/grib_accessor_class_round.cc @@ -39,12 +39,12 @@ int grib_accessor_round_t::unpack_double(double* val, size_t* len) double toround = 0; const char* oval = NULL; - oval = grib_arguments_get_name(grib_handle_of_accessor(this), arg_, 0); + oval = arg_->get_name(grib_handle_of_accessor(this), 0); if ((ret = grib_get_double_internal(grib_handle_of_accessor(this), oval, &toround)) != 0) return ret; - rounding_precision = grib_arguments_get_long(grib_handle_of_accessor(this), arg_, 1); + rounding_precision = arg_->get_long(grib_handle_of_accessor(this), 1); rounded = floor(rounding_precision * toround + 0.5) / rounding_precision; diff --git a/src/accessor/grib_accessor_class_scale.cc b/src/accessor/grib_accessor_class_scale.cc index 284a9ed51..2779c1c5b 100644 --- a/src/accessor/grib_accessor_class_scale.cc +++ b/src/accessor/grib_accessor_class_scale.cc @@ -19,10 +19,10 @@ void grib_accessor_scale_t::init(const long l, grib_arguments* c) grib_accessor_double_t::init(l, c); int n = 0; - value_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - multiplier_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - divisor_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - truncating_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); + value_ = c->get_name(grib_handle_of_accessor(this), n++); + multiplier_ = c->get_name(grib_handle_of_accessor(this), n++); + divisor_ = c->get_name(grib_handle_of_accessor(this), n++); + truncating_ = c->get_name(grib_handle_of_accessor(this), n++); } int grib_accessor_scale_t::unpack_double(double* val, size_t* len) diff --git a/src/accessor/grib_accessor_class_scale_values.cc b/src/accessor/grib_accessor_class_scale_values.cc index 651603254..f6d0c3f49 100644 --- a/src/accessor/grib_accessor_class_scale_values.cc +++ b/src/accessor/grib_accessor_class_scale_values.cc @@ -18,8 +18,8 @@ void grib_accessor_scale_values_t::init(const long l, grib_arguments* args) { grib_accessor_double_t::init(l, args); int n = 0; - values_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++); - missingValue_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++); + values_ = args->get_name(grib_handle_of_accessor(this), n++); + missingValue_ = args->get_name(grib_handle_of_accessor(this), n++); flags_ |= GRIB_ACCESSOR_FLAG_FUNCTION; length_ = 0; } diff --git a/src/accessor/grib_accessor_class_second_order_bits_per_value.cc b/src/accessor/grib_accessor_class_second_order_bits_per_value.cc index 1cdad1545..d7fa954c7 100644 --- a/src/accessor/grib_accessor_class_second_order_bits_per_value.cc +++ b/src/accessor/grib_accessor_class_second_order_bits_per_value.cc @@ -52,9 +52,9 @@ void grib_accessor_second_order_bits_per_value_t::init(const long l, grib_argume { grib_accessor_long_t::init(l, c); int n = 0; - values_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - binaryScaleFactor_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - decimalScaleFactor_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); + values_ = c->get_name(grib_handle_of_accessor(this), n++); + binaryScaleFactor_ = c->get_name(grib_handle_of_accessor(this), n++); + decimalScaleFactor_ = c->get_name(grib_handle_of_accessor(this), n++); bitsPerValue_ = 0; length_ = 0; diff --git a/src/accessor/grib_accessor_class_section_pointer.cc b/src/accessor/grib_accessor_class_section_pointer.cc index c584bf7c3..973e39e76 100644 --- a/src/accessor/grib_accessor_class_section_pointer.cc +++ b/src/accessor/grib_accessor_class_section_pointer.cc @@ -18,9 +18,9 @@ void grib_accessor_section_pointer_t::init(const long len, grib_arguments* arg) grib_accessor_gen_t::init(len, arg); int n = 0; - sectionOffset_ = grib_arguments_get_name(grib_handle_of_accessor(this), arg, n++); - sectionLength_ = grib_arguments_get_name(grib_handle_of_accessor(this), arg, n++); - sectionNumber_ = grib_arguments_get_long(grib_handle_of_accessor(this), arg, n++); + sectionOffset_ = arg->get_name(grib_handle_of_accessor(this), n++); + sectionLength_ = arg->get_name(grib_handle_of_accessor(this), n++); + sectionNumber_ = arg->get_long(grib_handle_of_accessor(this), n++); Assert(sectionNumber_ < MAX_NUM_SECTIONS); diff --git a/src/accessor/grib_accessor_class_select_step_template.cc b/src/accessor/grib_accessor_class_select_step_template.cc index 00cb2ca7b..b661f548e 100644 --- a/src/accessor/grib_accessor_class_select_step_template.cc +++ b/src/accessor/grib_accessor_class_select_step_template.cc @@ -19,8 +19,8 @@ void grib_accessor_select_step_template_t::init(const long l, grib_arguments* c) grib_handle* hand = grib_handle_of_accessor(this); int n = 0; - productDefinitionTemplateNumber_ = grib_arguments_get_name(hand, c, n++); - instant_ = grib_arguments_get_long(hand, c, n++); + productDefinitionTemplateNumber_ = c->get_name(hand, n++); + instant_ = c->get_long(hand, n++); } int grib_accessor_select_step_template_t::unpack_long(long* val, size_t* len) diff --git a/src/accessor/grib_accessor_class_signed.cc b/src/accessor/grib_accessor_class_signed.cc index d3b34203e..ab7bb51ed 100644 --- a/src/accessor/grib_accessor_class_signed.cc +++ b/src/accessor/grib_accessor_class_signed.cc @@ -150,7 +150,7 @@ int grib_accessor_signed_t::pack_long(const long* val, size_t* len) grib_encode_signed_long(buf, val[i], off, length_); off += length_; } - ret = grib_set_long_internal(grib_handle_of_accessor(this), grib_arguments_get_name(parent_->h, arg_, 0), *len); + ret = grib_set_long_internal(grib_handle_of_accessor(this), arg_->get_name(parent_->h, 0), *len); if (ret == GRIB_SUCCESS) grib_buffer_replace(this, buf, buflen, 1, 1); @@ -173,7 +173,7 @@ int grib_accessor_signed_t::value_count(long* len) *len = 1; return 0; } - return grib_get_long_internal(grib_handle_of_accessor(this), grib_arguments_get_name(parent_->h, arg_, 0), len); + return grib_get_long_internal(grib_handle_of_accessor(this), arg_->get_name(parent_->h, 0), len); } long grib_accessor_signed_t::byte_offset() diff --git a/src/accessor/grib_accessor_class_signed_bits.cc b/src/accessor/grib_accessor_class_signed_bits.cc index af75c55cf..5d969757f 100644 --- a/src/accessor/grib_accessor_class_signed_bits.cc +++ b/src/accessor/grib_accessor_class_signed_bits.cc @@ -45,8 +45,8 @@ void grib_accessor_signed_bits_t::init(const long len, grib_arguments* args) { grib_accessor_long_t::init(len, args); int n = 0; - numberOfBits_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++); - numberOfElements_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++); + numberOfBits_ = args->get_name(grib_handle_of_accessor(this), n++); + numberOfElements_ = args->get_name(grib_handle_of_accessor(this), n++); length_ = compute_byte_count(); } diff --git a/src/accessor/grib_accessor_class_simple_packing_error.cc b/src/accessor/grib_accessor_class_simple_packing_error.cc index 063d4bd84..efd903177 100644 --- a/src/accessor/grib_accessor_class_simple_packing_error.cc +++ b/src/accessor/grib_accessor_class_simple_packing_error.cc @@ -20,11 +20,11 @@ void grib_accessor_simple_packing_error_t::init(const long l, grib_arguments* c) int n = 0; grib_handle* h = grib_handle_of_accessor(this); - bitsPerValue_ = grib_arguments_get_name(h, c, n++); - binaryScaleFactor_ = grib_arguments_get_name(h, c, n++); - decimalScaleFactor_ = grib_arguments_get_name(h, c, n++); - referenceValue_ = grib_arguments_get_name(h, c, n++); - floatType_ = grib_arguments_get_name(h, c, n++); + bitsPerValue_ = c->get_name(h, n++); + binaryScaleFactor_ = c->get_name(h, n++); + decimalScaleFactor_ = c->get_name(h, n++); + referenceValue_ = c->get_name(h, n++); + floatType_ = c->get_name(h, n++); flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; length_ = 0; diff --git a/src/accessor/grib_accessor_class_size.cc b/src/accessor/grib_accessor_class_size.cc index 41a2e1078..d20023967 100644 --- a/src/accessor/grib_accessor_class_size.cc +++ b/src/accessor/grib_accessor_class_size.cc @@ -17,7 +17,7 @@ grib_accessor* grib_accessor_size = &_grib_accessor_size; void grib_accessor_size_t::init(const long l, grib_arguments* c) { grib_accessor_long_t::init(l, c); - accessor_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, 0); + accessor_ = c->get_name(grib_handle_of_accessor(this), 0); flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; flags_ |= GRIB_ACCESSOR_FLAG_FUNCTION; length_ = 0; diff --git a/src/accessor/grib_accessor_class_smart_table.cc b/src/accessor/grib_accessor_class_smart_table.cc index 1499c3f3d..e41e8a0a0 100644 --- a/src/accessor/grib_accessor_class_smart_table.cc +++ b/src/accessor/grib_accessor_class_smart_table.cc @@ -49,13 +49,13 @@ void grib_accessor_smart_table_t::init(const long len, grib_arguments* params) int n = 0; grib_handle* hand = grib_handle_of_accessor(this); - values_ = grib_arguments_get_name(hand, params, n++); - tablename_ = grib_arguments_get_string(hand, params, n++); - masterDir_ = grib_arguments_get_name(hand, params, n++); - localDir_ = grib_arguments_get_name(hand, params, n++); - widthOfCode_ = grib_arguments_get_long(hand, params, n++); - extraDir_ = grib_arguments_get_name(hand, params, n++); - extraTable_ = grib_arguments_get_string(hand, params, n++); + values_ = params->get_name(hand, n++); + tablename_ = params->get_string(hand, n++); + masterDir_ = params->get_name(hand, n++); + localDir_ = params->get_name(hand, n++); + widthOfCode_ = params->get_long(hand, n++); + extraDir_ = params->get_name(hand, n++); + extraTable_ = params->get_string(hand, n++); grib_accessor_unsigned_t::length_ = 0; flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; diff --git a/src/accessor/grib_accessor_class_smart_table_column.cc b/src/accessor/grib_accessor_class_smart_table_column.cc index 113f5d45f..ee7967634 100644 --- a/src/accessor/grib_accessor_class_smart_table_column.cc +++ b/src/accessor/grib_accessor_class_smart_table_column.cc @@ -19,8 +19,8 @@ void grib_accessor_smart_table_column_t::init(const long len, grib_arguments* pa grib_accessor_gen_t::init(len, params); int n = 0; - smartTable_ = grib_arguments_get_name(grib_handle_of_accessor(this), params, n++); - index_ = grib_arguments_get_long(grib_handle_of_accessor(this), params, n++); + smartTable_ = params->get_name(grib_handle_of_accessor(this), n++); + index_ = params->get_long(grib_handle_of_accessor(this), n++); length_ = 0; flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; diff --git a/src/accessor/grib_accessor_class_spd.cc b/src/accessor/grib_accessor_class_spd.cc index 8d0df9bad..f19fc7439 100644 --- a/src/accessor/grib_accessor_class_spd.cc +++ b/src/accessor/grib_accessor_class_spd.cc @@ -45,8 +45,8 @@ void grib_accessor_spd_t::init(const long len, grib_arguments* args) { grib_accessor_long_t::init(len, args); int n = 0; - numberOfBits_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++); - numberOfElements_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++); + numberOfBits_ = args->get_name(grib_handle_of_accessor(this), n++); + numberOfElements_ = args->get_name(grib_handle_of_accessor(this), n++); length_ = compute_byte_count(); } diff --git a/src/accessor/grib_accessor_class_spectral_truncation.cc b/src/accessor/grib_accessor_class_spectral_truncation.cc index a7c2c0a5d..e64b854ec 100644 --- a/src/accessor/grib_accessor_class_spectral_truncation.cc +++ b/src/accessor/grib_accessor_class_spectral_truncation.cc @@ -18,10 +18,10 @@ void grib_accessor_spectral_truncation_t::init(const long l, grib_arguments* c) grib_accessor_long_t::init(l, c); int n = 0; - J_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - K_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - M_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - T_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); + J_ = c->get_name(grib_handle_of_accessor(this), n++); + K_ = c->get_name(grib_handle_of_accessor(this), n++); + M_ = c->get_name(grib_handle_of_accessor(this), n++); + T_ = c->get_name(grib_handle_of_accessor(this), n++); flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; } diff --git a/src/accessor/grib_accessor_class_sprintf.cc b/src/accessor/grib_accessor_class_sprintf.cc index 075596edb..7b18ac3c2 100644 --- a/src/accessor/grib_accessor_class_sprintf.cc +++ b/src/accessor/grib_accessor_class_sprintf.cc @@ -36,7 +36,7 @@ int grib_accessor_sprintf_t::unpack_string(char* val, size_t* len) const char* tempname = NULL; size_t uname_len = 0; - uname = grib_arguments_get_string(grib_handle_of_accessor(this), args_, carg++); + uname = args_->get_string(grib_handle_of_accessor(this), carg++); snprintf(result, sizeof(result), "%s", ""); uname_len = strlen(uname); @@ -54,7 +54,7 @@ int grib_accessor_sprintf_t::unpack_string(char* val, size_t* len) } switch (uname[i]) { case 'd': - tempname = grib_arguments_get_name(grib_handle_of_accessor(this), args_, carg++); + tempname = args_->get_name(grib_handle_of_accessor(this), carg++); if ((ret = grib_get_long_internal(grib_handle_of_accessor(this), tempname, &ires)) != GRIB_SUCCESS) return ret; @@ -80,7 +80,7 @@ int grib_accessor_sprintf_t::unpack_string(char* val, size_t* len) break; case 'g': - tempname = grib_arguments_get_name(grib_handle_of_accessor(this), args_, carg++); + tempname = args_->get_name(grib_handle_of_accessor(this), carg++); if ((ret = grib_get_double_internal(grib_handle_of_accessor(this), tempname, &dres)) != GRIB_SUCCESS) return ret; snprintf(tempBuffer, sizeof(tempBuffer), "%s%g", result, dres); @@ -89,7 +89,7 @@ int grib_accessor_sprintf_t::unpack_string(char* val, size_t* len) break; case 's': - tempname = grib_arguments_get_name(grib_handle_of_accessor(this), args_, carg++); + tempname = args_->get_name(grib_handle_of_accessor(this), carg++); if ((ret = grib_get_string_internal(grib_handle_of_accessor(this), tempname, sres, &replen)) != GRIB_SUCCESS) return ret; snprintf(tempBuffer, sizeof(tempBuffer), "%s%s", result, sres); diff --git a/src/accessor/grib_accessor_class_statistics.cc b/src/accessor/grib_accessor_class_statistics.cc index b2fc3078d..8434f24ac 100644 --- a/src/accessor/grib_accessor_class_statistics.cc +++ b/src/accessor/grib_accessor_class_statistics.cc @@ -18,8 +18,8 @@ void grib_accessor_statistics_t::init(const long l, grib_arguments* c) grib_accessor_abstract_vector_t::init(l, c); int n = 0; - missing_value_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - values_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); + missing_value_ = c->get_name(grib_handle_of_accessor(this), n++); + values_ = c->get_name(grib_handle_of_accessor(this), n++); flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; flags_ |= GRIB_ACCESSOR_FLAG_FUNCTION; flags_ |= GRIB_ACCESSOR_FLAG_HIDDEN; diff --git a/src/accessor/grib_accessor_class_statistics_spectral.cc b/src/accessor/grib_accessor_class_statistics_spectral.cc index 5a092e25b..ff2218201 100644 --- a/src/accessor/grib_accessor_class_statistics_spectral.cc +++ b/src/accessor/grib_accessor_class_statistics_spectral.cc @@ -19,11 +19,11 @@ void grib_accessor_statistics_spectral_t::init(const long l, grib_arguments* c) int n = 0; grib_handle* h = grib_handle_of_accessor(this); - values_ = grib_arguments_get_name(h, c, n++); - J_ = grib_arguments_get_name(h, c, n++); - K_ = grib_arguments_get_name(h, c, n++); - M_ = grib_arguments_get_name(h, c, n++); - JS_ = grib_arguments_get_name(h, c, n++); + values_ = c->get_name(h, n++); + J_ = c->get_name(h, n++); + K_ = c->get_name(h, n++); + M_ = c->get_name(h, n++); + JS_ = c->get_name(h, n++); flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; flags_ |= GRIB_ACCESSOR_FLAG_FUNCTION; diff --git a/src/accessor/grib_accessor_class_step_human_readable.cc b/src/accessor/grib_accessor_class_step_human_readable.cc index 20f6ed199..1c77de2a7 100644 --- a/src/accessor/grib_accessor_class_step_human_readable.cc +++ b/src/accessor/grib_accessor_class_step_human_readable.cc @@ -19,8 +19,8 @@ void grib_accessor_step_human_readable_t::init(const long len, grib_arguments* p int n = 0; grib_handle* h = grib_handle_of_accessor(this); - stepUnits_ = grib_arguments_get_name(h, params, n++); - step_ = grib_arguments_get_name(h, params, n++); + stepUnits_ = params->get_name(h, n++); + step_ = params->get_name(h, n++); length_ = 0; flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; } diff --git a/src/accessor/grib_accessor_class_step_in_units.cc b/src/accessor/grib_accessor_class_step_in_units.cc index d63a13c76..8d87aa91f 100644 --- a/src/accessor/grib_accessor_class_step_in_units.cc +++ b/src/accessor/grib_accessor_class_step_in_units.cc @@ -21,11 +21,11 @@ void grib_accessor_step_in_units_t::init(const long l, grib_arguments* c) grib_handle* hand = grib_handle_of_accessor(this); int n = 0; - forecast_time_value_ = grib_arguments_get_name(hand, c, n++); - forecast_time_unit_ = grib_arguments_get_name(hand, c, n++); - step_units_ = grib_arguments_get_name(hand, c, n++); - time_range_unit_ = grib_arguments_get_name(hand, c, n++); - time_range_value_ = grib_arguments_get_name(hand, c, n++); + forecast_time_value_ = c->get_name(hand, n++); + forecast_time_unit_ = c->get_name(hand, n++); + step_units_ = c->get_name(hand, n++); + time_range_unit_ = c->get_name(hand, n++); + time_range_value_ = c->get_name(hand, n++); } void grib_accessor_step_in_units_t::dump(grib_dumper* dumper) diff --git a/src/accessor/grib_accessor_class_sum.cc b/src/accessor/grib_accessor_class_sum.cc index d23706077..78902eae4 100644 --- a/src/accessor/grib_accessor_class_sum.cc +++ b/src/accessor/grib_accessor_class_sum.cc @@ -17,7 +17,7 @@ void grib_accessor_sum_t::init(const long l, grib_arguments* c) { grib_accessor_double_t::init(l, c); int n = 0; - values_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); + values_ = c->get_name(grib_handle_of_accessor(this), n++); length_ = 0; flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; } diff --git a/src/accessor/grib_accessor_class_suppressed.cc b/src/accessor/grib_accessor_class_suppressed.cc index f0de3960f..02a87fc7a 100644 --- a/src/accessor/grib_accessor_class_suppressed.cc +++ b/src/accessor/grib_accessor_class_suppressed.cc @@ -31,9 +31,9 @@ void grib_accessor_suppressed_t::log_message() "key '%s' is unavailable in this version.", name_); grib_context_log(context_, GRIB_LOG_ERROR, "Please use the following key(s):"); - while (grib_arguments_get_name(hand, args_, i)) { + while (args_->get_name(hand, i)) { grib_context_log(context_, GRIB_LOG_ERROR, "\t- %s", - grib_arguments_get_name(hand, args_, i)); + args_->get_name(hand, i)); i++; } } diff --git a/src/accessor/grib_accessor_class_time.cc b/src/accessor/grib_accessor_class_time.cc index ce647581b..564b15d78 100644 --- a/src/accessor/grib_accessor_class_time.cc +++ b/src/accessor/grib_accessor_class_time.cc @@ -19,9 +19,9 @@ void grib_accessor_time_t::init(const long l, grib_arguments* c) grib_handle* hand = grib_handle_of_accessor(this); int n = 0; - hour_ = grib_arguments_get_name(hand, c, n++); - minute_ = grib_arguments_get_name(hand, c, n++); - second_ = grib_arguments_get_name(hand, c, n++); + hour_ = c->get_name(hand, n++); + minute_ = c->get_name(hand, n++); + second_ = c->get_name(hand, n++); } int grib_accessor_time_t::unpack_long(long* val, size_t* len) diff --git a/src/accessor/grib_accessor_class_to_double.cc b/src/accessor/grib_accessor_class_to_double.cc index 462af1b59..af37d911a 100644 --- a/src/accessor/grib_accessor_class_to_double.cc +++ b/src/accessor/grib_accessor_class_to_double.cc @@ -18,10 +18,10 @@ void grib_accessor_to_double_t::init(const long len, grib_arguments* arg) grib_accessor_gen_t::init(len, arg); grib_handle* hand = grib_handle_of_accessor(this); - key_ = grib_arguments_get_name(hand, arg, 0); - start_ = grib_arguments_get_long(hand, arg, 1); - str_length_ = grib_arguments_get_long(hand, arg, 2); - scale_ = grib_arguments_get_long(hand, arg, 3); + key_ = arg->get_name(hand, 0); + start_ = arg->get_long(hand, 1); + str_length_ = arg->get_long(hand, 2); + scale_ = arg->get_long(hand, 3); if (!scale_) scale_ = 1; diff --git a/src/accessor/grib_accessor_class_to_integer.cc b/src/accessor/grib_accessor_class_to_integer.cc index 33b7489ed..babb001aa 100644 --- a/src/accessor/grib_accessor_class_to_integer.cc +++ b/src/accessor/grib_accessor_class_to_integer.cc @@ -18,9 +18,9 @@ void grib_accessor_to_integer_t::init(const long len, grib_arguments* arg) grib_accessor_gen_t::init(len, arg); grib_handle* hand = grib_handle_of_accessor(this); - key_ = grib_arguments_get_name(hand, arg, 0); - start_ = grib_arguments_get_long(hand, arg, 1); - str_length_ = grib_arguments_get_long(hand, arg, 2); + key_ = arg->get_name(hand, 0); + start_ = arg->get_long(hand, 1); + str_length_ = arg->get_long(hand, 2); flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; grib_accessor::length_ = 0; diff --git a/src/accessor/grib_accessor_class_to_string.cc b/src/accessor/grib_accessor_class_to_string.cc index 2ac2d2a76..454c5d384 100644 --- a/src/accessor/grib_accessor_class_to_string.cc +++ b/src/accessor/grib_accessor_class_to_string.cc @@ -18,9 +18,9 @@ void grib_accessor_to_string_t::init(const long len, grib_arguments* arg) grib_accessor_gen_t::init(len, arg); grib_handle* hand = grib_handle_of_accessor(this); - key_ = grib_arguments_get_name(hand, arg, 0); - start_ = grib_arguments_get_long(hand, arg, 1); - str_length_ = grib_arguments_get_long(hand, arg, 2); + key_ = arg->get_name(hand, 0); + start_ = arg->get_long(hand, 1); + str_length_ = arg->get_long(hand, 2); flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; grib_accessor_gen_t::length_ = 0; diff --git a/src/accessor/grib_accessor_class_trim.cc b/src/accessor/grib_accessor_class_trim.cc index e8364eef0..26eb72181 100644 --- a/src/accessor/grib_accessor_class_trim.cc +++ b/src/accessor/grib_accessor_class_trim.cc @@ -19,9 +19,9 @@ void grib_accessor_trim_t::init(const long l, grib_arguments* arg) int n = 0; grib_handle* h = grib_handle_of_accessor(this); - input_ = grib_arguments_get_name(h, arg, n++); - trim_left_ = grib_arguments_get_long(h, arg, n++); - trim_right_ = grib_arguments_get_long(h, arg, n++); + input_ = arg->get_name(h, n++); + trim_left_ = arg->get_long(h, n++); + trim_right_ = arg->get_long(h, n++); DEBUG_ASSERT(trim_left_ == 0 || trim_left_ == 1); DEBUG_ASSERT(trim_right_ == 0 || trim_right_ == 1); } diff --git a/src/accessor/grib_accessor_class_unexpanded_descriptors.cc b/src/accessor/grib_accessor_class_unexpanded_descriptors.cc index 7c4ddd602..a822cb595 100644 --- a/src/accessor/grib_accessor_class_unexpanded_descriptors.cc +++ b/src/accessor/grib_accessor_class_unexpanded_descriptors.cc @@ -20,8 +20,8 @@ void grib_accessor_unexpanded_descriptors_t::init(const long len, grib_arguments int n = 0; grib_handle* hand = grib_handle_of_accessor(this); - unexpandedDescriptorsEncoded_ = grib_find_accessor(hand, grib_arguments_get_name(hand, args, n++)); - createNewData_ = grib_arguments_get_name(hand, args, n++); + unexpandedDescriptorsEncoded_ = grib_find_accessor(hand, args->get_name(hand, n++)); + createNewData_ = args->get_name(hand, n++); length_ = 0; } diff --git a/src/accessor/grib_accessor_class_unpack_bufr_values.cc b/src/accessor/grib_accessor_class_unpack_bufr_values.cc index be36e9a2d..2fc0de51f 100644 --- a/src/accessor/grib_accessor_class_unpack_bufr_values.cc +++ b/src/accessor/grib_accessor_class_unpack_bufr_values.cc @@ -17,7 +17,7 @@ void grib_accessor_unpack_bufr_values_t::init(const long len, grib_arguments* pa { grib_accessor_gen_t::init(len, params); char* key; - key = (char*)grib_arguments_get_name(grib_handle_of_accessor(this), params, 0); + key = (char*)params->get_name(grib_handle_of_accessor(this), 0); data_accessor_ = dynamic_cast(grib_find_accessor(grib_handle_of_accessor(this), key)); length_ = 0; diff --git a/src/accessor/grib_accessor_class_unsigned.cc b/src/accessor/grib_accessor_class_unsigned.cc index a00c0b603..4198158c3 100644 --- a/src/accessor/grib_accessor_class_unsigned.cc +++ b/src/accessor/grib_accessor_class_unsigned.cc @@ -146,7 +146,7 @@ int grib_accessor_unsigned_t::pack_long_unsigned_helper(const long* val, size_t* for (i = 0; i < *len; i++) grib_encode_unsigned_long(buf, val[i], &off, nbytes_ * 8); - ret = grib_set_long_internal(grib_handle_of_accessor(this), grib_arguments_get_name(parent_->h, arg_, 0), *len); + ret = grib_set_long_internal(grib_handle_of_accessor(this), arg_->get_name(parent_->h, 0), *len); if (ret == GRIB_SUCCESS) grib_buffer_replace(this, buf, buflen, 1, 1); @@ -217,7 +217,7 @@ int grib_accessor_unsigned_t::value_count(long* len) *len = 1; return 0; } - return grib_get_long_internal(grib_handle_of_accessor(this), grib_arguments_get_name(parent_->h, arg_, 0), len); + return grib_get_long_internal(grib_handle_of_accessor(this), arg_->get_name(parent_->h, 0), len); } long grib_accessor_unsigned_t::byte_offset() diff --git a/src/accessor/grib_accessor_class_unsigned_bits.cc b/src/accessor/grib_accessor_class_unsigned_bits.cc index eeb34614d..d4281b2e2 100644 --- a/src/accessor/grib_accessor_class_unsigned_bits.cc +++ b/src/accessor/grib_accessor_class_unsigned_bits.cc @@ -40,8 +40,8 @@ void grib_accessor_unsigned_bits_t::init(const long len, grib_arguments* args) { grib_accessor_long_t::init(len, args); int n = 0; - numberOfBits_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++); - numberOfElements_ = grib_arguments_get_name(grib_handle_of_accessor(this), args, n++); + numberOfBits_ = args->get_name(grib_handle_of_accessor(this), n++); + numberOfElements_ = args->get_name(grib_handle_of_accessor(this), n++); length_ = compute_byte_count(); } diff --git a/src/accessor/grib_accessor_class_validity_date.cc b/src/accessor/grib_accessor_class_validity_date.cc index c9b89d42b..9ab19f843 100644 --- a/src/accessor/grib_accessor_class_validity_date.cc +++ b/src/accessor/grib_accessor_class_validity_date.cc @@ -19,13 +19,13 @@ void grib_accessor_validity_date_t::init(const long l, grib_arguments* c) grib_handle* hand = grib_handle_of_accessor(this); int n = 0; - date_ = grib_arguments_get_name(hand, c, n++); - time_ = grib_arguments_get_name(hand, c, n++); - step_ = grib_arguments_get_name(hand, c, n++); - stepUnits_ = grib_arguments_get_name(hand, c, n++); - year_ = grib_arguments_get_name(hand, c, n++); - month_ = grib_arguments_get_name(hand, c, n++); - day_ = grib_arguments_get_name(hand, c, n++); + date_ = c->get_name(hand, n++); + time_ = c->get_name(hand, n++); + step_ = c->get_name(hand, n++); + stepUnits_ = c->get_name(hand, n++); + year_ = c->get_name(hand, n++); + month_ = c->get_name(hand, n++); + day_ = c->get_name(hand, n++); flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; } diff --git a/src/accessor/grib_accessor_class_validity_time.cc b/src/accessor/grib_accessor_class_validity_time.cc index d4b6f4865..518297280 100644 --- a/src/accessor/grib_accessor_class_validity_time.cc +++ b/src/accessor/grib_accessor_class_validity_time.cc @@ -19,12 +19,12 @@ void grib_accessor_validity_time_t::init(const long l, grib_arguments* c) grib_handle* hand = grib_handle_of_accessor(this); int n = 0; - date_ = grib_arguments_get_name(hand, c, n++); - time_ = grib_arguments_get_name(hand, c, n++); - step_ = grib_arguments_get_name(hand, c, n++); - stepUnits_ = grib_arguments_get_name(hand, c, n++); - hours_ = grib_arguments_get_name(hand, c, n++); - minutes_ = grib_arguments_get_name(hand, c, n++); + date_ = c->get_name(hand, n++); + time_ = c->get_name(hand, n++); + step_ = c->get_name(hand, n++); + stepUnits_ = c->get_name(hand, n++); + hours_ = c->get_name(hand, n++); + minutes_ = c->get_name(hand, n++); flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; } diff --git a/src/accessor/grib_accessor_class_values.cc b/src/accessor/grib_accessor_class_values.cc index b44c11ba4..8116e7d92 100644 --- a/src/accessor/grib_accessor_class_values.cc +++ b/src/accessor/grib_accessor_class_values.cc @@ -49,9 +49,9 @@ void grib_accessor_values_t::init(const long v, grib_arguments* params) grib_accessor_gen_t::init(v, params); carg_ = 0; - seclen_ = grib_arguments_get_name(grib_handle_of_accessor(this), params, carg_++); - offsetdata_ = grib_arguments_get_name(grib_handle_of_accessor(this), params, carg_++); - offsetsection_ = grib_arguments_get_name(grib_handle_of_accessor(this), params, carg_++); + seclen_ = params->get_name(grib_handle_of_accessor(this), carg_++); + offsetdata_ = params->get_name(grib_handle_of_accessor(this), carg_++); + offsetsection_ = params->get_name(grib_handle_of_accessor(this), carg_++); values_dirty_ = 1; length_ = init_length(); diff --git a/src/accessor/grib_accessor_class_variable.cc b/src/accessor/grib_accessor_class_variable.cc index 1fbc899d6..aeb70aaac 100644 --- a/src/accessor/grib_accessor_class_variable.cc +++ b/src/accessor/grib_accessor_class_variable.cc @@ -27,7 +27,8 @@ void grib_accessor_variable_t::init(const long length, grib_arguments* args) grib_accessor_gen_t::init(length, args); grib_handle* hand = grib_handle_of_accessor(this); - grib_expression* expression = grib_arguments_get_expression(hand, args, 0); + grib_expression* expression = nullptr; + if (args) expression = args->get_expression(hand, 0); const char* p = 0; size_t len = 1; long l = 0; @@ -41,23 +42,23 @@ void grib_accessor_variable_t::init(const long length, grib_arguments* args) length_ = 0; if (type_ == GRIB_TYPE_UNDEFINED && expression) { - type_ = grib_expression_native_type(hand, expression); + type_ = expression->native_type(hand); switch (type_) { case GRIB_TYPE_DOUBLE: - grib_expression_evaluate_double(hand, expression, &d); + expression->evaluate_double(hand, &d); pack_double(&d, &len); break; case GRIB_TYPE_LONG: - grib_expression_evaluate_long(hand, expression, &l); + expression->evaluate_long(hand, &l); pack_long(&l, &len); break; default: { char tmp[1024]; len = sizeof(tmp); - p = grib_expression_evaluate_string(hand, expression, tmp, &len, &ret); + p = expression->evaluate_string(hand, tmp, &len, &ret); if (ret != GRIB_SUCCESS) { grib_context_log(context_, GRIB_LOG_ERROR, "Unable to evaluate %s as string: %s", name_, grib_get_error_message(ret)); diff --git a/src/accessor/grib_accessor_class_vector.cc b/src/accessor/grib_accessor_class_vector.cc index 1c0526641..6ee016599 100644 --- a/src/accessor/grib_accessor_class_vector.cc +++ b/src/accessor/grib_accessor_class_vector.cc @@ -19,8 +19,8 @@ void grib_accessor_vector_t::init(const long l, grib_arguments* c) grib_accessor_abstract_vector_t::init(l, c); int n = 0; - vector_ = grib_arguments_get_name(grib_handle_of_accessor(this), c, n++); - index_ = grib_arguments_get_long(grib_handle_of_accessor(this), c, n++); + vector_ = c->get_name(grib_handle_of_accessor(this), n++); + index_ = c->get_long(grib_handle_of_accessor(this), n++); flags_ |= GRIB_ACCESSOR_FLAG_READ_ONLY; flags_ |= GRIB_ACCESSOR_FLAG_FUNCTION; length_ = 0; diff --git a/src/action_class_assert.cc b/src/action_class_assert.cc index bc449c7ab..9be7a0fc0 100644 --- a/src/action_class_assert.cc +++ b/src/action_class_assert.cc @@ -112,7 +112,7 @@ static void dump(grib_action* act, FILE* f, int lvl) static void destroy(grib_context* context, grib_action* act) { grib_action_assert* a = (grib_action_assert*)act; - grib_expression_free(context, a->expression); + a->expression->destroy(context); grib_context_free_persistent(context, act->name); grib_context_free_persistent(context, act->op); } @@ -123,7 +123,7 @@ static int execute(grib_action* a, grib_handle* h) double res = 0; grib_action_assert* self = (grib_action_assert*)a; - if ((ret = grib_expression_evaluate_double(h, self->expression, &res)) != GRIB_SUCCESS) + if ((ret = self->expression->evaluate_double(h, &res)) != GRIB_SUCCESS) return ret; if (res != 0) { @@ -131,7 +131,7 @@ static int execute(grib_action* a, grib_handle* h) } else { grib_context_log(h->context, GRIB_LOG_ERROR, "Assertion failure: "); - grib_expression_print(h->context, self->expression, h, stderr); + self->expression->print(h->context, h, stderr); fprintf(stderr, "\n"); return GRIB_ASSERTION_FAILURE; } @@ -144,7 +144,7 @@ static int notify_change(grib_action* a, grib_accessor* observer, grib_accessor* int ret = GRIB_SUCCESS; long lres; - if ((ret = grib_expression_evaluate_long(grib_handle_of_accessor(observed), self->expression, &lres)) != GRIB_SUCCESS) + if ((ret = self->expression->evaluate_long(grib_handle_of_accessor(observed), &lres)) != GRIB_SUCCESS) return ret; if (lres != 0) diff --git a/src/action_class_concept.cc b/src/action_class_concept.cc index 17886564b..598a4cd60 100644 --- a/src/action_class_concept.cc +++ b/src/action_class_concept.cc @@ -321,11 +321,11 @@ static int concept_condition_expression_true(grib_handle* h, grib_concept_condit long lres = 0; int ok = 0; int err = 0; - const int type = grib_expression_native_type(h, c->expression); + const int type = c->expression->native_type(h); switch (type) { case GRIB_TYPE_LONG: - grib_expression_evaluate_long(h, c->expression, &lres); + c->expression->evaluate_long(h, &lres); ok = (grib_get_long(h, c->name, &lval) == GRIB_SUCCESS) && (lval == lres); if (ok) @@ -335,7 +335,7 @@ static int concept_condition_expression_true(grib_handle* h, grib_concept_condit case GRIB_TYPE_DOUBLE: { double dval; double dres = 0.0; - grib_expression_evaluate_double(h, c->expression, &dres); + c->expression->evaluate_double(h, &dres); ok = (grib_get_double(h, c->name, &dval) == GRIB_SUCCESS) && (dval == dres); if (ok) @@ -351,7 +351,7 @@ static int concept_condition_expression_true(grib_handle* h, grib_concept_condit size_t size = sizeof(tmp); ok = (grib_get_string(h, c->name, buf, &len) == GRIB_SUCCESS) && - ((cval = grib_expression_evaluate_string(h, c->expression, tmp, &size, &err)) != NULL) && + ((cval = c->expression->evaluate_string(h, tmp, &size, &err)) != NULL) && (err == 0) && (strcmp(buf, cval) == 0); if (ok) { snprintf(exprVal, size, "%s", cval); diff --git a/src/action_class_gen.cc b/src/action_class_gen.cc index eaf1627ff..660931b9f 100644 --- a/src/action_class_gen.cc +++ b/src/action_class_gen.cc @@ -149,7 +149,7 @@ static int create_accessor(grib_section* p, grib_action* act, grib_loader* loade static int notify_change(grib_action* act, grib_accessor* notified, grib_accessor* changed) { if (act->default_value) - return notified->pack_expression(grib_arguments_get_expression(grib_handle_of_accessor(notified), act->default_value, 0)); + return notified->pack_expression(act->default_value->get_expression(grib_handle_of_accessor(notified), 0)); return GRIB_SUCCESS; } diff --git a/src/action_class_if.cc b/src/action_class_if.cc index 5d4140710..94609585c 100644 --- a/src/action_class_if.cc +++ b/src/action_class_if.cc @@ -141,7 +141,7 @@ static int create_accessor(grib_section* p, grib_action* act, grib_loader* h) gs = as->sub_section_; grib_push_accessor(as, p->block); - if ((ret = grib_expression_evaluate_long(p->h, a->expression, &lres)) != GRIB_SUCCESS) + if ((ret = a->expression->evaluate_long(p->h, &lres)) != GRIB_SUCCESS) return ret; if (lres) @@ -151,7 +151,7 @@ static int create_accessor(grib_section* p, grib_action* act, grib_loader* h) if (p->h->context->debug > 1) { fprintf(stderr, "EVALUATE create_accessor_handle "); - grib_expression_print(p->h->context, a->expression, p->h, stderr); + a->expression->print(p->h->context, p->h, stderr); fprintf(stderr, " [%s][_if%p]\n", (next == a->block_true ? "true" : "false"), (void*)a); /*grib_dump_action_branch(stdout,next,5);*/ @@ -172,7 +172,7 @@ static int create_accessor(grib_section* p, grib_action* act, grib_loader* h) static void print_expression_debug_info(grib_context* ctx, grib_expression* exp, grib_handle* h) { - grib_expression_print(ctx, exp, h, stderr); /* writes without a newline */ + exp->print(ctx, h, stderr); /* writes without a newline */ fprintf(stderr, "\n"); } @@ -185,9 +185,9 @@ static int execute(grib_action* act, grib_handle* h) long lres = 0; /* See GRIB-394 */ - int type = grib_expression_native_type(h, a->expression); + int type = a->expression->native_type(h); if (type != GRIB_TYPE_DOUBLE) { - if ((ret = grib_expression_evaluate_long(h, a->expression, &lres)) != GRIB_SUCCESS) { + if ((ret = a->expression->evaluate_long(h, &lres)) != GRIB_SUCCESS) { if (ret == GRIB_NOT_FOUND) lres = 0; else { @@ -199,7 +199,7 @@ static int execute(grib_action* act, grib_handle* h) } else { double dres = 0.0; - ret = grib_expression_evaluate_double(h, a->expression, &dres); + ret = a->expression->evaluate_double(h, &dres); lres = (long)dres; if (ret != GRIB_SUCCESS) { if (ret == GRIB_NOT_FOUND) @@ -236,7 +236,7 @@ static void dump(grib_action* act, FILE* f, int lvl) grib_context_print(act->context, f, " "); printf("if(%s) { ", act->name); - grib_expression_print(act->context, a->expression, 0, stdout); + a->expression->print(act->context, 0, stdout); printf("\n"); if (a->block_true) { @@ -248,7 +248,7 @@ static void dump(grib_action* act, FILE* f, int lvl) for (i = 0; i < lvl; i++) grib_context_print(act->context, f, " "); printf("else(%s) { ", act->name); - grib_expression_print(act->context, a->expression, 0, stdout); + a->expression->print(act->context, 0, stdout); /* grib_context_print(act->context,f,"ELSE \n" );*/ grib_dump_action_branch(f, a->block_false, lvl + 1); } @@ -265,7 +265,7 @@ static grib_action* reparse(grib_action* a, grib_accessor* acc, int* doit) /* printf("reparse %s %s\n",a->name,acc->name); */ - if ((ret = grib_expression_evaluate_long(grib_handle_of_accessor(acc), self->expression, &lres)) != GRIB_SUCCESS) + if ((ret = self->expression->evaluate_long(grib_handle_of_accessor(acc), &lres)) != GRIB_SUCCESS) grib_context_log(acc->context_, GRIB_LOG_ERROR, "action_class_if::reparse: grib_expression_evaluate_long failed: %s", grib_get_error_message(ret)); @@ -294,7 +294,7 @@ static void destroy(grib_context* context, grib_action* act) f = nf; } - grib_expression_free(context, a->expression); + a->expression->destroy(context); grib_context_free_persistent(context, act->name); grib_context_free_persistent(context, act->debug_info); diff --git a/src/action_class_list.cc b/src/action_class_list.cc index 00f8d1459..acc36c6a2 100644 --- a/src/action_class_list.cc +++ b/src/action_class_list.cc @@ -102,7 +102,7 @@ static int create_accessor(grib_section* p, grib_action* act, grib_loader* h) int ret = 0; long val = 0; - if ((ret = grib_expression_evaluate_long(p->h, a->expression, &val)) != GRIB_SUCCESS) { + if ((ret = a->expression->evaluate_long(p->h, &val)) != GRIB_SUCCESS) { grib_context_log(p->h->context, GRIB_LOG_DEBUG, "List %s creating %ld values: Unable to evaluate long", act->name, val); return ret; } @@ -159,7 +159,7 @@ static grib_action* reparse(grib_action* a, grib_accessor* acc, int* doit) long val = 0; - int ret = grib_expression_evaluate_long(grib_handle_of_accessor(acc), self->expression, &val); + int ret = self->expression->evaluate_long(grib_handle_of_accessor(acc), &val); if (ret != GRIB_SUCCESS) { grib_context_log(acc->context_, GRIB_LOG_ERROR, "List %s creating %ld values: Unable to evaluate long", acc->name_, val); @@ -183,5 +183,5 @@ static void destroy(grib_context* context, grib_action* act) grib_context_free_persistent(context, act->name); grib_context_free_persistent(context, act->op); - grib_expression_free(context, self->expression); + self->expression->destroy(context); } diff --git a/src/action_class_remove.cc b/src/action_class_remove.cc index 479811381..e46809dda 100644 --- a/src/action_class_remove.cc +++ b/src/action_class_remove.cc @@ -114,13 +114,13 @@ static int create_accessor(grib_section* p, grib_action* act, grib_loader* h) { grib_action_remove* a = (grib_action_remove*)act; - grib_accessor* ga = grib_find_accessor(p->h, grib_arguments_get_name(p->h, a->args, 0)); + grib_accessor* ga = grib_find_accessor(p->h, a->args->get_name(p->h, 0)); if (ga) { remove_accessor(ga); } else { grib_context_log(act->context, GRIB_LOG_DEBUG, - "Action_class_remove: create_accessor: No accessor named %s to remove", grib_arguments_get_name(p->h, a->args, 0)); + "Action_class_remove: create_accessor: No accessor named %s to remove", a->args->get_name(p->h, 0)); } return GRIB_SUCCESS; } diff --git a/src/action_class_set.cc b/src/action_class_set.cc index 799bd6be1..53ac105a0 100644 --- a/src/action_class_set.cc +++ b/src/action_class_set.cc @@ -124,7 +124,7 @@ static void destroy(grib_context* context, grib_action* act) grib_action_set* a = (grib_action_set*)act; grib_context_free_persistent(context, a->name); - grib_expression_free(context, a->expression); + a->expression->destroy(context); grib_context_free_persistent(context, act->name); grib_context_free_persistent(context, act->op); } diff --git a/src/action_class_switch.cc b/src/action_class_switch.cc index 547149987..d792d7cac 100644 --- a/src/action_class_switch.cc +++ b/src/action_class_switch.cc @@ -142,35 +142,35 @@ static int execute(grib_action* act, grib_handle* h) Assert(args); while (c) { - e = args->expression; + e = args->expression_; values = c->values; - value = values->expression; + value = values->expression_; ok = 0; while (e && value) { - if (!strcmp(value->cclass->name, "true")) + if (!strcmp(value->class_name(), "true")) ok = 1; else { - type = grib_expression_native_type(h, value); + type = value->native_type(h); switch (type) { case GRIB_TYPE_LONG: - ok = (grib_expression_evaluate_long(h, value, &lres) == GRIB_SUCCESS) && - (grib_expression_evaluate_long(h, e, &lval) == GRIB_SUCCESS) && + ok = (value->evaluate_long(h, &lres) == GRIB_SUCCESS) && + (e->evaluate_long(h, &lval) == GRIB_SUCCESS) && (lval == lres); break; case GRIB_TYPE_DOUBLE: - ok = (grib_expression_evaluate_double(h, value, &dres) == GRIB_SUCCESS) && - (grib_expression_evaluate_double(h, e, &dval) == GRIB_SUCCESS) && + ok = (value->evaluate_double(h, &dres) == GRIB_SUCCESS) && + (e->evaluate_double(h, &dval) == GRIB_SUCCESS) && (dval == dres); break; case GRIB_TYPE_STRING: len = sizeof(buf); size = sizeof(tmp); - ok = ((cres = grib_expression_evaluate_string(h, e, buf, &len, &err)) != NULL) && + ok = ((cres = e->evaluate_string(h, buf, &len, &err)) != NULL) && (err == 0) && - ((cval = grib_expression_evaluate_string(h, value, tmp, &size, &err)) != NULL) && + ((cval = value->evaluate_string(h, tmp, &size, &err)) != NULL) && (err == 0) && ((strcmp(buf, cval) == 0) || (strcmp(cval, "*") == 0)); break; @@ -183,15 +183,15 @@ static int execute(grib_action* act, grib_handle* h) if (!ok) break; - args = args->next; + args = args->next_; if (args) - e = args->expression; + e = args->expression_; else e = NULL; - values = values->next; + values = values->next_; if (values) - value = values->expression; + value = values->expression_; else value = NULL; } diff --git a/src/action_class_when.cc b/src/action_class_when.cc index a8af5bad4..16cb8790a 100644 --- a/src/action_class_when.cc +++ b/src/action_class_when.cc @@ -35,37 +35,38 @@ or edit "action.class" and rerun ./make_class.pl */ -static void init_class (grib_action_class*); -static void dump (grib_action* d, FILE*,int); -static void destroy (grib_context*,grib_action*); -static int create_accessor(grib_section*,grib_action*,grib_loader*); -static int notify_change(grib_action* a, grib_accessor* observer,grib_accessor* observed); +static void init_class(grib_action_class*); +static void dump(grib_action* d, FILE*, int); +static void destroy(grib_context*, grib_action*); +static int create_accessor(grib_section*, grib_action*, grib_loader*); +static int notify_change(grib_action* a, grib_accessor* observer, grib_accessor* observed); -typedef struct grib_action_when { - grib_action act; +typedef struct grib_action_when +{ + grib_action act; /* Members defined in when */ - grib_expression *expression; - grib_action *block_true; - grib_action *block_false; + grib_expression* expression; + grib_action* block_true; + grib_action* block_false; int loop; } grib_action_when; static grib_action_class _grib_action_class_when = { - 0, /* super */ - "action_class_when", /* name */ - sizeof(grib_action_when), /* size */ - 0, /* inited */ - &init_class, /* init_class */ - 0, /* init */ - &destroy, /* destroy */ - &dump, /* dump */ - 0, /* xref */ - &create_accessor, /* create_accessor */ - ¬ify_change, /* notify_change */ - 0, /* reparse */ - 0, /* execute */ + 0, /* super */ + "action_class_when", /* name */ + sizeof(grib_action_when), /* size */ + 0, /* inited */ + &init_class, /* init_class */ + 0, /* init */ + &destroy, /* destroy */ + &dump, /* dump */ + 0, /* xref */ + &create_accessor, /* create_accessor */ + ¬ify_change, /* notify_change */ + 0, /* reparse */ + 0, /* execute */ }; grib_action_class* grib_action_class_when = &_grib_action_class_when; @@ -77,7 +78,7 @@ static void init_class(grib_action_class* c) /* The check on self->loop can only be done in non-threaded mode */ #if defined(DEBUG) && GRIB_PTHREADS == 0 && GRIB_OMP_THREADS == 0 -#define CHECK_LOOP 1 + #define CHECK_LOOP 1 #endif grib_action* grib_action_create_when(grib_context* context, @@ -143,7 +144,7 @@ static void dump(grib_action* act, FILE* f, int lvl) grib_context_print(act->context, f, " "); printf("when(%s) { ", act->name); - grib_expression_print(act->context, a->expression, 0, stdout); + a->expression->print(act->context, 0, stdout); printf("\n"); grib_dump_action_branch(f, a->block_true, lvl + 1); @@ -165,9 +166,9 @@ static void dump(grib_action* act, FILE* f, int lvl) } #ifdef CHECK_LOOP -#define SET_LOOP(self, v) self->loop = v; + #define SET_LOOP(self, v) self->loop = v; #else -#define SET_LOOP(self, v) + #define SET_LOOP(self, v) #endif static int notify_change(grib_action* a, grib_accessor* observer, grib_accessor* observed) @@ -183,13 +184,13 @@ static int notify_change(grib_action* a, grib_accessor* observer, grib_accessor* */ grib_handle* hand = grib_handle_of_accessor(observed); - if ((ret = grib_expression_evaluate_long(hand, self->expression, &lres)) != GRIB_SUCCESS) + if ((ret = self->expression->evaluate_long(hand, &lres)) != GRIB_SUCCESS) return ret; #ifdef CHECK_LOOP if (self->loop) { printf("LOOP detected...\n"); printf("WHEN triggered by %s %ld\n", observed->name_, lres); - grib_expression_print(observed->context_, self->expression, 0, stderr); + self->expression->print(observed->context_, 0, stderr); fprintf(stderr, "\n"); return ret; } @@ -198,9 +199,9 @@ static int notify_change(grib_action* a, grib_accessor* observer, grib_accessor* if (hand->context->debug > 0) { grib_context_log(hand->context, GRIB_LOG_DEBUG, - "------------- SECTION action %s is triggered by [%s] (%s)", - a->name, observed->name_, a->debug_info ? a->debug_info : "no debug info"); - grib_expression_print(observed->context_, self->expression, 0, stderr); + "------------- SECTION action %s is triggered by [%s] (%s)", + a->name, observed->name_, a->debug_info ? a->debug_info : "no debug info"); + self->expression->print(observed->context_, 0, stderr); fprintf(stderr, "\n"); } @@ -241,7 +242,7 @@ static void destroy(grib_context* context, grib_action* act) t = nt; } - grib_expression_free(context, self->expression); + self->expression->destroy(context); grib_context_free_persistent(context, act->name); grib_context_free_persistent(context, act->debug_info); diff --git a/src/eccodes_prototypes.h b/src/eccodes_prototypes.h index 617f3c207..13640a376 100644 --- a/src/eccodes_prototypes.h +++ b/src/eccodes_prototypes.h @@ -813,23 +813,23 @@ eccodes::geo_iterator::Iterator* grib_iterator_factory(grib_handle* h, grib_argu int transform_iterator_data(grib_context* c, double* data, long iScansNegatively, long jScansPositively, long jPointsAreConsecutive, long alternativeRowScanning, size_t numPoints, long nx, long ny); /* grib_expression.cc */ -int grib_expression_native_type(grib_handle* h, grib_expression* g); -int grib_expression_evaluate_long(grib_handle* h, grib_expression* g, long* result); -int grib_expression_evaluate_double(grib_handle* h, grib_expression* g, double* result); -const char* grib_expression_evaluate_string(grib_handle* h, grib_expression* g, char* buf, size_t* size, int* err); -const char* grib_expression_get_name(grib_expression* g); -void grib_expression_print(grib_context* ctx, grib_expression* g, grib_handle* f, FILE*); -void grib_expression_free(grib_context* ctx, grib_expression* g); -void grib_expression_add_dependency(grib_expression* e, grib_accessor* observer); -grib_arguments* grib_arguments_new(grib_context* c, grib_expression* g, grib_arguments* n); -void grib_arguments_free(grib_context* c, grib_arguments* g); -void grib_arguments_print(grib_context* c, grib_arguments* g, grib_handle* f); -const char* grib_arguments_get_name(grib_handle* h, grib_arguments* args, int n); -const char* grib_arguments_get_string(grib_handle* h, grib_arguments* args, int n); -long grib_arguments_get_long(grib_handle* h, grib_arguments* args, int n); -double grib_arguments_get_double(grib_handle* h, grib_arguments* args, int n); -grib_expression* grib_arguments_get_expression(grib_handle* h, grib_arguments* args, int n); -int grib_arguments_get_count(grib_arguments* args); +//int grib_expression_native_type(grib_handle* h, grib_expression* g); +//int grib_expression_evaluate_long(grib_handle* h, grib_expression* g, long* result); +//int grib_expression_evaluate_double(grib_handle* h, grib_expression* g, double* result); +//const char* grib_expression_evaluate_string(grib_handle* h, grib_expression* g, char* buf, size_t* size, int* err); +//const char* grib_expression_get_name(grib_expression* g); +//void grib_expression_print(grib_context* ctx, grib_expression* g, grib_handle* f, FILE*); +//void grib_expression_free(grib_context* ctx, grib_expression* g); +//void grib_expression_add_dependency(grib_expression* e, grib_accessor* observer); +//grib_arguments* grib_arguments_new(grib_context* c, grib_expression* g, grib_arguments* n); +//void grib_arguments_free(grib_context* c, grib_arguments* g); +//void grib_arguments_print(grib_context* c, grib_arguments* g, grib_handle* f); +//const char* grib_arguments_get_name(grib_handle* h, grib_arguments* args, int n); +//const char* grib_arguments_get_string(grib_handle* h, grib_arguments* args, int n); +//long grib_arguments_get_long(grib_handle* h, grib_arguments* args, int n); +//double grib_arguments_get_double(grib_handle* h, grib_arguments* args, int n); +//grib_expression* grib_arguments_get_expression(grib_handle* h, grib_arguments* args, int n); +//int grib_arguments_get_count(grib_arguments* args); /* codes_util.cc */ double normalise_longitude_in_degrees(double lon); diff --git a/src/expression.class b/src/expression.class deleted file mode 100644 index 0db380e7c..000000000 --- a/src/expression.class +++ /dev/null @@ -1,39 +0,0 @@ -typedef const char* string; /* to keep make_class.pl happy */ - -static void init(grib_expression* e); -static void destroy(grib_context*,grib_expression* e); -static void print(grib_context*, grib_expression*, grib_handle*, FILE*); -static void add_dependency(grib_expression* e, grib_accessor* observer); -static string get_name(grib_expression* e); -static int native_type(grib_expression*,grib_handle*); -static int evaluate_long(grib_expression*,grib_handle*,long*); -static int evaluate_double(grib_expression*,grib_handle*,double*); -static string evaluate_string(grib_expression*,grib_handle*,char*,size_t*,int*); - -typedef struct grib_expression_NAME{ - grib_expression base; - MEMBERS -} grib_expression_NAME; - -extern grib_expression_class* SUPER; - -static grib_expression_class _grib_expression_class_NAME = { - &SUPER, /* super */ - "NAME", /* name */ - sizeof(grib_expression_NAME),/* size of instance */ - 0, /* inited */ - &init, /* constructor */ - &destroy, /* destructor */ - &print, - &add_dependency, - &native_type, - &get_name, - &evaluate_long, - &evaluate_double, - &evaluate_string, -}; - -grib_expression_class* grib_expression_class_NAME = &_grib_expression_class_NAME; - -ADD_TO_FILE grib_expression_class.h extern grib_expression_class* grib_expression_class_NAME; -ADD_TO_FILE grib_expression_factory.h { "NAME", &grib_expression_class_NAME, }, diff --git a/src/expression/grib_arguments.cc b/src/expression/grib_arguments.cc new file mode 100644 index 000000000..96a8030ec --- /dev/null +++ b/src/expression/grib_arguments.cc @@ -0,0 +1,145 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_arguments.h" + + +grib_arguments* grib_arguments_new(grib_context* c, eccodes::Expression* g, eccodes::Arguments* n) +{ + return new eccodes::Arguments(c, g, n); +} + +void grib_arguments_free(grib_context* c, grib_arguments* g) +{ + if (g) { + // TODO(maee): Check for memory leaks + // grib_arguments_free(c, g->next_); + // grib_expression_free(c, g->expression_); + delete g; + } +} + +namespace eccodes { + +Arguments::Arguments(grib_context* c, Expression* g, Arguments* n) +{ + context_ = c; + expression_ = g; + next_ = n; +} + +Arguments::~Arguments() +{ + grib_arguments_free(context_, next_); + grib_expression_free(context_, expression_); +} + +void Arguments::print(grib_handle* f) const +{ + if (expression_) + expression_->print(context_, f, stdout); + if (next_) { + printf(","); + next_->print(f); + } +} + +const char* Arguments::get_name(grib_handle* h, int n) const +{ + const Expression* e = NULL; + const Arguments* args = this; + while (args && n-- > 0) { + args = args->next_; + } + + if (!args) + return NULL; + + e = args->expression_; + return e ? e->get_name() : NULL; +} + +const char* Arguments::get_string(grib_handle* h, int n) const +{ + const Arguments* args = this; + int ret = 0; + while (args && n-- > 0) { + args = args->next_; + } + + if (!args) + return NULL; + + const Expression* e = args->expression_; + return e->evaluate_string(h, NULL, NULL, &ret); +} + +long Arguments::get_long(grib_handle* h, int n) const +{ + int ret = 0; + long lres = 0; + const Arguments* args = this; + while (args && n-- > 0) { + args = args->next_; + } + + if (!args) + return 0; + + const grib_expression* e = args->expression_; + ret = e->evaluate_long(h, &lres); + (void)ret; + return lres; +} + +double Arguments::get_double(grib_handle* h, int n) const +{ + int ret = 0; + double dres = 0.0; + + const Arguments* args = this; + while (args && n-- > 0) { + args = args->next_; + } + + if (!args) + return 0; + + const Expression* e = args->expression_; + ret = e->evaluate_double(h, &dres); + (void)ret; + return dres; +} + +grib_expression* Arguments::get_expression(grib_handle* h, int n) const +{ + const Arguments* args = this; + while (args && n-- > 0) { + args = args->next_; + } + + if (!args) + return 0; + + return args->expression_; +} + +int Arguments::get_count() const +{ + const Arguments* args = this; + int n = 0; + while (args) { + args = args->next_; + n++; + } + return n; +} + +} // namespace eccodes diff --git a/src/expression/grib_arguments.h b/src/expression/grib_arguments.h new file mode 100644 index 000000000..e71711923 --- /dev/null +++ b/src/expression/grib_arguments.h @@ -0,0 +1,42 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_api_internal.h" +#include "grib_expression.h" + +namespace eccodes { + +class Arguments +{ +public: + Arguments(grib_context* c, Expression* g, Arguments* n); + ~Arguments(); + + void print(grib_handle* f) const; + const char* get_name(grib_handle* h, int n) const; + const char* get_string(grib_handle* h, int n) const; + long get_long(grib_handle* h, int n) const; + double get_double(grib_handle* h, int n) const; + grib_expression* get_expression(grib_handle* h, int n) const; + int get_count() const; + + // TODO(maee): make this private + // private: + Arguments* next_ = nullptr; + Expression* expression_ = nullptr; + grib_context* context_ = nullptr; +}; + +} // namespace eccodes + +eccodes::Arguments* grib_arguments_new(grib_context* c, grib_expression* g, eccodes::Arguments* n); +void grib_arguments_free(grib_context* c, grib_arguments* g); diff --git a/src/expression/grib_expression.cc b/src/expression/grib_expression.cc new file mode 100644 index 000000000..e5435dcab --- /dev/null +++ b/src/expression/grib_expression.cc @@ -0,0 +1,56 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_expression.h" + +void grib_expression_free(grib_context* ctx, grib_expression* g) +{ + if (g) { + delete g; + } +} + +namespace eccodes { + +int Expression::native_type(grib_handle* h) const +{ + grib_context_log(h->context, GRIB_LOG_FATAL, "%s: No native_type() in %s", __func__, class_name()); + return 0; +} + +int Expression::evaluate_long(grib_handle* h, long* result) const +{ + return GRIB_INVALID_TYPE; +} + +int Expression::evaluate_double(grib_handle* h, double* result) const +{ + return GRIB_INVALID_TYPE; +} + +const char* Expression::evaluate_string(grib_handle* h, char* buf, size_t* size, int* err) const +{ + grib_context_log(h->context, GRIB_LOG_ERROR, "%s: No evaluate_string() in %s", __func__, class_name()); + *err = GRIB_INVALID_TYPE; + + return nullptr; +} + +const char* Expression::get_name() const +{ + grib_context_log(grib_context_get_default(), GRIB_LOG_FATAL, "%s: No get_name() in %s", __func__, class_name()); + return nullptr; +} + +void Expression::print(grib_context* ctx, grib_handle* f, FILE* out) const {} + +void Expression::add_dependency(grib_accessor* observer) {} + +} // namespace eccodes diff --git a/src/expression/grib_expression.h b/src/expression/grib_expression.h new file mode 100644 index 000000000..f61690e0c --- /dev/null +++ b/src/expression/grib_expression.h @@ -0,0 +1,50 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_api_internal.h" +#include + +namespace eccodes { + +class Expression +{ +public: + using string = const char*; + + using PackProc = std::function; + using UnpackProc = std::function; + using BinopLongProc = std::function; + using UnopLongProc = std::function; + using BinopDoubleProc = std::function; + using UnopDoubleProc = std::function; + using BinopStringProc = std::function; + + virtual ~Expression() {}; + virtual void destroy(grib_context*) {}; + virtual void print(grib_context*, grib_handle*, FILE*) const; + virtual void add_dependency(grib_accessor*); + virtual string get_name() const; + virtual int native_type(grib_handle*) const; + virtual int evaluate_long(grib_handle*, long*) const; + virtual int evaluate_double(grib_handle*, double*) const; + virtual string evaluate_string(grib_handle*, char*, size_t*, int*) const; + + virtual const char* class_name() const = 0; +}; + +} // namespace eccodes + +using grib_expression = eccodes::Expression; + +// Defined in grib_expression_class_accessor.cc +// grib_expression* new_accessor_expression(grib_context*, const char*, long, size_t); +void grib_expression_free(grib_context*, grib_expression*); diff --git a/src/expression/grib_expression_class_accessor.cc b/src/expression/grib_expression_class_accessor.cc new file mode 100644 index 000000000..4dbab030b --- /dev/null +++ b/src/expression/grib_expression_class_accessor.cc @@ -0,0 +1,122 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_expression_class_accessor.h" + +namespace eccodes::expression { + +const char* Accessor::get_name() const +{ + return name_; +} + +int Accessor::evaluate_long(grib_handle* h, long* result) const +{ + return grib_get_long_internal(h, name_, result); +} + +int Accessor::evaluate_double(grib_handle* h, double* result) const +{ + return grib_get_double_internal(h, name_, result); +} + +Accessor::string Accessor::evaluate_string(grib_handle* h, char* buf, size_t* size, int* err) const +{ + char mybuf[1024] = {0,}; + long start = start_; + if (length_ > sizeof(mybuf)) { + *err = GRIB_INVALID_ARGUMENT; + return NULL; + } + + Assert(buf); + if ((*err = grib_get_string_internal(h, name_, mybuf, size)) != GRIB_SUCCESS) + return NULL; + + if (start_ < 0) + start += *size; + + if (length_ != 0) { + if (start >= 0) + memcpy(buf, mybuf + start, length_); + buf[length_] = 0; + } + else { + memcpy(buf, mybuf, *size); + if (*size == 1024) + *size = *size - 1; /* ECC-336 */ + buf[*size] = 0; + } + return buf; +} + +void Accessor::print(grib_context* c, grib_handle* hand, FILE* out) const +{ + int err = 0; + fprintf(out, "access('%s", name_); + if (hand) { + const int ntype = native_type(hand); + if (ntype == GRIB_TYPE_STRING) { + char buf[256] = {0,}; + size_t len = sizeof(buf); + err = grib_get_string(hand, name_, buf, &len); + if (!err) fprintf(out, "=%s", buf); + } + else if (ntype == GRIB_TYPE_LONG) { + long lVal = 0; + err = grib_get_long(hand, name_, &lVal); + if (!err) fprintf(out, "=%ld", lVal); + } + } + fprintf(out, "')"); +} + +void Accessor::destroy(grib_context* c) +{ + grib_context_free_persistent(c, name_); +} + +void Accessor::add_dependency(grib_accessor* observer) +{ + grib_accessor* observed = grib_find_accessor(grib_handle_of_accessor(observer), name_); + + if (!observed) { + /* grib_context_log(observer->context, GRIB_LOG_ERROR, */ + /* "Error in accessor_add_dependency: cannot find [%s]", name_); */ + /* Assert(observed); */ + return; + } + + grib_dependency_add(observer, observed); +} + +Accessor::Accessor(grib_context* c, const char* name, long start, size_t length) +{ + name_ = grib_context_strdup_persistent(c, name); + start_ = start; + length_ = length; +} + +int Accessor::native_type(grib_handle* h) const +{ + int type = 0; + int err; + if ((err = grib_get_native_type(h, name_, &type)) != GRIB_SUCCESS) { + grib_context_log(h->context, GRIB_LOG_ERROR, + "Error in evaluating the type of '%s': %s", name_, grib_get_error_message(err)); + } + return type; +} + +} // namespace eccodes::expression + +grib_expression* new_accessor_expression(grib_context* c, const char* name, long start, size_t length) { + return new eccodes::expression::Accessor(c, name, start, length); +} diff --git a/src/expression/grib_expression_class_accessor.h b/src/expression/grib_expression_class_accessor.h new file mode 100644 index 000000000..3b8b0f05d --- /dev/null +++ b/src/expression/grib_expression_class_accessor.h @@ -0,0 +1,40 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_expression.h" + +namespace eccodes::expression { + +class Accessor : public Expression { +public: + Accessor(grib_context*, const char*, long, size_t); + + void destroy(grib_context*) override; + void print(grib_context*, grib_handle*, FILE*) const override; + void add_dependency(grib_accessor*) override; + string get_name() const override; + int native_type(grib_handle*) const override; + int evaluate_long(grib_handle*, long*) const override; + int evaluate_double(grib_handle*, double*) const override; + string evaluate_string(grib_handle*, char*, size_t*, int*) const override; + + const char* class_name() const override { return "accessor"; }; + +private: + char* name_; + long start_; + size_t length_; +}; + +} // namespace eccodes::expression + +grib_expression* new_accessor_expression(grib_context*, const char*, long, size_t); diff --git a/src/expression/grib_expression_class_binop.cc b/src/expression/grib_expression_class_binop.cc new file mode 100644 index 000000000..6037d929b --- /dev/null +++ b/src/expression/grib_expression_class_binop.cc @@ -0,0 +1,144 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_expression_class_binop.h" + +namespace eccodes::expression { + +int Binop::evaluate_long(grib_handle* h, long* lres) const +{ + long v1 = 0; + long v2 = 0; + +// { +// int typeLeft, typeRight; +// const char* nameLeft; +// const char* nameRight; +// typeLeft = grib_expression_native_type(h, left_); +// typeRight = grib_expression_native_type(h, right_); +// nameLeft = grib_expression_get_name(left_); +// nameRight= grib_expression_get_name(right_); +// printf("eval_long nameLeft=%s (type=%d), nameRight=%s (type=%d)\n",nameLeft,typeLeft, nameRight,typeRight); +// grib_expression_print(h->context, g, h); +// printf("\n"); +// } + + int ret = left_->evaluate_long(h, &v1); + if (ret != GRIB_SUCCESS) + return ret; + + ret = right_->evaluate_long(h, &v2); + if (ret != GRIB_SUCCESS) + return ret; + + *lres = long_func_(v1, v2); + return GRIB_SUCCESS; +} + +int Binop::evaluate_double(grib_handle* h, double* dres) const +{ + double v1 = 0.0; + double v2 = 0.0; + +// { +// int typeLeft, typeRight; +// const char* nameLeft; +// const char* nameRight; +// typeLeft = grib_expression_native_type(h, left_); +// typeRight = grib_expression_native_type(h, right_); +// nameLeft = grib_expression_get_name(left_); +// nameRight= grib_expression_get_name(right_); +// printf("eval_dbl nameLeft=%s (type=%d), nameRight=%s (type=%d)\n",nameLeft,typeLeft, nameRight,typeRight); +// grib_expression_print(h->context, g, h); +// printf("\n"); +// } + + int ret = left_->evaluate_double(h, &v1); + if (ret != GRIB_SUCCESS) + return ret; + + ret = right_->evaluate_double(h, &v2); + if (ret != GRIB_SUCCESS) + return ret; + + *dres = double_func_ ? double_func_(v1, v2) : long_func_(v1, v2); + + return GRIB_SUCCESS; +} + +void Binop::print(grib_context* c, grib_handle* f, FILE* out) const +{ + // Cover a subset of the most commonly used functions + // TODO(masn): Can be done in a much better way! + // e.g., the yacc parser passing in the functions name + if (long_func_ && long_func_.target>()) { + fprintf(out, "equals("); + } else if (long_func_ && long_func_.target>()) { + fprintf(out, "not_equals("); + } else if (long_func_ && long_func_.target>()) { + fprintf(out, "less_than("); + } else if (long_func_ && long_func_.target>()) { + fprintf(out, "greater_than("); + } else { + fprintf(out, "binop("); + } + left_->print(c, f, out); + fprintf(out, ","); + right_->print(c, f, out); + fprintf(out, ")"); +} + +void Binop::destroy(grib_context* c) +{ + left_->destroy(c); + right_->destroy(c); +} + +void Binop::add_dependency(grib_accessor* observer) +{ + left_->add_dependency(observer); + right_->add_dependency(observer); +} + +Binop::Binop(grib_context* c, + BinopLongProc long_func, + BinopDoubleProc double_func, + Expression* left, Expression* right) +{ + left_ = left; + right_ = right; + long_func_ = long_func; + double_func_ = double_func; +} + +int Binop::native_type(grib_handle* h) const +{ + /* See GRIB-394 : The type of this binary expression will be double if any of its operands are double */ + if (left_->native_type(h) == GRIB_TYPE_DOUBLE || + right_->native_type(h) == GRIB_TYPE_DOUBLE) { + return GRIB_TYPE_DOUBLE; + } + return long_func_ ? GRIB_TYPE_LONG : GRIB_TYPE_DOUBLE; +} + +} // namespace eccodes::expression + + +grib_expression* new_binop_expression(grib_context* c, grib_binop_long_proc long_func, grib_binop_double_proc double_func, grib_expression* left, grib_expression* right) { + return new eccodes::expression::Binop(c, long_func, double_func, left, right); +} + +//grib_expression* new_binop_expression(grib_context* c, +// eccodes::Expression::BinopLongProc long_func, +// eccodes::Expression::BinopDoubleProc double_func, +// grib_expression* left, grib_expression* right) +//{ +// return new eccodes::expression::Binop(c, long_func, double_func, left, right); +//} diff --git a/src/expression/grib_expression_class_binop.h b/src/expression/grib_expression_class_binop.h new file mode 100644 index 000000000..e0a4f2e69 --- /dev/null +++ b/src/expression/grib_expression_class_binop.h @@ -0,0 +1,40 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_expression.h" + +namespace eccodes::expression { + +class Binop : public Expression { +public: + Binop(grib_context*, BinopLongProc, BinopDoubleProc, Expression*, Expression*); + + void destroy(grib_context*) override; + void print(grib_context*, grib_handle*, FILE*) const override; + void add_dependency(grib_accessor*) override; + int native_type(grib_handle*) const override; + int evaluate_long(grib_handle*, long*) const override; + int evaluate_double(grib_handle*, double*) const override; + + const char* class_name() const override { return "binop"; }; + +private: + Expression* left_ = nullptr; + Expression* right_ = nullptr; + BinopLongProc long_func_ = nullptr; + BinopDoubleProc double_func_ = nullptr; + BinopStringProc string_func_ = nullptr; +}; + +} // namespace eccodes::expression + +grib_expression* new_binop_expression(grib_context*, grib_binop_long_proc, grib_binop_double_proc, grib_expression*, grib_expression*); diff --git a/src/expression/grib_expression_class_double.cc b/src/expression/grib_expression_class_double.cc new file mode 100644 index 000000000..82d9aaa88 --- /dev/null +++ b/src/expression/grib_expression_class_double.cc @@ -0,0 +1,47 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_expression_class_double.h" + +namespace eccodes::expression { + +int Double::evaluate_long(grib_handle* h, long* lres) const +{ + *lres = value_; + return GRIB_SUCCESS; +} + +int Double::evaluate_double(grib_handle* h, double* dres) const +{ + *dres = value_; + return GRIB_SUCCESS; +} + +void Double::print(grib_context* c, grib_handle* f, FILE* out) const +{ + fprintf(out, "double(%g)", value_); +} + +Double::Double(grib_context* c, double value) +{ + value_ = value; +} + +int Double::native_type(grib_handle* h) const +{ + return GRIB_TYPE_DOUBLE; +} + +} // namespace eccodes::expression + +grib_expression* new_double_expression(grib_context* c, double value) +{ + return new eccodes::expression::Double(c, value); +} diff --git a/src/expression/grib_expression_class_double.h b/src/expression/grib_expression_class_double.h new file mode 100644 index 000000000..5df2cb258 --- /dev/null +++ b/src/expression/grib_expression_class_double.h @@ -0,0 +1,36 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_expression.h" + +namespace eccodes::expression { + +class Double : public Expression +{ +public: + Double(grib_context*, double); + + void print(grib_context*, grib_handle*, FILE*) const override; + void add_dependency(grib_accessor*) override {} + int native_type(grib_handle*) const override; + int evaluate_long(grib_handle*, long*) const override; + int evaluate_double(grib_handle*, double*) const override; + + const char* class_name() const override { return "double"; }; + +private: + double value_ = 0.0; +}; + +} // namespace eccodes::expression + +grib_expression* new_double_expression(grib_context*, double); diff --git a/src/grib_expression_class_functor.cc b/src/expression/grib_expression_class_functor.cc similarity index 55% rename from src/grib_expression_class_functor.cc rename to src/expression/grib_expression_class_functor.cc index a85374886..901e357a5 100644 --- a/src/grib_expression_class_functor.cc +++ b/src/expression/grib_expression_class_functor.cc @@ -8,70 +8,13 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api_internal.h" +#include "grib_expression_class_functor.h" #include #include -/* - This is used by make_class.pl - START_CLASS_DEF - CLASS = expression - IMPLEMENTS = destroy - IMPLEMENTS = native_type - IMPLEMENTS = evaluate_long - IMPLEMENTS = print - IMPLEMENTS = add_dependency - MEMBERS = char *name - MEMBERS = grib_arguments *args - END_CLASS_DEF - - */ -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "expression.class" and rerun ./make_class.pl - -*/ - -typedef const char* string; /* to keep make_class.pl happy */ - -static void destroy(grib_context*,grib_expression* e); -static void print(grib_context*, grib_expression*, grib_handle*, FILE*); -static void add_dependency(grib_expression* e, grib_accessor* observer); -static int native_type(grib_expression*,grib_handle*); -static int evaluate_long(grib_expression*,grib_handle*,long*); - -typedef struct grib_expression_functor{ - grib_expression base; - /* Members defined in functor */ - char *name; - grib_arguments *args; -} grib_expression_functor; - - -static grib_expression_class _grib_expression_class_functor = { - 0, /* super */ - "functor", /* name */ - sizeof(grib_expression_functor),/* size of instance */ - 0, /* inited */ - 0, /* constructor */ - &destroy, /* destructor */ - &print, - &add_dependency, - &native_type, - 0, - &evaluate_long, - 0, - 0, -}; - -grib_expression_class* grib_expression_class_functor = &_grib_expression_class_functor; - -/* END_CLASS_IMP */ +namespace eccodes::expression +{ // See ECC-1936. We cannot use strcasestr (not on Windows and non-standard) static bool string_contains_case(const char* haystack, const char* needle, bool case_sensitive) @@ -90,30 +33,31 @@ static bool string_contains_case(const char* haystack, const char* needle, bool return copy_haystack.find(copy_needle) != std::string::npos; } -static int evaluate_long(grib_expression* g, grib_handle* h, long* lres) +int Functor::evaluate_long(grib_handle* h, long* lres) const { - grib_expression_functor* e = (grib_expression_functor*)g; - - // if (STR_EQUAL(e->name, "lookup")) { + // if (STR_EQUAL(name_, "lookup")) { // return GRIB_SUCCESS; // } - if (STR_EQUAL(e->name, "new")) { + if (STR_EQUAL(name_, "new")) { *lres = h->loader != NULL; return GRIB_SUCCESS; } - if (STR_EQUAL(e->name, "abs")) { - grib_expression* exp = grib_arguments_get_expression(h, e->args, 0); - long lval = 0; - int ret = grib_expression_evaluate_long(h, exp, &lval); - *lres = abs(lval); - return ret; + if (STR_EQUAL(name_, "abs")) { + const grib_expression* exp = args_ ? args_->get_expression(h, 0) : nullptr; + if (exp) { + long lval = 0; + int ret = exp->evaluate_long(h, &lval); + *lres = abs(lval); + return ret; + } + return GRIB_INVALID_ARGUMENT; } - if (STR_EQUAL(e->name, "size")) { + if (STR_EQUAL(name_, "size")) { *lres = 0; - const char* keyName = grib_arguments_get_name(h, e->args, 0); + const char* keyName = args_ ? args_->get_name(h, 0) : nullptr; if (keyName) { size_t size = 0; int err = grib_get_size(h, keyName, &size); @@ -124,16 +68,16 @@ static int evaluate_long(grib_expression* g, grib_handle* h, long* lres) return GRIB_INVALID_ARGUMENT; } - if (STR_EQUAL(e->name, "debug_mode")) { - const int n = grib_arguments_get_count(e->args); + if (STR_EQUAL(name_, "debug_mode")) { + const int n = args_ ? args_->get_count() : 0; if (n != 1) return GRIB_INVALID_ARGUMENT; - const int dmode = grib_arguments_get_long(h, e->args, 0); + const int dmode = args_ ? args_->get_long(h, 0) : 0; grib_context_set_debug(0, dmode); return GRIB_SUCCESS; } - if (STR_EQUAL(e->name, "missing")) { - const char* keyName = grib_arguments_get_name(h, e->args, 0); + if (STR_EQUAL(name_, "missing")) { + const char* keyName = args_ ? args_->get_name(h, 0) : nullptr; if (keyName) { long val = 0; int err = 0; @@ -159,8 +103,8 @@ static int evaluate_long(grib_expression* g, grib_handle* h, long* lres) return GRIB_SUCCESS; } - if (STR_EQUAL(e->name, "defined")) { - const char* keyName = grib_arguments_get_name(h, e->args, 0); + if (STR_EQUAL(name_, "defined")) { + const char* keyName = args_ ? args_->get_name(h, 0) : nullptr; if (keyName) { const grib_accessor* a = grib_find_accessor(h, keyName); *lres = a != NULL ? 1 : 0; @@ -170,12 +114,12 @@ static int evaluate_long(grib_expression* g, grib_handle* h, long* lres) return GRIB_SUCCESS; } - if (STR_EQUAL(e->name, "environment_variable")) { + if (STR_EQUAL(name_, "environment_variable")) { // ECC-1520: This implementation has some limitations: // 1. Cannot distinguish between environment variable NOT SET // and SET but equal to 0 // 2. Cannot deal with string values - const char* p = grib_arguments_get_name(h, e->args, 0); + const char* p = args_ ? args_->get_name(h, 0) : nullptr; if (p) { const char* env = getenv(p); if (env) { @@ -190,16 +134,16 @@ static int evaluate_long(grib_expression* g, grib_handle* h, long* lres) return GRIB_SUCCESS; } - if (STR_EQUAL(e->name, "changed")) { + if (STR_EQUAL(name_, "changed")) { *lres = 1; return GRIB_SUCCESS; } - if (STR_EQUAL(e->name, "contains")) { + if (STR_EQUAL(name_, "contains")) { *lres = 0; - const int n = grib_arguments_get_count(e->args); + const int n = args_ ? args_->get_count() : 0; if (n != 3) return GRIB_INVALID_ARGUMENT; - const char* keyName = grib_arguments_get_name(h, e->args, 0); + const char* keyName = args_ ? args_->get_name(h, 0) : nullptr; if (!keyName) return GRIB_INVALID_ARGUMENT; int type = 0; int err = grib_get_native_type(h, keyName, &type); @@ -209,9 +153,9 @@ static int evaluate_long(grib_expression* g, grib_handle* h, long* lres) size_t len = sizeof(keyValue); err = grib_get_string(h, keyName, keyValue, &len); if (err) return err; - const char* sValue = grib_arguments_get_string(h, e->args, 1); + const char* sValue = args_->get_string(h, 1); if (!sValue) return GRIB_INVALID_ARGUMENT; - const bool case_sens = grib_arguments_get_long(h, e->args, 2) == 0; // 0=case-sensitive, 1=case-insensitive + const bool case_sens = args_->get_long(h, 2) == 0; // 0=case-sensitive, 1=case-insensitive const bool contains = string_contains_case(keyValue, sValue, case_sens); if (contains) { *lres = 1; @@ -224,21 +168,21 @@ static int evaluate_long(grib_expression* g, grib_handle* h, long* lres) return GRIB_SUCCESS; } - if (STR_EQUAL(e->name, "is_one_of")) { + if (STR_EQUAL(name_, "is_one_of")) { *lres = 0; - const char* keyName = grib_arguments_get_name(h, e->args, 0); + const char* keyName = args_->get_name(h, 0); if (!keyName) return GRIB_INVALID_ARGUMENT; int type = 0; int err = grib_get_native_type(h, keyName, &type); if (err) return err; - int n = grib_arguments_get_count(e->args); + int n = args_->get_count(); if (type == GRIB_TYPE_STRING) { char keyValue[254] = {0,}; size_t len = sizeof(keyValue); err = grib_get_string(h, keyName, keyValue, &len); if (err) return err; for (int i = 1; i < n; ++i) { // skip 1st argument which is the key - const char* sValue = grib_arguments_get_string(h, e->args, i); + const char* sValue = args_->get_string(h, i); if (sValue && STR_EQUAL(keyValue, sValue)) { *lres = 1; return GRIB_SUCCESS; @@ -250,7 +194,7 @@ static int evaluate_long(grib_expression* g, grib_handle* h, long* lres) err = grib_get_long(h, keyName, &keyValue); if (err) return err; for (int i = 1; i < n; ++i) { // skip 1st argument which is the key - long lValue = grib_arguments_get_long(h, e->args, i); + long lValue = args_->get_long(h, i); if (keyValue == lValue) { *lres = 1; return GRIB_SUCCESS; @@ -263,47 +207,48 @@ static int evaluate_long(grib_expression* g, grib_handle* h, long* lres) return GRIB_SUCCESS; } - if (STR_EQUAL(e->name, "gribex_mode_on")) { + if (STR_EQUAL(name_, "gribex_mode_on")) { *lres = h->context->gribex_mode_on ? 1 : 0; return GRIB_SUCCESS; } - grib_context_log(h->context, GRIB_LOG_ERROR, "grib_expression_class_functor::%s failed for '%s'", __func__, e->name); + grib_context_log(h->context, GRIB_LOG_ERROR, "grib_expression_class_functor::%s failed for '%s'", __func__, name_); return GRIB_NOT_IMPLEMENTED; } -static void print(grib_context* c, grib_expression* g, grib_handle* f, FILE* out) +void Functor::print(grib_context* c,grib_handle* f, FILE* out) const { - const grib_expression_functor* e = (grib_expression_functor*)g; - fprintf(out, "%s(", e->name); - // grib_expression_print(c,e->args,f); + fprintf(out, "%s(", name_); + // grib_expression_print(c,args_,f); fprintf(out, ")"); } -static void destroy(grib_context* c, grib_expression* g) +void Functor::destroy(grib_context* c) { - grib_expression_functor* e = (grib_expression_functor*)g; - grib_context_free_persistent(c, e->name); - grib_arguments_free(c, e->args); + grib_context_free_persistent(c, name_); + grib_arguments_free(c, args_); } -static void add_dependency(grib_expression* g, grib_accessor* observer) +void Functor::add_dependency(grib_accessor* observer) { - grib_expression_functor* e = (grib_expression_functor*)g; - if (strcmp(e->name, "defined")) - grib_dependency_observe_arguments(observer, e->args); + if (strcmp(name_, "defined")) + grib_dependency_observe_arguments(observer, args_); } -grib_expression* new_func_expression(grib_context* c, const char* name, grib_arguments* args) +Functor::Functor(grib_context* c, const char* name, grib_arguments* args) { - grib_expression_functor* e = (grib_expression_functor*)grib_context_malloc_clear_persistent(c, sizeof(grib_expression_functor)); - e->base.cclass = grib_expression_class_functor; - e->name = grib_context_strdup_persistent(c, name); - e->args = args; - return (grib_expression*)e; + name_ = grib_context_strdup_persistent(c, name); + args_ = args; } -static int native_type(grib_expression* g, grib_handle* h) +int Functor::native_type(grib_handle* h) const { return GRIB_TYPE_LONG; } + +} // namespace eccodes::expression + + +grib_expression* new_func_expression(grib_context* c, const char* name, grib_arguments* args) { + return new eccodes::expression::Functor(c, name, args); +} diff --git a/src/expression/grib_expression_class_functor.h b/src/expression/grib_expression_class_functor.h new file mode 100644 index 000000000..70b0a366a --- /dev/null +++ b/src/expression/grib_expression_class_functor.h @@ -0,0 +1,43 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_expression.h" + +namespace eccodes::expression { + +class Functor : public Expression { +public: + Functor(grib_context* c, const char*, grib_arguments*); + + void destroy(grib_context*) override; + void print(grib_context*, grib_handle*, FILE*) const override; + void add_dependency(grib_accessor*) override; + int native_type(grib_handle*) const override; + int evaluate_long(grib_handle*, long*) const override; + + const char* class_name() const override { return "functor"; }; + + char* name() { return name_; } // For testing + +private: + char* name_ = nullptr; + grib_arguments* args_ = nullptr; + + friend Expression* new_func_expression(grib_context*, const char*, grib_arguments*); +}; + +Expression* new_func_expression(grib_context*, const char*, grib_arguments*); + +} // namespace eccodes::expression + + +grib_expression* new_func_expression(grib_context*, const char*, grib_arguments*); diff --git a/src/expression/grib_expression_class_is_in_dict.cc b/src/expression/grib_expression_class_is_in_dict.cc new file mode 100644 index 000000000..f62ea7f84 --- /dev/null +++ b/src/expression/grib_expression_class_is_in_dict.cc @@ -0,0 +1,175 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_expression_class_is_in_dict.h" + +namespace eccodes::expression { + +grib_trie* IsInDict::load_dictionary(grib_context* c, int* err) const +{ + char* filename = NULL; + char line[1024] = {0,}; + char key[1024] = {0,}; + char* list = 0; + grib_trie* dictionary = NULL; + FILE* f = NULL; + int i = 0; + + *err = GRIB_SUCCESS; + + filename = grib_context_full_defs_path(c, dictionary_); + if (!filename) { + grib_context_log(c, GRIB_LOG_ERROR, "unable to find def file %s", dictionary_); + *err = GRIB_FILE_NOT_FOUND; + return NULL; + } + else { + grib_context_log(c, GRIB_LOG_DEBUG, "is_in_dict: found def file %s", filename); + } + dictionary = (grib_trie*)grib_trie_get(c->lists, filename); + if (dictionary) { + grib_context_log(c, GRIB_LOG_DEBUG, "using dictionary %s from cache", dictionary_); + return dictionary; + } + else { + grib_context_log(c, GRIB_LOG_DEBUG, "using dictionary %s from file %s", dictionary_, filename); + } + + f = codes_fopen(filename, "r"); + if (!f) { + *err = GRIB_IO_PROBLEM; + return NULL; + } + + dictionary = grib_trie_new(c); + + while (fgets(line, sizeof(line) - 1, f)) { + i = 0; + while (line[i] != '|' && line[i] != 0) { + key[i] = line[i]; + i++; + } + key[i] = 0; + list = (char*)grib_context_malloc_clear(c, strlen(line) + 1); + memcpy(list, line, strlen(line)); + grib_trie_insert(dictionary, key, list); + } + + grib_trie_insert(c->lists, filename, dictionary); + + fclose(f); + + return dictionary; +} + +Expression::string IsInDict::get_name() const +{ + return key_; +} + +int IsInDict::evaluate_long(grib_handle* h, long* result) const +{ + int err = 0; + char mybuf[1024] = {0,}; + size_t size = 1024; + + grib_trie* dict = load_dictionary(h->context, &err); + + if ((err = grib_get_string_internal(h, key_, mybuf, &size)) != GRIB_SUCCESS) + return err; + + if (grib_trie_get(dict, mybuf)) + *result = 1; + else + *result = 0; + + return err; +} + +int IsInDict::evaluate_double(grib_handle* h, double* result) const +{ + return GRIB_NOT_IMPLEMENTED; + + // grib_expression_is_in_dict* e = (grib_expression_is_in_dict*)g; + // int err = 0; + // char mybuf[1024] = {0,}; + // size_t size = 1024; + // grib_trie* list = load_dictionary(h->context, g, &err); + // if ((err = grib_get_string_internal(h, key_, mybuf, &size)) != GRIB_SUCCESS) + // return err; + // if (grib_trie_get(list, mybuf)) + // *result = 1; + // else + // *result = 0; + // return err; +} + +Expression::string IsInDict::evaluate_string(grib_handle* h, char* buf, size_t* size, int* err) const +{ + *err = GRIB_NOT_IMPLEMENTED; + return NULL; + + // grib_expression_is_in_dict* e = (grib_expression_is_in_dict*)g; + // char mybuf[1024] = {0,}; + // size_t sizebuf = 1024; + // long result; + // grib_trie* list = load_dictionary(h->context, g, err); + // if ((*err = grib_get_string_internal(h, key_, mybuf, &sizebuf)) != GRIB_SUCCESS) + // return NULL; + // if (grib_trie_get(list, mybuf)) + // result = 1; + // else + // result = 0; + // snprintf(buf, 32, "%ld", result); + // *size = strlen(buf); + // return buf; +} + +void IsInDict::print(grib_context* c, grib_handle* f, FILE* out) const +{ + fprintf(out, "access('%s", key_); + if (f) { + long s = 0; + grib_get_long(f, key_, &s); + fprintf(out, "=%ld", s); + } + fprintf(out, "')"); +} + +IsInDict::IsInDict(grib_context* c, const char* name, const char* list) +{ + key_ = grib_context_strdup_persistent(c, name); + dictionary_ = grib_context_strdup_persistent(c, list); +} + +int IsInDict::native_type(grib_handle* h) const +{ + return GRIB_TYPE_LONG; +} + +void IsInDict::add_dependency(grib_accessor* observer) +{ + grib_accessor* observed = grib_find_accessor(grib_handle_of_accessor(observer), key_); + + if (!observed) { + /* grib_context_log(observer->context, GRIB_LOG_ERROR, */ + /* "Error in accessor_add_dependency: cannot find [%s]", name_); */ + /* Assert(observed); */ + return; + } + + grib_dependency_add(observer, observed); +} + +} // namespace eccodes::expression + +grib_expression* new_is_in_dict_expression(grib_context* c, const char* name, const char* list) { + return new eccodes::expression::IsInDict(c, name, list); +} diff --git a/src/expression/grib_expression_class_is_in_dict.h b/src/expression/grib_expression_class_is_in_dict.h new file mode 100644 index 000000000..4a5b62d57 --- /dev/null +++ b/src/expression/grib_expression_class_is_in_dict.h @@ -0,0 +1,43 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_expression.h" + +namespace eccodes::expression { + +class IsInDict : public Expression { +public: + IsInDict(grib_context*, const char*, const char*); + + void print(grib_context*, grib_handle*, FILE*) const override; + void add_dependency(grib_accessor*) override; + string get_name() const override; + int native_type(grib_handle*) const override; + int evaluate_long(grib_handle*, long*) const override; + int evaluate_double(grib_handle*, double*) const override; + string evaluate_string(grib_handle*, char*, size_t*, int*) const override; + + const char* class_name() const override { return "is_in_dict"; }; + +private: + const char* key_ = nullptr; + const char* dictionary_ = nullptr; + + grib_trie* load_dictionary(grib_context*, int* err) const; + friend Expression* new_is_in_dict_expression(grib_context*, const char*, const char*); +}; + +Expression* new_is_in_dict_expression(grib_context*, const char*, const char*); + +} // namespace eccodes::expression + +grib_expression* new_is_in_dict_expression(grib_context*, const char*, const char*); diff --git a/src/expression/grib_expression_class_is_in_list.cc b/src/expression/grib_expression_class_is_in_list.cc new file mode 100644 index 000000000..63ee22ecc --- /dev/null +++ b/src/expression/grib_expression_class_is_in_list.cc @@ -0,0 +1,183 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_expression_class_is_in_list.h" +#include "eccodes_prototypes.h" + +namespace eccodes::expression { + +grib_trie* IsInList::load_list(grib_context* c, int* err) const +{ + char* filename = NULL; + char line[1024] = {0,}; + grib_trie* list = NULL; + FILE* f = NULL; + + *err = GRIB_SUCCESS; + + filename = grib_context_full_defs_path(c, list_); + if (!filename) { + grib_context_log(c, GRIB_LOG_ERROR, "unable to find def file %s", list_); + *err = GRIB_FILE_NOT_FOUND; + return NULL; + } + else { + grib_context_log(c, GRIB_LOG_DEBUG, "is_in_list: found def file %s", filename); + } + list = (grib_trie*)grib_trie_get(c->lists, filename); + if (list) { + grib_context_log(c, GRIB_LOG_DEBUG, "using list %s from cache", list_); + return list; + } + else { + grib_context_log(c, GRIB_LOG_DEBUG, "using list %s from file %s", list_, filename); + } + + f = codes_fopen(filename, "r"); + if (!f) { + *err = GRIB_IO_PROBLEM; + return NULL; + } + + list = grib_trie_new(c); + + while (fgets(line, sizeof(line) - 1, f)) { + unsigned char* p = (unsigned char*)line; + while (*p != 0) { + if (*p < 33) { + *p = 0; + break; + } + p++; + } + grib_trie_insert(list, line, line); + } + + grib_trie_insert(c->lists, filename, list); + + fclose(f); + + return list; +} + +const char* IsInList::get_name() const +{ + return name_; +} + +int IsInList::evaluate_long(grib_handle* h, long* result) const +{ + int err = 0; + char mybuf[1024] = {0,}; + size_t size = 1024; + + grib_trie* list = load_list(h->context, &err); + + if ((err = grib_get_string_internal(h, name_, mybuf, &size)) != GRIB_SUCCESS) + return err; + + if (grib_trie_get(list, mybuf)) + *result = 1; + else + *result = 0; + + return err; +} + +int IsInList::evaluate_double(grib_handle* h, double* result) const +{ + return GRIB_NOT_IMPLEMENTED; + // grib_expression_is_in_list* e = (grib_expression_is_in_list*)g; + // int err = 0; + // char mybuf[1024] = {0,}; + // size_t size = 1024; + // grib_trie* list = load_list(h->context, g, &err); + // if ((err = grib_get_string_internal(h, name_, mybuf, &size)) != GRIB_SUCCESS) + // return err; + // if (grib_trie_get(list, mybuf)) + // *result = 1; + // else + // *result = 0; + // return err; +} + +Expression::string IsInList::evaluate_string(grib_handle* h, char* buf, size_t* size, int* err) const +{ + char mybuf[1024] = {0,}; + size_t sizebuf = 1024; + long result; + + grib_trie* list = load_list(h->context, err); + + if ((*err = grib_get_string_internal(h, name_, mybuf, &sizebuf)) != GRIB_SUCCESS) + return NULL; + + if (grib_trie_get(list, mybuf)) + result = 1; + else + result = 0; + + snprintf(buf, 32, "%ld", result); + *size = strlen(buf); + return buf; +} + +void IsInList::print(grib_context* c, grib_handle* f, FILE* out) const +{ + fprintf(out, "access('%s", name_); + if (f) { + long s = 0; + grib_get_long(f, name_, &s); + fprintf(out, "=%ld", s); + } + fprintf(out, "')"); +} + + +void IsInList::add_dependency(grib_accessor* observer) +{ + grib_accessor* observed = grib_find_accessor(grib_handle_of_accessor(observer), name_); + + if (!observed) { + /* grib_context_log(observer->context, GRIB_LOG_ERROR, */ + /* "Error in accessor_add_dependency: cannot find [%s]", name_); */ + /* Assert(observed); */ + return; + } + + grib_dependency_add(observer, observed); +} + +void IsInList::destroy(grib_context* c) { + grib_context_free_persistent(c, name_); + grib_context_free_persistent(c, list_); +} + +IsInList::IsInList(grib_context* c, const char* name, const char* list) +{ + name_ = grib_context_strdup_persistent(c, name); + list_ = grib_context_strdup_persistent(c, list); +} + +int IsInList::native_type(grib_handle* h) const +{ + int type = 0; + int err; + if ((err = grib_get_native_type(h, name_, &type)) != GRIB_SUCCESS) + grib_context_log(h->context, GRIB_LOG_ERROR, + "Error in native_type %s : %s", name_, grib_get_error_message(err)); + return type; +} + +} // namespace eccodes::expression + +grib_expression* new_is_in_list_expression(grib_context* c, const char* name, const char* list) { + return new eccodes::expression::IsInList(c, name, list); +} diff --git a/src/expression/grib_expression_class_is_in_list.h b/src/expression/grib_expression_class_is_in_list.h new file mode 100644 index 000000000..327f9f069 --- /dev/null +++ b/src/expression/grib_expression_class_is_in_list.h @@ -0,0 +1,42 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_expression.h" + +namespace eccodes::expression { + +class IsInList : public Expression { +public: + IsInList(grib_context*, const char*, const char*); + + void destroy(grib_context*) override; + void print(grib_context*, grib_handle*, FILE*) const override; + void add_dependency(grib_accessor*) override; + string get_name() const override; + int native_type(grib_handle*) const override; + int evaluate_long(grib_handle*, long*) const override; + int evaluate_double(grib_handle*, double*) const override; + string evaluate_string(grib_handle*, char*, size_t*, int*) const override; + + const char* class_name() const override { return "is_in_list"; }; + +private: + char* name_ = nullptr; + char* list_ = nullptr; + + grib_trie* load_list(grib_context*, int* err) const; + friend Expression* new_is_in_list_expression(grib_context*, const char*, const char*); +}; + +} // namespace eccodes::expression + +grib_expression* new_is_in_list_expression(grib_context*, const char*, const char*); diff --git a/src/expression/grib_expression_class_is_integer.cc b/src/expression/grib_expression_class_is_integer.cc new file mode 100644 index 000000000..7dcd48be3 --- /dev/null +++ b/src/expression/grib_expression_class_is_integer.cc @@ -0,0 +1,121 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_expression_class_is_integer.h" + +namespace eccodes::expression { + +Expression::string IsInteger::get_name() const +{ + return name_; +} + +int IsInteger::evaluate_long(grib_handle* h, long* result) const +{ + int err = 0; + char mybuf[1024] = {0,}; + size_t size = 1024; + char* p = 0; + char* start = 0; + + if ((err = grib_get_string_internal(h, name_, mybuf, &size)) != GRIB_SUCCESS) + return err; + + start = mybuf + start_; + + if (length_ > 0) + start[length_] = 0; + + strtol(start, &p, 10); + + if (*p != 0) + *result = 0; + else + *result = 1; + + return err; +} + +int IsInteger::evaluate_double(grib_handle* h, double* result) const +{ + int err = 0; + long lresult = 0; + + err = evaluate_long(h, &lresult); + *result = lresult; + return err; +} + +Expression::string IsInteger::evaluate_string(grib_handle* h, char* buf, size_t* size, int* err) const +{ + long lresult = 0; + double dresult = 0.0; + + switch (native_type(h)) { + case GRIB_TYPE_LONG: + *err = evaluate_long(h, &lresult); + snprintf(buf, 32, "%ld", lresult); + break; + case GRIB_TYPE_DOUBLE: + *err = evaluate_double(h, &dresult); + snprintf(buf, 32, "%g", dresult); + break; + } + return buf; +} + +void IsInteger::print(grib_context* c, grib_handle* f, FILE* out) const +{ + // grib_expression_is_integer* e = (grib_expression_is_integer*)g; + // printf("access('%s", name_); + // if (f) { + // long s = 0; + // grib_get_long(f, name_, &s); + // printf("=%ld", s); + // } + // printf("')"); +} + +void IsInteger::destroy(grib_context* c) +{ + grib_context_free_persistent(c, name_); +} + +void IsInteger::add_dependency(grib_accessor* observer) +{ + grib_accessor* observed = grib_find_accessor(grib_handle_of_accessor(observer), name_); + + if (!observed) { + /* grib_context_log(observer->context, GRIB_LOG_ERROR, */ + /* "Error in accessor_add_dependency: cannot find [%s]", name_); */ + /* Assert(observed); */ + return; + } + + grib_dependency_add(observer, observed); +} + +IsInteger::IsInteger(grib_context* c, const char* name, int start, int length) +{ + name_ = grib_context_strdup_persistent(c, name); + start_ = start; + length_ = length; +} + +int IsInteger::native_type(grib_handle* h) const +{ + return GRIB_TYPE_LONG; +} + +} // namespace eccodes::expression + +grib_expression* new_is_integer_expression(grib_context* c, const char* name, int start, int length) { + return new eccodes::expression::IsInteger(c, name, start, length); +} diff --git a/src/expression/grib_expression_class_is_integer.h b/src/expression/grib_expression_class_is_integer.h new file mode 100644 index 000000000..416735eec --- /dev/null +++ b/src/expression/grib_expression_class_is_integer.h @@ -0,0 +1,40 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_expression.h" + +namespace eccodes::expression { + +class IsInteger : public Expression { +public: + IsInteger(grib_context*, const char*, int, int); + + void destroy(grib_context*) override; + void print(grib_context*, grib_handle*, FILE*) const override; + void add_dependency(grib_accessor*) override; + string get_name() const override; + int native_type(grib_handle*) const override; + int evaluate_long(grib_handle*, long*) const override; + int evaluate_double(grib_handle*, double*) const override; + string evaluate_string(grib_handle*, char*, size_t*, int*) const override; + + const char* class_name() const override { return "is_integer"; }; + +private: + char* name_ = nullptr; + size_t start_ = 0; + size_t length_ = 0; +}; + +} // namespace eccodes::expression + +grib_expression* new_is_integer_expression(grib_context*, const char*, int, int); diff --git a/src/expression/grib_expression_class_length.cc b/src/expression/grib_expression_class_length.cc new file mode 100644 index 000000000..1ac617a11 --- /dev/null +++ b/src/expression/grib_expression_class_length.cc @@ -0,0 +1,99 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_expression_class_length.h" + +namespace eccodes::expression { + +Expression::string Length::get_name() const +{ + return name_; +} + +int Length::evaluate_long(grib_handle* h, long* result) const +{ + int err = 0; + char mybuf[1024] = {0,}; + size_t size = 1024; + if ((err = grib_get_string_internal(h, name_, mybuf, &size)) != GRIB_SUCCESS) + return err; + + *result = strlen(mybuf); + return err; +} + +int Length::evaluate_double(grib_handle* h, double* result) const +{ + char mybuf[1024] = {0,}; + size_t size = 1024; + int err = 0; + if ((err = grib_get_string_internal(h, name_, mybuf, &size)) != GRIB_SUCCESS) + return err; + + *result = strlen(mybuf); + return err; +} + +Expression::string Length::evaluate_string(grib_handle* h, char* buf, size_t* size, int* err) const +{ + char mybuf[1024] = {0,}; + Assert(buf); + if ((*err = grib_get_string_internal(h, name_, mybuf, size)) != GRIB_SUCCESS) + return NULL; + + snprintf(buf, 32, "%ld", (long)strlen(mybuf)); + return buf; +} + +void Length::print(grib_context* c, grib_handle* f, FILE* out) const +{ + fprintf(out, "access('%s", name_); + if (f) { + long s = 0; + grib_get_long(f, name_, &s); + fprintf(out, "=%ld", s); + } + fprintf(out, "')"); +} + +void Length::destroy(grib_context* c) +{ + grib_context_free_persistent(c, name_); +} + +void Length::add_dependency(grib_accessor* observer) +{ + grib_accessor* observed = grib_find_accessor(grib_handle_of_accessor(observer), name_); + + if (!observed) { + /* grib_context_log(observer->context, GRIB_LOG_ERROR, */ + /* "Error in accessor_add_dependency: cannot find [%s]", name_); */ + /* Assert(observed); */ + return; + } + + grib_dependency_add(observer, observed); +} + +Length::Length(grib_context* c, const char* name) +{ + name_ = grib_context_strdup_persistent(c, name); +} + +int Length::native_type(grib_handle* h) const +{ + return GRIB_TYPE_LONG; +} + +} // namespace eccodes::expression + +grib_expression* new_length_expression(grib_context* c, const char* name) { + return new eccodes::expression::Length(c, name); +} diff --git a/src/expression/grib_expression_class_length.h b/src/expression/grib_expression_class_length.h new file mode 100644 index 000000000..06a1d0669 --- /dev/null +++ b/src/expression/grib_expression_class_length.h @@ -0,0 +1,40 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_expression.h" + +namespace eccodes::expression { + +class Length : public Expression { +public: + Length(grib_context* c, const char*); + + void destroy(grib_context*) override; + void print(grib_context*, grib_handle*, FILE*) const override; + void add_dependency(grib_accessor*) override; + string get_name() const override; + int native_type(grib_handle*) const override; + int evaluate_long(grib_handle*, long*) const override; + int evaluate_double(grib_handle*, double*) const override; + string evaluate_string(grib_handle*, char*, size_t*, int*) const override; + + const char* class_name() const override { return "length"; }; + +private: + char* name_ = nullptr; + size_t start_ = 0; + size_t length = 0; +}; + +} // namespace eccodes::expression + +grib_expression* new_length_expression(grib_context* c, const char*); diff --git a/src/expression/grib_expression_class_logical_and.cc b/src/expression/grib_expression_class_logical_and.cc new file mode 100644 index 000000000..d5cfeaca8 --- /dev/null +++ b/src/expression/grib_expression_class_logical_and.cc @@ -0,0 +1,112 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_expression_class_logical_and.h" + + +namespace eccodes::expression { + +int LogicalAnd::evaluate_long(grib_handle* h, long* lres) const +{ + long v1 = 0; + long v2 = 0; + double dv1 = 0; + double dv2 = 0; + int ret; + + switch (left_->native_type(h)) { + case GRIB_TYPE_LONG: + ret = left_->evaluate_long(h, &v1); + if (ret != GRIB_SUCCESS) + return ret; + if (v1 == 0) { + *lres = 0; + return ret; + } + break; + case GRIB_TYPE_DOUBLE: + ret = left_->evaluate_double(h, &dv1); + if (ret != GRIB_SUCCESS) + return ret; + if (dv1 == 0) { + *lres = 0; + return ret; + } + break; + default: + return GRIB_INVALID_TYPE; + } + + switch (right_->native_type(h)) { + case GRIB_TYPE_LONG: + ret = right_->evaluate_long(h, &v2); + if (ret != GRIB_SUCCESS) + return ret; + *lres = v2 ? 1 : 0; + break; + case GRIB_TYPE_DOUBLE: + ret = right_->evaluate_double(h, &dv2); + if (ret != GRIB_SUCCESS) + return ret; + *lres = dv2 ? 1 : 0; + break; + default: + return GRIB_INVALID_TYPE; + } + + return GRIB_SUCCESS; +} + +int LogicalAnd::evaluate_double(grib_handle* h, double* dres) const +{ + long lres = 0; + int ret = evaluate_long(h, &lres); + *dres = (double)lres; + return ret; +} + +void LogicalAnd::print(grib_context* c, grib_handle* f, FILE* out) const +{ + fprintf(out, "("); + left_->print(c, f, out); + fprintf(out, " && "); + right_->print(c, f, out); + fprintf(out, ")"); +} + +void LogicalAnd::destroy(grib_context* c) +{ + left_->destroy(c); + right_->destroy(c); +} + +void LogicalAnd::add_dependency(grib_accessor* observer) +{ + left_->add_dependency(observer); + right_->add_dependency(observer); +} + +LogicalAnd::LogicalAnd(grib_context* c, Expression* left, Expression* right) +{ + left_ = left; + right_ = right; +} + +int LogicalAnd::native_type(grib_handle* h) const +{ + return GRIB_TYPE_LONG; +} + +} // namespace eccodes::expression + + +grib_expression* new_logical_and_expression(grib_context* c, grib_expression* left, grib_expression* right) { + return new eccodes::expression::LogicalAnd(c, left, right); +} diff --git a/src/expression/grib_expression_class_logical_and.h b/src/expression/grib_expression_class_logical_and.h new file mode 100644 index 000000000..830bbc7c1 --- /dev/null +++ b/src/expression/grib_expression_class_logical_and.h @@ -0,0 +1,37 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_expression.h" + +namespace eccodes::expression { + +class LogicalAnd : public Expression { +public: + LogicalAnd(grib_context*, Expression*, Expression*); + + void destroy(grib_context*) override; + void print(grib_context*, grib_handle*, FILE*) const override; + void add_dependency(grib_accessor*) override; + int native_type(grib_handle*) const override; + int evaluate_long(grib_handle*, long*) const override; + int evaluate_double(grib_handle*, double*) const override; + + const char* class_name() const override { return "logical_and"; }; + +private: + Expression* left_ = nullptr; + Expression* right_ = nullptr; +}; + +} // namespace eccodes::expression + +grib_expression* new_logical_and_expression(grib_context*, grib_expression*, grib_expression*); diff --git a/src/expression/grib_expression_class_logical_or.cc b/src/expression/grib_expression_class_logical_or.cc new file mode 100644 index 000000000..ff6cd01cf --- /dev/null +++ b/src/expression/grib_expression_class_logical_or.cc @@ -0,0 +1,112 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_expression_class_logical_or.h" + +namespace eccodes::expression { + + +LogicalOr::LogicalOr(grib_context* c, Expression* left, Expression* right) +{ + left_ = left; + right_ = right; +} + +int LogicalOr::evaluate_long(grib_handle* h, long* lres) const +{ + long v1 = 0; + long v2 = 0; + double dv1 = 0; + double dv2 = 0; + int ret; + + + switch (left_->native_type(h)) { + case GRIB_TYPE_LONG: + ret = left_->evaluate_long(h, &v1); + if (ret != GRIB_SUCCESS) + return ret; + if (v1 != 0) { + *lres = 1; + return ret; + } + break; + case GRIB_TYPE_DOUBLE: + ret = left_->evaluate_double(h, &dv1); + if (ret != GRIB_SUCCESS) + return ret; + if (dv1 != 0) { + *lres = 1; + return ret; + } + break; + default: + return GRIB_INVALID_TYPE; + } + + switch (right_->native_type(h)) { + case GRIB_TYPE_LONG: + ret = right_->evaluate_long(h, &v2); + if (ret != GRIB_SUCCESS) + return ret; + *lres = v2 ? 1 : 0; + break; + case GRIB_TYPE_DOUBLE: + ret = right_->evaluate_double(h, &dv2); + if (ret != GRIB_SUCCESS) + return ret; + *lres = dv2 ? 1 : 0; + break; + default: + return GRIB_INVALID_TYPE; + } + + return GRIB_SUCCESS; +} + +int LogicalOr::evaluate_double(grib_handle* h, double* dres) const +{ + long lres = 0; + int ret = evaluate_long(h, &lres); + *dres = (double)lres; + return ret; +} + +void LogicalOr::print(grib_context* c, grib_handle* f, FILE* out) const +{ + fprintf(out, "("); + left_->print(c, f, out); + fprintf(out, " || "); + right_->print(c, f, out); + fprintf(out, ")"); +} + +void LogicalOr::destroy(grib_context* c) +{ + left_->destroy(c); + right_->destroy(c); +} + +void LogicalOr::add_dependency(grib_accessor* observer) +{ + left_->add_dependency(observer); + right_->add_dependency(observer); +} + +int LogicalOr::native_type(grib_handle* h) const +{ + return GRIB_TYPE_LONG; +} + +} // namespace eccodes::expression + +grib_expression* new_logical_or_expression(grib_context* c, grib_expression* left, grib_expression* right) { + return new eccodes::expression::LogicalOr(c, left, right); +} diff --git a/src/expression/grib_expression_class_logical_or.h b/src/expression/grib_expression_class_logical_or.h new file mode 100644 index 000000000..b964a2260 --- /dev/null +++ b/src/expression/grib_expression_class_logical_or.h @@ -0,0 +1,35 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_expression.h" + +namespace eccodes::expression { + +class LogicalOr : public Expression { +public: + LogicalOr(grib_context*, Expression*, Expression*); + + void destroy(grib_context*) override; + void print(grib_context*, grib_handle*, FILE*) const override; + void add_dependency(grib_accessor*) override; + int native_type(grib_handle*) const override; + int evaluate_long(grib_handle*, long*) const override; + int evaluate_double(grib_handle*, double*) const override; + + const char* class_name() const override { return "logical_or"; }; + +private: + Expression* left_ = nullptr; + Expression* right_ = nullptr; +}; + +} // namespace eccodes::expression + +grib_expression* new_logical_or_expression(grib_context*, grib_expression*, grib_expression*); diff --git a/src/expression/grib_expression_class_long.cc b/src/expression/grib_expression_class_long.cc new file mode 100644 index 000000000..97e667eb8 --- /dev/null +++ b/src/expression/grib_expression_class_long.cc @@ -0,0 +1,46 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_expression_class_long.h" + +namespace eccodes::expression { + +int Long::evaluate_long(grib_handle* h, long* lres) const +{ + *lres = value_; + return GRIB_SUCCESS; +} + +int Long::evaluate_double(grib_handle* h, double* dres) const +{ + *dres = value_; + return GRIB_SUCCESS; +} + +void Long::print(grib_context* c, grib_handle* f, FILE* out) const +{ + fprintf(out, "long(%ld)", value_); +} + +void Long::add_dependency(grib_accessor* observer) +{ + /* grib_expression_long* e = (grib_expression_long*)g; */ +} + +int Long::native_type(grib_handle* h) const +{ + return GRIB_TYPE_LONG; +} + +} // namespace eccodes::expression + +grib_expression* new_long_expression(grib_context* c, long value) { + return new eccodes::expression::Long(value); +} diff --git a/src/expression/grib_expression_class_long.h b/src/expression/grib_expression_class_long.h new file mode 100644 index 000000000..f1a609b34 --- /dev/null +++ b/src/expression/grib_expression_class_long.h @@ -0,0 +1,35 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_expression.h" + +namespace eccodes::expression { + +class Long : public Expression { +public: + Long(long value) : value_(value) {} + + void print(grib_context*, grib_handle*, FILE*) const override; + void add_dependency(grib_accessor*) override; + int native_type(grib_handle*) const override; + int evaluate_long(grib_handle*, long*) const override; + int evaluate_double(grib_handle*, double*) const override; + + const char* class_name() const override { return "long"; }; + +private: + long value_ = 0; +}; + +} // namespace eccodes::expression + +grib_expression* new_long_expression(grib_context*, long); diff --git a/src/expression/grib_expression_class_string.cc b/src/expression/grib_expression_class_string.cc new file mode 100644 index 000000000..4d2991439 --- /dev/null +++ b/src/expression/grib_expression_class_string.cc @@ -0,0 +1,49 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_expression_class_string.h" + +namespace eccodes::expression { + +String::String(grib_context* c, const char* value) { + value_ = grib_context_strdup_persistent(c, value); +} + +Expression::string String::evaluate_string(grib_handle* h, char* buf, size_t* size, int* err) const +{ + *err = 0; + return value_; +} + +void String::print(grib_context* c, grib_handle* f, FILE* out) const +{ + fprintf(out, "string('%s')", value_); +} + +void String::destroy(grib_context* c) +{ + grib_context_free_persistent(c, value_); +} + +void String::add_dependency(grib_accessor* observer) +{ + /* grib_expression_string* e = (grib_expression_string*)g; */ +} + +int String::native_type(grib_handle* h) const +{ + return GRIB_TYPE_STRING; +} + +} // namespace eccodes::expression + +grib_expression* new_string_expression(grib_context* c, const char* value) { + return new eccodes::expression::String(c, value); +} diff --git a/src/expression/grib_expression_class_string.h b/src/expression/grib_expression_class_string.h new file mode 100644 index 000000000..9de5ddbd3 --- /dev/null +++ b/src/expression/grib_expression_class_string.h @@ -0,0 +1,35 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_expression.h" + +namespace eccodes::expression { + +class String : public Expression { +public: + String(grib_context*, const char*); + + void destroy(grib_context*) override; + void print(grib_context*, grib_handle*, FILE*) const override; + void add_dependency(grib_accessor*) override; + int native_type(grib_handle*) const override; + string evaluate_string(grib_handle*, char*, size_t*, int*) const override; + + const char* class_name() const override { return "string"; }; + +private: + char* value_ = nullptr; +}; + +} // namespace eccodes::expression + +grib_expression* new_string_expression(grib_context*, const char*); diff --git a/src/expression/grib_expression_class_string_compare.cc b/src/expression/grib_expression_class_string_compare.cc new file mode 100644 index 000000000..21cef316f --- /dev/null +++ b/src/expression/grib_expression_class_string_compare.cc @@ -0,0 +1,104 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_expression_class_string_compare.h" + +namespace eccodes::expression { + +/* Note: A fast cut-down version of strcmp which does NOT return -1 */ +/* 0 means input strings are equal and 1 means not equal */ +GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b) +{ + if (*a != *b) + return 1; + while ((*a != 0 && *b != 0) && *(a) == *(b)) { + a++; + b++; + } + return (*a == 0 && *b == 0) ? 0 : 1; +} + +int StringCompare::evaluate_long(grib_handle* h, long* lres) const +{ + int ret = 0; + char b1[1024] = {0,}; + size_t l1 = sizeof(b1); + char b2[1024] = {0,}; + size_t l2 = sizeof(b2); + const char* v1 = NULL; + const char* v2 = NULL; + + + v1 = left_->evaluate_string(h, b1, &l1, &ret); + if (!v1 || ret) { + *lres = 0; + return ret; + } + + v2 = right_->evaluate_string(h, b2, &l2, &ret); + if (!v2 || ret) { + *lres = 0; + return ret; + } + + if (eq_) // IS operator + *lres = (grib_inline_strcmp(v1, v2) == 0); + else // ISNOT operator + *lres = (grib_inline_strcmp(v1, v2) != 0); + + return GRIB_SUCCESS; +} + +int StringCompare::evaluate_double(grib_handle* h, double* dres) const +{ + long n; + int ret = evaluate_long(h, &n); + *dres = n; + return ret; +} + +void StringCompare::print(grib_context* c, grib_handle* f, FILE* out) const +{ + fprintf(out, "string_compare("); + left_->print(c, f, out); + fprintf(out, ","); + left_->print(c, f, out); + fprintf(out, ")"); +} + +void StringCompare::destroy(grib_context* c) +{ + left_->destroy(c); + right_->destroy(c); +} + +void StringCompare::add_dependency(grib_accessor* observer) +{ + left_->add_dependency(observer); + right_->add_dependency(observer); +} + +StringCompare::StringCompare(grib_context* c, Expression* left, Expression* right, int eq) +{ + left_ = left; + right_ = right; + eq_ = eq; +} + +int StringCompare::native_type(grib_handle* h) const +{ + return GRIB_TYPE_LONG; +} + +} // namespace eccodes::expression + +grib_expression* new_string_compare_expression(grib_context* c, grib_expression* left, grib_expression* right, int eq) { + return new eccodes::expression::StringCompare(c, left, right, eq); +} diff --git a/src/expression/grib_expression_class_string_compare.h b/src/expression/grib_expression_class_string_compare.h new file mode 100644 index 000000000..50d1a8572 --- /dev/null +++ b/src/expression/grib_expression_class_string_compare.h @@ -0,0 +1,38 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_expression.h" + +namespace eccodes::expression { + +class StringCompare : public Expression { +public: + StringCompare(grib_context*, Expression*, Expression*, int); + + void destroy(grib_context*) override; + void print(grib_context*, grib_handle*, FILE*) const override; + void add_dependency(grib_accessor*) override; + int native_type(grib_handle*) const override; + int evaluate_long(grib_handle*, long*) const override; + int evaluate_double(grib_handle*, double*) const override; + + const char* class_name() const override { return "string_compare"; }; + +private: + Expression* left_ = nullptr; + Expression* right_ = nullptr; + int eq_ = 0; +}; + +} // namespace eccodes::expression + +grib_expression* new_string_compare_expression(grib_context*, grib_expression*, grib_expression*, int); diff --git a/src/expression/grib_expression_class_sub_string.cc b/src/expression/grib_expression_class_sub_string.cc new file mode 100644 index 000000000..b37b7fa3e --- /dev/null +++ b/src/expression/grib_expression_class_sub_string.cc @@ -0,0 +1,70 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_expression_class_sub_string.h" + +namespace eccodes::expression { + +Expression::string SubString::evaluate_string(grib_handle* h, char* buf, size_t* size, int* err) const +{ + *err = 0; + return value_; +} + +void SubString::print(grib_context* c, grib_handle* f, FILE* out) const +{ + fprintf(out, "string('%s')", value_); +} + +void SubString::destroy(grib_context* c) +{ + grib_context_free_persistent(c, value_); +} + +void SubString::add_dependency(grib_accessor* observer) +{ + /* grib_expression_sub_string* e = (grib_expression_sub_string*)g; */ +} + +SubString::SubString(grib_context* c, const char* value, size_t start, size_t length) +{ + char v[1024] = {0,}; + + memcpy(v, value + start, length); + value_ = grib_context_strdup_persistent(c, v); +} + +int SubString::native_type(grib_handle* h) const +{ + return GRIB_TYPE_STRING; +} + +} // namespace eccodes::expression + +grib_expression* new_sub_string_expression(grib_context* c, const char* value, size_t start, size_t length) +{ + /* if (start<0) start+=strlen(value); */ + const size_t slen = strlen(value); + + if (length == 0) { + grib_context_log(c, GRIB_LOG_ERROR, "Invalid substring: length must be > 0"); + return NULL; + } + if (start > slen) { /* to catch a -ve number passed to start */ + grib_context_log(c, GRIB_LOG_ERROR, "Invalid substring: start=%lu", start); + return NULL; + } + if (start + length > slen) { + grib_context_log(c, GRIB_LOG_ERROR, "Invalid substring: start(=%lu)+length(=%lu) > length('%s'))", start, length, value); + return NULL; + } + + return new eccodes::expression::SubString(c, value, start, length); +} diff --git a/src/expression/grib_expression_class_sub_string.h b/src/expression/grib_expression_class_sub_string.h new file mode 100644 index 000000000..b1239f606 --- /dev/null +++ b/src/expression/grib_expression_class_sub_string.h @@ -0,0 +1,35 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_expression.h" + +namespace eccodes::expression { + +class SubString : public Expression { +public: + SubString(grib_context*, const char*, size_t, size_t); + + void destroy(grib_context*) override; + void print(grib_context*, grib_handle*, FILE*) const override; + void add_dependency(grib_accessor*) override; + int native_type(grib_handle*) const override; + string evaluate_string(grib_handle*, char*, size_t*, int*) const override; + + const char* class_name() const override { return "sub_string"; }; + +private: + char* value_ = nullptr; +}; + +} // namespace eccodes::expression + +grib_expression* new_sub_string_expression(grib_context*, const char*, size_t, size_t); diff --git a/src/expression/grib_expression_class_true.cc b/src/expression/grib_expression_class_true.cc new file mode 100644 index 000000000..f0ee218e7 --- /dev/null +++ b/src/expression/grib_expression_class_true.cc @@ -0,0 +1,42 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_expression_class_true.h" + +namespace eccodes::expression { + +int True::evaluate_long(grib_handle* h, long* lres) const +{ + *lres = 1; + return GRIB_SUCCESS; +} + +int True::evaluate_double(grib_handle* h, double* dres) const +{ + *dres = 1; + return GRIB_SUCCESS; +} + +void True::print(grib_context* c, grib_handle* f, FILE* out) const +{ + fprintf(out, "true()"); +} + +int True::native_type(grib_handle* h) const +{ + return GRIB_TYPE_LONG; +} + +} // namespace eccodes::expression + +grib_expression* new_true_expression(grib_context* c) { + return new eccodes::expression::True(); +} + diff --git a/src/expression/grib_expression_class_true.h b/src/expression/grib_expression_class_true.h new file mode 100644 index 000000000..588dfa767 --- /dev/null +++ b/src/expression/grib_expression_class_true.h @@ -0,0 +1,32 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_expression.h" + +namespace eccodes::expression { + +class True : public Expression { +public: + True() = default; + + void print(grib_context*, grib_handle*, FILE*) const override; + void add_dependency(grib_accessor*) override {}; + int native_type(grib_handle*) const override; + int evaluate_long(grib_handle*, long*) const override; + int evaluate_double(grib_handle*, double*) const override; + + const char* class_name() const override { return "true"; }; +}; + +} // namespace eccodes::expression + +grib_expression* new_true_expression(grib_context*); diff --git a/src/expression/grib_expression_class_unop.cc b/src/expression/grib_expression_class_unop.cc new file mode 100644 index 000000000..cd0026ed2 --- /dev/null +++ b/src/expression/grib_expression_class_unop.cc @@ -0,0 +1,70 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#include "grib_expression_class_unop.h" + +namespace eccodes::expression { + +Unop::Unop(grib_context* c, Expression::UnopLongProc long_func, + Expression::UnopDoubleProc double_func, + Expression* exp) : exp_(exp), long_func_(long_func), double_func_(double_func) {} + +int Unop::evaluate_long(grib_handle* h, long* lres) const +{ + long v = 0; + int ret = exp_->evaluate_long(h, &v); + if (ret != GRIB_SUCCESS) + return ret; + *lres = long_func_(v); + return GRIB_SUCCESS; +} + +int Unop::evaluate_double(grib_handle* h, double* dres) const +{ + double v = 0; + int ret = exp_->evaluate_double(h, &v); + if (ret != GRIB_SUCCESS) + return ret; + *dres = double_func_ ? double_func_(v) : long_func_(v); + return GRIB_SUCCESS; +} + +Expression::string Unop::get_name() const +{ + return exp_->get_name(); +} + +void Unop::print(grib_context* c, grib_handle* f, FILE* out) const +{ + fprintf(out, "unop("); + exp_->print(c, f, out); + fprintf(out, ")"); +} + +void Unop::destroy(grib_context* c) +{ + exp_->destroy(c); +} + +void Unop::add_dependency(grib_accessor* observer) +{ + exp_->add_dependency(observer); +} + +int Unop::native_type(grib_handle* h) const +{ + return long_func_ ? GRIB_TYPE_LONG : GRIB_TYPE_DOUBLE; +} + +} // namespace eccodes::expression + +grib_expression* new_unop_expression(grib_context* c, grib_unop_long_proc long_func, grib_unop_double_proc double_func, grib_expression* exp) { + return new eccodes::expression::Unop(c, long_func, double_func, exp); +} diff --git a/src/expression/grib_expression_class_unop.h b/src/expression/grib_expression_class_unop.h new file mode 100644 index 000000000..a16cd17a7 --- /dev/null +++ b/src/expression/grib_expression_class_unop.h @@ -0,0 +1,39 @@ +/* + * (C) Copyright 2005- ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#pragma once + +#include "grib_expression.h" + +namespace eccodes::expression { + +class Unop : public Expression { +public: + Unop(grib_context*, UnopLongProc, UnopDoubleProc, Expression*); + + void destroy(grib_context*) override; + void print(grib_context*, grib_handle*, FILE*) const override; + void add_dependency(grib_accessor*) override; + string get_name() const override; + int native_type(grib_handle*) const override; + int evaluate_long(grib_handle*, long*) const override; + int evaluate_double(grib_handle*, double*) const override; + + const char* class_name() const override { return "unop"; }; + +private: + Expression* exp_ = nullptr; + UnopLongProc long_func_ = nullptr; + UnopDoubleProc double_func_ = nullptr; +}; + +} // namespace eccodes::expression + +grib_expression* new_unop_expression(grib_context*, grib_unop_long_proc, grib_unop_double_proc, grib_expression*); diff --git a/src/geo_iterator/grib_iterator_class_gaussian.cc b/src/geo_iterator/grib_iterator_class_gaussian.cc index da50560ef..50618ed2a 100644 --- a/src/geo_iterator/grib_iterator_class_gaussian.cc +++ b/src/geo_iterator/grib_iterator_class_gaussian.cc @@ -33,10 +33,10 @@ int Gaussian::init(grib_handle* h, grib_arguments* args) double start; long istart = 0; - const char* latofirst = grib_arguments_get_name(h, args, carg_++); - const char* latoflast = grib_arguments_get_name(h, args, carg_++); - const char* numtrunc = grib_arguments_get_name(h, args, carg_++); - const char* s_jScansPositively = grib_arguments_get_name(h, args, carg_++); + const char* latofirst = args->get_name(h, carg_++); + const char* latoflast = args->get_name(h, carg_++); + const char* numtrunc = args->get_name(h, carg_++); + const char* s_jScansPositively = args->get_name(h, carg_++); if ((ret = grib_get_double_internal(h, latofirst, &laf))) return ret; diff --git a/src/geo_iterator/grib_iterator_class_gaussian_reduced.cc b/src/geo_iterator/grib_iterator_class_gaussian_reduced.cc index cb06386e7..a060d48f8 100644 --- a/src/geo_iterator/grib_iterator_class_gaussian_reduced.cc +++ b/src/geo_iterator/grib_iterator_class_gaussian_reduced.cc @@ -239,13 +239,13 @@ int GaussianReduced::init(grib_handle* h, grib_arguments* args) long row_count = 0; long angleSubdivisions = 0; const grib_context* c = h->context; - const char* slat_first = grib_arguments_get_name(h, args, carg_++); - const char* slon_first = grib_arguments_get_name(h, args, carg_++); - const char* slat_last = grib_arguments_get_name(h, args, carg_++); - const char* slon_last = grib_arguments_get_name(h, args, carg_++); - const char* sorder = grib_arguments_get_name(h, args, carg_++); - const char* spl = grib_arguments_get_name(h, args, carg_++); - const char* snj = grib_arguments_get_name(h, args, carg_++); + const char* slat_first = args->get_name(h, carg_++); + const char* slon_first = args->get_name(h, carg_++); + const char* slat_last = args->get_name(h, carg_++); + const char* slon_last = args->get_name(h, carg_++); + const char* sorder = args->get_name(h, carg_++); + const char* spl = args->get_name(h, carg_++); + const char* snj = args->get_name(h, carg_++); angleOfRotation_ = 0; isRotated_ = 0; diff --git a/src/geo_iterator/grib_iterator_class_gen.cc b/src/geo_iterator/grib_iterator_class_gen.cc index 1e14b9e37..6efea72e9 100644 --- a/src/geo_iterator/grib_iterator_class_gen.cc +++ b/src/geo_iterator/grib_iterator_class_gen.cc @@ -24,10 +24,10 @@ int Gen::init(grib_handle* h, grib_arguments* args) // e.g., latlon, gaussian_reduced etc carg_ = 1; // start from 1 and not 0 - const char* s_numPoints = grib_arguments_get_name(h, args, carg_++); + const char* s_numPoints = args->get_name(h, carg_++); // The missingValue argument is not currently used. Skip it - carg_++; //const char* s_missingValue = grib_arguments_get_name(h, args, carg_++); - const char* s_rawData = grib_arguments_get_name(h, args, carg_++); + carg_++; //const char* s_missingValue = args->get_name(h, carg_++); + const char* s_rawData = args->get_name(h, carg_++); size_t dli = 0; if ((err = grib_get_size(h, s_rawData, &dli)) != GRIB_SUCCESS) diff --git a/src/geo_iterator/grib_iterator_class_healpix.cc b/src/geo_iterator/grib_iterator_class_healpix.cc index 7b4ac56ef..b6dc2db57 100644 --- a/src/geo_iterator/grib_iterator_class_healpix.cc +++ b/src/geo_iterator/grib_iterator_class_healpix.cc @@ -268,8 +268,8 @@ int Healpix::init(grib_handle* h, grib_arguments* args) if ((err = Gen::init(h, args)) != GRIB_SUCCESS) return err; - const char* snside = grib_arguments_get_name(h, args, carg_++); - const char* sorder = grib_arguments_get_name(h, args, carg_++); + const char* snside = args->get_name(h, carg_++); + const char* sorder = args->get_name(h, carg_++); long N = 0; if ((err = grib_get_long_internal(h, snside, &N)) != GRIB_SUCCESS) { diff --git a/src/geo_iterator/grib_iterator_class_lambert_azimuthal_equal_area.cc b/src/geo_iterator/grib_iterator_class_lambert_azimuthal_equal_area.cc index 9db20fe81..f00bc974f 100644 --- a/src/geo_iterator/grib_iterator_class_lambert_azimuthal_equal_area.cc +++ b/src/geo_iterator/grib_iterator_class_lambert_azimuthal_equal_area.cc @@ -347,19 +347,19 @@ int LambertAzimuthalEqualArea::init(grib_handle* h, grib_arguments* args) long jScansPositively, jPointsAreConsecutive; double earthMajorAxisInMetres = 0, earthMinorAxisInMetres = 0; - const char* sradius = grib_arguments_get_name(h, args, carg_++); - const char* snx = grib_arguments_get_name(h, args, carg_++); - const char* sny = grib_arguments_get_name(h, args, carg_++); - const char* slatFirstInDegrees = grib_arguments_get_name(h, args, carg_++); - const char* slonFirstInDegrees = grib_arguments_get_name(h, args, carg_++); - const char* sstandardParallel = grib_arguments_get_name(h, args, carg_++); - const char* scentralLongitude = grib_arguments_get_name(h, args, carg_++); - const char* sDx = grib_arguments_get_name(h, args, carg_++); - const char* sDy = grib_arguments_get_name(h, args, carg_++); - const char* siScansNegatively = grib_arguments_get_name(h, args, carg_++); - const char* sjScansPositively = grib_arguments_get_name(h, args, carg_++); - const char* sjPointsAreConsecutive = grib_arguments_get_name(h, args, carg_++); - const char* salternativeRowScanning = grib_arguments_get_name(h, args, carg_++); + const char* sradius = args->get_name(h, carg_++); + const char* snx = args->get_name(h, carg_++); + const char* sny = args->get_name(h, carg_++); + const char* slatFirstInDegrees = args->get_name(h, carg_++); + const char* slonFirstInDegrees = args->get_name(h, carg_++); + const char* sstandardParallel = args->get_name(h, carg_++); + const char* scentralLongitude = args->get_name(h, carg_++); + const char* sDx = args->get_name(h, carg_++); + const char* sDy = args->get_name(h, carg_++); + const char* siScansNegatively = args->get_name(h, carg_++); + const char* sjScansPositively = args->get_name(h, carg_++); + const char* sjPointsAreConsecutive = args->get_name(h, carg_++); + const char* salternativeRowScanning = args->get_name(h, carg_++); const double d2r = acos(0.0) / 90.0; is_oblate = grib_is_earth_oblate(h); diff --git a/src/geo_iterator/grib_iterator_class_lambert_conformal.cc b/src/geo_iterator/grib_iterator_class_lambert_conformal.cc index 13162da77..aa3f79b32 100644 --- a/src/geo_iterator/grib_iterator_class_lambert_conformal.cc +++ b/src/geo_iterator/grib_iterator_class_lambert_conformal.cc @@ -359,22 +359,22 @@ int LambertConformal::init(grib_handle* h, grib_arguments* args) LaDInRadians; double earthMajorAxisInMetres = 0, earthMinorAxisInMetres = 0; - const char* sradius = grib_arguments_get_name(h, args, carg_++); - const char* snx = grib_arguments_get_name(h, args, carg_++); - const char* sny = grib_arguments_get_name(h, args, carg_++); - const char* sLoVInDegrees = grib_arguments_get_name(h, args, carg_++); - const char* sLaDInDegrees = grib_arguments_get_name(h, args, carg_++); - const char* sLatin1InDegrees = grib_arguments_get_name(h, args, carg_++); - const char* sLatin2InDegrees = grib_arguments_get_name(h, args, carg_++); - const char* slatFirstInDegrees = grib_arguments_get_name(h, args, carg_++); - const char* slonFirstInDegrees = grib_arguments_get_name(h, args, carg_++); + const char* sradius = args->get_name(h, carg_++); + const char* snx = args->get_name(h, carg_++); + const char* sny = args->get_name(h, carg_++); + const char* sLoVInDegrees = args->get_name(h, carg_++); + const char* sLaDInDegrees = args->get_name(h, carg_++); + const char* sLatin1InDegrees = args->get_name(h, carg_++); + const char* sLatin2InDegrees = args->get_name(h, carg_++); + const char* slatFirstInDegrees = args->get_name(h, carg_++); + const char* slonFirstInDegrees = args->get_name(h, carg_++); // Dx and Dy are in Metres - const char* sDx = grib_arguments_get_name(h, args, carg_++); - const char* sDy = grib_arguments_get_name(h, args, carg_++); - const char* siScansNegatively = grib_arguments_get_name(h, args, carg_++); - const char* sjScansPositively = grib_arguments_get_name(h, args, carg_++); - const char* sjPointsAreConsecutive = grib_arguments_get_name(h, args, carg_++); - const char* salternativeRowScanning = grib_arguments_get_name(h, args, carg_++); + const char* sDx = args->get_name(h, carg_++); + const char* sDy = args->get_name(h, carg_++); + const char* siScansNegatively = args->get_name(h, carg_++); + const char* sjScansPositively = args->get_name(h, carg_++); + const char* sjPointsAreConsecutive = args->get_name(h, carg_++); + const char* salternativeRowScanning = args->get_name(h, carg_++); if ((err = grib_get_long_internal(h, snx, &nx)) != GRIB_SUCCESS) return err; if ((err = grib_get_long_internal(h, sny, &ny)) != GRIB_SUCCESS) return err; diff --git a/src/geo_iterator/grib_iterator_class_latlon.cc b/src/geo_iterator/grib_iterator_class_latlon.cc index 603640130..93d0acb8f 100644 --- a/src/geo_iterator/grib_iterator_class_latlon.cc +++ b/src/geo_iterator/grib_iterator_class_latlon.cc @@ -71,14 +71,14 @@ int Latlon::init(grib_handle* h, grib_arguments* args) long jScansPositively; long lai; - const char* s_lat1 = grib_arguments_get_name(h, args, carg_++); - const char* s_jdir = grib_arguments_get_name(h, args, carg_++); - const char* s_jScansPos = grib_arguments_get_name(h, args, carg_++); - const char* s_jPtsConsec = grib_arguments_get_name(h, args, carg_++); - const char* s_isRotatedGrid = grib_arguments_get_name(h, args, carg_++); - const char* s_angleOfRotation = grib_arguments_get_name(h, args, carg_++); - const char* s_latSouthernPole = grib_arguments_get_name(h, args, carg_++); - const char* s_lonSouthernPole = grib_arguments_get_name(h, args, carg_++); + const char* s_lat1 = args->get_name(h, carg_++); + const char* s_jdir = args->get_name(h, carg_++); + const char* s_jScansPos = args->get_name(h, carg_++); + const char* s_jPtsConsec = args->get_name(h, carg_++); + const char* s_isRotatedGrid = args->get_name(h, carg_++); + const char* s_angleOfRotation = args->get_name(h, carg_++); + const char* s_latSouthernPole = args->get_name(h, carg_++); + const char* s_lonSouthernPole = args->get_name(h, carg_++); angleOfRotation_ = 0; isRotated_ = 0; diff --git a/src/geo_iterator/grib_iterator_class_latlon_reduced.cc b/src/geo_iterator/grib_iterator_class_latlon_reduced.cc index 784320d99..2d84a4ee3 100644 --- a/src/geo_iterator/grib_iterator_class_latlon_reduced.cc +++ b/src/geo_iterator/grib_iterator_class_latlon_reduced.cc @@ -50,13 +50,13 @@ int LatlonReduced::init(grib_handle* h, grib_arguments* args) int islocal = 0; long nlons2 = 0; /* adjusted num of longitudes */ - const char* latofirst = grib_arguments_get_name(h, args, carg_++); - const char* longoffirst = grib_arguments_get_name(h, args, carg_++); - const char* latoflast = grib_arguments_get_name(h, args, carg_++); - const char* longoflast = grib_arguments_get_name(h, args, carg_++); - const char* nlats_name = grib_arguments_get_name(h, args, carg_++); - const char* jdirec = grib_arguments_get_name(h, args, carg_++); - const char* plac = grib_arguments_get_name(h, args, carg_++); + const char* latofirst = args->get_name(h, carg_++); + const char* longoffirst = args->get_name(h, carg_++); + const char* latoflast = args->get_name(h, carg_++); + const char* longoflast = args->get_name(h, carg_++); + const char* nlats_name = args->get_name(h, carg_++); + const char* jdirec = args->get_name(h, carg_++); + const char* plac = args->get_name(h, carg_++); if ((ret = grib_get_double_internal(h, latofirst, &laf))) return ret; diff --git a/src/geo_iterator/grib_iterator_class_mercator.cc b/src/geo_iterator/grib_iterator_class_mercator.cc index 248ba7872..0a278d60e 100644 --- a/src/geo_iterator/grib_iterator_class_mercator.cc +++ b/src/geo_iterator/grib_iterator_class_mercator.cc @@ -174,22 +174,22 @@ int Mercator::init(grib_handle* h, grib_arguments* args) LaDInRadians, orientationInRadians; double earthMajorAxisInMetres = 0, earthMinorAxisInMetres = 0; - const char* sRadius = grib_arguments_get_name(h, args, carg_++); - const char* sNi = grib_arguments_get_name(h, args, carg_++); - const char* sNj = grib_arguments_get_name(h, args, carg_++); - const char* sLatFirstInDegrees = grib_arguments_get_name(h, args, carg_++); - const char* sLonFirstInDegrees = grib_arguments_get_name(h, args, carg_++); - const char* sLaDInDegrees = grib_arguments_get_name(h, args, carg_++); - const char* sLatLastInDegrees = grib_arguments_get_name(h, args, carg_++); - const char* sLonLastInDegrees = grib_arguments_get_name(h, args, carg_++); - const char* sOrientationInDegrees = grib_arguments_get_name(h, args, carg_++); + const char* sRadius = args->get_name(h, carg_++); + const char* sNi = args->get_name(h, carg_++); + const char* sNj = args->get_name(h, carg_++); + const char* sLatFirstInDegrees = args->get_name(h, carg_++); + const char* sLonFirstInDegrees = args->get_name(h, carg_++); + const char* sLaDInDegrees = args->get_name(h, carg_++); + const char* sLatLastInDegrees = args->get_name(h, carg_++); + const char* sLonLastInDegrees = args->get_name(h, carg_++); + const char* sOrientationInDegrees = args->get_name(h, carg_++); /* Dx and Dy are in Metres */ - const char* sDi = grib_arguments_get_name(h, args, carg_++); - const char* sDj = grib_arguments_get_name(h, args, carg_++); - const char* siScansNegatively = grib_arguments_get_name(h, args, carg_++); - const char* sjScansPositively = grib_arguments_get_name(h, args, carg_++); - const char* sjPointsAreConsecutive = grib_arguments_get_name(h, args, carg_++); - const char* sAlternativeRowScanning = grib_arguments_get_name(h, args, carg_++); + const char* sDi = args->get_name(h, carg_++); + const char* sDj = args->get_name(h, carg_++); + const char* siScansNegatively = args->get_name(h, carg_++); + const char* sjScansPositively = args->get_name(h, carg_++); + const char* sjPointsAreConsecutive = args->get_name(h, carg_++); + const char* sAlternativeRowScanning = args->get_name(h, carg_++); if ((err = grib_get_long_internal(h, sNi, &ni)) != GRIB_SUCCESS) return err; if ((err = grib_get_long_internal(h, sNj, &nj)) != GRIB_SUCCESS) return err; diff --git a/src/geo_iterator/grib_iterator_class_polar_stereographic.cc b/src/geo_iterator/grib_iterator_class_polar_stereographic.cc index beff11bd6..2e0623ecc 100644 --- a/src/geo_iterator/grib_iterator_class_polar_stereographic.cc +++ b/src/geo_iterator/grib_iterator_class_polar_stereographic.cc @@ -74,20 +74,20 @@ int PolarStereographic::init(grib_handle* h, grib_arguments* args) 0, }; - const char* s_radius = grib_arguments_get_name(h, args, carg_++); - const char* s_nx = grib_arguments_get_name(h, args, carg_++); - const char* s_ny = grib_arguments_get_name(h, args, carg_++); - const char* s_latFirstInDegrees = grib_arguments_get_name(h, args, carg_++); - const char* s_lonFirstInDegrees = grib_arguments_get_name(h, args, carg_++); - const char* s_southPoleOnPlane = grib_arguments_get_name(h, args, carg_++); - const char* s_centralLongitude = grib_arguments_get_name(h, args, carg_++); - const char* s_centralLatitude = grib_arguments_get_name(h, args, carg_++); - const char* s_Dx = grib_arguments_get_name(h, args, carg_++); - const char* s_Dy = grib_arguments_get_name(h, args, carg_++); - const char* s_iScansNegatively = grib_arguments_get_name(h, args, carg_++); - const char* s_jScansPositively = grib_arguments_get_name(h, args, carg_++); - const char* s_jPointsAreConsecutive = grib_arguments_get_name(h, args, carg_++); - const char* s_alternativeRowScanning = grib_arguments_get_name(h, args, carg_++); + const char* s_radius = args->get_name(h, carg_++); + const char* s_nx = args->get_name(h, carg_++); + const char* s_ny = args->get_name(h, carg_++); + const char* s_latFirstInDegrees = args->get_name(h, carg_++); + const char* s_lonFirstInDegrees = args->get_name(h, carg_++); + const char* s_southPoleOnPlane = args->get_name(h, carg_++); + const char* s_centralLongitude = args->get_name(h, carg_++); + const char* s_centralLatitude = args->get_name(h, carg_++); + const char* s_Dx = args->get_name(h, carg_++); + const char* s_Dy = args->get_name(h, carg_++); + const char* s_iScansNegatively = args->get_name(h, carg_++); + const char* s_jScansPositively = args->get_name(h, carg_++); + const char* s_jPointsAreConsecutive = args->get_name(h, carg_++); + const char* s_alternativeRowScanning = args->get_name(h, carg_++); if (grib_is_earth_oblate(h)) { grib_context_log(h->context, GRIB_LOG_ERROR, "%s: Only supported for spherical earth.", ITER); diff --git a/src/geo_iterator/grib_iterator_class_regular.cc b/src/geo_iterator/grib_iterator_class_regular.cc index 11d32ff03..694b7b420 100644 --- a/src/geo_iterator/grib_iterator_class_regular.cc +++ b/src/geo_iterator/grib_iterator_class_regular.cc @@ -67,11 +67,11 @@ int Regular::init(grib_handle* h, grib_arguments* args) double idir, idir_coded, lon1, lon2; long loi; - const char* s_lon1 = grib_arguments_get_name(h, args, carg_++); - const char* s_idir = grib_arguments_get_name(h, args, carg_++); - const char* s_Ni = grib_arguments_get_name(h, args, carg_++); - const char* s_Nj = grib_arguments_get_name(h, args, carg_++); - const char* s_iScansNeg = grib_arguments_get_name(h, args, carg_++); + const char* s_lon1 = args->get_name(h, carg_++); + const char* s_idir = args->get_name(h, carg_++); + const char* s_Ni = args->get_name(h, carg_++); + const char* s_Nj = args->get_name(h, carg_++); + const char* s_iScansNeg = args->get_name(h, carg_++); if ((ret = grib_get_double_internal(h, s_lon1, &lon1))) return ret; diff --git a/src/geo_iterator/grib_iterator_class_space_view.cc b/src/geo_iterator/grib_iterator_class_space_view.cc index d3085dd81..8f14b9c26 100644 --- a/src/geo_iterator/grib_iterator_class_space_view.cc +++ b/src/geo_iterator/grib_iterator_class_space_view.cc @@ -100,27 +100,27 @@ int SpaceView::init(grib_handle* h, grib_arguments* args) double *s_x, *c_x; /* arrays storing sin and cos values */ size_t array_size = (nv_ * sizeof(double)); - const char* sradius = grib_arguments_get_name(h, args, carg_++); - const char* sEarthIsOblate = grib_arguments_get_name(h, args, carg_++); - const char* sMajorAxisInMetres = grib_arguments_get_name(h, args, carg_++); - const char* sMinorAxisInMetres = grib_arguments_get_name(h, args, carg_++); - const char* snx = grib_arguments_get_name(h, args, carg_++); - const char* sny = grib_arguments_get_name(h, args, carg_++); - const char* sLatOfSubSatellitePointInDegrees = grib_arguments_get_name(h, args, carg_++); - const char* sLonOfSubSatellitePointInDegrees = grib_arguments_get_name(h, args, carg_++); - const char* sDx = grib_arguments_get_name(h, args, carg_++); - const char* sDy = grib_arguments_get_name(h, args, carg_++); - const char* sXpInGridLengths = grib_arguments_get_name(h, args, carg_++); - const char* sYpInGridLengths = grib_arguments_get_name(h, args, carg_++); - const char* sOrientationInDegrees = grib_arguments_get_name(h, args, carg_++); - const char* sNrInRadiusOfEarthScaled = grib_arguments_get_name(h, args, carg_++); - const char* sXo = grib_arguments_get_name(h, args, carg_++); - const char* sYo = grib_arguments_get_name(h, args, carg_++); + const char* sradius = args->get_name(h, carg_++); + const char* sEarthIsOblate = args->get_name(h, carg_++); + const char* sMajorAxisInMetres = args->get_name(h, carg_++); + const char* sMinorAxisInMetres = args->get_name(h, carg_++); + const char* snx = args->get_name(h, carg_++); + const char* sny = args->get_name(h, carg_++); + const char* sLatOfSubSatellitePointInDegrees = args->get_name(h, carg_++); + const char* sLonOfSubSatellitePointInDegrees = args->get_name(h, carg_++); + const char* sDx = args->get_name(h, carg_++); + const char* sDy = args->get_name(h, carg_++); + const char* sXpInGridLengths = args->get_name(h, carg_++); + const char* sYpInGridLengths = args->get_name(h, carg_++); + const char* sOrientationInDegrees = args->get_name(h, carg_++); + const char* sNrInRadiusOfEarthScaled = args->get_name(h, carg_++); + const char* sXo = args->get_name(h, carg_++); + const char* sYo = args->get_name(h, carg_++); - const char* siScansNegatively = grib_arguments_get_name(h, args, carg_++); - const char* sjScansPositively = grib_arguments_get_name(h, args, carg_++); - const char* sjPointsAreConsecutive = grib_arguments_get_name(h, args, carg_++); - const char* sAlternativeRowScanning = grib_arguments_get_name(h, args, carg_++); + const char* siScansNegatively = args->get_name(h, carg_++); + const char* sjScansPositively = args->get_name(h, carg_++); + const char* sjPointsAreConsecutive = args->get_name(h, carg_++); + const char* sAlternativeRowScanning = args->get_name(h, carg_++); if ((ret = grib_get_long_internal(h, snx, &nx)) != GRIB_SUCCESS) return ret; diff --git a/src/geo_iterator/grib_iterator_class_unstructured.cc b/src/geo_iterator/grib_iterator_class_unstructured.cc index dab834c12..2531bbd8a 100644 --- a/src/geo_iterator/grib_iterator_class_unstructured.cc +++ b/src/geo_iterator/grib_iterator_class_unstructured.cc @@ -37,7 +37,7 @@ int Unstructured::init(grib_handle* h, grib_arguments* args) if ((ret = Gen::init(h, args)) != GRIB_SUCCESS) return ret; - const char* s_uuidOfHGrid = grib_arguments_get_name(h, args, carg_++); + const char* s_uuidOfHGrid = args->get_name(h, carg_++); char uuidOfHGrid[32] = {0,}; auto slen = sizeof(uuidOfHGrid); if ((ret = grib_get_string_internal(h, s_uuidOfHGrid, uuidOfHGrid, &slen)) != GRIB_SUCCESS) { diff --git a/src/geo_nearest/grib_nearest_class_gen.cc b/src/geo_nearest/grib_nearest_class_gen.cc index 68a257367..9934f9083 100644 --- a/src/geo_nearest/grib_nearest_class_gen.cc +++ b/src/geo_nearest/grib_nearest_class_gen.cc @@ -20,8 +20,8 @@ int Gen::init(grib_handle* h, grib_arguments* args) cargs_ = 1; - values_key_ = grib_arguments_get_name(h, args, cargs_++); - radius_ = grib_arguments_get_name(h, args, cargs_++); + values_key_ = args->get_name(h, cargs_++); + radius_ = args->get_name(h, cargs_++); values_ = NULL; return ret; diff --git a/src/geo_nearest/grib_nearest_class_healpix.cc b/src/geo_nearest/grib_nearest_class_healpix.cc index ed49a9644..a4bb16bb0 100644 --- a/src/geo_nearest/grib_nearest_class_healpix.cc +++ b/src/geo_nearest/grib_nearest_class_healpix.cc @@ -21,8 +21,8 @@ int Healpix::init(grib_handle* h, grib_arguments* args) if ((ret = Gen::init(h, args) != GRIB_SUCCESS)) return ret; - Ni_ = grib_arguments_get_name(h, args, cargs_++); - Nj_ = grib_arguments_get_name(h, args, cargs_++); + Ni_ = args->get_name(h, cargs_++); + Nj_ = args->get_name(h, cargs_++); i_ = (size_t*)grib_context_malloc(h->context, 2 * sizeof(size_t)); j_ = (size_t*)grib_context_malloc(h->context, 2 * sizeof(size_t)); diff --git a/src/geo_nearest/grib_nearest_class_lambert_azimuthal_equal_area.cc b/src/geo_nearest/grib_nearest_class_lambert_azimuthal_equal_area.cc index eb701ee75..85498a112 100644 --- a/src/geo_nearest/grib_nearest_class_lambert_azimuthal_equal_area.cc +++ b/src/geo_nearest/grib_nearest_class_lambert_azimuthal_equal_area.cc @@ -21,8 +21,8 @@ int LambertAzimuthalEqualArea::init(grib_handle* h, grib_arguments* args) if ((ret = Gen::init(h, args) != GRIB_SUCCESS)) return ret; - Ni_ = grib_arguments_get_name(h, args, cargs_++); - Nj_ = grib_arguments_get_name(h, args, cargs_++); + Ni_ = args->get_name(h, cargs_++); + Nj_ = args->get_name(h, cargs_++); i_ = (size_t*)grib_context_malloc(h->context, 2 * sizeof(size_t)); j_ = (size_t*)grib_context_malloc(h->context, 2 * sizeof(size_t)); diff --git a/src/geo_nearest/grib_nearest_class_lambert_conformal.cc b/src/geo_nearest/grib_nearest_class_lambert_conformal.cc index a61756e54..ab7b3a487 100644 --- a/src/geo_nearest/grib_nearest_class_lambert_conformal.cc +++ b/src/geo_nearest/grib_nearest_class_lambert_conformal.cc @@ -21,8 +21,8 @@ int LambertConformal::init(grib_handle* h, grib_arguments* args) if ((ret = Gen::init(h, args) != GRIB_SUCCESS)) return ret; - Ni_ = grib_arguments_get_name(h, args, cargs_++); - Nj_ = grib_arguments_get_name(h, args, cargs_++); + Ni_ = args->get_name(h, cargs_++); + Nj_ = args->get_name(h, cargs_++); i_ = (size_t*)grib_context_malloc(h->context, 2 * sizeof(size_t)); j_ = (size_t*)grib_context_malloc(h->context, 2 * sizeof(size_t)); diff --git a/src/geo_nearest/grib_nearest_class_latlon_reduced.cc b/src/geo_nearest/grib_nearest_class_latlon_reduced.cc index 6eb1500a0..dbeae09ef 100644 --- a/src/geo_nearest/grib_nearest_class_latlon_reduced.cc +++ b/src/geo_nearest/grib_nearest_class_latlon_reduced.cc @@ -21,10 +21,10 @@ int LatlonReduced::init(grib_handle* h, grib_arguments* args) if ((ret = Gen::init(h, args) != GRIB_SUCCESS)) return ret; - Nj_ = grib_arguments_get_name(h, args, cargs_++); - pl_ = grib_arguments_get_name(h, args, cargs_++); - lonFirst_ = grib_arguments_get_name(h, args, cargs_++); - lonLast_ = grib_arguments_get_name(h, args, cargs_++); + Nj_ = args->get_name(h, cargs_++); + pl_ = args->get_name(h, cargs_++); + lonFirst_ = args->get_name(h, cargs_++); + lonLast_ = args->get_name(h, cargs_++); j_ = (size_t*)grib_context_malloc(h->context, 2 * sizeof(size_t)); if (!j_) return GRIB_OUT_OF_MEMORY; diff --git a/src/geo_nearest/grib_nearest_class_mercator.cc b/src/geo_nearest/grib_nearest_class_mercator.cc index 06558ed93..81e584ffb 100644 --- a/src/geo_nearest/grib_nearest_class_mercator.cc +++ b/src/geo_nearest/grib_nearest_class_mercator.cc @@ -21,8 +21,8 @@ int Mercator::init(grib_handle* h, grib_arguments* args) if ((ret = Gen::init(h, args) != GRIB_SUCCESS)) return ret; - Ni_ = grib_arguments_get_name(h, args, cargs_++); - Nj_ = grib_arguments_get_name(h, args, cargs_++); + Ni_ = args->get_name(h, cargs_++); + Nj_ = args->get_name(h, cargs_++); i_ = (size_t*)grib_context_malloc(h->context, 2 * sizeof(size_t)); j_ = (size_t*)grib_context_malloc(h->context, 2 * sizeof(size_t)); diff --git a/src/geo_nearest/grib_nearest_class_polar_stereographic.cc b/src/geo_nearest/grib_nearest_class_polar_stereographic.cc index 1eb52d06b..d2f4a8ce1 100644 --- a/src/geo_nearest/grib_nearest_class_polar_stereographic.cc +++ b/src/geo_nearest/grib_nearest_class_polar_stereographic.cc @@ -21,8 +21,8 @@ int PolarStereographic::init(grib_handle* h, grib_arguments* args) if ((ret = Gen::init(h, args) != GRIB_SUCCESS)) return ret; - Ni_ = grib_arguments_get_name(h, args, cargs_++); - Nj_ = grib_arguments_get_name(h, args, cargs_++); + Ni_ = args->get_name(h, cargs_++); + Nj_ = args->get_name(h, cargs_++); i_ = (size_t*)grib_context_malloc(h->context, 2 * sizeof(size_t)); j_ = (size_t*)grib_context_malloc(h->context, 2 * sizeof(size_t)); diff --git a/src/geo_nearest/grib_nearest_class_reduced.cc b/src/geo_nearest/grib_nearest_class_reduced.cc index 60a40fb15..c96de6b12 100644 --- a/src/geo_nearest/grib_nearest_class_reduced.cc +++ b/src/geo_nearest/grib_nearest_class_reduced.cc @@ -23,8 +23,8 @@ int Reduced::init(grib_handle* h, grib_arguments* args) if ((ret = Gen::init(h, args) != GRIB_SUCCESS)) return ret; - Nj_ = grib_arguments_get_name(h, args, cargs_++); - pl_ = grib_arguments_get_name(h, args, cargs_++); + Nj_ = args->get_name(h, cargs_++); + pl_ = args->get_name(h, cargs_++); j_ = (size_t*)grib_context_malloc(h->context, 2 * sizeof(size_t)); legacy_ = -1; rotated_ = -1; @@ -59,29 +59,29 @@ typedef void (*get_reduced_row_proc)(long pl, double lon_first, double lon_last, static int is_legacy(grib_handle* h, int* legacy) { - int err = 0; + int err = 0; long lVal = 0; - *legacy = 0; // false by default - err = grib_get_long(h, "legacyGaussSubarea", &lVal); + *legacy = 0; // false by default + err = grib_get_long(h, "legacyGaussSubarea", &lVal); if (err) return err; *legacy = (int)lVal; return GRIB_SUCCESS; } static int is_rotated(grib_handle* h, int* rotated) { - int err = 0; + int err = 0; long lVal = 0; - *rotated = 0; // false by default - err = grib_get_long(h, "isRotatedGrid", &lVal); + *rotated = 0; // false by default + err = grib_get_long(h, "isRotatedGrid", &lVal); if (err) return err; *rotated = (int)lVal; return GRIB_SUCCESS; } int Reduced::find(grib_handle* h, - double inlat, double inlon, unsigned long flags, - double* outlats, double* outlons, double* values, - double* distances, int* indexes, size_t* len) + double inlat, double inlon, unsigned long flags, + double* outlats, double* outlons, double* values, + double* distances, int* indexes, size_t* len) { int err = 0; @@ -91,16 +91,15 @@ int Reduced::find(grib_handle* h, } if (global_ && rotated_ == 0) { - err = find_global( h, - inlat, inlon, flags, - outlats, outlons, values, - distances, indexes, len); + err = find_global(h, + inlat, inlon, flags, + outlats, outlons, values, + distances, indexes, len); } - else - { + else { /* ECC-762, ECC-1432: Use brute force generic algorithm * for reduced grid subareas. Review in the future - */ + */ int lons_count = 0; /*dummy*/ err = grib_nearest_find_generic( @@ -119,12 +118,12 @@ int Reduced::find(grib_handle* h, /* Old implementation in src/deprecated/grib_nearest_class_reduced.old */ int Reduced::find_global(grib_handle* h, - double inlat, double inlon, unsigned long flags, - double* outlats, double* outlons, double* values, - double* distances, int* indexes, size_t* len) + double inlat, double inlon, unsigned long flags, + double* outlats, double* outlons, double* values, + double* distances, int* indexes, size_t* len) { int err = 0, kk = 0, ii = 0; - size_t jj = 0; + size_t jj = 0; long* pla = NULL; long* pl = NULL; size_t nvalues = 0; @@ -153,8 +152,8 @@ int Reduced::find_global(grib_handle* h, * This is for performance: if the grid has not changed, we only do this once * and reuse for other messages */ if (!h_ || (flags & GRIB_NEAREST_SAME_GRID) == 0) { - double olat = 1.e10; - long n = 0; + double olat = 1.e10; + long n = 0; ilat = 0; ilon = 0; @@ -187,7 +186,7 @@ int Reduced::find_global(grib_handle* h, while (grib_iterator_next(iter, &lat, &lon, NULL)) { if (ilat < lats_count_ && olat != lat) { lats_[ilat++] = lat; - olat = lat; + olat = lat; } while (lon > 360) lon -= 360; @@ -288,8 +287,8 @@ int Reduced::find_global(grib_handle* h, if (lons[nplm1] > lons[0]) { if (inlon < lons[0] || inlon > lons[nplm1]) { if (lons[nplm1] - lons[0] - 360 <= lons[nplm1] - lons[nplm1 - 1]) { - k_[0] = 0; - k_[1] = nplm1; + k_[0] = 0; + k_[1] = nplm1; nearest_lons_found = 1; } else @@ -299,8 +298,8 @@ int Reduced::find_global(grib_handle* h, else { if (inlon > lons[0] || inlon < lons[nplm1]) { if (lons[0] - lons[nplm1] - 360 <= lons[0] - lons[1]) { - k_[0] = 0; - k_[1] = nplm1; + k_[0] = 0; + k_[1] = nplm1; nearest_lons_found = 1; } else @@ -352,8 +351,8 @@ int Reduced::find_global(grib_handle* h, if (inlon < lons[0] || inlon > lons[nplm1]) { if (lons[nplm1] - lons[0] - 360 <= lons[nplm1] - lons[nplm1 - 1]) { - k_[2] = 0; - k_[3] = nplm1; + k_[2] = 0; + k_[3] = nplm1; nearest_lons_found = 1; } else @@ -364,8 +363,8 @@ int Reduced::find_global(grib_handle* h, if (inlon > lons[0] || inlon < lons[nplm1]) { if (lons[0] - lons[nplm1] - 360 <= lons[0] - lons[1]) { - k_[2] = 0; - k_[3] = nplm1; + k_[2] = 0; + k_[3] = nplm1; nearest_lons_found = 1; } else @@ -395,7 +394,7 @@ int Reduced::find_global(grib_handle* h, for (jj = 0; jj < 2; jj++) { for (ii = 0; ii < 2; ii++) { distances_[kk] = geographic_distance_spherical(radiusInKm, inlon, inlat, - lons_[k_[kk]], lats_[j_[jj]]); + lons_[k_[kk]], lats_[j_[jj]]); kk++; } } @@ -423,7 +422,8 @@ int Reduced::find_global(grib_handle* h, /* Current interface uses an 'int' for 'indexes' which is 32bits! We should change this to a 64bit type */ grib_context_log(h->context, GRIB_LOG_ERROR, "grib_nearest_reduced: Unable to compute index. Value too large"); return GRIB_OUT_OF_RANGE; - } else { + } + else { indexes[kk] = (int)k_[kk]; } kk++; diff --git a/src/geo_nearest/grib_nearest_class_regular.cc b/src/geo_nearest/grib_nearest_class_regular.cc index 9dac4b0cc..1884b347d 100644 --- a/src/geo_nearest/grib_nearest_class_regular.cc +++ b/src/geo_nearest/grib_nearest_class_regular.cc @@ -23,8 +23,8 @@ int Regular::init(grib_handle* h, grib_arguments* args) if ((ret = Gen::init(h, args) != GRIB_SUCCESS)) return ret; - Ni_ = grib_arguments_get_name(h, args, cargs_++); - Nj_ = grib_arguments_get_name(h, args, cargs_++); + Ni_ = args->get_name(h, cargs_++); + Nj_ = args->get_name(h, cargs_++); i_ = (size_t*)grib_context_malloc(h->context, 2 * sizeof(size_t)); j_ = (size_t*)grib_context_malloc(h->context, 2 * sizeof(size_t)); return ret; diff --git a/src/geo_nearest/grib_nearest_class_space_view.cc b/src/geo_nearest/grib_nearest_class_space_view.cc index fdad5fba6..22207087e 100644 --- a/src/geo_nearest/grib_nearest_class_space_view.cc +++ b/src/geo_nearest/grib_nearest_class_space_view.cc @@ -21,8 +21,8 @@ int SpaceView::init(grib_handle* h, grib_arguments* args) if ((ret = Gen::init(h, args) != GRIB_SUCCESS)) return ret; - Ni_ = grib_arguments_get_name(h, args, cargs_++); - Nj_ = grib_arguments_get_name(h, args, cargs_++); + Ni_ = args->get_name(h, cargs_++); + Nj_ = args->get_name(h, cargs_++); i_ = (size_t*)grib_context_malloc(h->context, 2 * sizeof(size_t)); j_ = (size_t*)grib_context_malloc(h->context, 2 * sizeof(size_t)); diff --git a/src/grib_api_internal.h b/src/grib_api_internal.h index 5a1f05f03..3c296575b 100644 --- a/src/grib_api_internal.h +++ b/src/grib_api_internal.h @@ -22,41 +22,41 @@ extern "C" { /* cmake config header */ #ifdef HAVE_ECCODES_CONFIG_H - #include "eccodes_config.h" + #include "eccodes_config.h" #endif /* autoconf config header */ #ifdef HAVE_CONFIG_H - #include "config.h" - #ifdef _LARGE_FILES - #undef _LARGE_FILE_API - #endif + #include "config.h" + #ifdef _LARGE_FILES + #undef _LARGE_FILE_API + #endif #endif #ifndef GRIB_INLINE - #define GRIB_INLINE + #define GRIB_INLINE #endif /* See ECC-670 */ #if IS_BIG_ENDIAN - #if GRIB_MEM_ALIGN - #define FAST_BIG_ENDIAN 1 - #else - #define FAST_BIG_ENDIAN 0 - #endif + #if GRIB_MEM_ALIGN + #define FAST_BIG_ENDIAN 1 + #else + #define FAST_BIG_ENDIAN 0 + #endif #endif #if IEEE_BE - #define IEEE + #define IEEE #else - #if IEEE_LE - #define IEEE - #endif + #if IEEE_LE + #define IEEE + #endif #endif #if defined(_WIN32) && defined(_MSC_VER) - #define _CRT_SECURE_NO_WARNINGS - #define _CRT_NONSTDC_NO_DEPRECATE + #define _CRT_SECURE_NO_WARNINGS + #define _CRT_NONSTDC_NO_DEPRECATE #endif #include @@ -66,44 +66,44 @@ extern "C" { #include "eccodes_windef.h" #ifndef ECCODES_ON_WINDOWS - #include - #include - #include + #include + #include + #include #else - #define strtok_r strtok_s - #include - #include + #define strtok_r strtok_s + #include + #include - /* Replace C99/Unix rint() for Windows Visual C++ (only before VC++ 2013 versions) */ - #if defined _MSC_VER && _MSC_VER < 1800 - double rint(double x); - #endif + /* Replace C99/Unix rint() for Windows Visual C++ (only before VC++ 2013 versions) */ + #if defined _MSC_VER && _MSC_VER < 1800 +double rint(double x); + #endif - #ifndef S_ISREG - #define S_ISREG(mode) (mode & S_IFREG) - #endif + #ifndef S_ISREG + #define S_ISREG(mode) (mode & S_IFREG) + #endif - #ifndef S_ISDIR - #define S_ISDIR(mode) (mode & S_IFDIR) - #endif + #ifndef S_ISDIR + #define S_ISDIR(mode) (mode & S_IFDIR) + #endif - #ifndef M_PI - #define M_PI 3.14159265358979323846 - #endif + #ifndef M_PI + #define M_PI 3.14159265358979323846 + #endif - #define R_OK 04 /* Needed for Windows */ + #define R_OK 04 /* Needed for Windows */ - #ifndef F_OK - #define F_OK 0 - #endif + #ifndef F_OK + #define F_OK 0 + #endif - #define mkdir(dirname, mode) _mkdir(dirname) + #define mkdir(dirname, mode) _mkdir(dirname) - #ifdef _MSC_VER - #define access(path, mode) _access(path, mode) - #define chmod(path, mode) _chmod(path, mode) - #define strdup(str) _strdup(str) - #endif + #ifdef _MSC_VER + #define access(path, mode) _access(path, mode) + #define chmod(path, mode) _chmod(path, mode) + #define strdup(str) _strdup(str) + #endif #endif /* ifndef ECCODES_ON_WINDOWS */ @@ -115,9 +115,9 @@ extern "C" { #ifdef HAVE_STRING_H - #include + #include #else - #include + #include #endif /* @@ -127,43 +127,43 @@ extern int pthread_mutexattr_settype(pthread_mutexattr_t* attr, int type); */ #if GRIB_PTHREADS -#include -#define GRIB_MUTEX_INIT_ONCE(a, b) pthread_once(a, b); -#define GRIB_MUTEX_LOCK(a) pthread_mutex_lock(a); -#define GRIB_MUTEX_UNLOCK(a) pthread_mutex_unlock(a); + #include + #define GRIB_MUTEX_INIT_ONCE(a, b) pthread_once(a, b); + #define GRIB_MUTEX_LOCK(a) pthread_mutex_lock(a); + #define GRIB_MUTEX_UNLOCK(a) pthread_mutex_unlock(a); /* #define GRIB_MUTEX_LOCK(a) {pthread_mutex_lock(a); printf("MUTEX LOCK %p %s line %d\n",(void*)a,__FILE__,__LINE__);} #define GRIB_MUTEX_UNLOCK(a) {pthread_mutex_unlock(a);printf("MUTEX UNLOCK %p %s line %d\n",(void*)a,__FILE__,__LINE__);} */ #elif GRIB_OMP_THREADS -#include -#ifdef _MSC_VER -#define GRIB_OMP_CRITICAL(a) __pragma(omp critical(a)) + #include + #ifdef _MSC_VER + #define GRIB_OMP_CRITICAL(a) __pragma(omp critical(a)) + #else + #define GRIB_OMP_STR(a) #a + #define GRIB_OMP_XSTR(a) GRIB_OMP_STR(a) + #define GRIB_OMP_CRITICAL(a) _Pragma(GRIB_OMP_XSTR(omp critical(a))) + #endif + #define GRIB_MUTEX_INIT_ONCE(a, b) (*(b))(); + #define GRIB_MUTEX_LOCK(a) omp_set_nest_lock(a); + #define GRIB_MUTEX_UNLOCK(a) omp_unset_nest_lock(a); #else -#define GRIB_OMP_STR(a) #a -#define GRIB_OMP_XSTR(a) GRIB_OMP_STR(a) -#define GRIB_OMP_CRITICAL(a) _Pragma(GRIB_OMP_XSTR(omp critical(a))) -#endif -#define GRIB_MUTEX_INIT_ONCE(a, b) (*(b))(); -#define GRIB_MUTEX_LOCK(a) omp_set_nest_lock(a); -#define GRIB_MUTEX_UNLOCK(a) omp_unset_nest_lock(a); -#else -#define GRIB_MUTEX_INIT_ONCE(a, b) -#define GRIB_MUTEX_LOCK(a) -#define GRIB_MUTEX_UNLOCK(a) + #define GRIB_MUTEX_INIT_ONCE(a, b) + #define GRIB_MUTEX_LOCK(a) + #define GRIB_MUTEX_UNLOCK(a) #endif #if GRIB_LINUX_PTHREADS -/* Note: in newer pthreads PTHREAD_MUTEX_RECURSIVE and PTHREAD_MUTEX_RECURSIVE_NP are enums */ -#if !defined(PTHREAD_MUTEX_RECURSIVE) -#define PTHREAD_MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NP -#endif + /* Note: in newer pthreads PTHREAD_MUTEX_RECURSIVE and PTHREAD_MUTEX_RECURSIVE_NP are enums */ + #if !defined(PTHREAD_MUTEX_RECURSIVE) + #define PTHREAD_MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NP + #endif #endif #ifndef HAVE_FSEEKO -#define fseeko fseek -#define ftello ftell + #define fseeko fseek + #define ftello ftell #endif #define Assert(a) \ @@ -172,17 +172,17 @@ extern int pthread_mutexattr_settype(pthread_mutexattr_t* attr, int type); } while (0) #ifdef DEBUG -#define DEBUG_ASSERT(a) Assert(a) -#define DEBUG_ASSERT_ACCESS(array, index, size) \ - do { \ - if (!((index) >= 0 && (index) < (size))) { \ - printf("ARRAY ACCESS ERROR: array=%s idx=%ld size=%ld @ %s +%d \n", #array, index, size, __FILE__, __LINE__); \ - abort(); \ - } \ - } while (0) + #define DEBUG_ASSERT(a) Assert(a) + #define DEBUG_ASSERT_ACCESS(array, index, size) \ + do { \ + if (!((index) >= 0 && (index) < (size))) { \ + printf("ARRAY ACCESS ERROR: array=%s idx=%ld size=%ld @ %s +%d \n", #array, index, size, __FILE__, __LINE__); \ + abort(); \ + } \ + } while (0) #else -#define DEBUG_ASSERT(a) -#define DEBUG_ASSERT_ACCESS(array, index, size) + #define DEBUG_ASSERT(a) + #define DEBUG_ASSERT_ACCESS(array, index, size) #endif /* Return true if two strings are equal */ @@ -192,11 +192,11 @@ extern int pthread_mutexattr_settype(pthread_mutexattr_t* attr, int type); #include "grib_api.h" -#define MAX_ACCESSOR_ATTRIBUTES 20 +#define MAX_ACCESSOR_ATTRIBUTES 20 #define MAX_FILE_HANDLES_WITH_MULTI 10 -#define ACCESSORS_ARRAY_SIZE 5000 -#define MAX_NUM_CONCEPTS 2000 -#define MAX_NUM_HASH_ARRAY 2000 +#define ACCESSORS_ARRAY_SIZE 5000 +#define MAX_NUM_CONCEPTS 2000 +#define MAX_NUM_HASH_ARRAY 2000 #define CODES_NAMESPACE 10 #define MAX_NAMESPACE_LEN 64 @@ -212,8 +212,8 @@ extern int pthread_mutexattr_settype(pthread_mutexattr_t* attr, int type); #define GRIB_HASH_ARRAY_TYPE_UNKNOWN 0 #define GRIB_HASH_ARRAY_TYPE_INTEGER 1 -#define GRIB_HASH_ARRAY_TYPE_DOUBLE 2 -#define GRIB_HASH_ARRAY_TYPE_STRING 3 +#define GRIB_HASH_ARRAY_TYPE_DOUBLE 2 +#define GRIB_HASH_ARRAY_TYPE_STRING 3 #define CODES_GRIB 1 #define CODES_BUFR 2 @@ -233,8 +233,14 @@ extern int pthread_mutexattr_settype(pthread_mutexattr_t* attr, int type); extern const int max_nbits; -typedef struct grib_expression grib_expression; -typedef struct grib_arguments grib_arguments; +// typedef struct grib_expression grib_expression; +// +namespace eccodes { +class Expression; +class Arguments; +} // namespace eccodes +using grib_expression = eccodes::Expression; +using grib_arguments = eccodes::Arguments; typedef struct grib_action_file grib_action_file; typedef struct grib_action_file_list grib_action_file_list; @@ -252,8 +258,9 @@ namespace eccodes::geo_iterator { class Iterator; } -typedef struct grib_iterator { - eccodes::geo_iterator::Iterator* iterator; +typedef struct grib_iterator +{ + eccodes::geo_iterator::Iterator* iterator; } grib_iterator; typedef struct grib_dumper grib_dumper; @@ -316,11 +323,11 @@ struct grib_loader }; /** -* An action -* Structure supporting the creation of accessor, resulting of a statement during a definition file parsing -* -* @see grib_action_class -*/ + * An action + * Structure supporting the creation of accessor, resulting of a statement during a definition file parsing + * + * @see grib_action_class + */ struct grib_action { char* name; /** name of the definition statement */ @@ -350,11 +357,11 @@ typedef grib_action* (*action_reparse_proc)(grib_action* a, grib_accessor*, int* typedef int (*action_execute_proc)(grib_action* a, grib_handle*); /** -* An action_class -* Structure supporting the specific behaviour of an action -* -* @see grib_action -*/ + * An action_class + * Structure supporting the specific behaviour of an action + * + * @see grib_action + */ struct grib_action_class { grib_action_class** super; /** < link to a more general behaviour */ @@ -377,9 +384,9 @@ struct grib_action_class }; /** -* A buffer -* Structure containing the data of a message -*/ + * A buffer + * Structure containing the data of a message + */ struct grib_buffer { int property; /** < property parameter of buffer */ @@ -392,10 +399,10 @@ struct grib_buffer }; /** -* An accessor -* Structure supporting each single data unit and allowing its access -* @see grib_accessor_class -*/ + * An accessor + * Structure supporting each single data unit and allowing its access + * @see grib_accessor_class + */ #define MAX_ACCESSOR_NAMES 20 @@ -411,31 +418,31 @@ struct grib_virtual_value int type; }; -#define GRIB_ACCESSOR_FLAG_READ_ONLY (1 << 1) -#define GRIB_ACCESSOR_FLAG_DUMP (1 << 2) -#define GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC (1 << 3) -#define GRIB_ACCESSOR_FLAG_CAN_BE_MISSING (1 << 4) -#define GRIB_ACCESSOR_FLAG_HIDDEN (1 << 5) -#define GRIB_ACCESSOR_FLAG_CONSTRAINT (1 << 6) -#define GRIB_ACCESSOR_FLAG_BUFR_DATA (1 << 7) -#define GRIB_ACCESSOR_FLAG_NO_COPY (1 << 8) -#define GRIB_ACCESSOR_FLAG_COPY_OK (1 << 9) -#define GRIB_ACCESSOR_FLAG_FUNCTION (1 << 10) -#define GRIB_ACCESSOR_FLAG_DATA (1 << 11) -#define GRIB_ACCESSOR_FLAG_NO_FAIL (1 << 12) -#define GRIB_ACCESSOR_FLAG_TRANSIENT (1 << 13) -#define GRIB_ACCESSOR_FLAG_STRING_TYPE (1 << 14) -#define GRIB_ACCESSOR_FLAG_LONG_TYPE (1 << 15) -#define GRIB_ACCESSOR_FLAG_DOUBLE_TYPE (1 << 16) -#define GRIB_ACCESSOR_FLAG_LOWERCASE (1 << 17) -#define GRIB_ACCESSOR_FLAG_BUFR_COORD (1 << 18) +#define GRIB_ACCESSOR_FLAG_READ_ONLY (1 << 1) +#define GRIB_ACCESSOR_FLAG_DUMP (1 << 2) +#define GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC (1 << 3) +#define GRIB_ACCESSOR_FLAG_CAN_BE_MISSING (1 << 4) +#define GRIB_ACCESSOR_FLAG_HIDDEN (1 << 5) +#define GRIB_ACCESSOR_FLAG_CONSTRAINT (1 << 6) +#define GRIB_ACCESSOR_FLAG_BUFR_DATA (1 << 7) +#define GRIB_ACCESSOR_FLAG_NO_COPY (1 << 8) +#define GRIB_ACCESSOR_FLAG_COPY_OK (1 << 9) +#define GRIB_ACCESSOR_FLAG_FUNCTION (1 << 10) +#define GRIB_ACCESSOR_FLAG_DATA (1 << 11) +#define GRIB_ACCESSOR_FLAG_NO_FAIL (1 << 12) +#define GRIB_ACCESSOR_FLAG_TRANSIENT (1 << 13) +#define GRIB_ACCESSOR_FLAG_STRING_TYPE (1 << 14) +#define GRIB_ACCESSOR_FLAG_LONG_TYPE (1 << 15) +#define GRIB_ACCESSOR_FLAG_DOUBLE_TYPE (1 << 16) +#define GRIB_ACCESSOR_FLAG_LOWERCASE (1 << 17) +#define GRIB_ACCESSOR_FLAG_BUFR_COORD (1 << 18) #define GRIB_ACCESSOR_FLAG_COPY_IF_CHANGING_EDITION (1 << 19) /** -* A section accessor -* Structure supporting hierarchical naming of the accessors -* @see grib_accessor -*/ + * A section accessor + * Structure supporting hierarchical naming of the accessors + * @see grib_accessor + */ struct grib_section { grib_accessor* owner; @@ -451,8 +458,9 @@ namespace eccodes::geo_nearest { class Nearest; } -typedef struct grib_nearest { - eccodes::geo_nearest::Nearest* nearest; +typedef struct grib_nearest +{ + eccodes::geo_nearest::Nearest* nearest; } grib_nearest; /* --------------- */ @@ -583,15 +591,15 @@ struct grib_viarray }; /* types of BUFR descriptors used in bufr_descriptor->type*/ -#define BUFR_DESCRIPTOR_TYPE_UNKNOWN 0 -#define BUFR_DESCRIPTOR_TYPE_STRING 1 -#define BUFR_DESCRIPTOR_TYPE_DOUBLE 2 -#define BUFR_DESCRIPTOR_TYPE_LONG 3 -#define BUFR_DESCRIPTOR_TYPE_TABLE 4 -#define BUFR_DESCRIPTOR_TYPE_FLAG 5 +#define BUFR_DESCRIPTOR_TYPE_UNKNOWN 0 +#define BUFR_DESCRIPTOR_TYPE_STRING 1 +#define BUFR_DESCRIPTOR_TYPE_DOUBLE 2 +#define BUFR_DESCRIPTOR_TYPE_LONG 3 +#define BUFR_DESCRIPTOR_TYPE_TABLE 4 +#define BUFR_DESCRIPTOR_TYPE_FLAG 5 #define BUFR_DESCRIPTOR_TYPE_REPLICATION 6 -#define BUFR_DESCRIPTOR_TYPE_OPERATOR 7 -#define BUFR_DESCRIPTOR_TYPE_SEQUENCE 8 +#define BUFR_DESCRIPTOR_TYPE_OPERATOR 7 +#define BUFR_DESCRIPTOR_TYPE_SEQUENCE 8 struct bufr_descriptor { @@ -649,7 +657,7 @@ struct codes_condition void codes_assertion_failed(const char* message, const char* file, int line); -#define MAX_SET_VALUES 10 +#define MAX_SET_VALUES 10 #define MAX_ACCESSOR_CACHE 100 struct grib_handle @@ -826,53 +834,54 @@ struct grib_context /* expression*/ -typedef int (*expression_evaluate_long_proc)(grib_expression*, grib_handle*, long*); -typedef int (*expression_evaluate_double_proc)(grib_expression*, grib_handle*, double*); -typedef const char* (*expression_evaluate_string_proc)(grib_expression*, grib_handle*, char*, size_t*, int*); -typedef const char* (*expression_get_name_proc)(grib_expression*); +// typedef int (*expression_evaluate_long_proc)(grib_expression*, grib_handle*, long*); +// typedef int (*expression_evaluate_double_proc)(grib_expression*, grib_handle*, double*); +// typedef const char* (*expression_evaluate_string_proc)(grib_expression*, grib_handle*, char*, size_t*, int*); +// typedef const char* (*expression_get_name_proc)(grib_expression*); -typedef void (*expression_print_proc)(grib_context*, grib_expression*, grib_handle*, FILE*); -typedef void (*expression_add_dependency_proc)(grib_expression* e, grib_accessor* observer); +// typedef void (*expression_print_proc)(grib_context*, grib_expression*, grib_handle*, FILE*); +// typedef void (*expression_add_dependency_proc)(grib_expression* e, grib_accessor* observer); -typedef struct grib_expression_class grib_expression_class; +// typedef struct grib_expression_class grib_expression_class; -typedef void (*expression_class_init_proc)(grib_expression_class* e); -typedef void (*expression_init_proc)(grib_expression* e); -typedef void (*expression_destroy_proc)(grib_context*, grib_expression* e); +// typedef void (*expression_class_init_proc)(grib_expression_class* e); +// typedef void (*expression_init_proc)(grib_expression* e); +// typedef void (*expression_destroy_proc)(grib_context*, grib_expression* e); -typedef int (*expression_native_type_proc)(grib_expression*, grib_handle*); - -struct grib_expression -{ - grib_expression_class* cclass; -}; - -struct grib_expression_class -{ - grib_expression_class** super; - const char* name; - size_t size; - int inited; - expression_init_proc init; - expression_destroy_proc destroy; - expression_print_proc print; - expression_add_dependency_proc add_dependency; - expression_native_type_proc native_type; - expression_get_name_proc get_name; - expression_evaluate_long_proc evaluate_long; - expression_evaluate_double_proc evaluate_double; - expression_evaluate_string_proc evaluate_string; -}; - -struct grib_arguments -{ - struct grib_arguments* next; - grib_expression* expression; -}; +// typedef int (*expression_native_type_proc)(grib_expression*, grib_handle*); -long grib_expression_evaluate(grib_handle*, grib_expression*); -void grib_expression_free(grib_context*, grib_expression*); +// struct grib_expression +//{ +// grib_expression_class* cclass; +// }; + +// struct grib_expression_class +//{ +// grib_expression_class** super; +// const char* name; +// size_t size; +// int inited; +// expression_init_proc init; +// expression_destroy_proc destroy; +// expression_print_proc print; +// expression_add_dependency_proc add_dependency; +// expression_native_type_proc native_type; +// expression_get_name_proc get_name; +// expression_evaluate_long_proc evaluate_long; +// expression_evaluate_double_proc evaluate_double; +// expression_evaluate_string_proc evaluate_string; +// }; + +// struct grib_arguments +//{ +// struct grib_arguments* next; +// grib_expression* expression; +// }; + + +// long grib_expression_evaluate(grib_handle*, grib_expression*); +// void grib_expression_free(grib_context*, grib_expression*); grib_arguments* grib_arguments_new(grib_context*, grib_expression*, grib_arguments*); void grib_arguments_free(grib_context*, grib_arguments*); @@ -1223,10 +1232,12 @@ typedef struct j2k_encode_helper #include "eccodes_prototypes.h" #ifdef __cplusplus } -#include "accessor/grib_accessor.h" -#include "accessor/grib_accessors_list.h" -#include "geo_iterator/grib_iterator.h" -#include "geo_nearest/grib_nearest.h" + #include "accessor/grib_accessor.h" + #include "accessor/grib_accessors_list.h" + #include "geo_iterator/grib_iterator.h" + #include "geo_nearest/grib_nearest.h" + #include "expression/grib_expression.h" + #include "expression/grib_arguments.h" #endif #endif diff --git a/src/grib_concept.cc b/src/grib_concept.cc index bcadeb1b5..424a043e4 100644 --- a/src/grib_concept.cc +++ b/src/grib_concept.cc @@ -41,7 +41,7 @@ grib_concept_condition* grib_concept_condition_new(grib_context* c, const char* void grib_concept_condition_delete(grib_context* c, grib_concept_condition* v) { - grib_expression_free(c, v->expression); + v->expression->destroy(c); grib_context_free_persistent(c, v->name); grib_context_free_persistent(c, v); } diff --git a/src/grib_dependency.cc b/src/grib_dependency.cc index 268ffa315..309c7677b 100644 --- a/src/grib_dependency.cc +++ b/src/grib_dependency.cc @@ -178,13 +178,13 @@ void grib_dependency_remove_observer(grib_accessor* observer) void grib_dependency_observe_expression(grib_accessor* observer, grib_expression* e) { - grib_expression_add_dependency(e, observer); + e->add_dependency(observer); } void grib_dependency_observe_arguments(grib_accessor* observer, grib_arguments* a) { while (a) { - grib_dependency_observe_expression(observer, a->expression); - a = a->next; + grib_dependency_observe_expression(observer, a->expression_); + a = a->next_; } } diff --git a/src/grib_dumper_class_debug.cc b/src/grib_dumper_class_debug.cc index 3bfd48217..40574e4f2 100644 --- a/src/grib_dumper_class_debug.cc +++ b/src/grib_dumper_class_debug.cc @@ -109,14 +109,14 @@ static void default_long_value(grib_dumper* d, grib_accessor* a, long actualValu return; grib_handle* h = grib_handle_of_accessor(a); - grib_expression* expression = grib_arguments_get_expression(h, act->default_value, 0); + grib_expression* expression = act->default_value->get_expression(h, 0); if (!expression) return; - const int type = grib_expression_native_type(h, expression); + const int type = expression->native_type(h); if (type == GRIB_TYPE_LONG) { long defaultValue = 0; - if (grib_expression_evaluate_long(h, expression, &defaultValue) == GRIB_SUCCESS && defaultValue != actualValue) { + if (expression->evaluate_long(h, &defaultValue) == GRIB_SUCCESS && defaultValue != actualValue) { if (defaultValue == GRIB_MISSING_LONG) fprintf(self->dumper.out, " (default=MISSING)"); else diff --git a/src/grib_expression.cc b/src/grib_expression.cc deleted file mode 100644 index 314e5ad8d..000000000 --- a/src/grib_expression.cc +++ /dev/null @@ -1,260 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -int grib_expression_native_type(grib_handle* h, grib_expression* g) -{ - grib_expression_class* c = g->cclass; - while (c) { - if (c->native_type) - return c->native_type(g, h); - c = c->super ? *(c->super) : NULL; - } - if (g->cclass) - grib_context_log(h->context, GRIB_LOG_FATAL, "%s: No native_type() in %s", __func__, g->cclass->name); - return 0; -} - -int grib_expression_evaluate_long(grib_handle* h, grib_expression* g, long* result) -{ - grib_expression_class* c = g->cclass; - while (c) { - if (c->evaluate_long) - return c->evaluate_long(g, h, result); - c = c->super ? *(c->super) : NULL; - } - return GRIB_INVALID_TYPE; -} - -int grib_expression_evaluate_double(grib_handle* h, grib_expression* g, double* result) -{ - grib_expression_class* c = g->cclass; - while (c) { - if (c->evaluate_double) - return c->evaluate_double(g, h, result); - c = c->super ? *(c->super) : NULL; - } - return GRIB_INVALID_TYPE; -} - -const char* grib_expression_evaluate_string(grib_handle* h, grib_expression* g, char* buf, size_t* size, int* err) -{ - grib_expression_class* c = g->cclass; - while (c) { - if (c->evaluate_string) - return c->evaluate_string(g, h, buf, size, err); - c = c->super ? *(c->super) : NULL; - } - if (g->cclass) - grib_context_log(h->context, GRIB_LOG_ERROR, "%s: No evaluate_string() in %s", __func__, g->cclass->name); - *err = GRIB_INVALID_TYPE; - - return 0; -} - -const char* grib_expression_get_name(grib_expression* g) -{ - grib_expression_class* c = g->cclass; - while (c) { - if (c->get_name) - return c->get_name(g); - c = c->super ? *(c->super) : NULL; - } - if (g->cclass) { - grib_context_log(grib_context_get_default(), GRIB_LOG_FATAL, "%s: No get_name() in %s", __func__, g->cclass->name); - } - return 0; -} - -void grib_expression_print(grib_context* ctx, grib_expression* g, grib_handle* f, FILE* out) -{ - grib_expression_class* c = g->cclass; - while (c) { - if (c->print) { - c->print(ctx, g, f, out); - return; - } - c = c->super ? *(c->super) : NULL; - } -} - -void grib_expression_free(grib_context* ctx, grib_expression* g) -{ - if (g) { - grib_expression_class* c = g->cclass; - while (c) { - if (c->destroy) - c->destroy(ctx, g); - c = c->super ? *(c->super) : NULL; - } - grib_context_free_persistent(ctx, g); - } -} - -void grib_expression_add_dependency(grib_expression* e, grib_accessor* observer) -{ - grib_expression_class* c = e->cclass; - while (c) { - if (c->add_dependency) { - c->add_dependency(e, observer); - return; - } - c = c->super ? *(c->super) : NULL; - } -} - -// int grib_expression_set_value(grib_handle* h, grib_expression* g, grib_values* v) -// { -// char buffer[1024]; -// int ret = 0; -// size_t size = sizeof(buffer); -// switch (v->type = grib_expression_native_type(h, g)) { -// case GRIB_TYPE_LONG: -// return grib_expression_evaluate_long(h, g, &v->long_value); -// break; -// case GRIB_TYPE_DOUBLE: -// return grib_expression_evaluate_double(h, g, &v->double_value); -// break; -// case GRIB_TYPE_STRING: -// v->string_value = grib_expression_evaluate_string(h, g, buffer, &size, &ret); -// if (ret != GRIB_SUCCESS) { -// grib_context_log(h->context, GRIB_LOG_ERROR, -// "grib_expression_set_value: unable to evaluate %s as string", -// grib_expression_get_name(g)); -// return ret; -// } -// Assert(v->string_value != buffer); -// Assert(v->string_value); -// break; -// default: -// Assert(!"grib_expression_set_value"); -// break; -// } -// return 0; -// } - -/*----------------------------------------*/ -grib_arguments* grib_arguments_new(grib_context* c, grib_expression* g, grib_arguments* n) -{ - grib_arguments* l = (grib_arguments*)grib_context_malloc_clear_persistent(c, sizeof(grib_arguments)); - l->expression = g; - l->next = n; - return l; -} - -void grib_arguments_free(grib_context* c, grib_arguments* g) -{ - if (g) { - grib_arguments_free(c, g->next); - grib_expression_free(c, g->expression); - grib_context_free_persistent(c, g); - } -} - -void grib_arguments_print(grib_context* c, grib_arguments* g, grib_handle* f) -{ - if (g) { - if (g->expression) - grib_expression_print(c, g->expression, f, stdout); - if (g->next) { - printf(","); - grib_arguments_print(c, g->next, f); - } - } -} - -const char* grib_arguments_get_name(grib_handle* h, grib_arguments* args, int n) -{ - grib_expression* e = NULL; - while (args && n-- > 0) { - args = args->next; - } - - if (!args) - return NULL; - - e = args->expression; - return e ? grib_expression_get_name(e) : NULL; -} - -const char* grib_arguments_get_string(grib_handle* h, grib_arguments* args, int n) -{ - grib_expression* e = NULL; - int ret = 0; - while (args && n-- > 0) { - args = args->next; - } - - if (!args) - return NULL; - - e = args->expression; - return grib_expression_evaluate_string(h, e, NULL, NULL, &ret); -} - -long grib_arguments_get_long(grib_handle* h, grib_arguments* args, int n) -{ - int ret = 0; - long lres = 0; - grib_expression* e = NULL; - while (args && n-- > 0) { - args = args->next; - } - - if (!args) - return 0; - - e = args->expression; - ret = grib_expression_evaluate_long(h, e, &lres); - (void)ret; - return lres; -} - -double grib_arguments_get_double(grib_handle* h, grib_arguments* args, int n) -{ - int ret = 0; - double dres = 0.0; - - grib_expression* e = NULL; - while (args && n-- > 0) { - args = args->next; - } - - if (!args) - return 0; - - e = args->expression; - ret = grib_expression_evaluate_double(h, e, &dres); - (void)ret; - return dres; -} - -grib_expression* grib_arguments_get_expression(grib_handle* h, grib_arguments* args, int n) -{ - while (args && n-- > 0) { - args = args->next; - } - - if (!args) - return 0; - - return args->expression; -} - -int grib_arguments_get_count(grib_arguments* args) -{ - int n = 0; - while (args) { - args = args->next; - n++; - } - return n; -} diff --git a/src/grib_expression_class.h b/src/grib_expression_class.h deleted file mode 100644 index 8660a7864..000000000 --- a/src/grib_expression_class.h +++ /dev/null @@ -1,17 +0,0 @@ -/* This file is automatically generated by ./make_class.pl, do not edit */ -extern grib_expression_class* grib_expression_class_accessor; -extern grib_expression_class* grib_expression_class_binop; -extern grib_expression_class* grib_expression_class_double; -extern grib_expression_class* grib_expression_class_functor; -extern grib_expression_class* grib_expression_class_is_in_dict; -extern grib_expression_class* grib_expression_class_is_in_list; -extern grib_expression_class* grib_expression_class_is_integer; -extern grib_expression_class* grib_expression_class_length; -extern grib_expression_class* grib_expression_class_logical_and; -extern grib_expression_class* grib_expression_class_logical_or; -extern grib_expression_class* grib_expression_class_long; -extern grib_expression_class* grib_expression_class_string; -extern grib_expression_class* grib_expression_class_string_compare; -extern grib_expression_class* grib_expression_class_sub_string; -extern grib_expression_class* grib_expression_class_true; -extern grib_expression_class* grib_expression_class_unop; diff --git a/src/grib_expression_class_accessor.cc b/src/grib_expression_class_accessor.cc deleted file mode 100644 index 71bc70526..000000000 --- a/src/grib_expression_class_accessor.cc +++ /dev/null @@ -1,194 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = expression - IMPLEMENTS = destroy - IMPLEMENTS = native_type - IMPLEMENTS = get_name - IMPLEMENTS = evaluate_long - IMPLEMENTS = evaluate_double - IMPLEMENTS = evaluate_string - IMPLEMENTS = print - IMPLEMENTS = add_dependency - MEMBERS = char *name - MEMBERS = long start - MEMBERS = size_t length - END_CLASS_DEF - - */ -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "expression.class" and rerun ./make_class.pl - -*/ - -typedef const char* string; /* to keep make_class.pl happy */ - -static void destroy(grib_context*,grib_expression* e); -static void print(grib_context*, grib_expression*, grib_handle*, FILE*); -static void add_dependency(grib_expression* e, grib_accessor* observer); -static string get_name(grib_expression* e); -static int native_type(grib_expression*,grib_handle*); -static int evaluate_long(grib_expression*,grib_handle*,long*); -static int evaluate_double(grib_expression*,grib_handle*,double*); -static string evaluate_string(grib_expression*,grib_handle*,char*,size_t*,int*); - -typedef struct grib_expression_accessor{ - grib_expression base; - /* Members defined in accessor */ - char *name; - long start; - size_t length; -} grib_expression_accessor; - - -static grib_expression_class _grib_expression_class_accessor = { - 0, /* super */ - "accessor", /* name */ - sizeof(grib_expression_accessor),/* size of instance */ - 0, /* inited */ - 0, /* constructor */ - &destroy, /* destructor */ - &print, - &add_dependency, - &native_type, - &get_name, - &evaluate_long, - &evaluate_double, - &evaluate_string, -}; - -grib_expression_class* grib_expression_class_accessor = &_grib_expression_class_accessor; - -/* END_CLASS_IMP */ - -static const char* get_name(grib_expression* g) -{ - const grib_expression_accessor* e = (grib_expression_accessor*)g; - return e->name; -} - -static int evaluate_long(grib_expression* g, grib_handle* h, long* result) -{ - const grib_expression_accessor* e = (grib_expression_accessor*)g; - return grib_get_long_internal(h, e->name, result); -} - -static int evaluate_double(grib_expression* g, grib_handle* h, double* result) -{ - const grib_expression_accessor* e = (grib_expression_accessor*)g; - return grib_get_double_internal(h, e->name, result); -} - -static string evaluate_string(grib_expression* g, grib_handle* h, char* buf, size_t* size, int* err) -{ - const grib_expression_accessor* e = (grib_expression_accessor*)g; - char mybuf[1024] = {0,}; - long start = e->start; - if (e->length > sizeof(mybuf)) { - *err = GRIB_INVALID_ARGUMENT; - return NULL; - } - - Assert(buf); - if ((*err = grib_get_string_internal(h, e->name, mybuf, size)) != GRIB_SUCCESS) - return NULL; - - if (e->start < 0) - start += *size; - - if (e->length != 0) { - if (start >= 0) - memcpy(buf, mybuf + start, e->length); - buf[e->length] = 0; - } - else { - memcpy(buf, mybuf, *size); - if (*size == 1024) - *size = *size - 1; /* ECC-336 */ - buf[*size] = 0; - } - return buf; -} - -static void print(grib_context* c, grib_expression* g, grib_handle* hand, FILE* out) -{ - const grib_expression_accessor* e = (grib_expression_accessor*)g; - int err = 0; - fprintf(out, "access('%s", e->name); - if (hand) { - const int ntype = native_type(g, hand); - if (ntype == GRIB_TYPE_STRING) { - char buf[256] = {0,}; - size_t len = sizeof(buf); - err = grib_get_string(hand, e->name, buf, &len); - if (!err) fprintf(out, "=%s", buf); - } - else if (ntype == GRIB_TYPE_LONG) { - long lVal = 0; - err = grib_get_long(hand, e->name, &lVal); - if (!err) fprintf(out, "=%ld", lVal); - } - } - fprintf(out, "')"); -} - -static void destroy(grib_context* c, grib_expression* g) -{ - grib_expression_accessor* e = (grib_expression_accessor*)g; - grib_context_free_persistent(c, e->name); -} - -static void add_dependency(grib_expression* g, grib_accessor* observer) -{ - const grib_expression_accessor* e = (grib_expression_accessor*)g; - grib_accessor* observed = grib_find_accessor(grib_handle_of_accessor(observer), e->name); - - if (!observed) { - /* grib_context_log(observer->context, GRIB_LOG_ERROR, */ - /* "Error in accessor_add_dependency: cannot find [%s]", e->name); */ - /* Assert(observed); */ - return; - } - - grib_dependency_add(observer, observed); -} - -grib_expression* new_accessor_expression(grib_context* c, const char* name, long start, size_t length) -{ - grib_expression_accessor* e = (grib_expression_accessor*)grib_context_malloc_clear_persistent(c, sizeof(grib_expression_accessor)); - e->base.cclass = grib_expression_class_accessor; - e->name = grib_context_strdup_persistent(c, name); - e->start = start; - e->length = length; - return (grib_expression*)e; -} - -static int native_type(grib_expression* g, grib_handle* h) -{ - grib_expression_accessor* e = (grib_expression_accessor*)g; - int type = 0; - int err; - if ((err = grib_get_native_type(h, e->name, &type)) != GRIB_SUCCESS) { - grib_context_log(h->context, GRIB_LOG_ERROR, - "Error in evaluating the type of '%s': %s", e->name, grib_get_error_message(err)); - } - return type; -} diff --git a/src/grib_expression_class_binop.cc b/src/grib_expression_class_binop.cc deleted file mode 100644 index 60547ec2f..000000000 --- a/src/grib_expression_class_binop.cc +++ /dev/null @@ -1,206 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = expression - IMPLEMENTS = destroy - IMPLEMENTS = native_type - IMPLEMENTS = evaluate_long - IMPLEMENTS = evaluate_double - IMPLEMENTS = print - IMPLEMENTS = add_dependency - MEMBERS = grib_expression *left - MEMBERS = grib_expression *right - MEMBERS = grib_binop_long_proc long_func - MEMBERS = grib_binop_double_proc double_func - MEMBERS = grib_binop_string_proc string_func - END_CLASS_DEF - - */ -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "expression.class" and rerun ./make_class.pl - -*/ - -typedef const char* string; /* to keep make_class.pl happy */ - -static void destroy(grib_context*,grib_expression* e); -static void print(grib_context*, grib_expression*, grib_handle*, FILE*); -static void add_dependency(grib_expression* e, grib_accessor* observer); -static int native_type(grib_expression*,grib_handle*); -static int evaluate_long(grib_expression*,grib_handle*,long*); -static int evaluate_double(grib_expression*,grib_handle*,double*); - -typedef struct grib_expression_binop{ - grib_expression base; - /* Members defined in binop */ - grib_expression *left; - grib_expression *right; - grib_binop_long_proc long_func; - grib_binop_double_proc double_func; - grib_binop_string_proc string_func; -} grib_expression_binop; - - -static grib_expression_class _grib_expression_class_binop = { - 0, /* super */ - "binop", /* name */ - sizeof(grib_expression_binop),/* size of instance */ - 0, /* inited */ - 0, /* constructor */ - &destroy, /* destructor */ - &print, - &add_dependency, - &native_type, - 0, - &evaluate_long, - &evaluate_double, - 0, -}; - -grib_expression_class* grib_expression_class_binop = &_grib_expression_class_binop; - -/* END_CLASS_IMP */ - -static int evaluate_long(grib_expression* g, grib_handle* h, long* lres) -{ - long v1 = 0; - long v2 = 0; - grib_expression_binop* e = (grib_expression_binop*)g; - -// { -// int typeLeft, typeRight; -// const char* nameLeft; -// const char* nameRight; -// typeLeft = grib_expression_native_type(h, e->left); -// typeRight = grib_expression_native_type(h, e->right); -// nameLeft = grib_expression_get_name(e->left); -// nameRight= grib_expression_get_name(e->right); -// printf("eval_long nameLeft=%s (type=%d), nameRight=%s (type=%d)\n",nameLeft,typeLeft, nameRight,typeRight); -// grib_expression_print(h->context, g, h); -// printf("\n"); -// } - - int ret = grib_expression_evaluate_long(h, e->left, &v1); - if (ret != GRIB_SUCCESS) - return ret; - - ret = grib_expression_evaluate_long(h, e->right, &v2); - if (ret != GRIB_SUCCESS) - return ret; - - *lres = e->long_func(v1, v2); - return GRIB_SUCCESS; -} - -static int evaluate_double(grib_expression* g, grib_handle* h, double* dres) -{ - double v1 = 0.0; - double v2 = 0.0; - grib_expression_binop* e = (grib_expression_binop*)g; - -// { -// int typeLeft, typeRight; -// const char* nameLeft; -// const char* nameRight; -// typeLeft = grib_expression_native_type(h, e->left); -// typeRight = grib_expression_native_type(h, e->right); -// nameLeft = grib_expression_get_name(e->left); -// nameRight= grib_expression_get_name(e->right); -// printf("eval_dbl nameLeft=%s (type=%d), nameRight=%s (type=%d)\n",nameLeft,typeLeft, nameRight,typeRight); -// grib_expression_print(h->context, g, h); -// printf("\n"); -// } - - int ret = grib_expression_evaluate_double(h, e->left, &v1); - if (ret != GRIB_SUCCESS) - return ret; - - ret = grib_expression_evaluate_double(h, e->right, &v2); - if (ret != GRIB_SUCCESS) - return ret; - - *dres = e->double_func ? e->double_func(v1, v2) : e->long_func(v1, v2); - - return GRIB_SUCCESS; -} - -static void print(grib_context* c, grib_expression* g, grib_handle* f, FILE* out) -{ - grib_expression_binop* e = (grib_expression_binop*)g; - - // Cover a subset of the most commonly used functions - // TODO(masn): Can be done in a much better way! - // e.g., the yacc parser passing in the functions name - if (e->long_func && e->long_func == grib_op_eq) { - fprintf(out, "equals("); - } else if (e->long_func && e->long_func == grib_op_ne) { - fprintf(out, "not_equals("); - } else if (e->long_func && e->long_func == grib_op_lt) { - fprintf(out, "less_than("); - } else if (e->long_func && e->long_func == grib_op_gt) { - fprintf(out, "greater_than("); - } else { - fprintf(out, "binop("); - } - grib_expression_print(c, e->left, f, out); - fprintf(out, ","); - grib_expression_print(c, e->right, f, out); - fprintf(out, ")"); -} - -static void destroy(grib_context* c, grib_expression* g) -{ - grib_expression_binop* e = (grib_expression_binop*)g; - grib_expression_free(c, e->left); - grib_expression_free(c, e->right); -} - -static void add_dependency(grib_expression* g, grib_accessor* observer) -{ - grib_expression_binop* e = (grib_expression_binop*)g; - grib_dependency_observe_expression(observer, e->left); - grib_dependency_observe_expression(observer, e->right); -} - -grib_expression* new_binop_expression(grib_context* c, - grib_binop_long_proc long_func, - grib_binop_double_proc double_func, - grib_expression* left, grib_expression* right) -{ - grib_expression_binop* e = (grib_expression_binop*)grib_context_malloc_clear_persistent(c, sizeof(grib_expression_binop)); - e->base.cclass = grib_expression_class_binop; - e->left = left; - e->right = right; - e->long_func = long_func; - e->double_func = double_func; - return (grib_expression*)e; -} - -static int native_type(grib_expression* g, grib_handle* h) -{ - grib_expression_binop* e = (grib_expression_binop*)g; - /* See GRIB-394 : The type of this binary expression will be double if any of its operands are double */ - if (grib_expression_native_type(h, e->left) == GRIB_TYPE_DOUBLE || - grib_expression_native_type(h, e->right) == GRIB_TYPE_DOUBLE) { - return GRIB_TYPE_DOUBLE; - } - return e->long_func ? GRIB_TYPE_LONG : GRIB_TYPE_DOUBLE; -} diff --git a/src/grib_expression_class_double.cc b/src/grib_expression_class_double.cc deleted file mode 100644 index 14e38e973..000000000 --- a/src/grib_expression_class_double.cc +++ /dev/null @@ -1,115 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = expression - IMPLEMENTS = destroy - IMPLEMENTS = native_type - IMPLEMENTS = evaluate_long - IMPLEMENTS = evaluate_double - IMPLEMENTS = print - IMPLEMENTS = add_dependency - MEMBERS = double value - END_CLASS_DEF - - */ -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "expression.class" and rerun ./make_class.pl - -*/ - -typedef const char* string; /* to keep make_class.pl happy */ - -static void destroy(grib_context*,grib_expression* e); -static void print(grib_context*, grib_expression*, grib_handle*, FILE*); -static void add_dependency(grib_expression* e, grib_accessor* observer); -static int native_type(grib_expression*,grib_handle*); -static int evaluate_long(grib_expression*,grib_handle*,long*); -static int evaluate_double(grib_expression*,grib_handle*,double*); - -typedef struct grib_expression_double{ - grib_expression base; - /* Members defined in double */ - double value; -} grib_expression_double; - - -static grib_expression_class _grib_expression_class_double = { - 0, /* super */ - "double", /* name */ - sizeof(grib_expression_double),/* size of instance */ - 0, /* inited */ - 0, /* constructor */ - &destroy, /* destructor */ - &print, - &add_dependency, - &native_type, - 0, - &evaluate_long, - &evaluate_double, - 0, -}; - -grib_expression_class* grib_expression_class_double = &_grib_expression_class_double; - -/* END_CLASS_IMP */ - -static int evaluate_long(grib_expression* g, grib_handle* h, long* lres) -{ - const grib_expression_double* e = (grib_expression_double*)g; - *lres = e->value; - return GRIB_SUCCESS; -} - -static int evaluate_double(grib_expression* g, grib_handle* h, double* dres) -{ - const grib_expression_double* e = (grib_expression_double*)g; - *dres = e->value; - return GRIB_SUCCESS; -} - -static void print(grib_context* c, grib_expression* g, grib_handle* f, FILE* out) -{ - const grib_expression_double* e = (grib_expression_double*)g; - fprintf(out, "double(%g)", e->value); -} - -static void destroy(grib_context* c, grib_expression* g) -{ - /* grib_expression_double* e = (grib_expression_double*)g; */ -} - -static void add_dependency(grib_expression* g, grib_accessor* observer) -{ - /* grib_expression_double* e = (grib_expression_double*)g; */ -} - -grib_expression* new_double_expression(grib_context* c, double value) -{ - grib_expression_double* e = (grib_expression_double*)grib_context_malloc_clear_persistent(c, sizeof(grib_expression_double)); - e->base.cclass = grib_expression_class_double; - e->value = value; - return (grib_expression*)e; -} - -static int native_type(grib_expression* g, grib_handle* h) -{ - return GRIB_TYPE_DOUBLE; -} diff --git a/src/grib_expression_class_is_in_dict.cc b/src/grib_expression_class_is_in_dict.cc deleted file mode 100644 index 8d86c24bf..000000000 --- a/src/grib_expression_class_is_in_dict.cc +++ /dev/null @@ -1,242 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = expression - IMPLEMENTS = native_type - IMPLEMENTS = add_dependency - IMPLEMENTS = get_name - IMPLEMENTS = evaluate_long - IMPLEMENTS = evaluate_double - IMPLEMENTS = evaluate_string - IMPLEMENTS = print - MEMBERS = const char *key - MEMBERS = const char *dictionary - END_CLASS_DEF - - */ -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "expression.class" and rerun ./make_class.pl - -*/ - -typedef const char* string; /* to keep make_class.pl happy */ - -static void print(grib_context*, grib_expression*, grib_handle*, FILE*); -static void add_dependency(grib_expression* e, grib_accessor* observer); -static string get_name(grib_expression* e); -static int native_type(grib_expression*,grib_handle*); -static int evaluate_long(grib_expression*,grib_handle*,long*); -static int evaluate_double(grib_expression*,grib_handle*,double*); -static string evaluate_string(grib_expression*,grib_handle*,char*,size_t*,int*); - -typedef struct grib_expression_is_in_dict{ - grib_expression base; - /* Members defined in is_in_dict */ - const char *key; - const char *dictionary; -} grib_expression_is_in_dict; - - -static grib_expression_class _grib_expression_class_is_in_dict = { - 0, /* super */ - "is_in_dict", /* name */ - sizeof(grib_expression_is_in_dict),/* size of instance */ - 0, /* inited */ - 0, /* constructor */ - 0, /* destructor */ - &print, - &add_dependency, - &native_type, - &get_name, - &evaluate_long, - &evaluate_double, - &evaluate_string, -}; - -grib_expression_class* grib_expression_class_is_in_dict = &_grib_expression_class_is_in_dict; - -/* END_CLASS_IMP */ - - -static grib_trie* load_dictionary(grib_context* c, grib_expression* e, int* err) -{ - grib_expression_is_in_dict* self = (grib_expression_is_in_dict*)e; - - char* filename = NULL; - char line[1024] = {0,}; - char key[1024] = {0,}; - char* list = 0; - grib_trie* dictionary = NULL; - FILE* f = NULL; - int i = 0; - - *err = GRIB_SUCCESS; - - filename = grib_context_full_defs_path(c, self->dictionary); - if (!filename) { - grib_context_log(c, GRIB_LOG_ERROR, "unable to find def file %s", self->dictionary); - *err = GRIB_FILE_NOT_FOUND; - return NULL; - } - else { - grib_context_log(c, GRIB_LOG_DEBUG, "is_in_dict: found def file %s", filename); - } - dictionary = (grib_trie*)grib_trie_get(c->lists, filename); - if (dictionary) { - grib_context_log(c, GRIB_LOG_DEBUG, "using dictionary %s from cache", self->dictionary); - return dictionary; - } - else { - grib_context_log(c, GRIB_LOG_DEBUG, "using dictionary %s from file %s", self->dictionary, filename); - } - - f = codes_fopen(filename, "r"); - if (!f) { - *err = GRIB_IO_PROBLEM; - return NULL; - } - - dictionary = grib_trie_new(c); - - while (fgets(line, sizeof(line) - 1, f)) { - i = 0; - while (line[i] != '|' && line[i] != 0) { - key[i] = line[i]; - i++; - } - key[i] = 0; - list = (char*)grib_context_malloc_clear(c, strlen(line) + 1); - memcpy(list, line, strlen(line)); - grib_trie_insert(dictionary, key, list); - } - - grib_trie_insert(c->lists, filename, dictionary); - - fclose(f); - - return dictionary; -} - -static const char* get_name(grib_expression* g) -{ - const grib_expression_is_in_dict* e = (grib_expression_is_in_dict*)g; - return e->key; -} - -static int evaluate_long(grib_expression* g, grib_handle* h, long* result) -{ - const grib_expression_is_in_dict* e = (grib_expression_is_in_dict*)g; - int err = 0; - char mybuf[1024] = {0,}; - size_t size = 1024; - - grib_trie* dict = load_dictionary(h->context, g, &err); - - if ((err = grib_get_string_internal(h, e->key, mybuf, &size)) != GRIB_SUCCESS) - return err; - - if (grib_trie_get(dict, mybuf)) - *result = 1; - else - *result = 0; - - return err; -} - -static int evaluate_double(grib_expression* g, grib_handle* h, double* result) -{ - return GRIB_NOT_IMPLEMENTED; - - // grib_expression_is_in_dict* e = (grib_expression_is_in_dict*)g; - // int err = 0; - // char mybuf[1024] = {0,}; - // size_t size = 1024; - // grib_trie* list = load_dictionary(h->context, g, &err); - // if ((err = grib_get_string_internal(h, e->key, mybuf, &size)) != GRIB_SUCCESS) - // return err; - // if (grib_trie_get(list, mybuf)) - // *result = 1; - // else - // *result = 0; - // return err; -} - -static string evaluate_string(grib_expression* g, grib_handle* h, char* buf, size_t* size, int* err) -{ - *err = GRIB_NOT_IMPLEMENTED; - return NULL; - - // grib_expression_is_in_dict* e = (grib_expression_is_in_dict*)g; - // char mybuf[1024] = {0,}; - // size_t sizebuf = 1024; - // long result; - // grib_trie* list = load_dictionary(h->context, g, err); - // if ((*err = grib_get_string_internal(h, e->key, mybuf, &sizebuf)) != GRIB_SUCCESS) - // return NULL; - // if (grib_trie_get(list, mybuf)) - // result = 1; - // else - // result = 0; - // snprintf(buf, 32, "%ld", result); - // *size = strlen(buf); - // return buf; -} - -static void print(grib_context* c, grib_expression* g, grib_handle* f, FILE* out) -{ - const grib_expression_is_in_dict* e = (grib_expression_is_in_dict*)g; - fprintf(out, "access('%s", e->key); - if (f) { - long s = 0; - grib_get_long(f, e->key, &s); - fprintf(out, "=%ld", s); - } - fprintf(out, "')"); -} - -grib_expression* new_is_in_dict_expression(grib_context* c, const char* name, const char* list) -{ - grib_expression_is_in_dict* e = (grib_expression_is_in_dict*)grib_context_malloc_clear_persistent(c, sizeof(grib_expression_is_in_dict)); - e->base.cclass = grib_expression_class_is_in_dict; - e->key = grib_context_strdup_persistent(c, name); - e->dictionary = grib_context_strdup_persistent(c, list); - return (grib_expression*)e; -} - -static int native_type(grib_expression* g, grib_handle* h) -{ - return GRIB_TYPE_LONG; -} - -static void add_dependency(grib_expression* g, grib_accessor* observer) -{ - const grib_expression_is_in_dict* e = (grib_expression_is_in_dict*)g; - grib_accessor* observed = grib_find_accessor(grib_handle_of_accessor(observer), e->key); - - if (!observed) { - /* grib_context_log(observer->context, GRIB_LOG_ERROR, */ - /* "Error in accessor_add_dependency: cannot find [%s]", e->name); */ - /* Assert(observed); */ - return; - } - - grib_dependency_add(observer, observed); -} diff --git a/src/grib_expression_class_is_in_list.cc b/src/grib_expression_class_is_in_list.cc deleted file mode 100644 index 953481ad0..000000000 --- a/src/grib_expression_class_is_in_list.cc +++ /dev/null @@ -1,251 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = expression - IMPLEMENTS = destroy - IMPLEMENTS = native_type - IMPLEMENTS = get_name - IMPLEMENTS = evaluate_long - IMPLEMENTS = evaluate_double - IMPLEMENTS = evaluate_string - IMPLEMENTS = print - IMPLEMENTS = add_dependency - MEMBERS = const char *name - MEMBERS = const char *list - END_CLASS_DEF - - */ -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "expression.class" and rerun ./make_class.pl - -*/ - -typedef const char* string; /* to keep make_class.pl happy */ - -static void destroy(grib_context*,grib_expression* e); -static void print(grib_context*, grib_expression*, grib_handle*, FILE*); -static void add_dependency(grib_expression* e, grib_accessor* observer); -static string get_name(grib_expression* e); -static int native_type(grib_expression*,grib_handle*); -static int evaluate_long(grib_expression*,grib_handle*,long*); -static int evaluate_double(grib_expression*,grib_handle*,double*); -static string evaluate_string(grib_expression*,grib_handle*,char*,size_t*,int*); - -typedef struct grib_expression_is_in_list{ - grib_expression base; - /* Members defined in is_in_list */ - const char *name; - const char *list; -} grib_expression_is_in_list; - - -static grib_expression_class _grib_expression_class_is_in_list = { - 0, /* super */ - "is_in_list", /* name */ - sizeof(grib_expression_is_in_list),/* size of instance */ - 0, /* inited */ - 0, /* constructor */ - &destroy, /* destructor */ - &print, - &add_dependency, - &native_type, - &get_name, - &evaluate_long, - &evaluate_double, - &evaluate_string, -}; - -grib_expression_class* grib_expression_class_is_in_list = &_grib_expression_class_is_in_list; - -/* END_CLASS_IMP */ - - -static grib_trie* load_list(grib_context* c, grib_expression* e, int* err) -{ - grib_expression_is_in_list* self = (grib_expression_is_in_list*)e; - - char* filename = NULL; - char line[1024] = {0,}; - grib_trie* list = NULL; - FILE* f = NULL; - - *err = GRIB_SUCCESS; - - filename = grib_context_full_defs_path(c, self->list); - if (!filename) { - grib_context_log(c, GRIB_LOG_ERROR, "unable to find def file %s", self->list); - *err = GRIB_FILE_NOT_FOUND; - return NULL; - } - else { - grib_context_log(c, GRIB_LOG_DEBUG, "is_in_list: found def file %s", filename); - } - list = (grib_trie*)grib_trie_get(c->lists, filename); - if (list) { - grib_context_log(c, GRIB_LOG_DEBUG, "using list %s from cache", self->list); - return list; - } - else { - grib_context_log(c, GRIB_LOG_DEBUG, "using list %s from file %s", self->list, filename); - } - - f = codes_fopen(filename, "r"); - if (!f) { - *err = GRIB_IO_PROBLEM; - return NULL; - } - - list = grib_trie_new(c); - - while (fgets(line, sizeof(line) - 1, f)) { - unsigned char* p = (unsigned char*)line; - while (*p != 0) { - if (*p < 33) { - *p = 0; - break; - } - p++; - } - grib_trie_insert(list, line, line); - } - - grib_trie_insert(c->lists, filename, list); - - fclose(f); - - return list; -} - -static const char* get_name(grib_expression* g) -{ - const grib_expression_is_in_list* e = (grib_expression_is_in_list*)g; - return e->name; -} - -static int evaluate_long(grib_expression* g, grib_handle* h, long* result) -{ - const grib_expression_is_in_list* e = (grib_expression_is_in_list*)g; - int err = 0; - char mybuf[1024] = {0,}; - size_t size = 1024; - - grib_trie* list = load_list(h->context, g, &err); - - if ((err = grib_get_string_internal(h, e->name, mybuf, &size)) != GRIB_SUCCESS) - return err; - - if (grib_trie_get(list, mybuf)) - *result = 1; - else - *result = 0; - - return err; -} - -static int evaluate_double(grib_expression* g, grib_handle* h, double* result) -{ - return GRIB_NOT_IMPLEMENTED; - // grib_expression_is_in_list* e = (grib_expression_is_in_list*)g; - // int err = 0; - // char mybuf[1024] = {0,}; - // size_t size = 1024; - // grib_trie* list = load_list(h->context, g, &err); - // if ((err = grib_get_string_internal(h, e->name, mybuf, &size)) != GRIB_SUCCESS) - // return err; - // if (grib_trie_get(list, mybuf)) - // *result = 1; - // else - // *result = 0; - // return err; -} - -static string evaluate_string(grib_expression* g, grib_handle* h, char* buf, size_t* size, int* err) -{ - const grib_expression_is_in_list* e = (grib_expression_is_in_list*)g; - char mybuf[1024] = {0,}; - size_t sizebuf = 1024; - long result; - - grib_trie* list = load_list(h->context, g, err); - - if ((*err = grib_get_string_internal(h, e->name, mybuf, &sizebuf)) != GRIB_SUCCESS) - return NULL; - - if (grib_trie_get(list, mybuf)) - result = 1; - else - result = 0; - - snprintf(buf, 32, "%ld", result); - *size = strlen(buf); - return buf; -} - -static void print(grib_context* c, grib_expression* g, grib_handle* f, FILE* out) -{ - const grib_expression_is_in_list* e = (grib_expression_is_in_list*)g; - fprintf(out, "access('%s", e->name); - if (f) { - long s = 0; - grib_get_long(f, e->name, &s); - fprintf(out, "=%ld", s); - } - fprintf(out, "')"); -} - -static void destroy(grib_context* c, grib_expression* g) -{ -} - -static void add_dependency(grib_expression* g, grib_accessor* observer) -{ - const grib_expression_is_in_list* e = (grib_expression_is_in_list*)g; - grib_accessor* observed = grib_find_accessor(grib_handle_of_accessor(observer), e->name); - - if (!observed) { - /* grib_context_log(observer->context, GRIB_LOG_ERROR, */ - /* "Error in accessor_add_dependency: cannot find [%s]", e->name); */ - /* Assert(observed); */ - return; - } - - grib_dependency_add(observer, observed); -} - -grib_expression* new_is_in_list_expression(grib_context* c, const char* name, const char* list) -{ - grib_expression_is_in_list* e = (grib_expression_is_in_list*)grib_context_malloc_clear_persistent(c, sizeof(grib_expression_is_in_list)); - e->base.cclass = grib_expression_class_is_in_list; - e->name = grib_context_strdup_persistent(c, name); - e->list = grib_context_strdup_persistent(c, list); - return (grib_expression*)e; -} - -static int native_type(grib_expression* g, grib_handle* h) -{ - grib_expression_is_in_list* e = (grib_expression_is_in_list*)g; - int type = 0; - int err; - if ((err = grib_get_native_type(h, e->name, &type)) != GRIB_SUCCESS) - grib_context_log(h->context, GRIB_LOG_ERROR, - "Error in native_type %s : %s", e->name, grib_get_error_message(err)); - return type; -} diff --git a/src/grib_expression_class_is_integer.cc b/src/grib_expression_class_is_integer.cc deleted file mode 100644 index d88756974..000000000 --- a/src/grib_expression_class_is_integer.cc +++ /dev/null @@ -1,190 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = expression - IMPLEMENTS = destroy - IMPLEMENTS = native_type - IMPLEMENTS = get_name - IMPLEMENTS = evaluate_long - IMPLEMENTS = evaluate_double - IMPLEMENTS = evaluate_string - IMPLEMENTS = print - IMPLEMENTS = add_dependency - MEMBERS = char *name - MEMBERS = size_t start - MEMBERS = size_t length - END_CLASS_DEF - - */ -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "expression.class" and rerun ./make_class.pl - -*/ - -typedef const char* string; /* to keep make_class.pl happy */ - -static void destroy(grib_context*,grib_expression* e); -static void print(grib_context*, grib_expression*, grib_handle*, FILE*); -static void add_dependency(grib_expression* e, grib_accessor* observer); -static string get_name(grib_expression* e); -static int native_type(grib_expression*,grib_handle*); -static int evaluate_long(grib_expression*,grib_handle*,long*); -static int evaluate_double(grib_expression*,grib_handle*,double*); -static string evaluate_string(grib_expression*,grib_handle*,char*,size_t*,int*); - -typedef struct grib_expression_is_integer{ - grib_expression base; - /* Members defined in is_integer */ - char *name; - size_t start; - size_t length; -} grib_expression_is_integer; - - -static grib_expression_class _grib_expression_class_is_integer = { - 0, /* super */ - "is_integer", /* name */ - sizeof(grib_expression_is_integer),/* size of instance */ - 0, /* inited */ - 0, /* constructor */ - &destroy, /* destructor */ - &print, - &add_dependency, - &native_type, - &get_name, - &evaluate_long, - &evaluate_double, - &evaluate_string, -}; - -grib_expression_class* grib_expression_class_is_integer = &_grib_expression_class_is_integer; - -/* END_CLASS_IMP */ - -static const char* get_name(grib_expression* g) -{ - const grib_expression_is_integer* e = (grib_expression_is_integer*)g; - return e->name; -} - -static int evaluate_long(grib_expression* g, grib_handle* h, long* result) -{ - grib_expression_is_integer* e = (grib_expression_is_integer*)g; - int err = 0; - char mybuf[1024] = {0,}; - size_t size = 1024; - char* p = 0; - char* start = 0; - - if ((err = grib_get_string_internal(h, e->name, mybuf, &size)) != GRIB_SUCCESS) - return err; - - start = mybuf + e->start; - - if (e->length > 0) - start[e->length] = 0; - - strtol(start, &p, 10); - - if (*p != 0) - *result = 0; - else - *result = 1; - - return err; -} - -static int evaluate_double(grib_expression* g, grib_handle* h, double* result) -{ - int err = 0; - long lresult = 0; - - err = evaluate_long(g, h, &lresult); - *result = lresult; - return err; -} - -static string evaluate_string(grib_expression* g, grib_handle* h, char* buf, size_t* size, int* err) -{ - long lresult = 0; - double dresult = 0.0; - - switch (grib_expression_native_type(h, g)) { - case GRIB_TYPE_LONG: - *err = evaluate_long(g, h, &lresult); - snprintf(buf, 32, "%ld", lresult); - break; - case GRIB_TYPE_DOUBLE: - *err = evaluate_double(g, h, &dresult); - snprintf(buf, 32, "%g", dresult); - break; - } - return buf; -} - -static void print(grib_context* c, grib_expression* g, grib_handle* f, FILE* out) -{ - // grib_expression_is_integer* e = (grib_expression_is_integer*)g; - // printf("access('%s", e->name); - // if (f) { - // long s = 0; - // grib_get_long(f, e->name, &s); - // printf("=%ld", s); - // } - // printf("')"); -} - -static void destroy(grib_context* c, grib_expression* g) -{ - grib_expression_is_integer* e = (grib_expression_is_integer*)g; - grib_context_free_persistent(c, e->name); -} - - -static void add_dependency(grib_expression* g, grib_accessor* observer) -{ - const grib_expression_is_integer* e = (grib_expression_is_integer*)g; - grib_accessor* observed = grib_find_accessor(grib_handle_of_accessor(observer), e->name); - - if (!observed) { - /* grib_context_log(observer->context, GRIB_LOG_ERROR, */ - /* "Error in accessor_add_dependency: cannot find [%s]", e->name); */ - /* Assert(observed); */ - return; - } - - grib_dependency_add(observer, observed); -} - -grib_expression* new_is_integer_expression(grib_context* c, const char* name, int start, int length) -{ - grib_expression_is_integer* e = (grib_expression_is_integer*)grib_context_malloc_clear_persistent(c, sizeof(grib_expression_is_integer)); - e->base.cclass = grib_expression_class_is_integer; - e->name = grib_context_strdup_persistent(c, name); - e->start = start; - e->length = length; - return (grib_expression*)e; -} - -static int native_type(grib_expression* g, grib_handle* h) -{ - return GRIB_TYPE_LONG; -} diff --git a/src/grib_expression_class_length.cc b/src/grib_expression_class_length.cc deleted file mode 100644 index e2c0d3202..000000000 --- a/src/grib_expression_class_length.cc +++ /dev/null @@ -1,170 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = expression - IMPLEMENTS = destroy - IMPLEMENTS = native_type - IMPLEMENTS = get_name - IMPLEMENTS = evaluate_long - IMPLEMENTS = evaluate_double - IMPLEMENTS = evaluate_string - IMPLEMENTS = print - IMPLEMENTS = add_dependency - MEMBERS = char *name - MEMBERS = size_t start - MEMBERS = size_t length - END_CLASS_DEF - - */ -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "expression.class" and rerun ./make_class.pl - -*/ - -typedef const char* string; /* to keep make_class.pl happy */ - -static void destroy(grib_context*,grib_expression* e); -static void print(grib_context*, grib_expression*, grib_handle*, FILE*); -static void add_dependency(grib_expression* e, grib_accessor* observer); -static string get_name(grib_expression* e); -static int native_type(grib_expression*,grib_handle*); -static int evaluate_long(grib_expression*,grib_handle*,long*); -static int evaluate_double(grib_expression*,grib_handle*,double*); -static string evaluate_string(grib_expression*,grib_handle*,char*,size_t*,int*); - -typedef struct grib_expression_length{ - grib_expression base; - /* Members defined in length */ - char *name; - size_t start; - size_t length; -} grib_expression_length; - - -static grib_expression_class _grib_expression_class_length = { - 0, /* super */ - "length", /* name */ - sizeof(grib_expression_length),/* size of instance */ - 0, /* inited */ - 0, /* constructor */ - &destroy, /* destructor */ - &print, - &add_dependency, - &native_type, - &get_name, - &evaluate_long, - &evaluate_double, - &evaluate_string, -}; - -grib_expression_class* grib_expression_class_length = &_grib_expression_class_length; - -/* END_CLASS_IMP */ - -static const char* get_name(grib_expression* g) -{ - const grib_expression_length* e = (grib_expression_length*)g; - return e->name; -} - -static int evaluate_long(grib_expression* g, grib_handle* h, long* result) -{ - const grib_expression_length* e = (grib_expression_length*)g; - int err = 0; - char mybuf[1024] = {0,}; - size_t size = 1024; - if ((err = grib_get_string_internal(h, e->name, mybuf, &size)) != GRIB_SUCCESS) - return err; - - *result = strlen(mybuf); - return err; -} - -static int evaluate_double(grib_expression* g, grib_handle* h, double* result) -{ - const grib_expression_length* e = (grib_expression_length*)g; - char mybuf[1024] = {0,}; - size_t size = 1024; - int err = 0; - if ((err = grib_get_string_internal(h, e->name, mybuf, &size)) != GRIB_SUCCESS) - return err; - - *result = strlen(mybuf); - return err; -} - -static string evaluate_string(grib_expression* g, grib_handle* h, char* buf, size_t* size, int* err) -{ - const grib_expression_length* e = (grib_expression_length*)g; - char mybuf[1024] = {0,}; - Assert(buf); - if ((*err = grib_get_string_internal(h, e->name, mybuf, size)) != GRIB_SUCCESS) - return NULL; - - snprintf(buf, 32, "%ld", (long)strlen(mybuf)); - return buf; -} - -static void print(grib_context* c, grib_expression* g, grib_handle* f, FILE* out) -{ - const grib_expression_length* e = (grib_expression_length*)g; - fprintf(out, "access('%s", e->name); - if (f) { - long s = 0; - grib_get_long(f, e->name, &s); - fprintf(out, "=%ld", s); - } - fprintf(out, "')"); -} - -static void destroy(grib_context* c, grib_expression* g) -{ - grib_expression_length* e = (grib_expression_length*)g; - grib_context_free_persistent(c, e->name); -} - -static void add_dependency(grib_expression* g, grib_accessor* observer) -{ - const grib_expression_length* e = (grib_expression_length*)g; - grib_accessor* observed = grib_find_accessor(grib_handle_of_accessor(observer), e->name); - - if (!observed) { - /* grib_context_log(observer->context, GRIB_LOG_ERROR, */ - /* "Error in accessor_add_dependency: cannot find [%s]", e->name); */ - /* Assert(observed); */ - return; - } - - grib_dependency_add(observer, observed); -} - -grib_expression* new_length_expression(grib_context* c, const char* name) -{ - grib_expression_length* e = (grib_expression_length*)grib_context_malloc_clear_persistent(c, sizeof(grib_expression_length)); - e->base.cclass = grib_expression_class_length; - e->name = grib_context_strdup_persistent(c, name); - return (grib_expression*)e; -} - -static int native_type(grib_expression* g, grib_handle* h) -{ - return GRIB_TYPE_LONG; -} diff --git a/src/grib_expression_class_logical_and.cc b/src/grib_expression_class_logical_and.cc deleted file mode 100644 index 419383373..000000000 --- a/src/grib_expression_class_logical_and.cc +++ /dev/null @@ -1,172 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = expression - IMPLEMENTS = destroy - IMPLEMENTS = native_type - IMPLEMENTS = evaluate_long - IMPLEMENTS = evaluate_double - IMPLEMENTS = print - IMPLEMENTS = add_dependency - MEMBERS = grib_expression *left - MEMBERS = grib_expression *right - END_CLASS_DEF - - */ -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "expression.class" and rerun ./make_class.pl - -*/ - -typedef const char* string; /* to keep make_class.pl happy */ - -static void destroy(grib_context*,grib_expression* e); -static void print(grib_context*, grib_expression*, grib_handle*, FILE*); -static void add_dependency(grib_expression* e, grib_accessor* observer); -static int native_type(grib_expression*,grib_handle*); -static int evaluate_long(grib_expression*,grib_handle*,long*); -static int evaluate_double(grib_expression*,grib_handle*,double*); - -typedef struct grib_expression_logical_and{ - grib_expression base; - /* Members defined in logical_and */ - grib_expression *left; - grib_expression *right; -} grib_expression_logical_and; - - -static grib_expression_class _grib_expression_class_logical_and = { - 0, /* super */ - "logical_and", /* name */ - sizeof(grib_expression_logical_and),/* size of instance */ - 0, /* inited */ - 0, /* constructor */ - &destroy, /* destructor */ - &print, - &add_dependency, - &native_type, - 0, - &evaluate_long, - &evaluate_double, - 0, -}; - -grib_expression_class* grib_expression_class_logical_and = &_grib_expression_class_logical_and; - -/* END_CLASS_IMP */ - -static int evaluate_long(grib_expression* g, grib_handle* h, long* lres) -{ - long v1 = 0; - long v2 = 0; - double dv1 = 0; - double dv2 = 0; - int ret; - grib_expression_logical_and* e = (grib_expression_logical_and*)g; - - switch (grib_expression_native_type(h, e->left)) { - case GRIB_TYPE_LONG: - ret = grib_expression_evaluate_long(h, e->left, &v1); - if (ret != GRIB_SUCCESS) - return ret; - if (v1 == 0) { - *lres = 0; - return ret; - } - break; - case GRIB_TYPE_DOUBLE: - ret = grib_expression_evaluate_double(h, e->left, &dv1); - if (ret != GRIB_SUCCESS) - return ret; - if (dv1 == 0) { - *lres = 0; - return ret; - } - break; - default: - return GRIB_INVALID_TYPE; - } - - switch (grib_expression_native_type(h, e->right)) { - case GRIB_TYPE_LONG: - ret = grib_expression_evaluate_long(h, e->right, &v2); - if (ret != GRIB_SUCCESS) - return ret; - *lres = v2 ? 1 : 0; - break; - case GRIB_TYPE_DOUBLE: - ret = grib_expression_evaluate_double(h, e->right, &dv2); - if (ret != GRIB_SUCCESS) - return ret; - *lres = dv2 ? 1 : 0; - break; - default: - return GRIB_INVALID_TYPE; - } - - return GRIB_SUCCESS; -} - -static int evaluate_double(grib_expression* g, grib_handle* h, double* dres) -{ - long lres = 0; - int ret = evaluate_long(g, h, &lres); - *dres = (double)lres; - return ret; -} - -static void print(grib_context* c, grib_expression* g, grib_handle* f, FILE* out) -{ - grib_expression_logical_and* e = (grib_expression_logical_and*)g; - fprintf(out, "("); - grib_expression_print(c, e->left, f, out); - fprintf(out, " && "); - grib_expression_print(c, e->right, f, out); - fprintf(out, ")"); -} - -static void destroy(grib_context* c, grib_expression* g) -{ - grib_expression_logical_and* e = (grib_expression_logical_and*)g; - grib_expression_free(c, e->left); - grib_expression_free(c, e->right); -} - -static void add_dependency(grib_expression* g, grib_accessor* observer) -{ - grib_expression_logical_and* e = (grib_expression_logical_and*)g; - grib_dependency_observe_expression(observer, e->left); - grib_dependency_observe_expression(observer, e->right); -} - -grib_expression* new_logical_and_expression(grib_context* c, grib_expression* left, grib_expression* right) -{ - grib_expression_logical_and* e = (grib_expression_logical_and*)grib_context_malloc_clear_persistent(c, sizeof(grib_expression_logical_and)); - e->base.cclass = grib_expression_class_logical_and; - e->left = left; - e->right = right; - return (grib_expression*)e; -} - -static int native_type(grib_expression* g, grib_handle* h) -{ - return GRIB_TYPE_LONG; -} diff --git a/src/grib_expression_class_logical_or.cc b/src/grib_expression_class_logical_or.cc deleted file mode 100644 index 88867f35f..000000000 --- a/src/grib_expression_class_logical_or.cc +++ /dev/null @@ -1,173 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = expression - IMPLEMENTS = destroy - IMPLEMENTS = native_type - IMPLEMENTS = evaluate_long - IMPLEMENTS = evaluate_double - IMPLEMENTS = print - IMPLEMENTS = add_dependency - MEMBERS = grib_expression *left - MEMBERS = grib_expression *right - END_CLASS_DEF - - */ -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "expression.class" and rerun ./make_class.pl - -*/ - -typedef const char* string; /* to keep make_class.pl happy */ - -static void destroy(grib_context*,grib_expression* e); -static void print(grib_context*, grib_expression*, grib_handle*, FILE*); -static void add_dependency(grib_expression* e, grib_accessor* observer); -static int native_type(grib_expression*,grib_handle*); -static int evaluate_long(grib_expression*,grib_handle*,long*); -static int evaluate_double(grib_expression*,grib_handle*,double*); - -typedef struct grib_expression_logical_or{ - grib_expression base; - /* Members defined in logical_or */ - grib_expression *left; - grib_expression *right; -} grib_expression_logical_or; - - -static grib_expression_class _grib_expression_class_logical_or = { - 0, /* super */ - "logical_or", /* name */ - sizeof(grib_expression_logical_or),/* size of instance */ - 0, /* inited */ - 0, /* constructor */ - &destroy, /* destructor */ - &print, - &add_dependency, - &native_type, - 0, - &evaluate_long, - &evaluate_double, - 0, -}; - -grib_expression_class* grib_expression_class_logical_or = &_grib_expression_class_logical_or; - -/* END_CLASS_IMP */ - -static int evaluate_long(grib_expression* g, grib_handle* h, long* lres) -{ - long v1 = 0; - long v2 = 0; - double dv1 = 0; - double dv2 = 0; - int ret; - grib_expression_logical_or* e = (grib_expression_logical_or*)g; - - - switch (grib_expression_native_type(h, e->left)) { - case GRIB_TYPE_LONG: - ret = grib_expression_evaluate_long(h, e->left, &v1); - if (ret != GRIB_SUCCESS) - return ret; - if (v1 != 0) { - *lres = 1; - return ret; - } - break; - case GRIB_TYPE_DOUBLE: - ret = grib_expression_evaluate_double(h, e->left, &dv1); - if (ret != GRIB_SUCCESS) - return ret; - if (dv1 != 0) { - *lres = 1; - return ret; - } - break; - default: - return GRIB_INVALID_TYPE; - } - - switch (grib_expression_native_type(h, e->right)) { - case GRIB_TYPE_LONG: - ret = grib_expression_evaluate_long(h, e->right, &v2); - if (ret != GRIB_SUCCESS) - return ret; - *lres = v2 ? 1 : 0; - break; - case GRIB_TYPE_DOUBLE: - ret = grib_expression_evaluate_double(h, e->right, &dv2); - if (ret != GRIB_SUCCESS) - return ret; - *lres = dv2 ? 1 : 0; - break; - default: - return GRIB_INVALID_TYPE; - } - - return GRIB_SUCCESS; -} - -static int evaluate_double(grib_expression* g, grib_handle* h, double* dres) -{ - long lres = 0; - int ret = evaluate_long(g, h, &lres); - *dres = (double)lres; - return ret; -} - -static void print(grib_context* c, grib_expression* g, grib_handle* f, FILE* out) -{ - grib_expression_logical_or* e = (grib_expression_logical_or*)g; - fprintf(out, "("); - grib_expression_print(c, e->left, f, out); - fprintf(out, " || "); - grib_expression_print(c, e->right, f, out); - fprintf(out, ")"); -} - -static void destroy(grib_context* c, grib_expression* g) -{ - grib_expression_logical_or* e = (grib_expression_logical_or*)g; - grib_expression_free(c, e->left); - grib_expression_free(c, e->right); -} - -static void add_dependency(grib_expression* g, grib_accessor* observer) -{ - grib_expression_logical_or* e = (grib_expression_logical_or*)g; - grib_dependency_observe_expression(observer, e->left); - grib_dependency_observe_expression(observer, e->right); -} - -grib_expression* new_logical_or_expression(grib_context* c, grib_expression* left, grib_expression* right) -{ - grib_expression_logical_or* e = (grib_expression_logical_or*)grib_context_malloc_clear_persistent(c, sizeof(grib_expression_logical_or)); - e->base.cclass = grib_expression_class_logical_or; - e->left = left; - e->right = right; - return (grib_expression*)e; -} - -static int native_type(grib_expression* g, grib_handle* h) -{ - return GRIB_TYPE_LONG; -} diff --git a/src/grib_expression_class_long.cc b/src/grib_expression_class_long.cc deleted file mode 100644 index 946e6456d..000000000 --- a/src/grib_expression_class_long.cc +++ /dev/null @@ -1,115 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = expression - IMPLEMENTS = native_type;pack_missing - IMPLEMENTS = destroy - IMPLEMENTS = evaluate_long - IMPLEMENTS = evaluate_double - IMPLEMENTS = print - IMPLEMENTS = add_dependency - MEMBERS = long value - END_CLASS_DEF - - */ -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "expression.class" and rerun ./make_class.pl - -*/ - -typedef const char* string; /* to keep make_class.pl happy */ - -static void destroy(grib_context*,grib_expression* e); -static void print(grib_context*, grib_expression*, grib_handle*, FILE*); -static void add_dependency(grib_expression* e, grib_accessor* observer); -static int native_type(grib_expression*,grib_handle*); -static int evaluate_long(grib_expression*,grib_handle*,long*); -static int evaluate_double(grib_expression*,grib_handle*,double*); - -typedef struct grib_expression_long{ - grib_expression base; - /* Members defined in long */ - long value; -} grib_expression_long; - - -static grib_expression_class _grib_expression_class_long = { - 0, /* super */ - "long", /* name */ - sizeof(grib_expression_long),/* size of instance */ - 0, /* inited */ - 0, /* constructor */ - &destroy, /* destructor */ - &print, - &add_dependency, - &native_type, - 0, - &evaluate_long, - &evaluate_double, - 0, -}; - -grib_expression_class* grib_expression_class_long = &_grib_expression_class_long; - -/* END_CLASS_IMP */ - -static int evaluate_long(grib_expression* g, grib_handle* h, long* lres) -{ - const grib_expression_long* e = (grib_expression_long*)g; - *lres = e->value; - return GRIB_SUCCESS; -} - -static int evaluate_double(grib_expression* g, grib_handle* h, double* dres) -{ - const grib_expression_long* e = (grib_expression_long*)g; - *dres = e->value; - return GRIB_SUCCESS; -} - -static void print(grib_context* c, grib_expression* g, grib_handle* f, FILE* out) -{ - const grib_expression_long* e = (grib_expression_long*)g; - fprintf(out, "long(%ld)", e->value); -} - -static void destroy(grib_context* c, grib_expression* g) -{ - /* grib_expression_long* e = (grib_expression_long*)g; */ -} - -static void add_dependency(grib_expression* g, grib_accessor* observer) -{ - /* grib_expression_long* e = (grib_expression_long*)g; */ -} - -grib_expression* new_long_expression(grib_context* c, long value) -{ - grib_expression_long* e = (grib_expression_long*)grib_context_malloc_clear_persistent(c, sizeof(grib_expression_long)); - e->base.cclass = grib_expression_class_long; - e->value = value; - return (grib_expression*)e; -} - -static int native_type(grib_expression* g, grib_handle* h) -{ - return GRIB_TYPE_LONG; -} diff --git a/src/grib_expression_class_string.cc b/src/grib_expression_class_string.cc deleted file mode 100644 index a085ed69e..000000000 --- a/src/grib_expression_class_string.cc +++ /dev/null @@ -1,107 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = expression - IMPLEMENTS = native_type - IMPLEMENTS = destroy - IMPLEMENTS = evaluate_string - IMPLEMENTS = print - IMPLEMENTS = add_dependency - MEMBERS = char* value - END_CLASS_DEF - - */ -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "expression.class" and rerun ./make_class.pl - -*/ - -typedef const char* string; /* to keep make_class.pl happy */ - -static void destroy(grib_context*,grib_expression* e); -static void print(grib_context*, grib_expression*, grib_handle*, FILE*); -static void add_dependency(grib_expression* e, grib_accessor* observer); -static int native_type(grib_expression*,grib_handle*); -static string evaluate_string(grib_expression*,grib_handle*,char*,size_t*,int*); - -typedef struct grib_expression_string{ - grib_expression base; - /* Members defined in string */ - char* value; -} grib_expression_string; - - -static grib_expression_class _grib_expression_class_string = { - 0, /* super */ - "string", /* name */ - sizeof(grib_expression_string),/* size of instance */ - 0, /* inited */ - 0, /* constructor */ - &destroy, /* destructor */ - &print, - &add_dependency, - &native_type, - 0, - 0, - 0, - &evaluate_string, -}; - -grib_expression_class* grib_expression_class_string = &_grib_expression_class_string; - -/* END_CLASS_IMP */ - -static const char* evaluate_string(grib_expression* g, grib_handle* h, char* buf, size_t* size, int* err) -{ - const grib_expression_string* e = (grib_expression_string*)g; - *err = 0; - return e->value; -} - -static void print(grib_context* c, grib_expression* g, grib_handle* f, FILE* out) -{ - const grib_expression_string* e = (grib_expression_string*)g; - fprintf(out, "string('%s')", e->value); -} - -static void destroy(grib_context* c, grib_expression* g) -{ - grib_expression_string* e = (grib_expression_string*)g; - grib_context_free_persistent(c, e->value); -} - -static void add_dependency(grib_expression* g, grib_accessor* observer) -{ - /* grib_expression_string* e = (grib_expression_string*)g; */ -} - -grib_expression* new_string_expression(grib_context* c, const char* value) -{ - grib_expression_string* e = (grib_expression_string*)grib_context_malloc_clear_persistent(c, sizeof(grib_expression_string)); - e->base.cclass = grib_expression_class_string; - e->value = grib_context_strdup_persistent(c, value); - return (grib_expression*)e; -} - -static int native_type(grib_expression* g, grib_handle* h) -{ - return GRIB_TYPE_STRING; -} diff --git a/src/grib_expression_class_string_compare.cc b/src/grib_expression_class_string_compare.cc deleted file mode 100644 index 603846b7b..000000000 --- a/src/grib_expression_class_string_compare.cc +++ /dev/null @@ -1,169 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = expression - IMPLEMENTS = destroy - IMPLEMENTS = native_type - IMPLEMENTS = evaluate_long - IMPLEMENTS = evaluate_double - IMPLEMENTS = print - IMPLEMENTS = add_dependency - MEMBERS = grib_expression *left - MEMBERS = grib_expression *right - MEMBERS = int eq - END_CLASS_DEF - - */ -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "expression.class" and rerun ./make_class.pl - -*/ - -typedef const char* string; /* to keep make_class.pl happy */ - -static void destroy(grib_context*,grib_expression* e); -static void print(grib_context*, grib_expression*, grib_handle*, FILE*); -static void add_dependency(grib_expression* e, grib_accessor* observer); -static int native_type(grib_expression*,grib_handle*); -static int evaluate_long(grib_expression*,grib_handle*,long*); -static int evaluate_double(grib_expression*,grib_handle*,double*); - -typedef struct grib_expression_string_compare{ - grib_expression base; - /* Members defined in string_compare */ - grib_expression *left; - grib_expression *right; - int eq; -} grib_expression_string_compare; - - -static grib_expression_class _grib_expression_class_string_compare = { - 0, /* super */ - "string_compare", /* name */ - sizeof(grib_expression_string_compare),/* size of instance */ - 0, /* inited */ - 0, /* constructor */ - &destroy, /* destructor */ - &print, - &add_dependency, - &native_type, - 0, - &evaluate_long, - &evaluate_double, - 0, -}; - -grib_expression_class* grib_expression_class_string_compare = &_grib_expression_class_string_compare; - -/* END_CLASS_IMP */ - -/* Note: A fast cut-down version of strcmp which does NOT return -1 */ -/* 0 means input strings are equal and 1 means not equal */ -GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b) -{ - if (*a != *b) - return 1; - while ((*a != 0 && *b != 0) && *(a) == *(b)) { - a++; - b++; - } - return (*a == 0 && *b == 0) ? 0 : 1; -} - -static int evaluate_long(grib_expression* g, grib_handle* h, long* lres) -{ - int ret = 0; - char b1[1024] = {0,}; - size_t l1 = sizeof(b1); - char b2[1024] = {0,}; - size_t l2 = sizeof(b2); - const char* v1 = NULL; - const char* v2 = NULL; - - grib_expression_string_compare* e = (grib_expression_string_compare*)g; - - v1 = grib_expression_evaluate_string(h, e->left, b1, &l1, &ret); - if (!v1 || ret) { - *lres = 0; - return ret; - } - - v2 = grib_expression_evaluate_string(h, e->right, b2, &l2, &ret); - if (!v2 || ret) { - *lres = 0; - return ret; - } - - if (e->eq) // IS operator - *lres = (grib_inline_strcmp(v1, v2) == 0); - else // ISNOT operator - *lres = (grib_inline_strcmp(v1, v2) != 0); - - return GRIB_SUCCESS; -} - -static int evaluate_double(grib_expression* g, grib_handle* h, double* dres) -{ - long n; - int ret = evaluate_long(g, h, &n); - *dres = n; - return ret; -} - -static void print(grib_context* c, grib_expression* g, grib_handle* f, FILE* out) -{ - grib_expression_string_compare* e = (grib_expression_string_compare*)g; - fprintf(out, "string_compare("); - grib_expression_print(c, e->left, f, out); - fprintf(out, ","); - grib_expression_print(c, e->right, f, out); - fprintf(out, ")"); -} - -static void destroy(grib_context* c, grib_expression* g) -{ - grib_expression_string_compare* e = (grib_expression_string_compare*)g; - grib_expression_free(c, e->left); - grib_expression_free(c, e->right); -} - -static void add_dependency(grib_expression* g, grib_accessor* observer) -{ - grib_expression_string_compare* e = (grib_expression_string_compare*)g; - grib_dependency_observe_expression(observer, e->left); - grib_dependency_observe_expression(observer, e->right); -} - -grib_expression* new_string_compare_expression(grib_context* c, - grib_expression* left, grib_expression* right, int eq) -{ - grib_expression_string_compare* e = (grib_expression_string_compare*)grib_context_malloc_clear_persistent(c, sizeof(grib_expression_string_compare)); - e->base.cclass = grib_expression_class_string_compare; - e->left = left; - e->right = right; - e->eq = eq; - return (grib_expression*)e; -} - -static int native_type(grib_expression* g, grib_handle* h) -{ - return GRIB_TYPE_LONG; -} diff --git a/src/grib_expression_class_sub_string.cc b/src/grib_expression_class_sub_string.cc deleted file mode 100644 index 8ed6c3dff..000000000 --- a/src/grib_expression_class_sub_string.cc +++ /dev/null @@ -1,128 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = expression - IMPLEMENTS = native_type - IMPLEMENTS = destroy - IMPLEMENTS = evaluate_string - IMPLEMENTS = print - IMPLEMENTS = add_dependency - MEMBERS = char* value - END_CLASS_DEF - - */ -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "expression.class" and rerun ./make_class.pl - -*/ - -typedef const char* string; /* to keep make_class.pl happy */ - -static void destroy(grib_context*,grib_expression* e); -static void print(grib_context*, grib_expression*, grib_handle*, FILE*); -static void add_dependency(grib_expression* e, grib_accessor* observer); -static int native_type(grib_expression*,grib_handle*); -static string evaluate_string(grib_expression*,grib_handle*,char*,size_t*,int*); - -typedef struct grib_expression_sub_string{ - grib_expression base; - /* Members defined in sub_string */ - char* value; -} grib_expression_sub_string; - - -static grib_expression_class _grib_expression_class_sub_string = { - 0, /* super */ - "sub_string", /* name */ - sizeof(grib_expression_sub_string),/* size of instance */ - 0, /* inited */ - 0, /* constructor */ - &destroy, /* destructor */ - &print, - &add_dependency, - &native_type, - 0, - 0, - 0, - &evaluate_string, -}; - -grib_expression_class* grib_expression_class_sub_string = &_grib_expression_class_sub_string; - -/* END_CLASS_IMP */ - -static const char* evaluate_string(grib_expression* g, grib_handle* h, char* buf, size_t* size, int* err) -{ - const grib_expression_sub_string* e = (grib_expression_sub_string*)g; - *err = 0; - return e->value; -} - -static void print(grib_context* c, grib_expression* g, grib_handle* f, FILE* out) -{ - const grib_expression_sub_string* e = (grib_expression_sub_string*)g; - fprintf(out, "string('%s')", e->value); -} - -static void destroy(grib_context* c, grib_expression* g) -{ - grib_expression_sub_string* e = (grib_expression_sub_string*)g; - grib_context_free_persistent(c, e->value); -} - -static void add_dependency(grib_expression* g, grib_accessor* observer) -{ - /* grib_expression_sub_string* e = (grib_expression_sub_string*)g; */ -} - -grib_expression* new_sub_string_expression(grib_context* c, const char* value, size_t start, size_t length) -{ - char v[1024] = {0,}; - grib_expression_sub_string* e = (grib_expression_sub_string*)grib_context_malloc_clear_persistent(c, sizeof(grib_expression_sub_string)); - const size_t slen = strlen(value); - /* if (start<0) start+=strlen(value); */ - - if (length == 0) { - grib_context_log(c, GRIB_LOG_ERROR, "Invalid substring: length must be > 0"); - grib_context_free_persistent(c, e); - return NULL; - } - if (start > slen) { /* to catch a -ve number passed to start */ - grib_context_log(c, GRIB_LOG_ERROR, "Invalid substring: start=%lu", start); - grib_context_free_persistent(c, e); - return NULL; - } - if (start + length > slen) { - grib_context_log(c, GRIB_LOG_ERROR, "Invalid substring: start(=%lu)+length(=%lu) > length('%s'))", start, length, value); - grib_context_free_persistent(c, e); - return NULL; - } - - memcpy(v, value + start, length); - e->base.cclass = grib_expression_class_sub_string; - e->value = grib_context_strdup_persistent(c, v); - return (grib_expression*)e; -} - -static int native_type(grib_expression* g, grib_handle* h) -{ - return GRIB_TYPE_STRING; -} diff --git a/src/grib_expression_class_true.cc b/src/grib_expression_class_true.cc deleted file mode 100644 index 41f3a40ae..000000000 --- a/src/grib_expression_class_true.cc +++ /dev/null @@ -1,108 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = expression - IMPLEMENTS = destroy - IMPLEMENTS = native_type - IMPLEMENTS = evaluate_long - IMPLEMENTS = evaluate_double - IMPLEMENTS = print - IMPLEMENTS = add_dependency - END_CLASS_DEF - - */ -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "expression.class" and rerun ./make_class.pl - -*/ - -typedef const char* string; /* to keep make_class.pl happy */ - -static void destroy(grib_context*,grib_expression* e); -static void print(grib_context*, grib_expression*, grib_handle*, FILE*); -static void add_dependency(grib_expression* e, grib_accessor* observer); -static int native_type(grib_expression*,grib_handle*); -static int evaluate_long(grib_expression*,grib_handle*,long*); -static int evaluate_double(grib_expression*,grib_handle*,double*); - -typedef struct grib_expression_true{ - grib_expression base; - /* Members defined in true */ -} grib_expression_true; - - -static grib_expression_class _grib_expression_class_true = { - 0, /* super */ - "true", /* name */ - sizeof(grib_expression_true),/* size of instance */ - 0, /* inited */ - 0, /* constructor */ - &destroy, /* destructor */ - &print, - &add_dependency, - &native_type, - 0, - &evaluate_long, - &evaluate_double, - 0, -}; - -grib_expression_class* grib_expression_class_true = &_grib_expression_class_true; - -/* END_CLASS_IMP */ - -static int evaluate_long(grib_expression* g, grib_handle* h, long* lres) -{ - *lres = 1; - return GRIB_SUCCESS; -} - -static int evaluate_double(grib_expression* g, grib_handle* h, double* dres) -{ - *dres = 1; - return GRIB_SUCCESS; -} - -static void print(grib_context* c, grib_expression* g, grib_handle* f, FILE* out) -{ - fprintf(out, "true()"); -} - -static void destroy(grib_context* c, grib_expression* g) -{ -} - - -static void add_dependency(grib_expression* g, grib_accessor* observer) -{ -} - -grib_expression* new_true_expression(grib_context* c) -{ - grib_expression_true* e = (grib_expression_true*)grib_context_malloc_clear_persistent(c, sizeof(grib_expression_true)); - e->base.cclass = grib_expression_class_true; - return (grib_expression*)e; -} - -static int native_type(grib_expression* g, grib_handle* h) -{ - return GRIB_TYPE_LONG; -} diff --git a/src/grib_expression_class_unop.cc b/src/grib_expression_class_unop.cc deleted file mode 100644 index 18eb073fb..000000000 --- a/src/grib_expression_class_unop.cc +++ /dev/null @@ -1,145 +0,0 @@ -/* - * (C) Copyright 2005- ECMWF. - * - * This software is licensed under the terms of the Apache Licence Version 2.0 - * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. - * - * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by - * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. - */ - -#include "grib_api_internal.h" - -/* - This is used by make_class.pl - - START_CLASS_DEF - CLASS = expression - IMPLEMENTS = destroy - IMPLEMENTS = native_type - IMPLEMENTS = get_name - IMPLEMENTS = evaluate_long - IMPLEMENTS = evaluate_double - IMPLEMENTS = print - IMPLEMENTS = add_dependency - MEMBERS = grib_expression *exp - MEMBERS = grib_unop_long_proc long_func - MEMBERS = grib_unop_double_proc double_func - END_CLASS_DEF - - */ -/* START_CLASS_IMP */ - -/* - -Don't edit anything between START_CLASS_IMP and END_CLASS_IMP -Instead edit values between START_CLASS_DEF and END_CLASS_DEF -or edit "expression.class" and rerun ./make_class.pl - -*/ - -typedef const char* string; /* to keep make_class.pl happy */ - -static void destroy(grib_context*,grib_expression* e); -static void print(grib_context*, grib_expression*, grib_handle*, FILE*); -static void add_dependency(grib_expression* e, grib_accessor* observer); -static string get_name(grib_expression* e); -static int native_type(grib_expression*,grib_handle*); -static int evaluate_long(grib_expression*,grib_handle*,long*); -static int evaluate_double(grib_expression*,grib_handle*,double*); - -typedef struct grib_expression_unop{ - grib_expression base; - /* Members defined in unop */ - grib_expression *exp; - grib_unop_long_proc long_func; - grib_unop_double_proc double_func; -} grib_expression_unop; - - -static grib_expression_class _grib_expression_class_unop = { - 0, /* super */ - "unop", /* name */ - sizeof(grib_expression_unop),/* size of instance */ - 0, /* inited */ - 0, /* constructor */ - &destroy, /* destructor */ - &print, - &add_dependency, - &native_type, - &get_name, - &evaluate_long, - &evaluate_double, - 0, -}; - -grib_expression_class* grib_expression_class_unop = &_grib_expression_class_unop; - -/* END_CLASS_IMP */ - -static int evaluate_long(grib_expression* g, grib_handle* h, long* lres) -{ - long v = 0; - grib_expression_unop* e = (grib_expression_unop*)g; - int ret = grib_expression_evaluate_long(h, e->exp, &v); - if (ret != GRIB_SUCCESS) - return ret; - *lres = e->long_func(v); - return GRIB_SUCCESS; -} - -static int evaluate_double(grib_expression* g, grib_handle* h, double* dres) -{ - double v = 0; - grib_expression_unop* e = (grib_expression_unop*)g; - int ret = grib_expression_evaluate_double(h, e->exp, &v); - if (ret != GRIB_SUCCESS) - return ret; - *dres = e->double_func ? e->double_func(v) : e->long_func(v); - return GRIB_SUCCESS; -} - -static const char* get_name(grib_expression* g) -{ - grib_expression_unop* e = (grib_expression_unop*)g; - return grib_expression_get_name(e->exp); -} - -static void print(grib_context* c, grib_expression* g, grib_handle* f, FILE* out) -{ - grib_expression_unop* e = (grib_expression_unop*)g; - fprintf(out, "unop("); - grib_expression_print(c, e->exp, f, out); - fprintf(out, ")"); -} - -static void destroy(grib_context* c, grib_expression* g) -{ - grib_expression_unop* e = (grib_expression_unop*)g; - grib_expression_free(c, e->exp); -} - -static void add_dependency(grib_expression* g, grib_accessor* observer) -{ - grib_expression_unop* e = (grib_expression_unop*)g; - grib_dependency_observe_expression(observer, e->exp); -} - -grib_expression* new_unop_expression(grib_context* c, - grib_unop_long_proc long_func, - grib_unop_double_proc double_func, - grib_expression* exp) -{ - grib_expression_unop* e = (grib_expression_unop*)grib_context_malloc_clear_persistent(c, sizeof(grib_expression_unop)); - e->base.cclass = grib_expression_class_unop; - e->exp = exp; - e->long_func = long_func; - e->double_func = double_func; - return (grib_expression*)e; -} - -static int native_type(grib_expression* g, grib_handle* h) -{ - grib_expression_unop* e = (grib_expression_unop*)g; - return e->long_func ? GRIB_TYPE_LONG : GRIB_TYPE_DOUBLE; -} diff --git a/src/grib_expression_factory.h b/src/grib_expression_factory.h deleted file mode 100644 index 7cacd3ac1..000000000 --- a/src/grib_expression_factory.h +++ /dev/null @@ -1,17 +0,0 @@ -/* This file is automatically generated by ./make_class.pl, do not edit */ -{ "accessor", &grib_expression_class_accessor, }, -{ "binop", &grib_expression_class_binop, }, -{ "double", &grib_expression_class_double, }, -{ "functor", &grib_expression_class_functor, }, -{ "is_in_dict", &grib_expression_class_is_in_dict, }, -{ "is_in_list", &grib_expression_class_is_in_list, }, -{ "is_integer", &grib_expression_class_is_integer, }, -{ "length", &grib_expression_class_length, }, -{ "logical_and", &grib_expression_class_logical_and, }, -{ "logical_or", &grib_expression_class_logical_or, }, -{ "long", &grib_expression_class_long, }, -{ "string", &grib_expression_class_string, }, -{ "string_compare", &grib_expression_class_string_compare, }, -{ "sub_string", &grib_expression_class_sub_string, }, -{ "true", &grib_expression_class_true, }, -{ "unop", &grib_expression_class_unop, }, diff --git a/src/grib_iterator_factory.cc b/src/grib_iterator_factory.cc index 9ea143b3d..15026358f 100644 --- a/src/grib_iterator_factory.cc +++ b/src/grib_iterator_factory.cc @@ -63,7 +63,7 @@ static const struct table_entry table[] = { eccodes::geo_iterator::Iterator* grib_iterator_factory(grib_handle* h, grib_arguments* args, unsigned long flags, int* error) { size_t i = 0, num_table_entries = 0; - const char* type = (char*)grib_arguments_get_name(h, args, 0); + const char* type = (char*)args->get_name(h, 0); *error = GRIB_NOT_IMPLEMENTED; num_table_entries = sizeof(table) / sizeof(table[0]); diff --git a/src/grib_lex.cc b/src/grib_lex.cc index 8efe0e58d..b08487049 100644 --- a/src/grib_lex.cc +++ b/src/grib_lex.cc @@ -47,7 +47,6 @@ typedef int16_t flex_int16_t; typedef uint16_t flex_uint16_t; typedef int32_t flex_int32_t; typedef uint32_t flex_uint32_t; -typedef uint64_t flex_uint64_t; #else typedef signed char flex_int8_t; typedef short int flex_int16_t; @@ -156,7 +155,7 @@ typedef struct grib_yy_buffer_state *YY_BUFFER_STATE; typedef size_t grib_yy_size_t; #endif -extern grib_yy_size_t grib_yyleng; +extern int grib_yyleng; extern FILE *grib_yyin, *grib_yyout; @@ -199,7 +198,7 @@ struct grib_yy_buffer_state /* Number of characters read into grib_yy_ch_buf, not including EOB * characters. */ - grib_yy_size_t grib_yy_n_chars; + int grib_yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to @@ -268,8 +267,8 @@ static YY_BUFFER_STATE * grib_yy_buffer_stack = NULL; /**< Stack as an array. */ /* grib_yy_hold_char holds the character lost when grib_yytext is formed. */ static char grib_yy_hold_char; -static grib_yy_size_t grib_yy_n_chars; /* number of characters read into grib_yy_ch_buf */ -grib_yy_size_t grib_yyleng; +static int grib_yy_n_chars; /* number of characters read into grib_yy_ch_buf */ +int grib_yyleng; /* Points to current character in buffer. */ static char *grib_yy_c_buf_p = NULL; @@ -296,7 +295,7 @@ static void grib_yy_init_buffer ( YY_BUFFER_STATE b, FILE *file ); YY_BUFFER_STATE grib_yy_scan_buffer ( char *base, grib_yy_size_t size ); YY_BUFFER_STATE grib_yy_scan_string ( const char *grib_yy_str ); -YY_BUFFER_STATE grib_yy_scan_bytes ( const char *bytes, grib_yy_size_t len ); +YY_BUFFER_STATE grib_yy_scan_bytes ( const char *bytes, int len ); void *grib_yyalloc ( grib_yy_size_t ); void *grib_yyrealloc ( void *, grib_yy_size_t ); @@ -349,7 +348,7 @@ static void grib_yynoreturn grib_yy_fatal_error ( const char* msg ); */ #define YY_DO_BEFORE_ACTION \ (grib_yytext_ptr) = grib_yy_bp; \ - grib_yyleng = (grib_yy_size_t) (grib_yy_cp - grib_yy_bp); \ + grib_yyleng = (int) (grib_yy_cp - grib_yy_bp); \ (grib_yy_hold_char) = *grib_yy_cp; \ *grib_yy_cp = '\0'; \ (grib_yy_c_buf_p) = grib_yy_cp; @@ -1199,8 +1198,8 @@ void _grib_ignore_grib_yyunput_unused_error() { grib_yyunput(0,0); } #define GET_INPUT input #endif +#line 1201 "gribl.cc" #line 1202 "gribl.cc" -#line 1203 "gribl.cc" #define INITIAL 0 @@ -1239,7 +1238,7 @@ FILE *grib_yyget_out ( void ); void grib_yyset_out ( FILE * _out_str ); - grib_yy_size_t grib_yyget_leng ( void ); + int grib_yyget_leng ( void ); char *grib_yyget_text ( void ); @@ -1308,7 +1307,7 @@ static int input ( void ); if ( YY_CURRENT_BUFFER_LVALUE->grib_yy_is_interactive ) \ { \ int c = '*'; \ - grib_yy_size_t n; \ + int n; \ for ( n = 0; n < max_size && \ (c = getc( grib_yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -1421,7 +1420,7 @@ YY_DECL -#line 1424 "gribl.cc" +#line 1423 "gribl.cc" while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -2222,7 +2221,7 @@ YY_RULE_SETUP #line 285 "gribl.l" ECHO; YY_BREAK -#line 2225 "gribl.cc" +#line 2224 "gribl.cc" case YY_STATE_EOF(INITIAL): grib_yyterminate(); @@ -2409,7 +2408,7 @@ static int grib_yy_get_next_buffer (void) else { - grib_yy_size_t num_to_read = + int num_to_read = YY_CURRENT_BUFFER_LVALUE->grib_yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) @@ -2423,7 +2422,7 @@ static int grib_yy_get_next_buffer (void) if ( b->grib_yy_is_our_buffer ) { - grib_yy_size_t new_size = b->grib_yy_buf_size * 2; + int new_size = b->grib_yy_buf_size * 2; if ( new_size <= 0 ) b->grib_yy_buf_size += b->grib_yy_buf_size / 8; @@ -2481,7 +2480,7 @@ static int grib_yy_get_next_buffer (void) if (((grib_yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->grib_yy_buf_size) { /* Extend the array by 50%, plus the number we really need. */ - grib_yy_size_t new_size = (grib_yy_n_chars) + number_to_move + ((grib_yy_n_chars) >> 1); + int new_size = (grib_yy_n_chars) + number_to_move + ((grib_yy_n_chars) >> 1); YY_CURRENT_BUFFER_LVALUE->grib_yy_ch_buf = (char *) grib_yyrealloc( (void *) YY_CURRENT_BUFFER_LVALUE->grib_yy_ch_buf, (grib_yy_size_t) new_size ); if ( ! YY_CURRENT_BUFFER_LVALUE->grib_yy_ch_buf ) @@ -2570,7 +2569,7 @@ static int grib_yy_get_next_buffer (void) if ( grib_yy_cp < YY_CURRENT_BUFFER_LVALUE->grib_yy_ch_buf + 2 ) { /* need to shift things up to make room */ /* +2 for EOB chars. */ - grib_yy_size_t number_to_move = (grib_yy_n_chars) + 2; + int number_to_move = (grib_yy_n_chars) + 2; char *dest = &YY_CURRENT_BUFFER_LVALUE->grib_yy_ch_buf[ YY_CURRENT_BUFFER_LVALUE->grib_yy_buf_size + 2]; char *source = @@ -2621,7 +2620,7 @@ static int grib_yy_get_next_buffer (void) else { /* need more input */ - grib_yy_size_t offset = (grib_yy_c_buf_p) - (grib_yytext_ptr); + int offset = (int) ((grib_yy_c_buf_p) - (grib_yytext_ptr)); ++(grib_yy_c_buf_p); switch ( grib_yy_get_next_buffer( ) ) @@ -2990,12 +2989,12 @@ YY_BUFFER_STATE grib_yy_scan_string (const char * grib_yystr ) * * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE grib_yy_scan_bytes (const char * grib_yybytes, grib_yy_size_t _grib_yybytes_len ) +YY_BUFFER_STATE grib_yy_scan_bytes (const char * grib_yybytes, int _grib_yybytes_len ) { YY_BUFFER_STATE b; char *buf; grib_yy_size_t n; - grib_yy_size_t i; + int i; /* Get memory for full buffer, including space for trailing EOB's. */ n = (grib_yy_size_t) (_grib_yybytes_len + 2); @@ -3037,7 +3036,7 @@ static void grib_yynoreturn grib_yy_fatal_error (const char* msg ) do \ { \ /* Undo effects of setting up grib_yytext. */ \ - grib_yy_size_t grib_yyless_macro_arg = (n); \ + int grib_yyless_macro_arg = (n); \ YY_LESS_LINENO(grib_yyless_macro_arg);\ grib_yytext[grib_yyleng] = (grib_yy_hold_char); \ (grib_yy_c_buf_p) = grib_yytext + grib_yyless_macro_arg; \ @@ -3077,7 +3076,7 @@ FILE *grib_yyget_out (void) /** Get the length of the current token. * */ -grib_yy_size_t grib_yyget_leng (void) +int grib_yyget_leng (void) { return grib_yyleng; } diff --git a/src/grib_loader_from_handle.cc b/src/grib_loader_from_handle.cc index ea85b0310..7b6161310 100644 --- a/src/grib_loader_from_handle.cc +++ b/src/grib_loader_from_handle.cc @@ -80,7 +80,7 @@ int grib_init_accessor_from_handle(grib_loader* loader, grib_accessor* ga, grib_ if (default_value) { grib_context_log(h->context, GRIB_LOG_DEBUG, "Copying: setting %s to default value", ga->name_); - ga->pack_expression(grib_arguments_get_expression(h, default_value, 0)); + ga->pack_expression(default_value->get_expression(h, 0)); } if ((ga->flags_ & GRIB_ACCESSOR_FLAG_NO_COPY) || diff --git a/src/grib_nearest_factory.cc b/src/grib_nearest_factory.cc index 6babc985c..9b4d24893 100644 --- a/src/grib_nearest_factory.cc +++ b/src/grib_nearest_factory.cc @@ -33,7 +33,7 @@ eccodes::geo_nearest::Nearest* grib_nearest_factory(grib_handle* h, grib_argumen { size_t i = 0, num_table_entries = 0; *error = GRIB_NOT_IMPLEMENTED; - char* type = (char*)grib_arguments_get_name(h, args, 0); + char* type = (char*)args->get_name(h, 0); num_table_entries = sizeof(table) / sizeof(table[0]); for (i = 0; i < num_table_entries; i++) { diff --git a/src/grib_yacc.cc b/src/grib_yacc.cc index c8a774711..d59f471d0 100644 --- a/src/grib_yacc.cc +++ b/src/grib_yacc.cc @@ -2459,7 +2459,7 @@ grib_yyreduce: case 35: /* arguments: argument ',' arguments */ #line 319 "griby.y" - { (grib_yyvsp[-2].explist)->next = (grib_yyvsp[0].explist); (grib_yyval.explist) = (grib_yyvsp[-2].explist); } + { (grib_yyvsp[-2].explist)->next_ = (grib_yyvsp[0].explist); (grib_yyval.explist) = (grib_yyvsp[-2].explist); } #line 2464 "y.tab.c" break; @@ -2594,7 +2594,7 @@ grib_yyreduce: { /* ECC-485: Set length to 0 and prepend the new argument */ grib_arguments* a = grib_arguments_new(grib_parser_context, new_accessor_expression(grib_parser_context,(grib_yyvsp[-5].str),0,0),NULL); - a->next = (grib_yyvsp[-2].explist); + a->next_ = (grib_yyvsp[-2].explist); (grib_yyval.act) = grib_action_create_gen(grib_parser_context, (grib_yyvsp[-3].str), "codetable", 0, a, /* length=0 and additional argument */ (grib_yyvsp[-1].explist), (grib_yyvsp[0].lval), NULL, NULL); @@ -2958,7 +2958,7 @@ grib_yyreduce: new_accessor_expression(grib_parser_context,(grib_yyvsp[-3].str),0,0), NULL ); - a->next=(grib_yyvsp[-1].explist); + a->next_=(grib_yyvsp[-1].explist); (grib_yyval.act) = grib_action_create_meta(grib_parser_context, "ITERATOR","iterator",a,NULL, GRIB_ACCESSOR_FLAG_HIDDEN|GRIB_ACCESSOR_FLAG_READ_ONLY,NULL); free((grib_yyvsp[-3].str)); @@ -2974,7 +2974,7 @@ grib_yyreduce: new_accessor_expression(grib_parser_context,(grib_yyvsp[-3].str),0,0), NULL ); - a->next=(grib_yyvsp[-1].explist); + a->next_=(grib_yyvsp[-1].explist); (grib_yyval.act) = grib_action_create_meta(grib_parser_context, "NEAREST","nearest",a,NULL, GRIB_ACCESSOR_FLAG_HIDDEN|GRIB_ACCESSOR_FLAG_READ_ONLY,NULL); free((grib_yyvsp[-3].str)); @@ -2990,7 +2990,7 @@ grib_yyreduce: new_accessor_expression(grib_parser_context,(grib_yyvsp[-3].str),0,0), NULL ); - a->next=(grib_yyvsp[-1].explist); + a->next_=(grib_yyvsp[-1].explist); (grib_yyval.act) = grib_action_create_meta(grib_parser_context, "BOX","box",a,NULL, GRIB_ACCESSOR_FLAG_HIDDEN|GRIB_ACCESSOR_FLAG_READ_ONLY,NULL); free((grib_yyvsp[-3].str)); diff --git a/src/griby.y b/src/griby.y index 823b24c17..8e330938a 100644 --- a/src/griby.y +++ b/src/griby.y @@ -316,7 +316,7 @@ argument_list: empty { $$ = 0; } ; arguments: argument - | argument ',' arguments { $1->next = $3; $$ = $1; } + | argument ',' arguments { $1->next_ = $3; $$ = $1; } ; argument: expression { $$ = grib_arguments_new(grib_parser_context,$1,NULL); } @@ -388,7 +388,7 @@ simple: UNSIGNED '[' INTEGER ']' IDENT default flags { /* ECC-485: Set length to 0 and prepend the new argument */ grib_arguments* a = grib_arguments_new(grib_parser_context, new_accessor_expression(grib_parser_context,$3,0,0),NULL); - a->next = $6; + a->next_ = $6; $$ = grib_action_create_gen(grib_parser_context, $5, "codetable", 0, a, /* length=0 and additional argument */ $7, $8, NULL, NULL); @@ -575,7 +575,7 @@ simple: UNSIGNED '[' INTEGER ']' IDENT default flags new_accessor_expression(grib_parser_context,$2,0,0), NULL ); - a->next=$4; + a->next_=$4; $$ = grib_action_create_meta(grib_parser_context, "ITERATOR","iterator",a,NULL, GRIB_ACCESSOR_FLAG_HIDDEN|GRIB_ACCESSOR_FLAG_READ_ONLY,NULL); free($2); @@ -587,7 +587,7 @@ simple: UNSIGNED '[' INTEGER ']' IDENT default flags new_accessor_expression(grib_parser_context,$2,0,0), NULL ); - a->next=$4; + a->next_=$4; $$ = grib_action_create_meta(grib_parser_context, "NEAREST","nearest",a,NULL, GRIB_ACCESSOR_FLAG_HIDDEN|GRIB_ACCESSOR_FLAG_READ_ONLY,NULL); free($2); @@ -599,7 +599,7 @@ simple: UNSIGNED '[' INTEGER ']' IDENT default flags new_accessor_expression(grib_parser_context,$2,0,0), NULL ); - a->next=$4; + a->next_=$4; $$ = grib_action_create_meta(grib_parser_context, "BOX","box",a,NULL, GRIB_ACCESSOR_FLAG_HIDDEN|GRIB_ACCESSOR_FLAG_READ_ONLY,NULL); free($2); diff --git a/tests/grib_check_param_concepts.cc b/tests/grib_check_param_concepts.cc index e46cbce0c..319217546 100644 --- a/tests/grib_check_param_concepts.cc +++ b/tests/grib_check_param_concepts.cc @@ -12,24 +12,11 @@ * Check GRIB2 parameter concept file e.g. shortName.def, paramId.def */ +#include "expression/grib_expression_class_long.h" +#include "expression/grib_expression_class_functor.h" +#include "expression/grib_expression_class_string.h" #include "grib_api_internal.h" -typedef struct grib_expression_long { - grib_expression base; - long value; -} grib_expression_long; - -typedef struct grib_expression_functor { - grib_expression base; - char* name; - grib_arguments* args; -} grib_expression_functor; - -typedef struct grib_expression_string { - grib_expression base; - char* value; -} grib_expression_string; - static int type_of_surface_missing(const char* name, const char* value) { /* Surface Type is Code Table 4.5 in which 255 is the same as missing */ @@ -95,26 +82,30 @@ static int grib_check_param_concepts(const char* key, const char* filename) } } while (concept_condition) { - char condition_value[512] = {0,}; - grib_expression* expression = concept_condition->expression; + char condition_value[512] = {0, }; + eccodes::Expression* expression = concept_condition->expression; const char* condition_name = concept_condition->name; /* printf("%s\n", concept_value->name); */ /* condition_name is discipline, parameterCategory etc. */ - if (strcmp(expression->cclass->name, "long") == 0) { - grib_expression_long* el = (grib_expression_long*)expression; - snprintf(condition_value, sizeof(condition_value), "%ld", el->value); + if (strcmp(expression->class_name(), "long") == 0) { + eccodes::expression::Long* el = dynamic_cast(expression); + long value; + el->evaluate_long(NULL, &value); + snprintf(condition_value, sizeof(condition_value), "%ld", value); } - else if (strcmp(expression->cclass->name, "functor") == 0) { - grib_expression_functor* ef = (grib_expression_functor*)expression; - snprintf(condition_value, sizeof(condition_value), "%s", ef->name); + else if (strcmp(expression->class_name(), "functor") == 0) { + eccodes::expression::Functor* ef = dynamic_cast(expression); + snprintf(condition_value, sizeof(condition_value), "%s", ef->name()); } - else if (strcmp(expression->cclass->name, "string") == 0) { - grib_expression_string* es = (grib_expression_string*)expression; - snprintf(condition_value, sizeof(condition_value), "%s", es->value); + else if (strcmp(expression->class_name(), "string") == 0) { + eccodes::expression::String* es = dynamic_cast(expression); + int error; + const char* value = es->evaluate_string(NULL, NULL, NULL, &error); + snprintf(condition_value, sizeof(condition_value), "%s", value); } else { fprintf(stderr, "%s %s: Unknown class name: '%s'\n", - key, concept_value->name, expression->cclass->name); + key, concept_value->name, expression->class_name()); Assert(0); } if (!isLocal && strcmp(condition_name, "localTablesVersion") == 0) { diff --git a/tests/list_codetable_flagtable_keys.cc b/tests/list_codetable_flagtable_keys.cc index 3d2d5da71..cf7b27144 100644 --- a/tests/list_codetable_flagtable_keys.cc +++ b/tests/list_codetable_flagtable_keys.cc @@ -65,7 +65,7 @@ static void print_names(grib_action* a) grib_action_gen* ag = (grib_action_gen*)a; if (strcmp(a->op,"codetable")==0 || strcmp(a->op,"codeflag")==0) { printf("%s", a->name); - table = grib_arguments_get_string(NULL, ag->params, 0); + table = ag->params->get_string(NULL, 0); if (table) printf("\t%s=%s", a->op, table); printf("\n"); }