Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ jobs:
os: ubuntu-latest
pkgs: 'libboost-all-dev libeigen3-dev libopencv-dev'
flags: '-DHIGHFIVE_USE_EIGEN:Bool=ON -DHIGHFIVE_USE_OPENCV:Bool=ON -GNinja'
- config:
os: ubuntu-20.04
pkgs: 'libboost-all-dev'
flags: '-DCMAKE_CXX_STANDARD=17'

steps:
- uses: actions/checkout@v3
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ if(HIGHFIVE_USE_XTENSOR)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()

add_compile_definitions(HIGHFIVE_CXX_STD=${CMAKE_CXX_STANDARD})

# Search dependencies (hdf5, boost, eigen, xtensor, mpi) and build target highfive_deps
include(${PROJECT_SOURCE_DIR}/CMake/HighFiveTargetDeps.cmake)
Expand Down
11 changes: 11 additions & 0 deletions include/highfive/bits/H5DataType_misc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
#include <string>
#include <complex>
#include <cstring>
#if HIGHFIVE_CXX_STD >= 17
#include <cstddef>
#endif

#include <H5Ppublic.h>
#include <H5Tpublic.h>
Expand Down Expand Up @@ -166,6 +169,14 @@ inline AtomicType<std::string>::AtomicType() {
_hid = create_string(H5T_VARIABLE);
}

#if HIGHFIVE_CXX_STD >= 17
// std byte
template <>
inline AtomicType<std::byte>::AtomicType() {
_hid = H5Tcopy(H5T_NATIVE_B8);
}
#endif

// Fixed-Length strings
// require class specialization templated for the char length
template <size_t StrLen>
Expand Down
30 changes: 30 additions & 0 deletions tests/unit/test_all_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,33 @@ TEMPLATE_TEST_CASE("Scalar in std::vector<std::array>", "[Types]", bool, std::st
CHECK(value.size() == 5);
}
}

#if HIGHFIVE_CXX_STD >= 17
TEMPLATE_PRODUCT_TEST_CASE("Scalar in std::vector<std::byte>", "[Types]", std::vector, std::byte) {
const std::string FILE_NAME("Test_vector_byte.h5");
const std::string DATASET_NAME("dset");
TestType t1(5, std::byte(0xCD));

{
// Create a new file using the default property lists.
File file(FILE_NAME, File::ReadWrite | File::Create | File::Truncate);

// Create the dataset
DataSet dataset = file.createDataSet(DATASET_NAME, {5}, create_datatype<std::byte>());

// Write into the initial part of the dataset
dataset.write(t1);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Despite the above tests not doing it, it might be nice to also check:

        auto dataset2 = file.createDataSet(DATASET_NAME2, t1);

We could leave this for when we refactor the whole file to be more DRY.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I leave this for the refactoring later.

}

// read it back
{
File file(FILE_NAME, File::ReadOnly);

TestType value(5, std::byte(0xCD));
DataSet dataset = file.getDataSet("/" + DATASET_NAME);
dataset.read(value);
CHECK(t1 == value);
CHECK(value.size() == 5);
}
}
#endif