/* Hdf_common.hpp */ #ifndef HDF_COMMON_HPP #define HDF_COMMON_HPP #include #include /* for to_string */ #include "mfhdf.h" #include namespace Hdf_common { const char *hdf_access_mode(const int32 mode); std::string hdf_type_info(const int32 data_type); const int32 hdf_int32_type(const char* data_type); const char *hdf_cstr_type(const int32 data_type); // static buffer inside template const char *hdf_cstr_type(); // static buffer inside size_t hdf_sizeof(const int32 data_type); size_t hdf_sizeof(const char* data_type); const char *hdf_format_string(const int32 data_type); // static buffer inside template std::string to_string(const num_type &i); } template const char *hdf_cstr_type() { static char cstr_type[10]; if (typeid(Hdf_Type)==typeid(uchar8)) strcpy(cstr_type, "uchar8"); else if (typeid(Hdf_Type)==typeid(char8)) strcpy(cstr_type, "char8"); else if (typeid(Hdf_Type)==typeid(uint8)) strcpy(cstr_type, "uint8"); else if (typeid(Hdf_Type)==typeid(int8)) strcpy(cstr_type, "int8"); else if (typeid(Hdf_Type)==typeid(uint16)) strcpy(cstr_type, "uint16"); else if (typeid(Hdf_Type)==typeid(int16)) strcpy(cstr_type, "int16"); else if (typeid(Hdf_Type)==typeid(uint32)) strcpy(cstr_type, "uint32"); else if (typeid(Hdf_Type)==typeid(int32)) strcpy(cstr_type, "int32"); else if (typeid(Hdf_Type)==typeid(float32)) strcpy(cstr_type, "float32"); else if (typeid(Hdf_Type)==typeid(float64)) strcpy(cstr_type, "float64"); else strcpy(cstr_type, "unknown"); return cstr_type; }; template std::string Hdf_common::to_string(const num_type &i) { std::ostringstream oss; oss << i; return oss.str(); }; /** * an attribute can be issued of different object : either a File, a Sds, a VData... This enum defines it */ typedef enum{ HDF_UNKNOWN, HDF_FILE, SDS, VDATA, VDATA_FIELD, } attribute_parent; #endif