Clean up of include files

This commit is contained in:
Shahram Najm 2023-04-20 12:40:11 +01:00
parent c4392c83d5
commit e3fb4e1817
7 changed files with 21 additions and 15 deletions

View File

@ -9,7 +9,7 @@
*/
#include "grib_api_internal.h"
#include <type_traits>
// #include <type_traits>
/*
This is used by make_class.pl

View File

@ -9,8 +9,8 @@
*/
#include "grib_api_internal_cpp.h"
#include <typeinfo>
#include <type_traits>
// #include <typeinfo>
// #include <type_traits>
/*
This is used by make_class.pl

View File

@ -9,7 +9,7 @@
*/
#include "grib_api_internal_cpp.h"
#include <type_traits>
// #include <type_traits>
/*
This is used by make_class.pl

View File

@ -9,7 +9,7 @@
*/
#include "grib_api_internal_cpp.h"
#include <type_traits>
// #include <type_traits>
#include <math.h>
/*
This is used by make_class.pl

View File

@ -10,7 +10,7 @@
#include "grib_api_internal.h"
#include <type_traits>
// #include <type_traits>
/*
This is used by make_class.pl

View File

@ -14,11 +14,11 @@
* Shahram Najm *
***************************************************************************/
#include "grib_api_internal.h"
#include <typeinfo>
//#include <typeinfo>
#include <limits>
#include <cassert>
#include <type_traits>
//#include <type_traits>
#include "grib_api_internal_cpp.h"
/*
This is used by make_class.pl
@ -326,7 +326,7 @@ static int unpack(grib_accessor* a, T* v, size_t* len)
size_t l = 1;
grib_unpack_long(a, &val, &l);
*v = val;
grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting long %s to %s", a->name, typeid(T).name());
grib_context_log(a->context, GRIB_LOG_DEBUG, "Casting long %s to %s", a->name, type_to_string<T>(*v));
return GRIB_SUCCESS;
}

View File

@ -1,8 +1,12 @@
#pragma once
#include "grib_api_internal.h"
#include <typeinfo>
#include <type_traits>
//#include <typeinfo>
//#include <type_traits>
template<typename T> const char* type_to_string(T) { return "unknown"; }
template<> inline const char* type_to_string<>(double) { return "double"; }
template<> inline const char* type_to_string<>(float) { return "float"; }
template <typename T>
int grib_get_array(const grib_handle* h, const char* name, T* val, size_t* length);
@ -13,10 +17,12 @@ int grib_get_array_internal(const grib_handle* h, const char* name, T* val, size
static_assert(std::is_floating_point<T>::value, "Requires floating point numbers");
int ret = grib_get_array<T>(h, name, val, length);
if (ret != GRIB_SUCCESS)
if (ret != GRIB_SUCCESS) {
// Note: typeid(T).name() returns "f" or "d". Not very helpful
grib_context_log(h->context, GRIB_LOG_ERROR,
"unable to get %s as %s array (%s)",
name, typeid(T).name(), grib_get_error_message(ret));
"unable to get %s as %s array (each array element being %zu bytes): %s",
name, type_to_string<T>(*val), sizeof(T), grib_get_error_message(ret));
}
return ret;
}