annotate libinterp/corefcn/ls-hdf5.cc @ 30564:796f54d4ddbf stable

update Octave Project Developers copyright for the new year In files that have the "Octave Project Developers" copyright notice, update for 2021. In all .txi and .texi files except gpl.txi and gpl.texi in the doc/liboctave and doc/interpreter directories, change the copyright to "Octave Project Developers", the same as used for other source files. Update copyright notices for 2022 (not done since 2019). For gpl.txi and gpl.texi, change the copyright notice to be "Free Software Foundation, Inc." and leave the date at 2007 only because this file only contains the text of the GPL, not anything created by the Octave Project Developers. Add Paul Thomas to contributors.in.
author John W. Eaton <jwe@octave.org>
date Tue, 28 Dec 2021 18:22:40 -0500
parents a4061ae5ff79
children 83f9f8bda883
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 30243
diff changeset
3 // Copyright (C) 1996-2022 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
25
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21691
diff changeset
26 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21211
diff changeset
27 # include "config.h"
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
28 #endif
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
29
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
30 #if defined (HAVE_HDF5)
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
31
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
32 #include <cctype>
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
33
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
34 #include <iomanip>
25438
cb1606f78f6b prefer <istream>, <ostream>, or <iosfwd> to <iostream> where possible
John W. Eaton <jwe@octave.org>
parents: 25392
diff changeset
35 #include <istream>
22028
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
36 #include <limits>
25438
cb1606f78f6b prefer <istream>, <ostream>, or <iosfwd> to <iostream> where possible
John W. Eaton <jwe@octave.org>
parents: 25392
diff changeset
37 #include <ostream>
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
38 #include <string>
4726
14dc2267c343 [project @ 2004-01-23 20:04:35 by jwe]
jwe
parents: 4696
diff changeset
39 #include <vector>
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
40
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
41 #include "byte-swap.h"
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
42 #include "data-conv.h"
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
43 #include "file-ops.h"
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
44 #include "glob-match.h"
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
45 #include "lo-mappers.h"
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
46 #include "mach-info.h"
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
47 #include "oct-env.h"
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
48 #include "oct-time.h"
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
49 #include "quit.h"
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
50 #include "str-vec.h"
8377
25bc2d31e1bf improve OCTAVE_LOCAL_BUFFER
Jaroslav Hajek <highegg@gmail.com>
parents: 7336
diff changeset
51 #include "oct-locbuf.h"
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
52
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
53 #include "Cell.h"
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
54 #include "defun.h"
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
55 #include "error.h"
21100
e39e05d90788 Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents: 21022
diff changeset
56 #include "errwarn.h"
28427
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
57 #include "interpreter.h"
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
58 #include "interpreter-private.h"
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
59 #include "load-save.h"
20264
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
60 #include "oct-hdf5.h"
20940
48b2ad5ee801 maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents: 20449
diff changeset
61 #include "ovl.h"
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
62 #include "oct-map.h"
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
63 #include "ov-cell.h"
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
64 #include "pager.h"
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
65 #include "sysdep.h"
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
66 #include "unwind-prot.h"
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
67 #include "utils.h"
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
68 #include "variables.h"
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
69 #include "version.h"
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
70 #include "dMatrix.h"
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
71 #include "ov-lazy-idx.h"
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
72
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
73 #include "ls-utils.h"
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
74 #include "ls-hdf5.h"
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
75
22028
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
76 #if defined (HAVE_HDF5)
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
77
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
78 static hid_t
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
79 check_hdf5_id_value (octave_hdf5_id id, const char *who)
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
80 {
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
81 if (id > std::numeric_limits<hid_t>::max ())
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
82 error ("%s: internal error: ID too large for hid_t", who);
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
83
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
84 return static_cast<hid_t> (id);
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
85 }
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
86
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
87 #endif
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
88
20264
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
89 hdf5_fstreambase::hdf5_fstreambase (const char *name, int mode, int /* prot */)
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
90 : file_id (-1), current_item (-1)
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
91 {
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
92 #if defined (HAVE_HDF5)
25693
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
93 open_create (name, mode);
20264
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
94
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
95 current_item = 0;
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
96
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
97 #else
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
98 err_disabled_feature ("hdf5_fstreambase", "HDF5");
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
99 #endif
20264
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
100 }
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
101
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
102 void
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
103 hdf5_fstreambase::close (void)
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
104 {
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
105 #if defined (HAVE_HDF5)
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
106
20264
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
107 if (file_id >= 0)
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
108 {
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
109 if (H5Fclose (file_id) < 0)
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
110 std::ios::setstate (std::ios::badbit);
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
111 file_id = -1;
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
112 }
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
113
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
114 #else
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
115 // This shouldn't happen because construction of hdf5_fstreambase
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
116 // objects is supposed to be impossible if HDF5 is not available.
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
117
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
118 panic_impossible ();
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
119 #endif
20264
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
120 }
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
121
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
122 void
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
123 hdf5_fstreambase::open (const char *name, int mode, int)
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
124 {
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
125 #if defined (HAVE_HDF5)
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
126
20264
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
127 clear ();
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
128
25693
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
129 open_create (name, mode);
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
130
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
131 current_item = 0;
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
132
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
133 #else
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
134 // This shouldn't happen because construction of hdf5_fstreambase
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
135 // objects is supposed to be impossible if HDF5 is not available.
25604
ca413f326224 Fix lifetime issues with temporary char arrays returned by get_ASCII_filename (bug #54299).
Markus Mützel <markus.muetzel@gmx.de>
parents: 25551
diff changeset
136
25693
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
137 panic_impossible ();
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
138 #endif
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
139 }
25604
ca413f326224 Fix lifetime issues with temporary char arrays returned by get_ASCII_filename (bug #54299).
Markus Mützel <markus.muetzel@gmx.de>
parents: 25551
diff changeset
140
25693
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
141 void
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
142 hdf5_fstreambase::open_create (const char *name, int mode)
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
143 {
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
144 #if defined (HAVE_HDF5)
27929
265b386f8b20 maint: Use two spaces between sentences in code comments.
Rik <rik@octave.org>
parents: 27923
diff changeset
145 // Open the HDF5 file NAME. If it does not exist, create the file.
25693
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
146
30243
a4061ae5ff79 Use UTF-8 file API if supported by HDF5 library.
Markus Mützel <markus.muetzel@gmx.de>
parents: 30007
diff changeset
147 # if defined (HAVE_HDF5_UTF8)
a4061ae5ff79 Use UTF-8 file API if supported by HDF5 library.
Markus Mützel <markus.muetzel@gmx.de>
parents: 30007
diff changeset
148 const char *fname = name;
a4061ae5ff79 Use UTF-8 file API if supported by HDF5 library.
Markus Mützel <markus.muetzel@gmx.de>
parents: 30007
diff changeset
149 # else
25693
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
150 std::string fname_str (name);
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
151 std::string ascii_fname_str = octave::sys::get_ASCII_filename (fname_str);
30243
a4061ae5ff79 Use UTF-8 file API if supported by HDF5 library.
Markus Mützel <markus.muetzel@gmx.de>
parents: 30007
diff changeset
152 const char *fname = ascii_fname_str.c_str ();
a4061ae5ff79 Use UTF-8 file API if supported by HDF5 library.
Markus Mützel <markus.muetzel@gmx.de>
parents: 30007
diff changeset
153 # endif
25551
64715551b515 Call get_ASCII_filename for HDF5 functions (bug #49118).
Markus Mützel <markus.muetzel@gmx.de>
parents: 25438
diff changeset
154
20264
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
155 if (mode & std::ios::in)
30243
a4061ae5ff79 Use UTF-8 file API if supported by HDF5 library.
Markus Mützel <markus.muetzel@gmx.de>
parents: 30007
diff changeset
156 file_id = H5Fopen (fname, H5F_ACC_RDONLY, octave_H5P_DEFAULT);
20264
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
157 else if (mode & std::ios::out)
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
158 {
30243
a4061ae5ff79 Use UTF-8 file API if supported by HDF5 library.
Markus Mützel <markus.muetzel@gmx.de>
parents: 30007
diff changeset
159 if (mode & std::ios::app && H5Fis_hdf5 (fname) > 0)
a4061ae5ff79 Use UTF-8 file API if supported by HDF5 library.
Markus Mützel <markus.muetzel@gmx.de>
parents: 30007
diff changeset
160 file_id = H5Fopen (fname, H5F_ACC_RDWR, octave_H5P_DEFAULT);
20264
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
161 else
30243
a4061ae5ff79 Use UTF-8 file API if supported by HDF5 library.
Markus Mützel <markus.muetzel@gmx.de>
parents: 30007
diff changeset
162 # if defined (HAVE_HDF5_UTF8)
a4061ae5ff79 Use UTF-8 file API if supported by HDF5 library.
Markus Mützel <markus.muetzel@gmx.de>
parents: 30007
diff changeset
163 file_id = H5Fcreate (fname, H5F_ACC_TRUNC, octave_H5P_DEFAULT,
a4061ae5ff79 Use UTF-8 file API if supported by HDF5 library.
Markus Mützel <markus.muetzel@gmx.de>
parents: 30007
diff changeset
164 octave_H5P_DEFAULT);
a4061ae5ff79 Use UTF-8 file API if supported by HDF5 library.
Markus Mützel <markus.muetzel@gmx.de>
parents: 30007
diff changeset
165 # else
25693
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
166 {
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
167 // Check whether file already exists
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
168 std::string abs_ascii_fname
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
169 = octave::sys::canonicalize_file_name (ascii_fname_str);
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
170 if (! abs_ascii_fname.empty ())
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
171 {
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
172 // Use the existing file
30243
a4061ae5ff79 Use UTF-8 file API if supported by HDF5 library.
Markus Mützel <markus.muetzel@gmx.de>
parents: 30007
diff changeset
173 file_id = H5Fcreate (fname, H5F_ACC_TRUNC,
25693
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
174 octave_H5P_DEFAULT, octave_H5P_DEFAULT);
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
175 if (file_id < 0)
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
176 std::ios::setstate (std::ios::badbit);
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
177
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
178 return;
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
179 }
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
180
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
181 // Check whether filename contains non-ASCII (UTF-8) characters.
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
182 std::string::const_iterator first_non_ASCII
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
183 = std::find_if (fname_str.begin (), fname_str.end (),
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
184 [](char c) { return (c < 0 || c >= 128); });
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
185 if (first_non_ASCII == fname_str.end ())
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
186 {
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
187 // No non-ASCII characters
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
188 file_id = H5Fcreate (name, H5F_ACC_TRUNC, octave_H5P_DEFAULT,
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
189 octave_H5P_DEFAULT);
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
190 if (file_id < 0)
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
191 std::ios::setstate (std::ios::badbit);
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
192
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
193 return;
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
194 }
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
195
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
196 // Create file in temp folder
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
197 std::string tmp_name = octave::sys::tempnam ("", "oct-");
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
198 octave_hdf5_id hdf5_fid = H5Fcreate (tmp_name.c_str (), H5F_ACC_TRUNC,
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
199 octave_H5P_DEFAULT,
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
200 octave_H5P_DEFAULT);
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
201 if (hdf5_fid < 0)
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
202 {
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
203 file_id = -1;
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
204 std::ios::setstate (std::ios::badbit);
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
205 return;
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
206 }
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
207
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
208 // Close file
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
209 H5Fclose (hdf5_fid);
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
210
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
211 // Move temporary file to final destination
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
212 std::string msg;
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
213 int res = octave::sys::rename (tmp_name, name, msg);
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
214 if (res < 0)
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
215 {
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
216 std::ios::setstate (std::ios::badbit);
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
217 file_id = -1;
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
218 return;
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
219 }
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
220
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
221 // Open file at final location
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
222 ascii_fname_str = octave::sys::get_ASCII_filename (fname_str);
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
223 ascii_fname = ascii_fname_str.c_str ();
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
224 file_id = H5Fopen (ascii_fname, H5F_ACC_RDWR, octave_H5P_DEFAULT);
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
225 }
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
226 # endif
20264
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
227 }
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
228 if (file_id < 0)
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
229 std::ios::setstate (std::ios::badbit);
25828
8b548f2f8086 maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 25693
diff changeset
230
25693
038fb01854a0 Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents: 25646
diff changeset
231 return;
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
232
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
233 #else
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
234 // This shouldn't happen because construction of hdf5_fstreambase
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
235 // objects is supposed to be impossible if HDF5 is not available.
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
236
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
237 panic_impossible ();
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
238 #endif
20264
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
239 }
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
240
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
241 static std::string
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
242 make_valid_identifier (const std::string& nm)
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
243 {
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
244 std::string retval;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
245
29572
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29385
diff changeset
246 std::size_t nm_len = nm.length ();
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
247
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
248 if (nm_len > 0)
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
249 {
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
250 if (! isalpha (nm[0]))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
251 retval += '_';
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
252
29572
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29385
diff changeset
253 for (std::size_t i = 0; i < nm_len; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
254 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
255 char c = nm[i];
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
256 retval += (isalnum (c) || c == '_') ? c : '_';
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
257 }
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
258 }
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
259
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
260 return retval;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
261 }
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
262
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
263 // Given two compound types t1 and t2, determine whether they
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
264 // are compatible for reading/writing. This function only
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
265 // works for non-nested types composed of simple elements (ints, floats...),
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
266 // which is all we need it for
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
267
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
268 bool
20264
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
269 hdf5_types_compatible (octave_hdf5_id t1, octave_hdf5_id t2)
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
270 {
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
271 #if defined (HAVE_HDF5)
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
272
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
273 int n;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
274 if ((n = H5Tget_nmembers (t1)) != H5Tget_nmembers (t2))
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
275 return false;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
276
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
277 for (int i = 0; i < n; ++i)
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
278 {
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
279 hid_t mt1 = H5Tget_member_type (t1, i);
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
280 hid_t mt2 = H5Tget_member_type (t2, i);
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
281
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
282 if (H5Tget_class (mt1) != H5Tget_class (mt2))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
283 return false;
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
284
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
285 H5Tclose (mt2);
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
286 H5Tclose (mt1);
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
287 }
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
288
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
289 return true;
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
290
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
291 #else
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
292 err_disabled_feature ("hdf5_types_compatible", "HDF5");
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
293 #endif
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
294 }
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
295
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
296 // Return true if loc_id has the attribute named attr_name, and false
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
297 // otherwise.
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
298
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
299 bool
20264
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
300 hdf5_check_attr (octave_hdf5_id loc_id, const char *attr_name)
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
301 {
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
302 #if defined (HAVE_HDF5)
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
303
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
304 bool retval = false;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
305
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
306 // we have to pull some shenanigans here to make sure
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
307 // HDF5 doesn't print out all sorts of error messages if we
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
308 // call H5Aopen for a non-existing attribute
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
309
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
310 H5E_auto_t err_func;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
311 void *err_func_data;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
312
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
313 // turn off error reporting temporarily, but save the error
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
314 // reporting function:
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
315
21211
2cf8bc5c7017 use "#if defined (HAVE_FOO)" instead of "#if HAVE_FOO" for feature tests
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
316 #if defined (HAVE_HDF5_18)
21022
ebc439187d29 avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
317 H5Eget_auto (octave_H5E_DEFAULT, &err_func, &err_func_data);
23796
4f12819a634f Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23795
diff changeset
318 H5Eset_auto (octave_H5E_DEFAULT, nullptr, nullptr);
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
319 #else
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
320 H5Eget_auto (&err_func, &err_func_data);
23796
4f12819a634f Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23795
diff changeset
321 H5Eset_auto (nullptr, nullptr);
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
322 #endif
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
323
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
324 hid_t attr_id = H5Aopen_name (loc_id, attr_name);
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
325
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
326 if (attr_id >= 0)
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
327 {
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
328 // successful
11176
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
329 retval = true;
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
330 H5Aclose (attr_id);
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
331 }
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
332
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
333 // restore error reporting:
21211
2cf8bc5c7017 use "#if defined (HAVE_FOO)" instead of "#if HAVE_FOO" for feature tests
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
334 #if defined (HAVE_HDF5_18)
21022
ebc439187d29 avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
335 H5Eset_auto (octave_H5E_DEFAULT, err_func, err_func_data);
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
336 #else
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
337 H5Eset_auto (err_func, err_func_data);
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
338 #endif
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
339 return retval;
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
340
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
341 #else
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
342 err_disabled_feature ("hdf5_check_attr", "HDF5");
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
343 #endif
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
344 }
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
345
11176
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
346 bool
20264
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
347 hdf5_get_scalar_attr (octave_hdf5_id loc_id, octave_hdf5_id type_id,
11176
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
348 const char *attr_name, void *buf)
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
349 {
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
350 #if defined (HAVE_HDF5)
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
351
11176
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
352 bool retval = false;
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
353
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
354 // we have to pull some shenanigans here to make sure
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
355 // HDF5 doesn't print out all sorts of error messages if we
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
356 // call H5Aopen for a non-existing attribute
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
357
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
358 H5E_auto_t err_func;
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
359 void *err_func_data;
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
360
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
361 // turn off error reporting temporarily, but save the error
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
362 // reporting function:
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
363
21211
2cf8bc5c7017 use "#if defined (HAVE_FOO)" instead of "#if HAVE_FOO" for feature tests
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
364 #if defined (HAVE_HDF5_18)
21022
ebc439187d29 avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
365 H5Eget_auto (octave_H5E_DEFAULT, &err_func, &err_func_data);
23796
4f12819a634f Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23795
diff changeset
366 H5Eset_auto (octave_H5E_DEFAULT, nullptr, nullptr);
11176
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
367 #else
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
368 H5Eget_auto (&err_func, &err_func_data);
23796
4f12819a634f Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23795
diff changeset
369 H5Eset_auto (nullptr, nullptr);
11176
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
370 #endif
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
371
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
372 hid_t attr_id = H5Aopen_name (loc_id, attr_name);
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
373
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
374 if (attr_id >= 0)
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
375 {
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
376 hid_t space_id = H5Aget_space (attr_id);
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
377
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
378 hsize_t rank = H5Sget_simple_extent_ndims (space_id);
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
379
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
380 if (rank == 0)
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
381 retval = H5Aread (attr_id, type_id, buf) >= 0;
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
382 H5Aclose (attr_id);
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
383 }
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
384
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
385 // restore error reporting:
21211
2cf8bc5c7017 use "#if defined (HAVE_FOO)" instead of "#if HAVE_FOO" for feature tests
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
386 #if defined (HAVE_HDF5_18)
21022
ebc439187d29 avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
387 H5Eset_auto (octave_H5E_DEFAULT, err_func, err_func_data);
11176
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
388 #else
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
389 H5Eset_auto (err_func, err_func_data);
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
390 #endif
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
391 return retval;
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
392
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
393 #else
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
394 err_disabled_feature ("hdf5_get_scalar_attr", "HDF5");
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
395 #endif
11176
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
396 }
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
397
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
398 // The following subroutines creates an HDF5 representations of the way
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
399 // we will store Octave complex types (pairs of floating-point numbers).
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
400 // NUM_TYPE is the HDF5 numeric type to use for storage (e.g.
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21724
diff changeset
401 // H5T_NATIVE_DOUBLE to save as 'double'). Note that any necessary
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
402 // conversions are handled automatically by HDF5.
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
403
20264
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
404 octave_hdf5_id
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
405 hdf5_make_complex_type (octave_hdf5_id num_type)
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
406 {
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
407 #if defined (HAVE_HDF5)
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
408
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
409 hid_t type_id = H5Tcreate (H5T_COMPOUND, sizeof (double) * 2);
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
410
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
411 H5Tinsert (type_id, "real", 0 * sizeof (double), num_type);
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
412 H5Tinsert (type_id, "imag", 1 * sizeof (double), num_type);
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
413
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
414 return type_id;
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
415
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
416 #else
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
417 err_disabled_feature ("hdf5_make_complex_type", "HDF5");
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
418 #endif
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
419 }
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
420
22028
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
421 #if defined (HAVE_HDF5)
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
422
27138
9e5c1d343a2c Skip HDF5 elements which are unrecognized, but continue reading file (bug #32756).
Daniel Davis <ddesics@gmail.com>
parents: 27063
diff changeset
423 // The following subroutine creates an HDF5 representation of the way
9e5c1d343a2c Skip HDF5 elements which are unrecognized, but continue reading file (bug #32756).
Daniel Davis <ddesics@gmail.com>
parents: 27063
diff changeset
424 // we will store Octave range types (triplets of floating-point numbers).
9e5c1d343a2c Skip HDF5 elements which are unrecognized, but continue reading file (bug #32756).
Daniel Davis <ddesics@gmail.com>
parents: 27063
diff changeset
425 // NUM_TYPE is the HDF5 numeric type to use for storage
9e5c1d343a2c Skip HDF5 elements which are unrecognized, but continue reading file (bug #32756).
Daniel Davis <ddesics@gmail.com>
parents: 27063
diff changeset
426 // (e.g., H5T_NATIVE_DOUBLE to save as 'double').
9e5c1d343a2c Skip HDF5 elements which are unrecognized, but continue reading file (bug #32756).
Daniel Davis <ddesics@gmail.com>
parents: 27063
diff changeset
427 // Note that any necessary conversions are handled automatically by HDF5.
9e5c1d343a2c Skip HDF5 elements which are unrecognized, but continue reading file (bug #32756).
Daniel Davis <ddesics@gmail.com>
parents: 27063
diff changeset
428
9e5c1d343a2c Skip HDF5 elements which are unrecognized, but continue reading file (bug #32756).
Daniel Davis <ddesics@gmail.com>
parents: 27063
diff changeset
429 static hid_t
9e5c1d343a2c Skip HDF5 elements which are unrecognized, but continue reading file (bug #32756).
Daniel Davis <ddesics@gmail.com>
parents: 27063
diff changeset
430 hdf5_make_range_type (hid_t num_type)
9e5c1d343a2c Skip HDF5 elements which are unrecognized, but continue reading file (bug #32756).
Daniel Davis <ddesics@gmail.com>
parents: 27063
diff changeset
431 {
9e5c1d343a2c Skip HDF5 elements which are unrecognized, but continue reading file (bug #32756).
Daniel Davis <ddesics@gmail.com>
parents: 27063
diff changeset
432 hid_t type_id = H5Tcreate (H5T_COMPOUND, sizeof (double) * 3);
9e5c1d343a2c Skip HDF5 elements which are unrecognized, but continue reading file (bug #32756).
Daniel Davis <ddesics@gmail.com>
parents: 27063
diff changeset
433
9e5c1d343a2c Skip HDF5 elements which are unrecognized, but continue reading file (bug #32756).
Daniel Davis <ddesics@gmail.com>
parents: 27063
diff changeset
434 H5Tinsert (type_id, "base", 0 * sizeof (double), num_type);
9e5c1d343a2c Skip HDF5 elements which are unrecognized, but continue reading file (bug #32756).
Daniel Davis <ddesics@gmail.com>
parents: 27063
diff changeset
435 H5Tinsert (type_id, "limit", 1 * sizeof (double), num_type);
9e5c1d343a2c Skip HDF5 elements which are unrecognized, but continue reading file (bug #32756).
Daniel Davis <ddesics@gmail.com>
parents: 27063
diff changeset
436 H5Tinsert (type_id, "increment", 2 * sizeof (double), num_type);
9e5c1d343a2c Skip HDF5 elements which are unrecognized, but continue reading file (bug #32756).
Daniel Davis <ddesics@gmail.com>
parents: 27063
diff changeset
437
9e5c1d343a2c Skip HDF5 elements which are unrecognized, but continue reading file (bug #32756).
Daniel Davis <ddesics@gmail.com>
parents: 27063
diff changeset
438 return type_id;
9e5c1d343a2c Skip HDF5 elements which are unrecognized, but continue reading file (bug #32756).
Daniel Davis <ddesics@gmail.com>
parents: 27063
diff changeset
439 }
9e5c1d343a2c Skip HDF5 elements which are unrecognized, but continue reading file (bug #32756).
Daniel Davis <ddesics@gmail.com>
parents: 27063
diff changeset
440
28427
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
441 static herr_t
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
442 load_inline_fcn (hid_t loc_id, const char *name, octave_value& retval)
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
443 {
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
444 #if defined (HAVE_HDF5)
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
445
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
446 hid_t group_hid, data_hid, space_hid, type_hid, type_class_hid, st_id;
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
447 hsize_t rank;
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
448 int slen;
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
449
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
450 #if defined (HAVE_HDF5_18)
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
451 group_hid = H5Gopen (loc_id, name, octave_H5P_DEFAULT);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
452 #else
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
453 group_hid = H5Gopen (loc_id, name);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
454 #endif
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
455 if (group_hid < 0) return -1;
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
456
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
457 #if defined (HAVE_HDF5_18)
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
458 data_hid = H5Dopen (group_hid, "args", octave_H5P_DEFAULT);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
459 #else
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
460 data_hid = H5Dopen (group_hid, "args");
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
461 #endif
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
462 space_hid = H5Dget_space (data_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
463 rank = H5Sget_simple_extent_ndims (space_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
464
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
465 if (rank != 2)
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
466 {
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
467 H5Dclose (data_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
468 H5Sclose (space_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
469 H5Gclose (group_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
470 return -1;
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
471 }
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
472
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
473 OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
474 OCTAVE_LOCAL_BUFFER (hsize_t, maxdims, rank);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
475
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
476 H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
477
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
478 octave_value_list args (hdims[1]+1);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
479
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
480 OCTAVE_LOCAL_BUFFER (char, s1, hdims[0] * hdims[1]);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
481
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
482 if (H5Dread (data_hid, H5T_NATIVE_UCHAR, octave_H5S_ALL, octave_H5S_ALL,
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
483 octave_H5P_DEFAULT, s1) < 0)
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
484 {
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
485 H5Dclose (data_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
486 H5Sclose (space_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
487 H5Gclose (group_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
488 return -1;
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
489 }
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
490
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
491 H5Dclose (data_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
492 H5Sclose (space_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
493
29572
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29385
diff changeset
494 for (std::size_t i = 0; i < hdims[1]; i++)
28427
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
495 args(i+1) = std::string (s1 + i*hdims[0]);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
496
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
497 #if defined (HAVE_HDF5_18)
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
498 data_hid = H5Dopen (group_hid, "nm", octave_H5P_DEFAULT);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
499 #else
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
500 data_hid = H5Dopen (group_hid, "nm");
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
501 #endif
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
502
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
503 if (data_hid < 0)
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
504 {
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
505 H5Gclose (group_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
506 return -1;
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
507 }
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
508
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
509 type_hid = H5Dget_type (data_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
510 type_class_hid = H5Tget_class (type_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
511
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
512 if (type_class_hid != H5T_STRING)
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
513 {
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
514 H5Tclose (type_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
515 H5Dclose (data_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
516 H5Gclose (group_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
517 return -1;
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
518 }
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
519
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
520 space_hid = H5Dget_space (data_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
521 rank = H5Sget_simple_extent_ndims (space_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
522
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
523 if (rank != 0)
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
524 {
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
525 H5Sclose (space_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
526 H5Tclose (type_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
527 H5Dclose (data_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
528 H5Gclose (group_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
529 return -1;
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
530 }
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
531
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
532 slen = H5Tget_size (type_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
533 if (slen < 0)
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
534 {
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
535 H5Sclose (space_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
536 H5Tclose (type_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
537 H5Dclose (data_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
538 H5Gclose (group_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
539 return -1;
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
540 }
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
541
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
542 OCTAVE_LOCAL_BUFFER (char, nm_tmp, slen);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
543
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
544 // create datatype for (null-terminated) string to read into:
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
545 st_id = H5Tcopy (H5T_C_S1);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
546 H5Tset_size (st_id, slen);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
547
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
548 if (H5Dread (data_hid, st_id, octave_H5S_ALL, octave_H5S_ALL,
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
549 octave_H5P_DEFAULT, nm_tmp) < 0)
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
550 {
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
551 H5Sclose (space_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
552 H5Tclose (type_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
553 H5Gclose (group_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
554 return -1;
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
555 }
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
556 H5Tclose (st_id);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
557 H5Dclose (data_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
558 // NAME is obsolete and unused.
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
559 // std::string name (nm_tmp);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
560
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
561 #if defined (HAVE_HDF5_18)
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
562 data_hid = H5Dopen (group_hid, "iftext", octave_H5P_DEFAULT);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
563 #else
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
564 data_hid = H5Dopen (group_hid, "iftext");
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
565 #endif
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
566
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
567 if (data_hid < 0)
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
568 {
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
569 H5Gclose (group_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
570 return -1;
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
571 }
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
572
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
573 type_hid = H5Dget_type (data_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
574 type_class_hid = H5Tget_class (type_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
575
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
576 if (type_class_hid != H5T_STRING)
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
577 {
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
578 H5Tclose (type_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
579 H5Dclose (data_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
580 H5Gclose (group_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
581 return -1;
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
582 }
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
583
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
584 space_hid = H5Dget_space (data_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
585 rank = H5Sget_simple_extent_ndims (space_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
586
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
587 if (rank != 0)
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
588 {
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
589 H5Sclose (space_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
590 H5Tclose (type_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
591 H5Dclose (data_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
592 H5Gclose (group_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
593 return -1;
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
594 }
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
595
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
596 slen = H5Tget_size (type_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
597 if (slen < 0)
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
598 {
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
599 H5Sclose (space_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
600 H5Tclose (type_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
601 H5Dclose (data_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
602 H5Gclose (group_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
603 return -1;
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
604 }
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
605
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
606 OCTAVE_LOCAL_BUFFER (char, iftext_tmp, slen);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
607
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
608 // create datatype for (null-terminated) string to read into:
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
609 st_id = H5Tcopy (H5T_C_S1);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
610 H5Tset_size (st_id, slen);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
611
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
612 if (H5Dread (data_hid, st_id, octave_H5S_ALL, octave_H5S_ALL,
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
613 octave_H5P_DEFAULT, iftext_tmp) < 0)
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
614 {
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
615 H5Sclose (space_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
616 H5Tclose (type_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
617 H5Gclose (group_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
618 return -1;
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
619 }
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
620 H5Tclose (st_id);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
621 H5Dclose (data_hid);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
622
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
623 args(0) = std::string (iftext_tmp);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
624
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
625 octave::interpreter& interp
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
626 = octave::__get_interpreter__ ("load_inline_fcn");
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
627
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
628 octave_value_list tmp = interp.feval ("inline", args, 1);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
629
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
630 if (tmp.length () > 0)
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
631 {
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
632 retval = tmp(0);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
633 return 1;
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
634 }
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
635
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
636 #else
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
637 octave_unused_parameter (loc_id);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
638 octave_unused_parameter (name);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
639 octave_unused_parameter (retval);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
640
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
641 warn_load ("hdf5");
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
642 #endif
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
643
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
644 return -1;
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
645 }
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
646
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
647 // This function is designed to be passed to H5Giterate, which calls it
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
648 // on each data item in an HDF5 file. For the item whose name is NAME in
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
649 // the group GROUP_ID, this function sets dv->tc to an Octave representation
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
650 // of that item. (dv must be a pointer to hdf5_callback_data.) (It also
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
651 // sets the other fields of dv).
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
652 //
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
653 // It returns 1 on success (in which case H5Giterate stops and returns),
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
654 // -1 on error, and 0 to tell H5Giterate to continue on to the next item
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21724
diff changeset
655 // (e.g., if NAME was a data type we don't recognize).
29384
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
656 //
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
657 // This function must not throw an exception.
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
658
22028
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
659 static herr_t
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
660 hdf5_read_next_data_internal (hid_t group_id, const char *name, void *dv)
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
661 {
19739
3fa35defe495 Adjust spacing of static_cast<> calls to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
662 hdf5_callback_data *d = static_cast<hdf5_callback_data *> (dv);
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
663 hid_t type_id = -1;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
664 hid_t type_class_id = -1;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
665 hid_t data_id = -1;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
666 hid_t subgroup_id = -1;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
667 hid_t space_id = -1;;
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
668
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
669 H5G_stat_t info;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
670 herr_t retval = 0;
25646
4d565baa475e move libinterp/utils functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 25604
diff changeset
671 bool ident_valid = octave::valid_identifier (name);
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
672
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
673 std::string vname = name;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
674
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
675 octave::type_info& type_info
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
676 = octave::__get_type_info__ ("hdf5_read_next_data_internal");
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
677
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
678 // Allow identifiers as all digits so we can load lists saved by
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
679 // earlier versions of Octave.
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
680
18678
6113e0c6920b maint: Clean up extra spaces before/after parentheses.
Rik <rik@octave.org>
parents: 18676
diff changeset
681 if (! ident_valid)
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
682 {
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
683 // fix the identifier, replacing invalid chars with underscores
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
684 vname = make_valid_identifier (vname);
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
685
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
686 // check again (in case vname was null, empty, or some such thing):
25646
4d565baa475e move libinterp/utils functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 25604
diff changeset
687 ident_valid = octave::valid_identifier (vname);
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
688 }
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
689
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
690 H5Gget_objinfo (group_id, name, 1, &info);
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
691
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
692 if (info.type == H5G_GROUP && ident_valid)
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
693 {
21211
2cf8bc5c7017 use "#if defined (HAVE_FOO)" instead of "#if HAVE_FOO" for feature tests
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
694 #if defined (HAVE_HDF5_18)
21022
ebc439187d29 avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
695 subgroup_id = H5Gopen (group_id, name, octave_H5P_DEFAULT);
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
696 #else
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
697 subgroup_id = H5Gopen (group_id, name);
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
698 #endif
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
699
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
700 if (subgroup_id < 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
701 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
702 retval = subgroup_id;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
703 goto done;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
704 }
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
705
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
706 if (hdf5_check_attr (subgroup_id, "OCTAVE_NEW_FORMAT"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
707 {
21211
2cf8bc5c7017 use "#if defined (HAVE_FOO)" instead of "#if HAVE_FOO" for feature tests
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
708 #if defined (HAVE_HDF5_18)
21022
ebc439187d29 avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
709 data_id = H5Dopen (subgroup_id, "type", octave_H5P_DEFAULT);
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
710 #else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
711 data_id = H5Dopen (subgroup_id, "type");
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
712 #endif
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
713
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
714 if (data_id < 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
715 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
716 retval = data_id;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
717 goto done;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
718 }
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
719
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
720 type_id = H5Dget_type (data_id);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
721
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
722 type_class_id = H5Tget_class (type_id);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
723
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
724 if (type_class_id != H5T_STRING)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
725 goto done;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
726
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
727 space_id = H5Dget_space (data_id);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
728 hsize_t rank = H5Sget_simple_extent_ndims (space_id);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
729
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
730 if (rank != 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
731 goto done;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
732
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
733 int slen = H5Tget_size (type_id);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
734 if (slen < 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
735 goto done;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
736
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
737 OCTAVE_LOCAL_BUFFER (char, typ, slen);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
738
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
739 // create datatype for (null-terminated) string to read into:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
740 hid_t st_id = H5Tcopy (H5T_C_S1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
741 H5Tset_size (st_id, slen);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
742
29384
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
743 if (H5Dread (data_id, st_id, octave_H5S_ALL, octave_H5S_ALL,
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
744 octave_H5P_DEFAULT, typ) < 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
745 goto done;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
746
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
747 H5Tclose (st_id);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
748 H5Dclose (data_id);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
749
29385
cee1cf711a4e ls-hdf5.cc: Handle non-zero terminated type strings (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29384
diff changeset
750 if (std::string (typ, slen-1) == "inline function")
28427
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
751 {
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
752 retval = load_inline_fcn (subgroup_id, name, d->tc);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
753 }
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
754 else
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
755 {
29385
cee1cf711a4e ls-hdf5.cc: Handle non-zero terminated type strings (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29384
diff changeset
756 d->tc = type_info.lookup_type (std::string (typ, slen-1));
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
757
29384
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
758 try
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
759 {
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
760 retval = (d->tc.load_hdf5 (subgroup_id, "value") ? 1 : -1);
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
761 }
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
762 catch (const octave::execution_exception& ee)
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
763 {
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
764 retval = -1;
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
765 }
28427
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
766 }
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
767
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
768 // check for OCTAVE_GLOBAL attribute:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
769 d->global = hdf5_check_attr (subgroup_id, "OCTAVE_GLOBAL");
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
770
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
771 H5Gclose (subgroup_id);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
772 }
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
773 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
774 {
28427
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
775 // It seems that this block only applies to an old list type
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
776 // and that we shouldn't need to handle the old inline
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
777 // function type here.
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
778
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
779 // an HDF5 group is treated as an octave structure by
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
780 // default (since that preserves name information), and an
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
781 // octave list otherwise.
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
782
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
783 if (hdf5_check_attr (subgroup_id, "OCTAVE_LIST"))
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
784 d->tc = type_info.lookup_type ("list");
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
785 else
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
786 d->tc = type_info.lookup_type ("struct");
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
787
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
788 // check for OCTAVE_GLOBAL attribute:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
789 d->global = hdf5_check_attr (subgroup_id, "OCTAVE_GLOBAL");
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
790
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
791 H5Gclose (subgroup_id);
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
792
29384
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
793 try
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
794 {
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
795 retval = (d->tc.load_hdf5 (group_id, name) ? 1 : -1);
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
796 }
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
797 catch (const octave::execution_exception& ee)
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
798 {
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
799 retval = -1;
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
800 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
801 }
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
802
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
803 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
804 else if (info.type == H5G_DATASET && ident_valid)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
805 {
28427
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
806 // It seems that this block only applies to an old version of
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
807 // Octave HDF5 files and that it is probably not important to
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
808 // handle the old inline function type here.
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
809
20449
df4165dfc676 maint: Fix misspelled word compatibility in code comments.
Rik <rik@octave.org>
parents: 20264
diff changeset
810 // For backwards compatibility.
21211
2cf8bc5c7017 use "#if defined (HAVE_FOO)" instead of "#if HAVE_FOO" for feature tests
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
811 #if defined (HAVE_HDF5_18)
21022
ebc439187d29 avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
812 data_id = H5Dopen (group_id, name, octave_H5P_DEFAULT);
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
813 #else
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
814 data_id = H5Dopen (group_id, name);
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
815 #endif
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
816
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
817 if (data_id < 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
818 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
819 retval = data_id;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
820 goto done;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
821 }
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
822
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
823 type_id = H5Dget_type (data_id);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
824
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
825 type_class_id = H5Tget_class (type_id);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
826
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
827 if (type_class_id == H5T_FLOAT)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
828 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
829 space_id = H5Dget_space (data_id);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
830
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
831 hsize_t rank = H5Sget_simple_extent_ndims (space_id);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
832
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
833 if (rank == 0)
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
834 d->tc = type_info.lookup_type ("scalar");
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
835 else
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
836 d->tc = type_info.lookup_type ("matrix");
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
837
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
838 H5Sclose (space_id);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
839 }
4948
7124436476cb [project @ 2004-08-31 17:57:21 by jwe]
jwe
parents: 4805
diff changeset
840 else if (type_class_id == H5T_INTEGER)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
841 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
842 // What integer type do we really have..
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
843 std::string int_typ;
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21691
diff changeset
844 #if defined (HAVE_H5T_GET_NATIVE_TYPE)
17861
870f3e12e163 maint: Use phrase "FIXME:" for problem areas in code.
Rik <rik@octave.org>
parents: 17787
diff changeset
845 // FIXME: test this code and activated with an autoconf
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
846 // test!! It is also incorrect for 64-bit indexing!!
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
847
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
848 switch (H5Tget_native_type (type_id, H5T_DIR_ASCEND))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
849 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
850 case H5T_NATIVE_CHAR:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
851 int_typ = "int8 ";
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
852 break;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
853
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
854 case H5T_NATIVE_SHORT:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
855 int_typ = "int16 ";
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
856 break;
4948
7124436476cb [project @ 2004-08-31 17:57:21 by jwe]
jwe
parents: 4805
diff changeset
857
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
858 case H5T_NATIVE_INT:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
859 case H5T_NATIVE_LONG:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
860 int_typ = "int32 ";
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
861 break;
4948
7124436476cb [project @ 2004-08-31 17:57:21 by jwe]
jwe
parents: 4805
diff changeset
862
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
863 case H5T_NATIVE_LLONG:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
864 int_typ = "int64 ";
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
865 break;
4948
7124436476cb [project @ 2004-08-31 17:57:21 by jwe]
jwe
parents: 4805
diff changeset
866
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
867 case H5T_NATIVE_UCHAR:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
868 int_typ = "uint8 ";
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
869 break;
4948
7124436476cb [project @ 2004-08-31 17:57:21 by jwe]
jwe
parents: 4805
diff changeset
870
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
871 case H5T_NATIVE_USHORT:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
872 int_typ = "uint16 ";
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
873 break;
4948
7124436476cb [project @ 2004-08-31 17:57:21 by jwe]
jwe
parents: 4805
diff changeset
874
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
875 case H5T_NATIVE_UINT:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
876 case H5T_NATIVE_ULONG:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
877 int_typ = "uint32 ";
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
878 break;
4948
7124436476cb [project @ 2004-08-31 17:57:21 by jwe]
jwe
parents: 4805
diff changeset
879
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
880 case H5T_NATIVE_ULLONG:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
881 int_typ = "uint64 ";
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
882 break;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
883 }
4948
7124436476cb [project @ 2004-08-31 17:57:21 by jwe]
jwe
parents: 4805
diff changeset
884 #else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
885 hid_t int_sign = H5Tget_sign (type_id);
4948
7124436476cb [project @ 2004-08-31 17:57:21 by jwe]
jwe
parents: 4805
diff changeset
886
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
887 if (int_sign == H5T_SGN_ERROR)
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
888 warning ("load: can't read '%s' (unknown datatype)", name);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
889 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
890 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
891 if (int_sign == H5T_SGN_NONE)
23807
336f89b6208b Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents: 23796
diff changeset
892 int_typ.push_back ('u');
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
893 int_typ.append ("int");
4948
7124436476cb [project @ 2004-08-31 17:57:21 by jwe]
jwe
parents: 4805
diff changeset
894
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
895 int slen = H5Tget_size (type_id);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
896 if (slen < 0)
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
897 warning ("load: can't read '%s' (unknown datatype)", name);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
898 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
899 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
900 switch (slen)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
901 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
902 case 1:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
903 int_typ.append ("8 ");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
904 break;
4948
7124436476cb [project @ 2004-08-31 17:57:21 by jwe]
jwe
parents: 4805
diff changeset
905
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
906 case 2:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
907 int_typ.append ("16 ");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
908 break;
4948
7124436476cb [project @ 2004-08-31 17:57:21 by jwe]
jwe
parents: 4805
diff changeset
909
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
910 case 4:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
911 int_typ.append ("32 ");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
912 break;
4948
7124436476cb [project @ 2004-08-31 17:57:21 by jwe]
jwe
parents: 4805
diff changeset
913
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
914 case 8:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
915 int_typ.append ("64 ");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
916 break;
4948
7124436476cb [project @ 2004-08-31 17:57:21 by jwe]
jwe
parents: 4805
diff changeset
917
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
918 default:
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
919 warning ("load: can't read '%s' (unknown datatype)",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
920 name);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
921 int_typ = "";
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
922 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
923 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
924 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
925 }
4948
7124436476cb [project @ 2004-08-31 17:57:21 by jwe]
jwe
parents: 4805
diff changeset
926 #endif
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
927 if (int_typ == "")
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
928 warning ("load: can't read '%s' (unknown datatype)", name);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
929 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
930 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
931 // Matrix or scalar?
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
932 space_id = H5Dget_space (data_id);
4948
7124436476cb [project @ 2004-08-31 17:57:21 by jwe]
jwe
parents: 4805
diff changeset
933
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
934 hsize_t rank = H5Sget_simple_extent_ndims (space_id);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
935
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
936 if (rank == 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
937 int_typ.append ("scalar");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
938 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
939 int_typ.append ("matrix");
4948
7124436476cb [project @ 2004-08-31 17:57:21 by jwe]
jwe
parents: 4805
diff changeset
940
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
941 d->tc = type_info.lookup_type (int_typ);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
942 H5Sclose (space_id);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
943 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
944 }
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
945 else if (type_class_id == H5T_STRING)
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
946 d->tc = type_info.lookup_type ("string");
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
947 else if (type_class_id == H5T_COMPOUND)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
948 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
949 hid_t complex_type = hdf5_make_complex_type (H5T_NATIVE_DOUBLE);
27138
9e5c1d343a2c Skip HDF5 elements which are unrecognized, but continue reading file (bug #32756).
Daniel Davis <ddesics@gmail.com>
parents: 27063
diff changeset
950 hid_t range_type = hdf5_make_range_type (H5T_NATIVE_DOUBLE);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
951
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
952 if (hdf5_types_compatible (type_id, complex_type))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
953 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
954 // read complex matrix or scalar variable
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
955 space_id = H5Dget_space (data_id);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
956 hsize_t rank = H5Sget_simple_extent_ndims (space_id);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
957
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
958 if (rank == 0)
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
959 d->tc = type_info.lookup_type ("complex scalar");
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
960 else
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
961 d->tc = type_info.lookup_type ("complex matrix");
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
962
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
963 H5Sclose (space_id);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
964 }
27138
9e5c1d343a2c Skip HDF5 elements which are unrecognized, but continue reading file (bug #32756).
Daniel Davis <ddesics@gmail.com>
parents: 27063
diff changeset
965 else if (hdf5_types_compatible (type_id, range_type))
9e5c1d343a2c Skip HDF5 elements which are unrecognized, but continue reading file (bug #32756).
Daniel Davis <ddesics@gmail.com>
parents: 27063
diff changeset
966 {
27932
b018f553fd85 maint: Use Octave coding conventions in libinterp/
Rik <rik@octave.org>
parents: 27929
diff changeset
967 // If it's not a complex, check if it's a range
b018f553fd85 maint: Use Octave coding conventions in libinterp/
Rik <rik@octave.org>
parents: 27929
diff changeset
968 d->tc = octave_value_typeinfo::lookup_type ("range");
27138
9e5c1d343a2c Skip HDF5 elements which are unrecognized, but continue reading file (bug #32756).
Daniel Davis <ddesics@gmail.com>
parents: 27063
diff changeset
969 }
9e5c1d343a2c Skip HDF5 elements which are unrecognized, but continue reading file (bug #32756).
Daniel Davis <ddesics@gmail.com>
parents: 27063
diff changeset
970 else // Otherwise, just ignore it with a warning.
9e5c1d343a2c Skip HDF5 elements which are unrecognized, but continue reading file (bug #32756).
Daniel Davis <ddesics@gmail.com>
parents: 27063
diff changeset
971 {
27932
b018f553fd85 maint: Use Octave coding conventions in libinterp/
Rik <rik@octave.org>
parents: 27929
diff changeset
972 warning ("load: can't read '%s' (unknown datatype)", name);
b018f553fd85 maint: Use Octave coding conventions in libinterp/
Rik <rik@octave.org>
parents: 27929
diff changeset
973 retval = 0; // unknown datatype; skip
b018f553fd85 maint: Use Octave coding conventions in libinterp/
Rik <rik@octave.org>
parents: 27929
diff changeset
974 return retval;
27138
9e5c1d343a2c Skip HDF5 elements which are unrecognized, but continue reading file (bug #32756).
Daniel Davis <ddesics@gmail.com>
parents: 27063
diff changeset
975 }
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
976
27138
9e5c1d343a2c Skip HDF5 elements which are unrecognized, but continue reading file (bug #32756).
Daniel Davis <ddesics@gmail.com>
parents: 27063
diff changeset
977 H5Tclose (range_type);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
978 H5Tclose (complex_type);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
979 }
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
980 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
981 {
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
982 warning ("load: can't read '%s' (unknown datatype)", name);
27138
9e5c1d343a2c Skip HDF5 elements which are unrecognized, but continue reading file (bug #32756).
Daniel Davis <ddesics@gmail.com>
parents: 27063
diff changeset
983 retval = 0; // unknown datatype; skip
18676
5bd1ca29c5f0 Clean up questionable code bits identified by clang sanitize.
Rik <rik@octave.org>
parents: 18100
diff changeset
984 return retval;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
985 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
986
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
987 // check for OCTAVE_GLOBAL attribute:
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
988 d->global = hdf5_check_attr (data_id, "OCTAVE_GLOBAL");
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
989
29384
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
990 try
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
991 {
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
992 retval = (d->tc.load_hdf5 (group_id, name) ? 1 : -1);
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
993 }
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
994 catch (const octave::execution_exception& ee)
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
995 {
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
996 retval = -1;
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
997 }
27063
eb25b491dad7 Don't segfault at exit after reading malformed HDF5 file (bug #56149).
Rik <rik@octave.org>
parents: 26499
diff changeset
998
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
999 H5Tclose (type_id);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1000 H5Dclose (data_id);
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1001 }
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1002
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20945
diff changeset
1003 if (! ident_valid)
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1004 {
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1005 // should we attempt to handle invalid identifiers by converting
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1006 // bad characters to '_', say?
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1007 warning ("load: skipping invalid identifier '%s' in hdf5 file",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1008 name);
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1009 }
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1010
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1011 done:
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1012 if (retval < 0)
27063
eb25b491dad7 Don't segfault at exit after reading malformed HDF5 file (bug #56149).
Rik <rik@octave.org>
parents: 26499
diff changeset
1013 {
eb25b491dad7 Don't segfault at exit after reading malformed HDF5 file (bug #56149).
Rik <rik@octave.org>
parents: 26499
diff changeset
1014 // Must be warning. A call to error aborts and leaves H5Giterate in
eb25b491dad7 Don't segfault at exit after reading malformed HDF5 file (bug #56149).
Rik <rik@octave.org>
parents: 26499
diff changeset
1015 // a mangled state that causes segfault on exit (bug #56149).
eb25b491dad7 Don't segfault at exit after reading malformed HDF5 file (bug #56149).
Rik <rik@octave.org>
parents: 26499
diff changeset
1016 warning ("load: error while reading hdf5 item '%s'", name);
eb25b491dad7 Don't segfault at exit after reading malformed HDF5 file (bug #56149).
Rik <rik@octave.org>
parents: 26499
diff changeset
1017 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1018
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1019 if (retval > 0)
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1020 {
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1021 // get documentation string, if any:
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23470
diff changeset
1022 int comment_length = H5Gget_comment (group_id, name, 0, nullptr);
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1023
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1024 if (comment_length > 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1025 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1026 OCTAVE_LOCAL_BUFFER (char, tdoc, comment_length);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1027 H5Gget_comment (group_id, name, comment_length, tdoc);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1028 d->doc = tdoc;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1029 }
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1030 else if (vname != name)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1031 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1032 // the name was changed; store the original name
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1033 // as the documentation string:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1034 d->doc = name;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1035 }
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1036
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1037 // copy name (actually, vname):
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1038 d->name = vname;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1039 }
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1040
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1041 return retval;
22028
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1042 }
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1043
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1044 #endif
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1045
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1046 octave_hdf5_err
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1047 hdf5_read_next_data (octave_hdf5_id group_id, const char *name, void *dv)
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1048 {
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1049 #if defined (HAVE_HDF5)
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1050
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1051 hid_t new_id = check_hdf5_id_value (group_id, "hdf5_read_next_data");
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1052
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1053 return hdf5_read_next_data_internal (new_id, name, dv);
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1054
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1055 #else
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1056 err_disabled_feature ("hdf5_read_next_data", "HDF5");
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1057 #endif
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1058 }
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1059
22028
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1060 octave_hdf5_err
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23440
diff changeset
1061 hdf5_h5g_iterate (octave_hdf5_id loc_id, const char *name, int *idx,
22028
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1062 void *operator_data)
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1063 {
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1064 #if defined (HAVE_HDF5)
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1065
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1066 hid_t new_id = check_hdf5_id_value (loc_id, "hdf5_h5g_iterate");
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1067
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1068 return H5Giterate (new_id, name, idx, hdf5_read_next_data_internal,
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1069 operator_data);
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1070
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1071 #else
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1072 err_disabled_feature ("hdf5_h5g_iterate", "HDF5");
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1073 #endif
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1074 }
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1075
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23455
diff changeset
1076 // Read the next Octave variable from the stream IS, which must really be an
27063
eb25b491dad7 Don't segfault at exit after reading malformed HDF5 file (bug #56149).
Rik <rik@octave.org>
parents: 26499
diff changeset
1077 // hdf5_ifstream. Return the variable value in tc, its docstring in doc, and
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23455
diff changeset
1078 // whether it is global in global. The return value is the name of the
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23455
diff changeset
1079 // variable, or NULL if none were found or there was an error.
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1080 std::string
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1081 read_hdf5_data (std::istream& is, const std::string& /* filename */,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1082 bool& global, octave_value& tc, std::string& doc,
17709
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1083 const string_vector& argv, int argv_idx, int argc)
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1084 {
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1085 #if defined (HAVE_HDF5)
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1086
30007
62f2c0a3982c move check_hdf5_types function inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29572
diff changeset
1087 octave::check_hdf5_types ();
19863
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19739
diff changeset
1088
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1089 std::string retval;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1090
23812
057a894914df Use C++11 string fcns back() and pop_back() to simplify code.
Rik <rik@octave.org>
parents: 23807
diff changeset
1091 doc.clear ();
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1092
5760
8d7162924bd3 [project @ 2006-04-14 04:01:37 by jwe]
jwe
parents: 5351
diff changeset
1093 hdf5_ifstream& hs = dynamic_cast<hdf5_ifstream&> (is);
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1094 hdf5_callback_data d;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1095
4696
fcab389ad291 [project @ 2004-01-15 02:11:59 by jwe]
jwe
parents: 4687
diff changeset
1096 herr_t H5Giterate_retval = -1;
fcab389ad291 [project @ 2004-01-15 02:11:59 by jwe]
jwe
parents: 4687
diff changeset
1097
fcab389ad291 [project @ 2004-01-15 02:11:59 by jwe]
jwe
parents: 4687
diff changeset
1098 hsize_t num_obj = 0;
21211
2cf8bc5c7017 use "#if defined (HAVE_FOO)" instead of "#if HAVE_FOO" for feature tests
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
1099 #if defined (HAVE_HDF5_18)
21022
ebc439187d29 avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
1100 hid_t group_id = H5Gopen (hs.file_id, "/", octave_H5P_DEFAULT);
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
1101 #else
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1102 hid_t group_id = H5Gopen (hs.file_id, "/");
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
1103 #endif
5060
34a904ac130d [project @ 2004-11-02 03:08:10 by jwe]
jwe
parents: 4948
diff changeset
1104 H5Gget_num_objs (group_id, &num_obj);
34a904ac130d [project @ 2004-11-02 03:08:10 by jwe]
jwe
parents: 4948
diff changeset
1105 H5Gclose (group_id);
17709
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1106
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1107 // For large datasets and out-of-core functionality,
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1108 // check if only parts of the data is requested
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1109 bool load_named_vars = argv_idx < argc;
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1110 while (load_named_vars && hs.current_item < static_cast<int> (num_obj))
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1111 {
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1112 std::vector<char> var_name;
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1113 bool found = false;
29572
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29385
diff changeset
1114 std::size_t len = 0;
17709
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1115
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23470
diff changeset
1116 len = H5Gget_objname_by_idx (hs.file_id, hs.current_item, nullptr, 0);
17709
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1117 var_name.resize (len+1);
18678
6113e0c6920b maint: Clean up extra spaces before/after parentheses.
Rik <rik@octave.org>
parents: 18676
diff changeset
1118 H5Gget_objname_by_idx (hs.file_id, hs.current_item, &var_name[0], len+1);
17709
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1119
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1120 for (int i = argv_idx; i < argc; i++)
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1121 {
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1122 glob_match pattern (argv[i]);
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1123 if (pattern.match (std::string (&var_name[0])))
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1124 {
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1125 found = true;
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1126 break;
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1127 }
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1128 }
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1129
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1130 if (found)
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1131 break;
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1132
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1133 hs.current_item++;
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1134 }
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1135
4696
fcab389ad291 [project @ 2004-01-15 02:11:59 by jwe]
jwe
parents: 4687
diff changeset
1136 if (hs.current_item < static_cast<int> (num_obj))
fcab389ad291 [project @ 2004-01-15 02:11:59 by jwe]
jwe
parents: 4687
diff changeset
1137 H5Giterate_retval = H5Giterate (hs.file_id, "/", &hs.current_item,
22028
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1138 hdf5_read_next_data_internal, &d);
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1139
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1140 if (H5Giterate_retval > 0)
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1141 {
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1142 global = d.global;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1143 tc = d.tc;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1144 doc = d.doc;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1145 }
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1146 else
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1147 {
27063
eb25b491dad7 Don't segfault at exit after reading malformed HDF5 file (bug #56149).
Rik <rik@octave.org>
parents: 26499
diff changeset
1148 // An error occurred (H5Giterate_retval < 0),
eb25b491dad7 Don't segfault at exit after reading malformed HDF5 file (bug #56149).
Rik <rik@octave.org>
parents: 26499
diff changeset
1149 // or there are no more datasets (H5Giterate_retval == 0).
eb25b491dad7 Don't segfault at exit after reading malformed HDF5 file (bug #56149).
Rik <rik@octave.org>
parents: 26499
diff changeset
1150 // hdf5_read_next_data_internal has already printed a warning msg.
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1151 }
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1152
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1153 if (! d.name.empty ())
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1154 retval = d.name;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1155
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1156 return retval;
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1157
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1158 #else
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1159 err_disabled_feature ("read_hdf5_data", "HDF5");
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1160 #endif
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1161 }
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1162
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1163 // Add an attribute named attr_name to loc_id (a simple scalar
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1164 // attribute with value 1). Return value is >= 0 on success.
20264
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
1165 octave_hdf5_err
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
1166 hdf5_add_attr (octave_hdf5_id loc_id, const char *attr_name)
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1167 {
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1168 #if defined (HAVE_HDF5)
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1169
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1170 herr_t retval = 0;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1171
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1172 hid_t as_id = H5Screate (H5S_SCALAR);
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1173
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1174 if (as_id >= 0)
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1175 {
21211
2cf8bc5c7017 use "#if defined (HAVE_FOO)" instead of "#if HAVE_FOO" for feature tests
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
1176 #if defined (HAVE_HDF5_18)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1177 hid_t a_id = H5Acreate (loc_id, attr_name, H5T_NATIVE_UCHAR,
21022
ebc439187d29 avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
1178 as_id, octave_H5P_DEFAULT, octave_H5P_DEFAULT);
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
1179 #else
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1180 hid_t a_id = H5Acreate (loc_id, attr_name,
21022
ebc439187d29 avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
1181 H5T_NATIVE_UCHAR, as_id, octave_H5P_DEFAULT);
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
1182 #endif
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1183 if (a_id >= 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1184 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1185 unsigned char attr_val = 1;
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1186
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1187 retval = H5Awrite (a_id, H5T_NATIVE_UCHAR, &attr_val);
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1188
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1189 H5Aclose (a_id);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1190 }
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1191 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1192 retval = a_id;
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1193
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1194 H5Sclose (as_id);
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1195 }
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1196 else
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1197 retval = as_id;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1198
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1199 return retval;
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1200
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1201 #else
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1202 err_disabled_feature ("hdf5_add_attr", "HDF5");
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1203 #endif
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1204 }
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1205
20264
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
1206 octave_hdf5_err
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
1207 hdf5_add_scalar_attr (octave_hdf5_id loc_id, octave_hdf5_id type_id,
11176
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1208 const char *attr_name, void *buf)
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1209 {
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1210 #if defined (HAVE_HDF5)
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1211
11176
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1212 herr_t retval = 0;
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1213
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1214 hid_t as_id = H5Screate (H5S_SCALAR);
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1215
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1216 if (as_id >= 0)
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1217 {
21211
2cf8bc5c7017 use "#if defined (HAVE_FOO)" instead of "#if HAVE_FOO" for feature tests
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
1218 #if defined (HAVE_HDF5_18)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1219 hid_t a_id = H5Acreate (loc_id, attr_name, type_id,
21022
ebc439187d29 avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
1220 as_id, octave_H5P_DEFAULT, octave_H5P_DEFAULT);
11176
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1221 #else
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1222 hid_t a_id = H5Acreate (loc_id, attr_name,
21022
ebc439187d29 avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
1223 type_id, as_id, octave_H5P_DEFAULT);
11176
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1224 #endif
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1225 if (a_id >= 0)
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1226 {
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1227 retval = H5Awrite (a_id, type_id, buf);
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1228
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1229 H5Aclose (a_id);
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1230 }
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1231 else
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1232 retval = a_id;
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1233
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1234 H5Sclose (as_id);
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1235 }
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1236 else
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1237 retval = as_id;
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1238
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1239 return retval;
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1240
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1241 #else
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1242 err_disabled_feature ("hdf5_add_scalar_attr", "HDF5");
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1243 #endif
11176
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1244 }
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1245
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21724
diff changeset
1246 // Save an empty matrix, if needed. Returns
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1247 // > 0 Saved empty matrix
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1248 // = 0 Not an empty matrix; did nothing
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1249 // < 0 Error condition
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1250 int
23440
f15f0d8b78c8 pass dim_vector as const reference, not by value
John W. Eaton <jwe@octave.org>
parents: 23433
diff changeset
1251 save_hdf5_empty (octave_hdf5_id loc_id, const char *name, const dim_vector& d)
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1252 {
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1253 #if defined (HAVE_HDF5)
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1254
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1255 hsize_t sz = d.length ();
6276
d26c558691cd [project @ 2007-02-07 09:01:24 by jwe]
jwe
parents: 5775
diff changeset
1256 OCTAVE_LOCAL_BUFFER (octave_idx_type, dims, sz);
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1257 bool empty = false;
18100
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
1258 hid_t space_hid = -1;
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
1259 hid_t data_hid = -1;
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1260 int retval;
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1261 for (hsize_t i = 0; i < sz; i++)
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1262 {
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1263 dims[i] = d(i);
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1264 if (dims[i] < 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1265 empty = true;
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1266 }
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1267
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20945
diff changeset
1268 if (! empty)
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1269 return 0;
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1270
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23470
diff changeset
1271 space_hid = H5Screate_simple (1, &sz, nullptr);
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1272 if (space_hid < 0) return space_hid;
21211
2cf8bc5c7017 use "#if defined (HAVE_FOO)" instead of "#if HAVE_FOO" for feature tests
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
1273 #if defined (HAVE_HDF5_18)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1274 data_hid = H5Dcreate (loc_id, name, H5T_NATIVE_IDX, space_hid,
21022
ebc439187d29 avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
1275 octave_H5P_DEFAULT, octave_H5P_DEFAULT, octave_H5P_DEFAULT);
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
1276 #else
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1277 data_hid = H5Dcreate (loc_id, name, H5T_NATIVE_IDX, space_hid,
21022
ebc439187d29 avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
1278 octave_H5P_DEFAULT);
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
1279 #endif
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1280 if (data_hid < 0)
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1281 {
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1282 H5Sclose (space_hid);
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1283 return data_hid;
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1284 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1285
21022
ebc439187d29 avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
1286 retval = H5Dwrite (data_hid, H5T_NATIVE_IDX, octave_H5S_ALL, octave_H5S_ALL,
ebc439187d29 avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
1287 octave_H5P_DEFAULT, dims) >= 0;
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1288
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1289 H5Dclose (data_hid);
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1290 H5Sclose (space_hid);
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1291
26499
9326e683c3a4 ls-hdf5.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents: 26376
diff changeset
1292 if (retval)
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1293 retval = hdf5_add_attr (loc_id, "OCTAVE_EMPTY_MATRIX");
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1294
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1295 return (retval == 0 ? 1 : retval);
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1296
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1297 #else
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1298 err_disabled_feature ("save_hdf5_empty", "HDF5");
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1299 #endif
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1300 }
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1301
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21724
diff changeset
1302 // Load an empty matrix, if needed. Returns
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1303 // > 0 loaded empty matrix, dimensions returned
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1304 // = 0 Not an empty matrix; did nothing
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1305 // < 0 Error condition
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1306 int
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
1307 load_hdf5_empty (octave_hdf5_id loc_id, const char *name, dim_vector& d)
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1308 {
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1309 #if defined (HAVE_HDF5)
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1310
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1311 if (! hdf5_check_attr (loc_id, "OCTAVE_EMPTY_MATRIX"))
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1312 return 0;
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1313
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1314 hsize_t hdims, maxdims;
21211
2cf8bc5c7017 use "#if defined (HAVE_FOO)" instead of "#if HAVE_FOO" for feature tests
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
1315 #if defined (HAVE_HDF5_18)
21022
ebc439187d29 avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
1316 hid_t data_hid = H5Dopen (loc_id, name, octave_H5P_DEFAULT);
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
1317 #else
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1318 hid_t data_hid = H5Dopen (loc_id, name);
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
1319 #endif
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1320 hid_t space_id = H5Dget_space (data_hid);
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1321 H5Sget_simple_extent_dims (space_id, &hdims, &maxdims);
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1322 int retval;
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1323
5351
05adf9de7657 [project @ 2005-05-16 20:07:36 by dbateman]
dbateman
parents: 5307
diff changeset
1324 OCTAVE_LOCAL_BUFFER (octave_idx_type, dims, hdims);
05adf9de7657 [project @ 2005-05-16 20:07:36 by dbateman]
dbateman
parents: 5307
diff changeset
1325
21022
ebc439187d29 avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
1326 retval = H5Dread (data_hid, H5T_NATIVE_IDX, octave_H5S_ALL, octave_H5S_ALL,
ebc439187d29 avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
1327 octave_H5P_DEFAULT, dims);
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1328 if (retval >= 0)
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1329 {
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1330 d.resize (hdims);
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1331 for (hsize_t i = 0; i < hdims; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1332 d(i) = dims[i];
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1333 }
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1334
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1335 H5Sclose (space_id);
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1336 H5Dclose (data_hid);
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1337
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1338 return (retval == 0 ? hdims : retval);
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1339
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1340 #else
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1341 err_disabled_feature ("load_hdf5_empty", "HDF5");
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1342 #endif
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1343 }
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1344
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1345 // save_type_to_hdf5 is not currently used, since hdf5 doesn't yet support
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1346 // automatic float<->integer conversions:
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1347
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1348 // return the HDF5 type id corresponding to the Octave save_type
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1349
20264
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
1350 octave_hdf5_id
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1351 save_type_to_hdf5 (save_type st)
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1352 {
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1353 #if defined (HAVE_HDF5)
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1354 # if defined (HAVE_HDF5_INT2FLOAT_CONVERSIONS)
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1355
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1356 switch (st)
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1357 {
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1358 case LS_U_CHAR:
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1359 return H5T_NATIVE_UCHAR;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1360
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1361 case LS_U_SHORT:
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1362 return H5T_NATIVE_USHORT;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1363
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1364 case LS_U_INT:
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1365 return H5T_NATIVE_UINT;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1366
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1367 case LS_CHAR:
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1368 return H5T_NATIVE_CHAR;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1369
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1370 case LS_SHORT:
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1371 return H5T_NATIVE_SHORT;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1372
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1373 case LS_INT:
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1374 return H5T_NATIVE_INT;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1375
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1376 case LS_FLOAT:
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1377 return H5T_NATIVE_FLOAT;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1378
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1379 case LS_DOUBLE:
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1380 default:
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1381 return H5T_NATIVE_DOUBLE;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1382 }
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1383
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1384 # else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21682
diff changeset
1385
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21682
diff changeset
1386 octave_unused_parameter (st);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21682
diff changeset
1387
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1388 return -1;
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21682
diff changeset
1389
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1390 # endif
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21682
diff changeset
1391
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1392 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21682
diff changeset
1393
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21682
diff changeset
1394 octave_unused_parameter (st);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21682
diff changeset
1395
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1396 err_disabled_feature ("save_type_to_hdf5", "HDF5");
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21682
diff changeset
1397
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1398 #endif
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1399 }
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1400
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1401 // Add the data from TC to the HDF5 location loc_id, which could
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1402 // be either a file or a group within a file. Return true if
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1403 // successful. This function calls itself recursively for lists
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1404 // (stored as HDF5 groups).
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1405
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1406 bool
20264
bfe66db8addb don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents: 19863
diff changeset
1407 add_hdf5_data (octave_hdf5_id loc_id, const octave_value& tc,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1408 const std::string& name, const std::string& doc,
23470
a41fdb801db6 use mark_global and mark_persistent consistently
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
1409 bool mark_global, bool save_as_floats)
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1410 {
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1411 #if defined (HAVE_HDF5)
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1412
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1413 hsize_t dims[3];
18100
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
1414 hid_t type_id, space_id, data_id, data_type_id;
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
1415 type_id = space_id = data_id = data_type_id = -1;
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
1416
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1417 bool retval = false;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1418 octave_value val = tc;
8401
712cfdc2e417 allow saving diagonal & permutation matrices to hdf5 as full
Jaroslav Hajek <highegg@gmail.com>
parents: 8377
diff changeset
1419 // FIXME: diagonal & permutation matrices currently don't know how to save
712cfdc2e417 allow saving diagonal & permutation matrices to hdf5 as full
Jaroslav Hajek <highegg@gmail.com>
parents: 8377
diff changeset
1420 // themselves, so we convert them first to normal matrices using A = A(:,:).
712cfdc2e417 allow saving diagonal & permutation matrices to hdf5 as full
Jaroslav Hajek <highegg@gmail.com>
parents: 8377
diff changeset
1421 // This is a temporary hack.
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1422 if (val.is_diag_matrix () || val.is_perm_matrix ()
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
1423 || val.type_id () == octave_lazy_index::static_type_id ())
8914
354179c24c79 fix hdf5 saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8676
diff changeset
1424 val = val.full_value ();
8401
712cfdc2e417 allow saving diagonal & permutation matrices to hdf5 as full
Jaroslav Hajek <highegg@gmail.com>
parents: 8377
diff changeset
1425
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
1426 std::string t = val.type_name ();
21211
2cf8bc5c7017 use "#if defined (HAVE_FOO)" instead of "#if HAVE_FOO" for feature tests
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
1427 #if defined (HAVE_HDF5_18)
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
1428 data_id = H5Gcreate (loc_id, name.c_str (), octave_H5P_DEFAULT,
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
1429 octave_H5P_DEFAULT, octave_H5P_DEFAULT);
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
1430 #else
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1431 data_id = H5Gcreate (loc_id, name.c_str (), 0);
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
1432 #endif
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1433 if (data_id < 0)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1434 goto error_cleanup;
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1435
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1436 // attach the type of the variable
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1437 type_id = H5Tcopy (H5T_C_S1); H5Tset_size (type_id, t.length () + 1);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1438 if (type_id < 0)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1439 goto error_cleanup;
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1440
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1441 dims[0] = 0;
27932
b018f553fd85 maint: Use Octave coding conventions in libinterp/
Rik <rik@octave.org>
parents: 27929
diff changeset
1442 space_id = H5Screate_simple (0, dims, nullptr);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1443 if (space_id < 0)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1444 goto error_cleanup;
21211
2cf8bc5c7017 use "#if defined (HAVE_FOO)" instead of "#if HAVE_FOO" for feature tests
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
1445 #if defined (HAVE_HDF5_18)
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
1446 data_type_id = H5Dcreate (data_id, "type", type_id, space_id,
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
1447 octave_H5P_DEFAULT, octave_H5P_DEFAULT,
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
1448 octave_H5P_DEFAULT);
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
1449 #else
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
1450 data_type_id = H5Dcreate (data_id, "type", type_id, space_id,
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
1451 octave_H5P_DEFAULT);
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
1452 #endif
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
1453 if (data_type_id < 0
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
1454 || H5Dwrite (data_type_id, type_id, octave_H5S_ALL, octave_H5S_ALL,
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
1455 octave_H5P_DEFAULT, t.c_str ()) < 0)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1456 goto error_cleanup;
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1457
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1458 // Now call the real function to save the variable
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1459 retval = val.save_hdf5 (data_id, "value", save_as_floats);
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1460
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1461 // attach doc string as comment:
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1462 if (retval && doc.length () > 0
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1463 && H5Gset_comment (loc_id, name.c_str (), doc.c_str ()) < 0)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1464 retval = false;
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1465
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1466 // if it's global, add an attribute "OCTAVE_GLOBAL" with value 1
23470
a41fdb801db6 use mark_global and mark_persistent consistently
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
1467 if (retval && mark_global)
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1468 retval = hdf5_add_attr (data_id, "OCTAVE_GLOBAL") >= 0;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1469
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1470 // We are saving in the new variable format, so mark it
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1471 if (retval)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1472 retval = hdf5_add_attr (data_id, "OCTAVE_NEW_FORMAT") >= 0;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1473
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1474 error_cleanup:
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1475
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1476 if (data_type_id >= 0)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1477 H5Dclose (data_type_id);
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1478
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1479 if (type_id >= 0)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1480 H5Tclose (type_id);
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1481
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1482 if (space_id >= 0)
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1483 H5Sclose (space_id);
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1484
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1485 if (data_id >= 0)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1486 H5Gclose (data_id);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1487
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1488 if (! retval)
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1489 error ("save: error while writing '%s' to hdf5 file", name.c_str ());
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1490
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1491 return retval;
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1492
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1493 #else
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1494 err_disabled_feature ("add_hdf5_data", "HDF5");
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1495 #endif
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1496 }
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1497
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1498 // Write data from TC in HDF5 (binary) format to the stream OS,
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1499 // which must be an hdf5_ofstream, returning true on success.
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1500
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1501 bool
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1502 save_hdf5_data (std::ostream& os, const octave_value& tc,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1503 const std::string& name, const std::string& doc,
23470
a41fdb801db6 use mark_global and mark_persistent consistently
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
1504 bool mark_global, bool save_as_floats)
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1505 {
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1506 #if defined (HAVE_HDF5)
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1507
30007
62f2c0a3982c move check_hdf5_types function inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29572
diff changeset
1508 octave::check_hdf5_types ();
19863
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19739
diff changeset
1509
5760
8d7162924bd3 [project @ 2006-04-14 04:01:37 by jwe]
jwe
parents: 5351
diff changeset
1510 hdf5_ofstream& hs = dynamic_cast<hdf5_ofstream&> (os);
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1511
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1512 return add_hdf5_data (hs.file_id, tc, name, doc,
23470
a41fdb801db6 use mark_global and mark_persistent consistently
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
1513 mark_global, save_as_floats);
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1514
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1515 #else
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1516 err_disabled_feature ("save_hdf5_data", "HDF5");
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1517 #endif
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1518 }
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1519
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1520 #endif