1 /**
2   HDF5 bindings
3 
4   This file is part of HDF5.  The full HDF5 copyright notice, including     *
5   terms governing use, modification, and redistribution, is contained in    *
6   the files COPYING and Copyright.html.  COPYING can be found at the root   *
7   of the source code distribution tree; Copyright.html can be found at the  *
8   root level of an installed copy of the electronic HDF5 document set and   *
9   is linked from the top-level documents page.  It can also be found at     *
10   http://hdfgroup.org/HDF5/doc/Copyright.html.  If you do not have          *
11   access to either file, you may request a copy from help@hdfgroup.org.     *
12   * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
13   Ported to D by Laeeth Isharc 2014
14   Borrowed heavily in terms of C API declarations from https://github.com/SFrijters/hdf5-d
15   Stefan Frijters bindings for D
16 
17   Bindings probably not yet complete or bug-free.
18 
19   Consider this not even alpha stage.  It probably isn't so far away from being useful though.
20   This is written for Linux and will need modification to work on other platforms.
21 
22   Modified by Shigeki Karita 2018
23  */
24 module grain.hdf5;
25 
26 extern (C):
27 
28 /// NOTE: changed from int to int64_t at 1.10.0
29 alias hid_t = long;
30 ///
31 alias hsize_t = ulong;
32 ///
33 alias hssize_t = long;
34 ///
35 alias herr_t = int;
36 
37 /** Define atomic datatypes */
38 enum H5S_ALL = 0;
39 ///
40 enum H5S_UNLIMITED = (cast(hsize_t) cast(hssize_t)(-1));
41 /** Define user-level maximum number of dimensions */
42 enum H5S_MAX_RANK = 32;
43 
44 // this ddoc make adrdox die
45 
46 // absence of rdwr => rd-only
47 enum H5F_ACC_RDONLY = 0x0000u;
48 // open for read and write
49 enum H5F_ACC_RDWR = 0x0001u;
50 // overwrite existing files
51 enum H5F_ACC_TRUNC = 0x0002u;
52 // fail if file already exists
53 enum H5F_ACC_EXCL = 0x0004u;
54 // print debug info
55 enum H5F_ACC_DEBUG = 0x0008u;
56 // create non-existing files
57 enum H5F_ACC_CREAT = 0x0010u;
58 
59 // Value passed to H5Pset_elink_acc_flags to cause flags to be taken from the parent file.
60 enum H5F_ACC_DEFAULT = 0xffffu; /*ignore setting on lapl     */
61 
62 // Default value for all property list classes 
63 enum H5P_DEFAULT = 0;
64 
65 /* The IEEE floating point types in various byte orders. */
66 alias H5T_IEEE_F32BE = H5T_IEEE_F32BE_g;
67 alias H5T_IEEE_F32LE = H5T_IEEE_F32LE_g;
68 alias H5T_IEEE_F64BE = H5T_IEEE_F64BE_g;
69 alias H5T_IEEE_F64LE = H5T_IEEE_F64LE_g;
70 extern __gshared hid_t H5T_IEEE_F32BE_g;
71 extern __gshared hid_t H5T_IEEE_F32LE_g;
72 extern __gshared hid_t H5T_IEEE_F64BE_g;
73 extern __gshared hid_t H5T_IEEE_F64LE_g;
74 
75 /*
76  * These are "standard" types.  For instance, signed (2's complement) and
77  * unsigned integers of various sizes and byte orders.
78  */
79 alias H5T_STD_I8BE = H5T_STD_I8BE_g;
80 alias H5T_STD_I8LE = H5T_STD_I8LE_g;
81 alias H5T_STD_I16BE = H5T_STD_I16BE_g;
82 alias H5T_STD_I16LE = H5T_STD_I16LE_g;
83 alias H5T_STD_I32BE = H5T_STD_I32BE_g;
84 alias H5T_STD_I32LE = H5T_STD_I32LE_g;
85 alias H5T_STD_I64BE = H5T_STD_I64BE_g;
86 alias H5T_STD_I64LE = H5T_STD_I64LE_g;
87 alias H5T_STD_U8BE = H5T_STD_U8BE_g;
88 alias H5T_STD_U8LE = H5T_STD_U8LE_g;
89 alias H5T_STD_U16BE = H5T_STD_U16BE_g;
90 alias H5T_STD_U16LE = H5T_STD_U16LE_g;
91 alias H5T_STD_U32BE = H5T_STD_U32BE_g;
92 alias H5T_STD_U32LE = H5T_STD_U32LE_g;
93 alias H5T_STD_U64BE = H5T_STD_U64BE_g;
94 alias H5T_STD_U64LE = H5T_STD_U64LE_g;
95 alias H5T_STD_B8BE = H5T_STD_B8BE_g;
96 alias H5T_STD_B8LE = H5T_STD_B8LE_g;
97 alias H5T_STD_B16BE = H5T_STD_B16BE_g;
98 alias H5T_STD_B16LE = H5T_STD_B16LE_g;
99 alias H5T_STD_B32BE = H5T_STD_B32BE_g;
100 alias H5T_STD_B32LE = H5T_STD_B32LE_g;
101 alias H5T_STD_B64BE = H5T_STD_B64BE_g;
102 alias H5T_STD_B64LE = H5T_STD_B64LE_g;
103 alias H5T_STD_REF_OBJ = H5T_STD_REF_OBJ_g;
104 alias H5T_STD_REF_DSETREG = H5T_STD_REF_DSETREG_g;
105 extern __gshared hid_t H5T_STD_I8BE_g;
106 extern __gshared hid_t H5T_STD_I8LE_g;
107 extern __gshared hid_t H5T_STD_I16BE_g;
108 extern __gshared hid_t H5T_STD_I16LE_g;
109 extern __gshared hid_t H5T_STD_I32BE_g;
110 extern __gshared hid_t H5T_STD_I32LE_g;
111 extern __gshared hid_t H5T_STD_I64BE_g;
112 extern __gshared hid_t H5T_STD_I64LE_g;
113 extern __gshared hid_t H5T_STD_U8BE_g;
114 extern __gshared hid_t H5T_STD_U8LE_g;
115 extern __gshared hid_t H5T_STD_U16BE_g;
116 extern __gshared hid_t H5T_STD_U16LE_g;
117 extern __gshared hid_t H5T_STD_U32BE_g;
118 extern __gshared hid_t H5T_STD_U32LE_g;
119 extern __gshared hid_t H5T_STD_U64BE_g;
120 extern __gshared hid_t H5T_STD_U64LE_g;
121 extern __gshared hid_t H5T_STD_B8BE_g;
122 extern __gshared hid_t H5T_STD_B8LE_g;
123 extern __gshared hid_t H5T_STD_B16BE_g;
124 extern __gshared hid_t H5T_STD_B16LE_g;
125 extern __gshared hid_t H5T_STD_B32BE_g;
126 extern __gshared hid_t H5T_STD_B32LE_g;
127 extern __gshared hid_t H5T_STD_B64BE_g;
128 extern __gshared hid_t H5T_STD_B64LE_g;
129 extern __gshared hid_t H5T_STD_REF_OBJ_g;
130 extern __gshared hid_t H5T_STD_REF_DSETREG_g;
131 
132 ///
133 hid_t H5Fcreate(const char* filename, uint flags, hid_t create_plist, hid_t access_plist);
134 ///
135 hid_t H5Fopen(const char* filename, uint flags, hid_t access_plist);
136 ///
137 herr_t H5Fclose(hid_t file_id);
138 
139 ///
140 hid_t H5Screate_simple(int rank, const hsize_t* dims, const hsize_t* maxdims);
141 ///
142 herr_t H5Sclose(hid_t space_id);
143 
144 ///
145 hid_t H5Dopen2(hid_t file_id, const char* name, hid_t dapl_id);
146 ///
147 hid_t H5Dcreate2(hid_t loc_id, const char* name, hid_t type_id, hid_t space_id,
148         hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id); //
149 ///
150 herr_t H5Dclose(hid_t dset_id);
151 ///
152 herr_t H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
153         hid_t file_space_id, hid_t plist_id, void* buf /*out*/ );
154 ///
155 herr_t H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
156         hid_t file_space_id, hid_t plist_id, const void* buf);
157 
158 void H5open();
159 
160 shared static this() {
161     H5open();
162 }