Skip to content

Commit

Permalink
Merge pull request #651 from achilleas-k/bitfield-read
Browse files Browse the repository at this point in the history
Read bitfields as booleans
  • Loading branch information
jgrewe committed Nov 13, 2016
2 parents 87c5e6c + 27f645a commit 9f991b7
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions backend/hdf5/h5x/H5DataType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,13 @@

#include "H5DataType.hpp"

#include <stdexcept>
#include <iostream>
#include <cassert>
#include <string>
#include <memory>
#include <cstdlib>

namespace nix {
namespace hdf5 {
namespace h5x {


DataType DataType::copy(hid_t source) {
DataType hi_copy = H5Tcopy(source);
hi_copy.check("Could not copy type");
Expand Down Expand Up @@ -163,6 +159,11 @@ bool DataType::enum_equal(const DataType &other) const {

} // h5x

static herr_t bitfield2bool(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t nl, size_t buf_stride, size_t bkg_stride, void *buf_i,
void *bkg_i, hid_t dxpl) {
return 0;
}

h5x::DataType make_file_booltype() {
h5x::DataType booltype = h5x::DataType::makeEnum(H5T_NATIVE_INT8);
Expand All @@ -175,6 +176,8 @@ h5x::DataType make_mem_booltype() {
h5x::DataType booltype = h5x::DataType::make(H5T_ENUM, sizeof(bool));
booltype.insert("FALSE", false);
booltype.insert("TRUE", true);
// Register converter for old-style boolean (bitfield)
H5Tregister(H5T_PERS_SOFT, "bitfield2bool", H5T_STD_B8LE, booltype.h5id(), bitfield2bool);
return booltype;
}

Expand Down Expand Up @@ -214,6 +217,7 @@ h5x::DataType data_type_to_h5_filetype(DataType dtype) {
throw std::invalid_argument("Unkown DataType"); //FIXME
}


h5x::DataType data_type_to_h5_memtype(DataType dtype) {

// See data_type_to_h5_filetype for the reason why the switch is structured
Expand Down

0 comments on commit 9f991b7

Please sign in to comment.