From 03a187f0635288649164114aea0968d90a50bdd7 Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Sun, 11 Dec 2016 16:26:17 +0100 Subject: [PATCH] Added string support --- src/hdf5_array.hpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/hdf5_array.hpp b/src/hdf5_array.hpp index 43c5221..f9835a1 100644 --- a/src/hdf5_array.hpp +++ b/src/hdf5_array.hpp @@ -202,6 +202,29 @@ namespace CosmoTool { } }; + class hdf5_StringType + { + public: + H5::StrType type; + + hdf5_StringType() + : type(0, H5T_VARIABLE) + { + } + + static const hdf5_StringType *ctype() + { + static hdf5_StringType singleton; + return &singleton; + } + }; + + template<> struct get_hdf5_data_type { + static H5::DataType type() { + return hdf5_StringType::ctype()->type; + } + }; + class hdf5_BoolType { public: @@ -326,7 +349,7 @@ namespace CosmoTool { H5::DataSpace dataspace = dataset.getSpace(); std::vector dimensions(data.num_dimensions()); - if (dataspace.getSimpleExtentNdims() != data.num_dimensions()) + if ((size_t)dataspace.getSimpleExtentNdims() != (size_t)data.num_dimensions()) { throw InvalidDimensions(); }