H5Eall.hpp
1 /*
2  * Copyright (c) 2018 vargaconsulting, Toronto,ON Canada
3  * Author: Varga, Steven <steven@vargaconsulting.ca>
4  *
5  */
6 
7 
8 #ifndef H5CPP_EALL_HPP
9 #define H5CPP_EALL_HPP
10 namespace h5{
11  using herr_t = ::herr_t;
12 
13  static thread_local herr_t (*error_stack_callback)(::hid_t, void*);
14  static thread_local void * error_stack_client_data;
15 }
16 
17 namespace h5 {
28  inline void mute( ){
29  H5Eget_auto2(H5E_DEFAULT, &error_stack_callback, &error_stack_client_data);
30  H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
31  }
41  inline void unmute( ){
42  H5Eset_auto2(H5E_DEFAULT, error_stack_callback, error_stack_client_data);
43  }
44 }
45 
46 namespace h5 { namespace error {
47  struct any : public std::runtime_error {
48  any() : std::runtime_error("H5CPP ERROR") {}
49  any(const std::string& msg ) : std::runtime_error( msg ){}
50  };
51  struct rollback {
52  rollback(const std::string& msg ) {
53  std::cerr <<"UNRECOVERABLE ERROR:" << msg << std::endl;
54 #ifdef H5CPP_HARD_ERROR
55  exit(1)
56 #endif
57  }
58  };
59  namespace msg {
60  const std::string inc_ref = "couldn't increment reference...";
61  const std::string dec_ref = "couldn't decrement reference...";
62  const std::string create_memspace = "couldn't create memory space...";
63  const std::string select_memspace = "couldn't do memory space selection...";
64  const std::string select_hyperslab = "couldn't do hyper-slab selection...";
65  const std::string get_filespace = "couldn't get file space...";
66  const std::string get_memspace = "couldn't get memory space...";
67  const std::string get_memtype = "couldn't get mem type...";
68  const std::string get_filetype = "couldn't get file type...";
69  const std::string get_filetype_size = "could_t get file type size...";
70  const std::string close_memspace = "could_t close memory space...";
71  const std::string close_filespace = "could_t close file space...";
72  const std::string close_filetype = "could_t close file type...";
73  const std::string close_memtype = "could_t close memory type...";
74  const std::string close_property_list = "couldn't close property list...";
75  const std::string close_group = "couldn't close group/directory...";
76  const std::string get_rank = "couldn't obtain rank...";
77  const std::string get_chunk_dims = "couldn't obtain chunk dimensions...";
78  const std::string get_dims = "couldn't obtain data dimensions...";
79  const std::string mem_alloc = "couldn't allocate memory of requested size...";
80  const std::string set_extent = "couldn't set extent...";
81  const std::string set_chunk = "couldn't set chunk...";
82  const std::string write_dataset = "couldn't write dataset...";
83  const std::string read_dataset = "couldn't read dataset...";
84  const std::string create_dataset = "couldn't create dataset...";
85  const std::string create_file = "couldn't create file...";
86  const std::string create_property_list = "couldn't create property list...";
87  const std::string create_dims = "couldn't create dimension descriptor...";
88  const std::string link_check = "checking if object exists fails...";
89  const std::string open_dataset = "opening dataset failed...";
90  const std::string open_file = "opening hdf5 container failed...";
91  const std::string open_group = "opening directory failed...";
92  const std::string dataset_descriptor = "invalid dataset descriptor ...";
93  const std::string file_descriptor = "invalid file descriptor ...";
94  const std::string file_space = "invalid file space ...";
95  const std::string prop_descriptor = "invalid file descriptor ...";
96  const std::string list_directory = "error traversing directory ...";
97  const std::string rank_mismatch = "rank of file space and mem space must match ...";
98  const std::string get_simple_extent_dims = "???? ...";
99  const std::string get_dataset_type = "???? ...";
100  const std::string create_dcpl = "???? ...";
101  }
102 }}
103 namespace h5 { namespace error { namespace io {
104  struct rollback : public h5::error::rollback {
105  rollback( const std::string& msg ) : h5::error::rollback( msg ){}
106  };
107  struct any : public h5::error::any {
108  any() : h5::error::any() {}
109  any( const std::string& msg ) : h5::error::any( msg ){}
110  };
111 }}}
112 
113 namespace h5 { namespace error { namespace io { namespace file {
114  struct rollback : public h5::error::io::rollback {
115  rollback( const std::string& msg ) : h5::error::io::rollback( msg ){}
116  };
117  struct any : public h5::error::io::any {
118  any() : h5::error::io::any() {}
119  any( const std::string& msg ) : h5::error::io::any( msg ){}
120  };
121  struct open : public h5::error::io::file::any {
122  open() : h5::error::io::file::any() {}
123  open( const std::string& msg ) : h5::error::io::file::any( msg ){}
124  };
125  struct close : public h5::error::io::file::any {
126  close() : h5::error::io::file::any() {}
127  close( const std::string& msg ) : h5::error::io::file::any( msg ){}
128  };
129  struct read : public h5::error::io::file::any {
130  read() : h5::error::io::file::any() {}
131  read( const std::string& msg ) : h5::error::io::file::any( msg ){}
132  };
133  struct write : public h5::error::io::file::any {
134  write() : h5::error::io::file::any() {}
135  write( const std::string& msg ) : h5::error::io::file::any( msg ){}
136  };
137  struct create : public h5::error::io::file::any {
138  create() : h5::error::io::file::any() {}
139  create( const std::string& msg ) : h5::error::io::file::any( msg ){}
140  };
141  struct misc : public h5::error::io::file::any {
142  misc() : h5::error::io::file::any() {}
143  misc( const std::string& msg ) : h5::error::io::file::any( msg ){}
144  };
145 }}}}
146 
147 namespace h5 { namespace error { namespace io { namespace dataset {
148  struct rollback : public h5::error::io::rollback {
149  rollback( const std::string& msg ) : h5::error::io::rollback( msg ){}
150  };
151  struct any : public h5::error::io::any {
152  any() : h5::error::io::any() {}
153  any( const std::string& msg ) : h5::error::io::any( msg ){}
154  };
155  struct open : public h5::error::io::dataset::any {
156  open() : h5::error::io::dataset::any() {}
157  open( const std::string& msg ) : h5::error::io::dataset::any( msg ){}
158  };
159  struct close : public h5::error::io::dataset::any {
160  close() : h5::error::io::dataset::any() {}
161  close( const std::string& msg ) : h5::error::io::dataset::any( msg ){}
162  };
163  struct read : public h5::error::io::dataset::any {
164  read() : h5::error::io::dataset::any() {}
165  read( const std::string& msg ) : h5::error::io::dataset::any( msg ){}
166  };
167  struct write : public h5::error::io::dataset::any {
168  write() : h5::error::io::dataset::any() {}
169  write( const std::string& msg ) : h5::error::io::dataset::any( msg ){}
170  };
171  struct append : public h5::error::io::dataset::any {
172  append() : h5::error::io::dataset::any() {}
173  append( const std::string& msg ) : h5::error::io::dataset::any( msg ){}
174  };
175  struct create : public h5::error::io::dataset::any {
176  create() : h5::error::io::dataset::any() {}
177  create( const std::string& msg ) : h5::error::io::dataset::any( msg ){}
178  };
179  struct misc : public h5::error::io::dataset::any {
180  misc() : h5::error::io::dataset::any() {}
181  misc( const std::string& msg ) : h5::error::io::dataset::any( msg ){}
182  };
183 }}}}
184 namespace h5 { namespace error { namespace io { namespace packet_table {
185  struct rollback : public h5::error::io::rollback {
186  rollback( const std::string& msg ) : h5::error::io::rollback( msg ){}
187  };
188  struct any : public h5::error::io::any {
189  any() : h5::error::io::any() {}
190  any( const std::string& msg ) : h5::error::io::any( msg ){}
191  };
192  struct open : public h5::error::io::packet_table::any {
193  open() : h5::error::io::packet_table::any() {}
194  open( const std::string& msg ) : h5::error::io::packet_table::any( msg ){}
195  };
196  struct close : public h5::error::io::packet_table::any {
197  close() : h5::error::io::packet_table::any() {}
198  close( const std::string& msg ) : h5::error::io::packet_table::any( msg ){}
199  };
200  struct read : public h5::error::io::packet_table::any {
201  read() : h5::error::io::packet_table::any() {}
202  read( const std::string& msg ) : h5::error::io::packet_table::any( msg ){}
203  };
204  struct write : public h5::error::io::packet_table::any {
205  write() : h5::error::io::packet_table::any() {}
206  write( const std::string& msg ) : h5::error::io::packet_table::any( msg ){}
207  };
208  struct append : public h5::error::io::packet_table::any {
209  append() : h5::error::io::packet_table::any() {}
210  append( const std::string& msg ) : h5::error::io::packet_table::any( msg ){}
211  };
212  struct create : public h5::error::io::packet_table::any {
213  create() : h5::error::io::packet_table::any() {}
214  create( const std::string& msg ) : h5::error::io::packet_table::any( msg ){}
215  };
216  struct misc : public h5::error::io::packet_table::any {
217  misc() : h5::error::io::packet_table::any() {}
218  misc( const std::string& msg ) : h5::error::io::packet_table::any( msg ){}
219  };
220 }}}}
221 
222 namespace h5 { namespace error { namespace io { namespace attribute {
223  struct rollback : public h5::error::io::rollback {
224  rollback( const std::string& msg ) : h5::error::io::rollback( msg ){}
225  };
226  struct any : public h5::error::io::any {
227  any() : h5::error::io::any() {}
228  any( const std::string& msg ) : h5::error::io::any( msg ){}
229  };
230  struct open : public h5::error::io::attribute::any {
231  open() : h5::error::io::attribute::any() {}
232  open( const std::string& msg ) : h5::error::io::attribute::any( msg ){}
233  };
234  struct close : public h5::error::io::attribute::any {
235  close() : h5::error::io::attribute::any() {}
236  close( const std::string& msg ) : h5::error::io::attribute::any( msg ){}
237  };
238  struct read : public h5::error::io::attribute::any {
239  read() : h5::error::io::attribute::any() {}
240  read( const std::string& msg ) : h5::error::io::attribute::any( msg ){}
241  };
242  struct write : public h5::error::io::attribute::any {
243  write() : h5::error::io::attribute::any() {}
244  write( const std::string& msg ) : h5::error::io::attribute::any( msg ){}
245  };
246  struct create : public h5::error::io::attribute::any {
247  create() : h5::error::io::attribute::any() {}
248  create( const std::string& msg ) : h5::error::io::attribute::any( msg ){}
249  };
250  struct misc : public h5::error::io::attribute::any {
251  misc() : h5::error::io::attribute::any() {}
252  misc( const std::string& msg ) : h5::error::io::attribute::any( msg ){}
253  };
254 }}}}
255 
256 namespace h5 { namespace error { namespace property_list {
257  struct rollback : public h5::error::rollback {
258  rollback( const std::string& msg ) : h5::error::rollback( msg ){}
259  };
260  struct any : public h5::error::any {
261  any() : h5::error::any() {}
262  any( const std::string& msg ) : h5::error::any( msg ){}
263  };
264  struct argument : public h5::error::property_list::any {
265  argument() : h5::error::property_list::any() {}
266  argument( const std::string& msg ) : h5::error::property_list::any( msg ){}
267  };
268  struct misc : public h5::error::property_list::any {
269  misc() : h5::error::property_list::any() {}
270  misc( const std::string& msg ) : h5::error::property_list::any( msg ){}
271  };
272 }}}
273 #endif
274 
public namespace
Definition: H5Acreate.hpp:10
void unmute()
restores previously saved error handler with h5::mute Read on Error Handling/Exceptions ...
Definition: H5Eall.hpp:41
void write(const h5::ds_t &ds, const h5::sp_t &mem_space, const h5::sp_t &file_space, const h5::dxpl_t &dxpl, const T *ptr)
Definition: H5Dwrite.hpp:15
h5::ds_t open(const h5::fd_t &fd, const std::string &path, const h5::dapl_t &dapl=h5::default_dapl)
Definition: H5Dopen.hpp:24
T endl(T...args)
void mute()
removes default error handler preventing diagnostic error messages printed for direct CAPI calls...
Definition: H5Eall.hpp:28
std::enable_if<!std::is_same< T, char * >::value, void >::type read(const h5::ds_t &ds, T *ptr, args_t &&...args)
Definition: H5Dread.hpp:29
void append(h5::pt_t &pt, const T &ref)
extends HDF5 dataset along the first/slowest growing dimension, then writes passed object to the newl...
Definition: H5Dappend.hpp:130
h5::ds_t create(const h5::fd_t &fd, const std::string &dataset_path, args_t &&...args)
Definition: H5Dcreate.hpp:22