GNU Octave  4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ls-hdf5.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2003-2017 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if ! defined (octave_ls_hdf5_h)
24 #define octave_ls_hdf5_h 1
25 
26 #include "octave-config.h"
27 
28 #include "oct-hdf5-types.h"
29 
30 // first, we need to define our own dummy stream subclass, since
31 // HDF5 needs to do its own file i/o
32 
33 // hdf5_fstreambase is used for both input and output streams, modeled
34 // on the fstreambase class in <fstream.h>
35 
36 class hdf5_fstreambase : virtual public std::ios
37 {
38 public:
39 
40  // HDF5 uses an "id" to refer to an open file
42 
43  // keep track of current item index in the file
45 
46  hdf5_fstreambase () : file_id (-1), current_item () { }
47 
49 
50  hdf5_fstreambase (const char *name, int mode, int /* prot */ = 0);
51 
52  void close (void);
53 
54  void open (const char *name, int mode, int);
55 };
56 
57 // input and output streams, subclassing istream and ostream
58 // so that we can pass them for stream parameters in the functions below.
59 
60 class hdf5_ifstream : public hdf5_fstreambase, public std::istream
61 {
62 public:
63 
64  hdf5_ifstream () : hdf5_fstreambase (), std::istream (0) { }
65 
66  hdf5_ifstream (const char *name, int mode = std::ios::in | std::ios::binary,
67  int prot = 0)
68  : hdf5_fstreambase (name, mode, prot), std::istream (0) { }
69 
70  void open (const char *name, int mode = std::ios::in | std::ios::binary,
71  int prot = 0)
72  { hdf5_fstreambase::open (name, mode, prot); }
73 };
74 
75 class hdf5_ofstream : public hdf5_fstreambase, public std::ostream
76 {
77 public:
78 
79  hdf5_ofstream () : hdf5_fstreambase (), std::ostream (0) { }
80 
81  hdf5_ofstream (const char *name, int mode = std::ios::out | std::ios::binary,
82  int prot = 0)
83  : hdf5_fstreambase (name, mode, prot), std::ostream (0) { }
84 
85  void open (const char *name, int mode = std::ios::out | std::ios::binary,
86  int prot = 0)
87  { hdf5_fstreambase::open (name, mode, prot); }
88 };
89 
90 // Callback data structure for passing data to hdf5_read_next_data, below.
91 
92 struct
94 {
96  : name (), global (false), tc (), doc () { }
97 
98  // the following fields are set by hdf5_read_data on successful return:
99 
100  // the name of the variable
102 
103  // whether it is global
104  bool global;
105 
106  // the value of the variable, in Octave form
108 
109  // a documentation string (NULL if none)
111 };
112 
115 
118 
119 extern OCTINTERP_API bool
121 
123 hdf5_read_next_data (octave_hdf5_id group_id, const char *name, void *dv);
124 
126 hdf5_h5g_iterate (octave_hdf5_id loc_id, const char* name, int *idx,
127  void *operator_data);
128 
129 extern OCTINTERP_API bool
130 add_hdf5_data (octave_hdf5_id loc_id, const octave_value& tc,
131  const std::string& name, const std::string& doc,
132  bool mark_as_global, bool save_as_floats);
133 
134 extern OCTINTERP_API int
135 save_hdf5_empty (octave_hdf5_id loc_id, const char *name, const dim_vector d);
136 
137 extern OCTINTERP_API int
138 load_hdf5_empty (octave_hdf5_id loc_id, const char *name, dim_vector &d);
139 
141 read_hdf5_data (std::istream& is, const std::string& filename, bool& global,
142  octave_value& tc, std::string& doc,
143  const string_vector& argv, int argv_idx, int argc);
144 
145 extern OCTINTERP_API bool
146 save_hdf5_data (std::ostream& os, const octave_value& tc,
147  const std::string& name, const std::string& doc,
148  bool mark_as_global, bool save_as_floats);
149 
150 extern OCTINTERP_API bool
151 hdf5_check_attr (octave_hdf5_id loc_id, const char *attr_name);
152 
153 extern OCTINTERP_API bool
155  const char *attr_name, void *buf);
156 
158 hdf5_add_attr (octave_hdf5_id loc_id, const char *attr_name);
159 
160 
163  const char *attr_name, void *buf);
164 
165 #endif
save_type
Definition: data-conv.h:85
void close(void)
Definition: ls-hdf5.cc:115
hdf5_ifstream()
Definition: ls-hdf5.h:64
OCTINTERP_API bool save_hdf5_data(std::ostream &os, const octave_value &tc, const std::string &name, const std::string &doc, bool mark_as_global, bool save_as_floats)
Definition: ls-hdf5.cc:1148
octave_value tc
Definition: ls-hdf5.h:107
OCTINTERP_API std::string read_hdf5_data(std::istream &is, const std::string &filename, bool &global, octave_value &tc, std::string &doc, const string_vector &argv, int argv_idx, int argc)
Definition: ls-hdf5.cc:727
int argc
Definition: load-save.cc:633
Return the CPU time used by your Octave session The first output is the total time spent executing your process and is equal to the sum of second and third which are the number of CPU seconds spent executing in user mode and the number of CPU seconds spent executing in system mode
Definition: data.cc:6386
std::string name
Definition: ls-hdf5.h:101
OCTINTERP_API octave_hdf5_id hdf5_make_complex_type(octave_hdf5_id num_type)
Definition: ls-hdf5.cc:328
OCTINTERP_API octave_hdf5_err hdf5_read_next_data(octave_hdf5_id group_id, const char *name, void *dv)
Definition: ls-hdf5.cc:692
OCTINTERP_API int save_hdf5_empty(octave_hdf5_id loc_id, const char *name, const dim_vector d)
Definition: ls-hdf5.cc:897
STL namespace.
std::string filename
Definition: urlwrite.cc:340
OCTINTERP_API octave_hdf5_err hdf5_h5g_iterate(octave_hdf5_id loc_id, const char *name, int *idx, void *operator_data)
Definition: ls-hdf5.cc:706
void open(const char *name, int mode=std::ios::in|std::ios::binary, int prot=0)
Definition: ls-hdf5.h:70
OCTINTERP_API int load_hdf5_empty(octave_hdf5_id loc_id, const char *name, dim_vector &d)
Definition: ls-hdf5.cc:953
hdf5_ofstream(const char *name, int mode=std::ios::out|std::ios::binary, int prot=0)
Definition: ls-hdf5.h:81
F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
std::string doc
Definition: ls-hdf5.h:110
string_vector argv
Definition: load-save.cc:635
OCTINTERP_API octave_hdf5_err hdf5_add_attr(octave_hdf5_id loc_id, const char *attr_name)
Definition: ls-hdf5.cc:812
OCTINTERP_API bool hdf5_get_scalar_attr(octave_hdf5_id loc_id, octave_hdf5_id type_id, const char *attr_name, void *buf)
Definition: ls-hdf5.cc:270
OCTAVE_EXPORT octave_value_list any number nd example oindent prints the prompt xample Pick a any number!nd example oindent and waits for the user to enter a value The string entered by the user is evaluated as an so it may be a literal a variable name
Definition: input.cc:871
OCTINTERP_API octave_hdf5_err hdf5_add_scalar_attr(octave_hdf5_id loc_id, octave_hdf5_id type_id, const char *attr_name, void *buf)
Definition: ls-hdf5.cc:853
#define OCTINTERP_API
Definition: mexproto.h:69
hdf5_ifstream(const char *name, int mode=std::ios::in|std::ios::binary, int prot=0)
Definition: ls-hdf5.h:66
OCTINTERP_API bool hdf5_check_attr(octave_hdf5_id loc_id, const char *attr_name)
Definition: ls-hdf5.cc:223
hdf5_callback_data(void)
Definition: ls-hdf5.h:95
bool save_as_floats
Definition: load-save.cc:1581
is false
Definition: cellfun.cc:398
int64_t octave_hdf5_id
void open(const char *name, int mode=std::ios::out|std::ios::binary, int prot=0)
Definition: ls-hdf5.h:85
octave_hdf5_id file_id
Definition: ls-hdf5.h:41
hdf5_ofstream()
Definition: ls-hdf5.h:79
write the output to stdout if nargout is
Definition: load-save.cc:1576
int current_item
Definition: ls-hdf5.h:44
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:87
void open(const char *name, int mode, int)
Definition: ls-hdf5.cc:135
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition: utils.cc:854
dim_vector dv
Definition: sub2ind.cc:263
OCTINTERP_API bool add_hdf5_data(octave_hdf5_id loc_id, const octave_value &tc, const std::string &name, const std::string &doc, bool mark_as_global, bool save_as_floats)
Definition: ls-hdf5.cc:1053
OCTINTERP_API bool hdf5_types_compatible(octave_hdf5_id t1, octave_hdf5_id t2)
Definition: ls-hdf5.cc:192
OCTINTERP_API octave_hdf5_id save_type_to_hdf5(save_type st)
Definition: ls-hdf5.cc:997