Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extend supported stl types for std::array #55

Closed
nevion opened this issue Feb 26, 2020 · 3 comments
Closed

extend supported stl types for std::array #55

nevion opened this issue Feb 26, 2020 · 3 comments

Comments

@nevion
Copy link

nevion commented Feb 26, 2020

I think I see 2 spaces where std::array should be incorporated

The first is in simply writing or reading std::array<T, N> to a dataset/attribute.

The second is writing a collection of std::array<T, N>, like std::vector<std::array<T, N>>

@steven-varga
Copy link
Owner

Next version will have native STL support, until then you can obtain the pointer to std::array with data() then use h5::write template for typed pointers, with the correct/desired dimensions

[...]
std::array<double,5> my_data = {1,2,3,4,5};
h5::write("my_file.h5", "my_dataset", my_array.data(), 
   h5::max_dims{30,40,50}, // maximum size of file space
   h5::count{5,1,1},       // size of memory space
   h5::offset{5,0,0});     // the start of location/coordinates in file space  

std::vector<std::array<T, N>> is a bit trickier, as of now can only be done if you know details of the HDF5 format, ragged arrays in particular. In any event this will be and many more combinations in the upcoming version. Here is the list of objects .

@nevion
Copy link
Author

nevion commented Feb 27, 2020

Hmm, ess's h5cpp ( as well as my old dead project) did this pretty easily, re the std::vector handler, you just need to recursively construct the type T's h5 type; no need to bring in the dreaded vlen: https://github.com/ess-dmsc/h5cpp/blob/2cfb0adae60d847f95d692374df5a69732c2c0e2/src/h5cpp/datatype/type_trait.hpp#L217 . Does make the assumption of types though; however I've only ever needed this for fixed size types (except std::vectorstd::string ...)

Understood you're working on the whole system of type support though.

@steven-varga
Copy link
Owner

yes you are correct, the particular type is indeed a standard layout, the std::array<std::vector,N) and similar variants fall under VLEN category. The types are 'reasoned' as opposed to 'baked in'.

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

No branches or pull requests

2 participants