1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  * Copyright by The HDF Group.                                               *
3  * Copyright by the Board of Trustees of the University of Illinois.         *
4  * All rights reserved.                                                      *
5  *                                                                           *
6  * This file is part of HDF5.  The full HDF5 copyright notice, including     *
7  * terms governing use, modification, and redistribution, is contained in    *
8  * the COPYING file, which can be found at the root of the source code       *
9  * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.  *
10  * If you do not have access to either file, you may request a copy from     *
11  * help@hdfgroup.org.                                                        *
12  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
13 
14 /*
15  * This file contains private information about the H5T module
16  */
17 #ifndef _H5Tprivate_H
18 #define _H5Tprivate_H
19 
20 /* Early typedefs to avoid circular dependencies */
21 typedef struct H5T_t H5T_t;
22 
23 /* Get package's public header */
24 #include "H5Tpublic.h"
25 
26 /* Other public headers needed by this file */
27 #include "H5MMpublic.h"         /* Memory management                    */
28 
29 /* Private headers needed by this file */
30 #include "H5private.h"          /* Generic Functions                        */
31 #include "H5Gprivate.h"         /* Groups                                   */
32 #include "H5Rprivate.h"         /* References                               */
33 
34 /* Macro for size of temporary buffers to contain a single element */
35 #define H5T_ELEM_BUF_SIZE       256
36 
37 /* If the module using this macro is allowed access to the private variables, access them directly */
38 #ifdef H5T_MODULE
39 #define H5T_GET_SIZE(T)                 ((T)->shared->size)
40 #define H5T_GET_SHARED(T)               ((T)->shared)
41 #define H5T_GET_MEMBER_OFFSET(T, I)     ((T)->u.compnd.memb[I].offset)
42 #define H5T_GET_MEMBER_SIZE(T, I)       ((T)->u.compnd.memb[I].shared->size)
43 #else /* H5T_MODULE */
44 #define H5T_GET_SIZE(T)                 (H5T_get_size(T))
45 #define H5T_GET_SHARED(T)               (H5T_get_shared(T))
46 #define H5T_GET_MEMBER_OFFSET(T, I)     (H5T_get_member_offset((T), (I)))
47 #define H5T_GET_MEMBER_SIZE(T, I)       (H5T_get_member_size((T), (I)))
48 #endif /* H5T_MODULE */
49 
50 /* Forward references of package typedefs (declared in H5Tpkg.h) */
51 typedef struct H5T_stats_t H5T_stats_t;
52 typedef struct H5T_path_t H5T_path_t;
53 
54 /* How to copy a datatype */
55 typedef enum H5T_copy_t {
56     H5T_COPY_TRANSIENT,
57     H5T_COPY_ALL,
58     H5T_COPY_REOPEN
59 } H5T_copy_t;
60 
61 /* Location of datatype information */
62 typedef enum {
63     H5T_LOC_BADLOC =   0,  /* invalid datatype location */
64     H5T_LOC_MEMORY,        /* data stored in memory */
65     H5T_LOC_DISK,          /* data stored on disk */
66     H5T_LOC_MAXLOC         /* highest value (Invalid as true value) */
67 } H5T_loc_t;
68 
69 /* VL allocation information */
70 typedef struct {
71     H5MM_allocate_t alloc_func; /* Allocation function */
72     void *alloc_info;           /* Allocation information */
73     H5MM_free_t free_func;      /* Free function */
74     void *free_info;            /* Free information */
75 } H5T_vlen_alloc_info_t;
76 
77 /* Structure for conversion callback property */
78 typedef struct H5T_conv_cb_t {
79     H5T_conv_except_func_t      func;
80     void*                       user_data;
81 } H5T_conv_cb_t;
82 
83 /* Values for the optimization of compound data reading and writing.  They indicate
84  * whether the fields of the source and destination are subset of each other and
85  * there is no conversion needed.
86  */
87 typedef enum {
88     H5T_SUBSET_BADVALUE = -1,   /* Invalid value */
89     H5T_SUBSET_FALSE = 0,       /* Source and destination aren't subset of each other */
90     H5T_SUBSET_SRC,             /* Source is the subset of dest and no conversion is needed */
91     H5T_SUBSET_DST,             /* Dest is the subset of source and no conversion is needed */
92     H5T_SUBSET_CAP              /* Must be the last value */
93 } H5T_subset_t;
94 
95 typedef struct H5T_subset_info_t {
96     H5T_subset_t    subset;     /* See above */
97     size_t          copy_size;  /* Size in bytes, to copy for each element */
98 } H5T_subset_info_t;
99 
100 /* Forward declarations for prototype arguments */
101 struct H5O_t;
102 
103 /* The native endianness of the platform */
104 H5_DLLVAR H5T_order_t H5T_native_order_g;
105 
106 /* Private functions */
107 H5_DLL herr_t H5T_init(void);
108 H5_DLL H5T_t *H5T_copy(H5T_t *old_dt, H5T_copy_t method);
109 H5_DLL herr_t H5T_lock(H5T_t *dt, hbool_t immutable);
110 H5_DLL herr_t H5T_close(H5T_t *dt);
111 H5_DLL herr_t H5T_close_real(H5T_t *dt);
112 H5_DLL H5T_t *H5T_get_super(const H5T_t *dt);
113 H5_DLL H5T_class_t H5T_get_class(const H5T_t *dt, htri_t internal);
114 H5_DLL htri_t H5T_detect_class(const H5T_t *dt, H5T_class_t cls, hbool_t from_api);
115 H5_DLL size_t H5T_get_size(const H5T_t *dt);
116 H5_DLL int    H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset);
117 H5_DLL herr_t H5T_encode(H5T_t *obj, unsigned char *buf, size_t *nalloc);
118 H5_DLL H5T_t *H5T_decode(size_t buf_size, const unsigned char *buf);
119 H5_DLL herr_t H5T_debug(const H5T_t *dt, FILE * stream);
120 H5_DLL struct H5O_loc_t *H5T_oloc(H5T_t *dt);
121 H5_DLL H5G_name_t *H5T_nameof(H5T_t *dt);
122 H5_DLL htri_t H5T_is_immutable(const H5T_t *dt);
123 H5_DLL htri_t H5T_is_named(const H5T_t *dt);
124 H5_DLL herr_t H5T_convert_committed_datatype(H5T_t *dt, H5F_t *f);
125 H5_DLL htri_t H5T_is_relocatable(const H5T_t *dt);
126 H5_DLL H5T_path_t *H5T_path_find(const H5T_t *src, const H5T_t *dst);
127 H5_DLL hbool_t H5T_path_noop(const H5T_path_t *p);
128 H5_DLL H5T_bkg_t H5T_path_bkg(const H5T_path_t *p);
129 H5_DLL H5T_subset_info_t *H5T_path_compound_subset(const H5T_path_t *p);
130 H5_DLL herr_t H5T_convert(H5T_path_t *tpath, hid_t src_id, hid_t dst_id,
131     size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg);
132 H5_DLL herr_t H5T_vlen_reclaim(void *elem, hid_t type_id, unsigned ndim, const hsize_t *point, void *_op_data);
133 H5_DLL herr_t H5T_vlen_reclaim_elmt(void *elem, H5T_t *dt);
134 H5_DLL htri_t H5T_set_loc(H5T_t *dt, H5F_t *f, H5T_loc_t loc);
135 H5_DLL htri_t H5T_is_sensible(const H5T_t *dt);
136 H5_DLL uint32_t H5T_hash(H5F_t * file, const H5T_t *dt);
137 H5_DLL herr_t H5T_set_version(H5F_t *f, H5T_t *dt);
138 H5_DLL herr_t H5T_patch_file(H5T_t *dt, H5F_t *f);
139 H5_DLL herr_t H5T_patch_vlen_file(H5T_t *dt, H5F_t *f);
140 H5_DLL htri_t H5T_is_variable_str(const H5T_t *dt);
141 H5_DLL htri_t H5T_is_vl_storage(const H5T_t *dt);
142 
143 /* Reference specific functions */
144 H5_DLL H5R_type_t H5T_get_ref_type(const H5T_t *dt);
145 
146 /* Operations on named datatypes */
147 H5_DLL H5T_t *H5T_open(const H5G_loc_t *loc);
148 H5_DLL htri_t H5T_committed(const H5T_t *type);
149 H5_DLL int H5T_link(const H5T_t *type, int adjust);
150 H5_DLL herr_t H5T_update_shared(H5T_t *type);
151 
152 /* Field functions (for both compound & enumerated types) */
153 H5_DLL int H5T_get_nmembers(const H5T_t *dt);
154 H5_DLL H5T_t *H5T_get_member_type(const H5T_t *dt, unsigned membno, H5T_copy_t method);
155 H5_DLL size_t H5T_get_member_offset(const H5T_t *dt, unsigned membno);
156 
157 /* Atomic functions */
158 H5_DLL H5T_order_t H5T_get_order(const H5T_t *dt);
159 H5_DLL size_t H5T_get_precision(const H5T_t *dt);
160 H5_DLL int H5T_get_offset(const H5T_t *dt);
161 
162 /* Fixed-point functions */
163 H5_DLL H5T_sign_t H5T_get_sign(H5T_t const *dt);
164 
165 #endif /* _H5Tprivate_H */
166 
167