Property lists: H5copy_prop (advanced)

HDF5 uses property lists to set values which if were added to C API calls as arguments would result overly complex C calls. As an example:
hid_t H5Dcreate( hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t dcpl_id );
manages nicely with dcpl_id to control in what manner datasets are created. There are many other property lists as well controlling some important or less important aspects of HDF5 objects.

In fact there is a set of dedicated C API calls H5Pxxx to manage these properties, and my question is about H5Pcopy_prop
herr_t H5Pcopy_prop( hid_t dst_id, hid_t src_id, const char name )
The documentation is clear, with the exception of how to get the name of the property to be copied.
In the source hdf5/src/H5Dprivate.h
#define H5D_CRT_LAYOUT_NAME “layout” /
Storage layout */
reveals that what layout property is called, but I can’t seem to find relationship between many other properties: chunk, deflate, fletcher32

motivation: using a single copy properties could reduce boiler plate code when implementing manipulators for property lists

steven

Hi Steven,
Can you use H5Pcopy() instead? That copies the entire property list, instead of individual properties, and is more likely to be what you’d like for the predefined HDF5 properties (like dataset layout, etc). The H5Pcopy_prop() is targeted at application-defined properties, where the property name is known to the application (because they defined it with H5Pinsert).

Quincey

Hi Quincey,

thank you for the reply! I am doing a merge/sequential update on properties with the following syntax in C++:
h5::dcpl_t dcpl = h5::chunks{1,4,5} | h5::deflate{4} | h5::layout_compact | h5::dont_filter_partial_chunks | h5::fill_value<my_struct>{init_data} | h5::fill_time_never | h5::alloc_time_early | h5::fletcher32 | h5::shuffle | h5::nbit;
The right hand side are temporaries which are merged into a single typesafe/templated hid_t by updating and moving the right most hid_t identifier to left until it hits the assignment operator.
I think the H5Pcopy would wipe out the already set values?

By now I worked out a more verbose solution with macros/template metaprogramming.
Then again, if you happened to know how to merge them more elegantly?

steve

Hi Steve,
Very nice! :slight_smile: I’m not certain about the C++ aspects of this, but H5Pcopy will duplicate the property list, including property values that were set on the property list being duplicated.

	Quincey