Skip to content

feat: add explicit constructor for DataType class#113

Open
StupidBh wants to merge 1 commit intohighfive-devs:mainfrom
StupidBh:main
Open

feat: add explicit constructor for DataType class#113
StupidBh wants to merge 1 commit intohighfive-devs:mainfrom
StupidBh:main

Conversation

@StupidBh
Copy link
Copy Markdown

@StupidBh StupidBh commented Mar 31, 2026

The purpose is to adapt to H5::ArrayType, like this:

struct Grid {
    std::array<double, 3> grid = { 1.0, 2.0, 3.0 };
    static HighFive::CompoundType CompType()
    {
        static constinit hsize_t array_dims[1] = { 3 };
        H5::ArrayType array_type(HDF5Utils::H5_NATIVE_TYPE<double>(), 1, array_dims);

        HighFive::CompoundType result(
            std::vector<HighFive::CompoundType::member_def> {
                { "GRID", HighFive::DataType(array_type.getId()), offsetof(Grid, grid) }
            },
            sizeof(Grid)
        );

        return result;
    }
};

If it is because I have misunderstood the implementation of HighFive, please correct me.
Thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant