Hi list,
I am doing some work that should convert integer datasets
automatically from a larger integer type in memory, to a smaller
integer type on disk, when appropriate.
To give a concrete example: I might have code that converts a uint32_t
dataset in memory to a uint16_t dataset on disk if it turns out that
the values in the in-memory dataset all can be expressed losslessly in
16 bits.
The problem is that I wish to allow for the possibility of one
specific value that does *not* fit in 16 bits, which however I'd like
to translate to a suitable 16-bit replacement value on disk. That is:
if (memValue == (uint32_t)(-1))
diskValue = (uint16_t)(-1); /* Quietly replace all instances of
4294967295 in RAM with 65535 on-disk */
It seems clear that in order to effect this automatic replacement, I
need to write a callback to be given to H5Pset_type_conv_cb() that
will catch overflows and make them instead quietly translate the
out-of-range value to the desired replacement value. What I don't
understand is what code should go in the body of the callback function
to do this. (Feel free to assume that the only out-of-range value
that might occur will be the specific value I wish to translate.)
I've not been able to find any examples showing how to write such a
callback function online. Advice would be greatly appreciated!
Thanks in advance,
--
Kevin B. McCarty
<[email protected]>
_______________________________________________
Hdf-forum is for HDF software users discussion.
[email protected]
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter: https://twitter.com/hdf5