Mercurial > hg > octave-nkf
comparison src/ls-hdf5.h @ 10313:f3b65e1ae355
untabify src header files
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 11 Feb 2010 12:16:43 -0500 |
parents | cd96d29c5efa |
children | 2271261f088a |
comparison
equal
deleted
inserted
replaced
10312:cbc402e64d83 | 10313:f3b65e1ae355 |
---|---|
48 ~hdf5_fstreambase () { close (); } | 48 ~hdf5_fstreambase () { close (); } |
49 | 49 |
50 hdf5_fstreambase (const char *name, int mode, int /* prot */ = 0) | 50 hdf5_fstreambase (const char *name, int mode, int /* prot */ = 0) |
51 { | 51 { |
52 if (mode & std::ios::in) | 52 if (mode & std::ios::in) |
53 file_id = H5Fopen (name, H5F_ACC_RDONLY, H5P_DEFAULT); | 53 file_id = H5Fopen (name, H5F_ACC_RDONLY, H5P_DEFAULT); |
54 else if (mode & std::ios::out) | 54 else if (mode & std::ios::out) |
55 { | 55 { |
56 if (mode & std::ios::app && H5Fis_hdf5 (name) > 0) | 56 if (mode & std::ios::app && H5Fis_hdf5 (name) > 0) |
57 file_id = H5Fopen (name, H5F_ACC_RDWR, H5P_DEFAULT); | 57 file_id = H5Fopen (name, H5F_ACC_RDWR, H5P_DEFAULT); |
58 else | 58 else |
59 file_id = H5Fcreate (name, H5F_ACC_TRUNC, H5P_DEFAULT, | 59 file_id = H5Fcreate (name, H5F_ACC_TRUNC, H5P_DEFAULT, |
60 H5P_DEFAULT); | 60 H5P_DEFAULT); |
61 } | 61 } |
62 if (file_id < 0) | 62 if (file_id < 0) |
63 std::ios::setstate (std::ios::badbit); | 63 std::ios::setstate (std::ios::badbit); |
64 | 64 |
65 current_item = 0; | 65 current_item = 0; |
66 } | 66 } |
67 | 67 |
68 void close () | 68 void close () |
69 { | 69 { |
70 if (file_id >= 0) | 70 if (file_id >= 0) |
71 { | 71 { |
72 if (H5Fclose (file_id) < 0) | 72 if (H5Fclose (file_id) < 0) |
73 std::ios::setstate (std::ios::badbit); | 73 std::ios::setstate (std::ios::badbit); |
74 file_id = -1; | 74 file_id = -1; |
75 } | 75 } |
76 } | 76 } |
77 | 77 |
78 void open (const char *name, int mode, int) | 78 void open (const char *name, int mode, int) |
79 { | 79 { |
80 clear (); | 80 clear (); |
81 | 81 |
82 if (mode & std::ios::in) | 82 if (mode & std::ios::in) |
83 file_id = H5Fopen (name, H5F_ACC_RDONLY, H5P_DEFAULT); | 83 file_id = H5Fopen (name, H5F_ACC_RDONLY, H5P_DEFAULT); |
84 else if (mode & std::ios::out) | 84 else if (mode & std::ios::out) |
85 { | 85 { |
86 if (mode & std::ios::app && H5Fis_hdf5 (name) > 0) | 86 if (mode & std::ios::app && H5Fis_hdf5 (name) > 0) |
87 file_id = H5Fopen (name, H5F_ACC_RDWR, H5P_DEFAULT); | 87 file_id = H5Fopen (name, H5F_ACC_RDWR, H5P_DEFAULT); |
88 else | 88 else |
89 file_id = H5Fcreate (name, H5F_ACC_TRUNC, H5P_DEFAULT, | 89 file_id = H5Fcreate (name, H5F_ACC_TRUNC, H5P_DEFAULT, |
90 H5P_DEFAULT); | 90 H5P_DEFAULT); |
91 } | 91 } |
92 if (file_id < 0) | 92 if (file_id < 0) |
93 std::ios::setstate (std::ios::badbit); | 93 std::ios::setstate (std::ios::badbit); |
94 | 94 |
95 current_item = 0; | 95 current_item = 0; |
96 } | 96 } |
97 }; | 97 }; |
98 | 98 |
104 public: | 104 public: |
105 | 105 |
106 hdf5_ifstream () : hdf5_fstreambase (), std::istream (0) { } | 106 hdf5_ifstream () : hdf5_fstreambase (), std::istream (0) { } |
107 | 107 |
108 hdf5_ifstream (const char *name, int mode = std::ios::in|std::ios::binary, | 108 hdf5_ifstream (const char *name, int mode = std::ios::in|std::ios::binary, |
109 int prot = 0) | 109 int prot = 0) |
110 : hdf5_fstreambase (name, mode, prot), std::istream (0) { } | 110 : hdf5_fstreambase (name, mode, prot), std::istream (0) { } |
111 | 111 |
112 void open (const char *name, int mode = std::ios::in|std::ios::binary, | 112 void open (const char *name, int mode = std::ios::in|std::ios::binary, |
113 int prot = 0) | 113 int prot = 0) |
114 { hdf5_fstreambase::open (name, mode, prot); } | 114 { hdf5_fstreambase::open (name, mode, prot); } |
115 }; | 115 }; |
116 | 116 |
117 class hdf5_ofstream : public hdf5_fstreambase, public std::ostream | 117 class hdf5_ofstream : public hdf5_fstreambase, public std::ostream |
118 { | 118 { |
119 public: | 119 public: |
120 | 120 |
121 hdf5_ofstream () : hdf5_fstreambase (), std::ostream (0) { } | 121 hdf5_ofstream () : hdf5_fstreambase (), std::ostream (0) { } |
122 | 122 |
123 hdf5_ofstream (const char *name, int mode = std::ios::out|std::ios::binary, | 123 hdf5_ofstream (const char *name, int mode = std::ios::out|std::ios::binary, |
124 int prot = 0) | 124 int prot = 0) |
125 : hdf5_fstreambase (name, mode, prot), std::ostream (0) { } | 125 : hdf5_fstreambase (name, mode, prot), std::ostream (0) { } |
126 | 126 |
127 void open (const char *name, int mode = std::ios::out|std::ios::binary, | 127 void open (const char *name, int mode = std::ios::out|std::ios::binary, |
128 int prot = 0) | 128 int prot = 0) |
129 { hdf5_fstreambase::open (name, mode, prot); } | 129 { hdf5_fstreambase::open (name, mode, prot); } |
130 }; | 130 }; |
131 | 131 |
132 // Callback data structure for passing data to hdf5_read_next_data, below. | 132 // Callback data structure for passing data to hdf5_read_next_data, below. |
133 | 133 |
166 extern OCTINTERP_API herr_t | 166 extern OCTINTERP_API herr_t |
167 hdf5_read_next_data (hid_t group_id, const char *name, void *dv); | 167 hdf5_read_next_data (hid_t group_id, const char *name, void *dv); |
168 | 168 |
169 extern OCTINTERP_API bool | 169 extern OCTINTERP_API bool |
170 add_hdf5_data (hid_t loc_id, const octave_value& tc, | 170 add_hdf5_data (hid_t loc_id, const octave_value& tc, |
171 const std::string& name, const std::string& doc, | 171 const std::string& name, const std::string& doc, |
172 bool mark_as_global, bool save_as_floats); | 172 bool mark_as_global, bool save_as_floats); |
173 | 173 |
174 extern OCTINTERP_API int | 174 extern OCTINTERP_API int |
175 save_hdf5_empty (hid_t loc_id, const char *name, const dim_vector d); | 175 save_hdf5_empty (hid_t loc_id, const char *name, const dim_vector d); |
176 | 176 |
177 extern OCTINTERP_API int | 177 extern OCTINTERP_API int |
178 load_hdf5_empty (hid_t loc_id, const char *name, dim_vector &d); | 178 load_hdf5_empty (hid_t loc_id, const char *name, dim_vector &d); |
179 | 179 |
180 extern OCTINTERP_API std::string | 180 extern OCTINTERP_API std::string |
181 read_hdf5_data (std::istream& is, const std::string& filename, bool& global, | 181 read_hdf5_data (std::istream& is, const std::string& filename, bool& global, |
182 octave_value& tc, std::string& doc); | 182 octave_value& tc, std::string& doc); |
183 | 183 |
184 extern OCTINTERP_API bool | 184 extern OCTINTERP_API bool |
185 save_hdf5_data (std::ostream& os, const octave_value& tc, | 185 save_hdf5_data (std::ostream& os, const octave_value& tc, |
186 const std::string& name, const std::string& doc, | 186 const std::string& name, const std::string& doc, |
187 bool mark_as_global, bool save_as_floats); | 187 bool mark_as_global, bool save_as_floats); |
188 | 188 |
189 #ifdef IDX_TYPE_LONG | 189 #ifdef IDX_TYPE_LONG |
190 #define H5T_NATIVE_IDX H5T_NATIVE_LONG | 190 #define H5T_NATIVE_IDX H5T_NATIVE_LONG |
191 #else | 191 #else |
192 #define H5T_NATIVE_IDX H5T_NATIVE_INT | 192 #define H5T_NATIVE_IDX H5T_NATIVE_INT |