1XDF_CLOSEST_TYPE(3) xdffileio library manual XDF_CLOSEST_TYPE(3)
2
3
4
6 xdf_closest_type - Returns a compatible data type
7
9 #include <xdfio.h>
10
11 int xdf_closest_type(struct xdf* xdf, enum xdftype target);
12
14 xdf_closest_type() selects among the data types supported by the file
15 referenced by xdf the type that is the closest to the target argument.
16 The selected type can then be safely used in a call to
17 xdf_set_chconf(3) with the XDF_CF_STOTYPE field.
18
19 The selection algorithm is based on the 3 following criterions (cited
20 by priority, i.e. most important cited first): data size,
21 signed/unsigned type, float/integer value. The data size criterion
22 forces the selected type to have a data size (number of byte to repre‐
23 sent the value) equal or bigger than the one of the target type (with a
24 preference with sizes the closest to the size of target). The
25 signed/unsigned criterion tries to select a type that has the same
26 signeness (signed or unsigned data type) as the target. Finally the
27 float/integer criterion tries to select a floating point type if target
28 is float or double or an integer data type if target is an integer
29 type.
30
31 As a consequence, if target is supported by the underlying file format
32 of xdf, the function is ensured to return target.
33
35 xdf_closest_type() returns the selected data type in case of success,
36 otherwise -1 and errno is set appropriately.
37
39 EINVAL the xdf pointer is NULL, or the argument type is not an admissi‐
40 ble enum xdftype value.
41
43 xdf_set_chconf(3)
44
45
46
47
48
49
50EPFL 2010 XDF_CLOSEST_TYPE(3)