Skip to content

Commit

Permalink
Consistent casing for Dataset, Datatype, Dataspace
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Smith committed Jan 11, 2023
1 parent 7acd30e commit bd07df1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 21 deletions.
6 changes: 3 additions & 3 deletions modules/c++/hdf5.lite/include/hdf5/lite/HDF5Exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ namespace lite
*/
CODA_OSS_DECLARE_EXCEPTION(HDF5);

CODA_OSS_DECLARE_EXTENDED_EXCEPTION(DataSet, hdf5::lite::HDF5Exception)
CODA_OSS_DECLARE_EXTENDED_EXCEPTION(DataSpace, hdf5::lite::HDF5Exception)
CODA_OSS_DECLARE_EXTENDED_EXCEPTION(DataType, hdf5::lite::HDF5Exception)
CODA_OSS_DECLARE_EXTENDED_EXCEPTION(Dataset, hdf5::lite::HDF5Exception)
CODA_OSS_DECLARE_EXTENDED_EXCEPTION(Dataspace, hdf5::lite::HDF5Exception)
CODA_OSS_DECLARE_EXTENDED_EXCEPTION(Datatype, hdf5::lite::HDF5Exception)

}
}
Expand Down
30 changes: 16 additions & 14 deletions modules/c++/hdf5.lite/source/Read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,35 @@

static void read(const H5::DataSet& dataset, std::vector<double>& result)
{
static_assert(sizeof(double) * 8 == 64, "'double' should be 64-bits"); // IEEE_F64LE

const auto mem_type = dataset.getDataType();
if (mem_type != H5::PredType::NATIVE_DOUBLE)
if (mem_type != H5::PredType::IEEE_F64LE)
{
const except::Context context("mem_type != IEEE_F64LE", __FILE__, __LINE__, "read");
throw hdf5::lite::DataSetException(context);
const except::Context context("getDataType() != IEEE_F64LE", __FILE__, __LINE__, "read");
throw hdf5::lite::DatasetException(context);
}
dataset.read(result.data(), mem_type);
}
static void read(const H5::DataSet& dataset, std::vector<float>& result)
{
static_assert(sizeof(float) * 8 == 32, "'float' should be 32-bits"); // IEEE_F32LE

const auto mem_type = dataset.getDataType();
if (mem_type != H5::PredType::NATIVE_FLOAT)
if (mem_type != H5::PredType::IEEE_F32LE)
{
const except::Context context("mem_type != IEEE_F32LE", __FILE__, __LINE__, "read");
throw hdf5::lite::DataSetException(context);
const except::Context context("getDataType() != IEEE_F32LE", __FILE__, __LINE__, "read");
throw hdf5::lite::DatasetException(context);
}
dataset.read(result.data(), mem_type);
}
template<typename T>
static types::RowCol<size_t> readDatasetT(const H5::DataSet& dataset, H5T_class_t type_class,
std::vector<T>& result)
static types::RowCol<size_t> readDatasetT(const H5::DataSet& dataset, std::vector<T>& result)
{
if (type_class != dataset.getTypeClass())
if (dataset.getTypeClass() != H5T_FLOAT)
{
throw std::invalid_argument("getTypeClass() returned wrong value.");
const except::Context context("getTypeClass() != H5T_FLOAT", __FILE__, __LINE__, "readDatasetT");
throw hdf5::lite::DatatypeException(context);
}

const auto retval = hdf5::lite::details::getSimpleExtentSize(dataset);
Expand All @@ -72,13 +76,11 @@ static types::RowCol<size_t> readDatasetT(const H5::DataSet& dataset, H5T_class_

inline types::RowCol<size_t> readDataset_(const H5::DataSet& dataset, std::vector<float>& result)
{
static_assert(sizeof(float) * 8 == 32, "'float' should be 32-bits"); // IEEE_F32LE
return readDatasetT(dataset, H5T_FLOAT, result);
return readDatasetT(dataset, result);
}
inline types::RowCol<size_t> readDataset_(const H5::DataSet& dataset, std::vector<double>& result)
{
static_assert(sizeof(double) * 8 == 64, "'double' should be 64-bits"); // IEEE_F64LE
return readDatasetT(dataset, H5T_FLOAT, result);
return readDatasetT(dataset, result);
}
template<typename T>
static types::RowCol<size_t> readFile_(const coda_oss::filesystem::path& fileName, const std::string& datasetName,
Expand Down
6 changes: 3 additions & 3 deletions modules/c++/hdf5.lite/source/hdf5.lite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,18 @@ void hdf5::lite::details::try_catch_H5Exceptions_(std::function<void(void*)> f,
// catch failure caused by the DataSet operations
catch (const H5::DataSetIException& error)
{
throw hdf5::lite::DataSetException(make_Context(error, file, line));
throw hdf5::lite::DatasetException(make_Context(error, file, line));
}

// catch failure caused by the DataSpace operations
catch (const H5::DataSpaceIException& error)
{
throw hdf5::lite::DataSpaceException(make_Context(error, file, line));
throw hdf5::lite::DataspaceException(make_Context(error, file, line));
}

// catch failure caused by the DataType operations
catch (const H5::DataTypeIException& error)
{
throw hdf5::lite::DataTypeException(make_Context(error, file, line));
throw hdf5::lite::DatatypeException(make_Context(error, file, line));
}
}
2 changes: 1 addition & 1 deletion modules/c++/hdf5.lite/unittests/test_hdf5read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ TEST_CASE(test_hdf5Read_nested_small_wrongType)
std::vector<double> data;
TEST_SPECIFIC_EXCEPTION(
hdf5::lite::readFile(path, "/Data/1/bar/cat/a/r", data),
hdf5::lite::DataSetException);
hdf5::lite::DatasetException);
}

TEST_MAIN(
Expand Down

0 comments on commit bd07df1

Please sign in to comment.