annotate libinterp/corefcn/ls-hdf5.cc @ 31238:67cad4e8f866

Include graphics objects with hidden handles in axes limit calculation (bug #63095). * libinterp/corefcn/graphics.cc (get_children_limits): Get handles to all axes children including those with hidden handle visibility. Add BIST. * libinterp/corefcn/graphics.in.h (text::update_position): Do not automatically change "zliminclude" property. Axes labels are implemented as text objects, and we don't want their extent to be included in the axis limit calculation.
author Markus Mützel <markus.muetzel@gmx.de>
date Sat, 24 Sep 2022 11:57:44 +0200
parents 670a0d878af1
children aac27ad79be6
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
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
310 H5E_auto_t err_fcn;
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
311 void *err_fcn_data;
4634
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)
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
317 H5Eget_auto (octave_H5E_DEFAULT, &err_fcn, &err_fcn_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
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
320 H5Eget_auto (&err_fcn, &err_fcn_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)
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
335 H5Eset_auto (octave_H5E_DEFAULT, err_fcn, err_fcn_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
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
337 H5Eset_auto (err_fcn, err_fcn_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
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
358 H5E_auto_t err_fcn;
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
359 void *err_fcn_data;
11176
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)
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
365 H5Eget_auto (octave_H5E_DEFAULT, &err_fcn, &err_fcn_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
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
368 H5Eget_auto (&err_fcn, &err_fcn_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)
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
387 H5Eset_auto (octave_H5E_DEFAULT, err_fcn, err_fcn_data);
11176
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
388 #else
30896
c9788d7f6e65 maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents: 30565
diff changeset
389 H5Eset_auto (err_fcn, err_fcn_data);
11176
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
31105
670a0d878af1 eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents: 30896
diff changeset
625 octave::interpreter& interp = octave::__get_interpreter__ ();
28427
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
626
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
627 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
628
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
629 if (tmp.length () > 0)
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
630 {
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
631 retval = tmp(0);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
632 return 1;
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
633 }
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 #else
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
636 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
637 octave_unused_parameter (name);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
638 octave_unused_parameter (retval);
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
639
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
640 warn_load ("hdf5");
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
641 #endif
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
642
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
643 return -1;
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
644 }
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
645
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
646 // 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
647 // 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
648 // 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
649 // 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
650 // sets the other fields of dv).
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
651 //
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
652 // 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
653 // -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
654 // (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
655 //
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
656 // This function must not throw an exception.
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
657
22028
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
658 static herr_t
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
659 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
660 {
19739
3fa35defe495 Adjust spacing of static_cast<> calls to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
661 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
662 hid_t type_id = -1;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
663 hid_t type_class_id = -1;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
664 hid_t data_id = -1;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
665 hid_t subgroup_id = -1;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
666 hid_t space_id = -1;;
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
667
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
668 H5G_stat_t info;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
669 herr_t retval = 0;
25646
4d565baa475e move libinterp/utils functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 25604
diff changeset
670 bool ident_valid = octave::valid_identifier (name);
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
671
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
672 std::string vname = name;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
673
31105
670a0d878af1 eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents: 30896
diff changeset
674 octave::type_info& type_info = octave::__get_type_info__ ();
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
675
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
676 // 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
677 // earlier versions of Octave.
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
678
18678
6113e0c6920b maint: Clean up extra spaces before/after parentheses.
Rik <rik@octave.org>
parents: 18676
diff changeset
679 if (! ident_valid)
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
680 {
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
681 // fix the identifier, replacing invalid chars with underscores
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
682 vname = make_valid_identifier (vname);
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
683
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
684 // 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
685 ident_valid = octave::valid_identifier (vname);
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
686 }
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
687
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
688 H5Gget_objinfo (group_id, name, 1, &info);
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
689
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
690 if (info.type == H5G_GROUP && ident_valid)
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
691 {
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
692 #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
693 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
694 #else
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
695 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
696 #endif
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
697
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
698 if (subgroup_id < 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
699 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
700 retval = subgroup_id;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
701 goto done;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
702 }
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
703
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
704 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
705 {
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
706 #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
707 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
708 #else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
709 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
710 #endif
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
711
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
712 if (data_id < 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
713 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
714 retval = data_id;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
715 goto done;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
716 }
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
717
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
718 type_id = H5Dget_type (data_id);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
719
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
720 type_class_id = H5Tget_class (type_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 if (type_class_id != H5T_STRING)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
723 goto done;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
724
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
725 space_id = H5Dget_space (data_id);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
726 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
727
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
728 if (rank != 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
729 goto done;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
730
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
731 int slen = H5Tget_size (type_id);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
732 if (slen < 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
733 goto done;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
734
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
735 OCTAVE_LOCAL_BUFFER (char, typ, slen);
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 // 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
738 hid_t st_id = H5Tcopy (H5T_C_S1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
739 H5Tset_size (st_id, slen);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
740
29384
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
741 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
742 octave_H5P_DEFAULT, typ) < 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
743 goto done;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
744
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
745 H5Tclose (st_id);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
746 H5Dclose (data_id);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
747
29385
cee1cf711a4e ls-hdf5.cc: Handle non-zero terminated type strings (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29384
diff changeset
748 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
749 {
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
750 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
751 }
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
752 else
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
753 {
29385
cee1cf711a4e ls-hdf5.cc: Handle non-zero terminated type strings (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29384
diff changeset
754 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
755
29384
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
756 try
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
757 {
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
758 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
759 }
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
760 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
761 {
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
762 retval = -1;
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
763 }
28427
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
764 }
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
765
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
766 // check for OCTAVE_GLOBAL attribute:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
767 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
768
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
769 H5Gclose (subgroup_id);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
770 }
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
771 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
772 {
28427
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
773 // 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
774 // 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
775 // function type here.
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
776
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
777 // 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
778 // default (since that preserves name information), and an
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
779 // octave list otherwise.
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
780
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
781 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
782 d->tc = type_info.lookup_type ("list");
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
783 else
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 ("struct");
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
785
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
786 // check for OCTAVE_GLOBAL attribute:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
787 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
788
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
789 H5Gclose (subgroup_id);
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
790
29384
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
791 try
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
792 {
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
793 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
794 }
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
795 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
796 {
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
797 retval = -1;
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
798 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
799 }
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
800
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
801 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
802 else if (info.type == H5G_DATASET && ident_valid)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
803 {
28427
7a8c69c4eb55 convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
804 // 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
805 // 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
806 // 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
807
20449
df4165dfc676 maint: Fix misspelled word compatibility in code comments.
Rik <rik@octave.org>
parents: 20264
diff changeset
808 // 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
809 #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
810 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
811 #else
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
812 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
813 #endif
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
814
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
815 if (data_id < 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
816 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
817 retval = data_id;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
818 goto done;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
819 }
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
820
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
821 type_id = H5Dget_type (data_id);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
822
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
823 type_class_id = H5Tget_class (type_id);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
824
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
825 if (type_class_id == H5T_FLOAT)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
826 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
827 space_id = H5Dget_space (data_id);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
828
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
829 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
830
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
831 if (rank == 0)
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
832 d->tc = type_info.lookup_type ("scalar");
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
833 else
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 ("matrix");
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
835
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
836 H5Sclose (space_id);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
837 }
4948
7124436476cb [project @ 2004-08-31 17:57:21 by jwe]
jwe
parents: 4805
diff changeset
838 else if (type_class_id == H5T_INTEGER)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
839 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
840 // What integer type do we really have..
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
841 std::string int_typ;
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21691
diff changeset
842 #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
843 // 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
844 // 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
845
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
846 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
847 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
848 case H5T_NATIVE_CHAR:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
849 int_typ = "int8 ";
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
850 break;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
851
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
852 case H5T_NATIVE_SHORT:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
853 int_typ = "int16 ";
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
854 break;
4948
7124436476cb [project @ 2004-08-31 17:57:21 by jwe]
jwe
parents: 4805
diff changeset
855
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
856 case H5T_NATIVE_INT:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
857 case H5T_NATIVE_LONG:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
858 int_typ = "int32 ";
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
859 break;
4948
7124436476cb [project @ 2004-08-31 17:57:21 by jwe]
jwe
parents: 4805
diff changeset
860
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
861 case H5T_NATIVE_LLONG:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
862 int_typ = "int64 ";
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
863 break;
4948
7124436476cb [project @ 2004-08-31 17:57:21 by jwe]
jwe
parents: 4805
diff changeset
864
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
865 case H5T_NATIVE_UCHAR:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
866 int_typ = "uint8 ";
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
867 break;
4948
7124436476cb [project @ 2004-08-31 17:57:21 by jwe]
jwe
parents: 4805
diff changeset
868
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
869 case H5T_NATIVE_USHORT:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
870 int_typ = "uint16 ";
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
871 break;
4948
7124436476cb [project @ 2004-08-31 17:57:21 by jwe]
jwe
parents: 4805
diff changeset
872
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
873 case H5T_NATIVE_UINT:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
874 case H5T_NATIVE_ULONG:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
875 int_typ = "uint32 ";
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
876 break;
4948
7124436476cb [project @ 2004-08-31 17:57:21 by jwe]
jwe
parents: 4805
diff changeset
877
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
878 case H5T_NATIVE_ULLONG:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
879 int_typ = "uint64 ";
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
880 break;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
881 }
4948
7124436476cb [project @ 2004-08-31 17:57:21 by jwe]
jwe
parents: 4805
diff changeset
882 #else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
883 hid_t int_sign = H5Tget_sign (type_id);
4948
7124436476cb [project @ 2004-08-31 17:57:21 by jwe]
jwe
parents: 4805
diff changeset
884
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
885 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
886 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
887 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
888 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
889 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
890 int_typ.push_back ('u');
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
891 int_typ.append ("int");
4948
7124436476cb [project @ 2004-08-31 17:57:21 by jwe]
jwe
parents: 4805
diff changeset
892
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
893 int slen = H5Tget_size (type_id);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
894 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
895 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
896 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
897 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
898 switch (slen)
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 case 1:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
901 int_typ.append ("8 ");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
902 break;
4948
7124436476cb [project @ 2004-08-31 17:57:21 by jwe]
jwe
parents: 4805
diff changeset
903
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
904 case 2:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
905 int_typ.append ("16 ");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
906 break;
4948
7124436476cb [project @ 2004-08-31 17:57:21 by jwe]
jwe
parents: 4805
diff changeset
907
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
908 case 4:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
909 int_typ.append ("32 ");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
910 break;
4948
7124436476cb [project @ 2004-08-31 17:57:21 by jwe]
jwe
parents: 4805
diff changeset
911
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
912 case 8:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
913 int_typ.append ("64 ");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
914 break;
4948
7124436476cb [project @ 2004-08-31 17:57:21 by jwe]
jwe
parents: 4805
diff changeset
915
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
916 default:
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
917 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
918 name);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
919 int_typ = "";
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
920 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
921 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
922 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
923 }
4948
7124436476cb [project @ 2004-08-31 17:57:21 by jwe]
jwe
parents: 4805
diff changeset
924 #endif
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
925 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
926 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
927 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
928 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
929 // Matrix or scalar?
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
930 space_id = H5Dget_space (data_id);
4948
7124436476cb [project @ 2004-08-31 17:57:21 by jwe]
jwe
parents: 4805
diff changeset
931
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
932 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
933
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
934 if (rank == 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
935 int_typ.append ("scalar");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
936 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
937 int_typ.append ("matrix");
4948
7124436476cb [project @ 2004-08-31 17:57:21 by jwe]
jwe
parents: 4805
diff changeset
938
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
939 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
940 H5Sclose (space_id);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
941 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
942 }
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
943 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
944 d->tc = type_info.lookup_type ("string");
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
945 else if (type_class_id == H5T_COMPOUND)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
946 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
947 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
948 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
949
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
950 if (hdf5_types_compatible (type_id, complex_type))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
951 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
952 // read complex matrix or scalar variable
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
953 space_id = H5Dget_space (data_id);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
954 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
955
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
956 if (rank == 0)
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
957 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
958 else
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 matrix");
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
960
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
961 H5Sclose (space_id);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
962 }
27138
9e5c1d343a2c Skip HDF5 elements which are unrecognized, but continue reading file (bug #32756).
Daniel Davis <ddesics@gmail.com>
parents: 27063
diff changeset
963 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
964 {
27932
b018f553fd85 maint: Use Octave coding conventions in libinterp/
Rik <rik@octave.org>
parents: 27929
diff changeset
965 // 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
966 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
967 }
9e5c1d343a2c Skip HDF5 elements which are unrecognized, but continue reading file (bug #32756).
Daniel Davis <ddesics@gmail.com>
parents: 27063
diff changeset
968 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
969 {
27932
b018f553fd85 maint: Use Octave coding conventions in libinterp/
Rik <rik@octave.org>
parents: 27929
diff changeset
970 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
971 retval = 0; // unknown datatype; skip
b018f553fd85 maint: Use Octave coding conventions in libinterp/
Rik <rik@octave.org>
parents: 27929
diff changeset
972 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
973 }
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
974
27138
9e5c1d343a2c Skip HDF5 elements which are unrecognized, but continue reading file (bug #32756).
Daniel Davis <ddesics@gmail.com>
parents: 27063
diff changeset
975 H5Tclose (range_type);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
976 H5Tclose (complex_type);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
977 }
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
978 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
979 {
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
980 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
981 retval = 0; // unknown datatype; skip
18676
5bd1ca29c5f0 Clean up questionable code bits identified by clang sanitize.
Rik <rik@octave.org>
parents: 18100
diff changeset
982 return retval;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
983 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
984
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
985 // check for OCTAVE_GLOBAL attribute:
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
986 d->global = hdf5_check_attr (data_id, "OCTAVE_GLOBAL");
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
987
29384
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
988 try
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
989 {
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
990 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
991 }
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
992 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
993 {
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
994 retval = -1;
26039aa0d2c4 ls-hdf5.cc: Avoid throwing inside HDF5 function (bug #60081).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
995 }
27063
eb25b491dad7 Don't segfault at exit after reading malformed HDF5 file (bug #56149).
Rik <rik@octave.org>
parents: 26499
diff changeset
996
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
997 H5Tclose (type_id);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
998 H5Dclose (data_id);
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
999 }
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1000
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20945
diff changeset
1001 if (! ident_valid)
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1002 {
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1003 // should we attempt to handle invalid identifiers by converting
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1004 // 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
1005 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
1006 name);
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1007 }
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1008
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1009 done:
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1010 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
1011 {
eb25b491dad7 Don't segfault at exit after reading malformed HDF5 file (bug #56149).
Rik <rik@octave.org>
parents: 26499
diff changeset
1012 // 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
1013 // 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
1014 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
1015 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1016
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1017 if (retval > 0)
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1018 {
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1019 // 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
1020 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
1021
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1022 if (comment_length > 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1023 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1024 OCTAVE_LOCAL_BUFFER (char, tdoc, comment_length);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1025 H5Gget_comment (group_id, name, comment_length, tdoc);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1026 d->doc = tdoc;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1027 }
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1028 else if (vname != name)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1029 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1030 // the name was changed; store the original name
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1031 // as the documentation string:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1032 d->doc = name;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1033 }
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1034
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1035 // copy name (actually, vname):
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1036 d->name = vname;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1037 }
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1038
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1039 return retval;
22028
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1040 }
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1041
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1042 #endif
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 octave_hdf5_err
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1045 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
1046 {
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1047 #if defined (HAVE_HDF5)
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 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
1050
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1051 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
1052
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1053 #else
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1054 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
1055 #endif
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1056 }
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1057
22028
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1058 octave_hdf5_err
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23440
diff changeset
1059 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
1060 void *operator_data)
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1061 {
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1062 #if defined (HAVE_HDF5)
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 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
1065
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1066 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
1067 operator_data);
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1068
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1069 #else
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1070 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
1071 #endif
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1072 }
5c949eecb6dd use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents: 22022
diff changeset
1073
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23455
diff changeset
1074 // 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
1075 // 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
1076 // 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
1077 // 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
1078 std::string
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1079 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
1080 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
1081 const string_vector& argv, int argv_idx, int argc)
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1082 {
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1083 #if defined (HAVE_HDF5)
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1084
30007
62f2c0a3982c move check_hdf5_types function inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29572
diff changeset
1085 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
1086
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1087 std::string retval;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1088
23812
057a894914df Use C++11 string fcns back() and pop_back() to simplify code.
Rik <rik@octave.org>
parents: 23807
diff changeset
1089 doc.clear ();
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1090
5760
8d7162924bd3 [project @ 2006-04-14 04:01:37 by jwe]
jwe
parents: 5351
diff changeset
1091 hdf5_ifstream& hs = dynamic_cast<hdf5_ifstream&> (is);
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1092 hdf5_callback_data d;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1093
4696
fcab389ad291 [project @ 2004-01-15 02:11:59 by jwe]
jwe
parents: 4687
diff changeset
1094 herr_t H5Giterate_retval = -1;
fcab389ad291 [project @ 2004-01-15 02:11:59 by jwe]
jwe
parents: 4687
diff changeset
1095
fcab389ad291 [project @ 2004-01-15 02:11:59 by jwe]
jwe
parents: 4687
diff changeset
1096 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
1097 #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
1098 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
1099 #else
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1100 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
1101 #endif
5060
34a904ac130d [project @ 2004-11-02 03:08:10 by jwe]
jwe
parents: 4948
diff changeset
1102 H5Gget_num_objs (group_id, &num_obj);
34a904ac130d [project @ 2004-11-02 03:08:10 by jwe]
jwe
parents: 4948
diff changeset
1103 H5Gclose (group_id);
17709
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1104
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1105 // For large datasets and out-of-core functionality,
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1106 // 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
1107 bool load_named_vars = argv_idx < argc;
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1108 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
1109 {
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1110 std::vector<char> var_name;
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1111 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
1112 std::size_t len = 0;
17709
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1113
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23470
diff changeset
1114 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
1115 var_name.resize (len+1);
18678
6113e0c6920b maint: Clean up extra spaces before/after parentheses.
Rik <rik@octave.org>
parents: 18676
diff changeset
1116 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
1117
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1118 for (int i = argv_idx; i < argc; i++)
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 glob_match pattern (argv[i]);
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1121 if (pattern.match (std::string (&var_name[0])))
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1122 {
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1123 found = true;
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1124 break;
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1125 }
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1126 }
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 if (found)
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1129 break;
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1130
5415a9cd61d4 Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents: 16892
diff changeset
1131 hs.current_item++;
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
4696
fcab389ad291 [project @ 2004-01-15 02:11:59 by jwe]
jwe
parents: 4687
diff changeset
1134 if (hs.current_item < static_cast<int> (num_obj))
fcab389ad291 [project @ 2004-01-15 02:11:59 by jwe]
jwe
parents: 4687
diff changeset
1135 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
1136 hdf5_read_next_data_internal, &d);
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1137
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1138 if (H5Giterate_retval > 0)
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 global = d.global;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1141 tc = d.tc;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1142 doc = d.doc;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1143 }
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1144 else
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1145 {
27063
eb25b491dad7 Don't segfault at exit after reading malformed HDF5 file (bug #56149).
Rik <rik@octave.org>
parents: 26499
diff changeset
1146 // 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
1147 // 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
1148 // 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
1149 }
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1150
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1151 if (! d.name.empty ())
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1152 retval = d.name;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1153
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1154 return retval;
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1155
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1156 #else
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1157 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
1158 #endif
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1159 }
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1160
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1161 // 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
1162 // 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
1163 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
1164 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
1165 {
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1166 #if defined (HAVE_HDF5)
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1167
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1168 herr_t retval = 0;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1169
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1170 hid_t as_id = H5Screate (H5S_SCALAR);
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 if (as_id >= 0)
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1173 {
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
1174 #if defined (HAVE_HDF5_18)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1175 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
1176 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
1177 #else
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1178 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
1179 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
1180 #endif
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1181 if (a_id >= 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1182 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1183 unsigned char attr_val = 1;
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1184
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1185 retval = H5Awrite (a_id, H5T_NATIVE_UCHAR, &attr_val);
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 H5Aclose (a_id);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1188 }
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1189 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1190 retval = a_id;
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1191
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1192 H5Sclose (as_id);
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 else
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1195 retval = as_id;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1196
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1197 return retval;
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1198
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1199 #else
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1200 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
1201 #endif
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1202 }
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1203
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
1204 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
1205 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
1206 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
1207 {
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1208 #if defined (HAVE_HDF5)
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1209
11176
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1210 herr_t retval = 0;
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1211
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1212 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
1213
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1214 if (as_id >= 0)
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1215 {
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
1216 #if defined (HAVE_HDF5_18)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1217 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
1218 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
1219 #else
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1220 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
1221 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
1222 #endif
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1223 if (a_id >= 0)
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1224 {
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1225 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
1226
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1227 H5Aclose (a_id);
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 else
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1230 retval = a_id;
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1231
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1232 H5Sclose (as_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 else
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1235 retval = as_id;
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1236
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1237 return retval;
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1238
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1239 #else
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1240 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
1241 #endif
11176
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1242 }
2271261f088a Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents: 10325
diff changeset
1243
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21724
diff changeset
1244 // Save an empty matrix, if needed. Returns
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1245 // > 0 Saved empty matrix
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1246 // = 0 Not an empty matrix; did nothing
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1247 // < 0 Error condition
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1248 int
23440
f15f0d8b78c8 pass dim_vector as const reference, not by value
John W. Eaton <jwe@octave.org>
parents: 23433
diff changeset
1249 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
1250 {
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1251 #if defined (HAVE_HDF5)
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1252
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1253 hsize_t sz = d.length ();
6276
d26c558691cd [project @ 2007-02-07 09:01:24 by jwe]
jwe
parents: 5775
diff changeset
1254 OCTAVE_LOCAL_BUFFER (octave_idx_type, dims, sz);
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1255 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
1256 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
1257 hid_t data_hid = -1;
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1258 int retval;
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1259 for (hsize_t i = 0; i < sz; i++)
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1260 {
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1261 dims[i] = d(i);
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1262 if (dims[i] < 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1263 empty = true;
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1264 }
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1265
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20945
diff changeset
1266 if (! empty)
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1267 return 0;
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1268
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23470
diff changeset
1269 space_hid = H5Screate_simple (1, &sz, nullptr);
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1270 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
1271 #if defined (HAVE_HDF5_18)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1272 data_hid = H5Dcreate (loc_id, name, H5T_NATIVE_IDX, space_hid,
30346
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 30243
diff changeset
1273 octave_H5P_DEFAULT, octave_H5P_DEFAULT,
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 30243
diff changeset
1274 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
1275 #else
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1276 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
1277 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
1278 #endif
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1279 if (data_hid < 0)
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1280 {
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1281 H5Sclose (space_hid);
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1282 return data_hid;
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1283 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1284
21022
ebc439187d29 avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
1285 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
1286 octave_H5P_DEFAULT, dims) >= 0;
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1287
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1288 H5Dclose (data_hid);
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1289 H5Sclose (space_hid);
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1290
26499
9326e683c3a4 ls-hdf5.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents: 26376
diff changeset
1291 if (retval)
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1292 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
1293
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1294 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
1295
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1296 #else
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1297 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
1298 #endif
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1299 }
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1300
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21724
diff changeset
1301 // Load an empty matrix, if needed. Returns
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1302 // > 0 loaded empty matrix, dimensions returned
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1303 // = 0 Not an empty matrix; did nothing
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1304 // < 0 Error condition
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1305 int
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
1306 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
1307 {
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1308 #if defined (HAVE_HDF5)
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1309
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1310 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
1311 return 0;
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1312
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1313 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
1314 #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
1315 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
1316 #else
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1317 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
1318 #endif
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1319 hid_t space_id = H5Dget_space (data_hid);
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1320 H5Sget_simple_extent_dims (space_id, &hdims, &maxdims);
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1321 int retval;
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1322
5351
05adf9de7657 [project @ 2005-05-16 20:07:36 by dbateman]
dbateman
parents: 5307
diff changeset
1323 OCTAVE_LOCAL_BUFFER (octave_idx_type, dims, hdims);
05adf9de7657 [project @ 2005-05-16 20:07:36 by dbateman]
dbateman
parents: 5307
diff changeset
1324
21022
ebc439187d29 avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
1325 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
1326 octave_H5P_DEFAULT, dims);
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1327 if (retval >= 0)
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1328 {
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1329 d.resize (hdims);
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1330 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
1331 d(i) = dims[i];
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1332 }
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 H5Sclose (space_id);
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1335 H5Dclose (data_hid);
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1336
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1337 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
1338
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1339 #else
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1340 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
1341 #endif
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1342 }
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
1343
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1344 // 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
1345 // automatic float<->integer conversions:
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1346
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1347 // 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
1348
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
1349 octave_hdf5_id
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1350 save_type_to_hdf5 (save_type st)
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1351 {
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1352 #if defined (HAVE_HDF5)
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1353 # 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
1354
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1355 switch (st)
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1356 {
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1357 case LS_U_CHAR:
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1358 return H5T_NATIVE_UCHAR;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1359
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1360 case LS_U_SHORT:
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1361 return H5T_NATIVE_USHORT;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1362
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1363 case LS_U_INT:
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1364 return H5T_NATIVE_UINT;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1365
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1366 case LS_CHAR:
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1367 return H5T_NATIVE_CHAR;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1368
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1369 case LS_SHORT:
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1370 return H5T_NATIVE_SHORT;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1371
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1372 case LS_INT:
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1373 return H5T_NATIVE_INT;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1374
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1375 case LS_FLOAT:
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1376 return H5T_NATIVE_FLOAT;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1377
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1378 case LS_DOUBLE:
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1379 default:
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1380 return H5T_NATIVE_DOUBLE;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1381 }
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1382
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1383 # else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21682
diff changeset
1384
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21682
diff changeset
1385 octave_unused_parameter (st);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21682
diff changeset
1386
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1387 return -1;
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21682
diff changeset
1388
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1389 # endif
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21682
diff changeset
1390
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1391 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21682
diff changeset
1392
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21682
diff changeset
1393 octave_unused_parameter (st);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21682
diff changeset
1394
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1395 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
1396
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1397 #endif
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1398 }
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 // 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
1401 // 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
1402 // successful. This function calls itself recursively for lists
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1403 // (stored as HDF5 groups).
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1404
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1405 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
1406 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
1407 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
1408 bool mark_global, bool save_as_floats)
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1409 {
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1410 #if defined (HAVE_HDF5)
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1411
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1412 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
1413 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
1414 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
1415
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1416 bool retval = false;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1417 octave_value val = tc;
8401
712cfdc2e417 allow saving diagonal & permutation matrices to hdf5 as full
Jaroslav Hajek <highegg@gmail.com>
parents: 8377
diff changeset
1418 // 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
1419 // 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
1420 // This is a temporary hack.
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1421 if (val.is_diag_matrix () || val.is_perm_matrix ()
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
1422 || 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
1423 val = val.full_value ();
8401
712cfdc2e417 allow saving diagonal & permutation matrices to hdf5 as full
Jaroslav Hajek <highegg@gmail.com>
parents: 8377
diff changeset
1424
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
1425 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
1426 #if defined (HAVE_HDF5_18)
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
1427 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
1428 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
1429 #else
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1430 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
1431 #endif
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1432 if (data_id < 0)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1433 goto error_cleanup;
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1434
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1435 // attach the type of the variable
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1436 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
1437 if (type_id < 0)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1438 goto error_cleanup;
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1439
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1440 dims[0] = 0;
27932
b018f553fd85 maint: Use Octave coding conventions in libinterp/
Rik <rik@octave.org>
parents: 27929
diff changeset
1441 space_id = H5Screate_simple (0, dims, nullptr);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1442 if (space_id < 0)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1443 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
1444 #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
1445 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
1446 octave_H5P_DEFAULT, octave_H5P_DEFAULT,
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
1447 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
1448 #else
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
1449 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
1450 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
1451 #endif
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
1452 if (data_type_id < 0
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
1453 || 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
1454 octave_H5P_DEFAULT, t.c_str ()) < 0)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1455 goto error_cleanup;
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1456
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1457 // Now call the real function to save the variable
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1458 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
1459
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1460 // attach doc string as comment:
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1461 if (retval && doc.length () > 0
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1462 && 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
1463 retval = false;
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1464
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1465 // 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
1466 if (retval && mark_global)
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1467 retval = hdf5_add_attr (data_id, "OCTAVE_GLOBAL") >= 0;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1468
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1469 // 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
1470 if (retval)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1471 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
1472
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1473 error_cleanup:
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1474
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1475 if (data_type_id >= 0)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1476 H5Dclose (data_type_id);
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1477
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1478 if (type_id >= 0)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1479 H5Tclose (type_id);
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1480
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1481 if (space_id >= 0)
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1482 H5Sclose (space_id);
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1483
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1484 if (data_id >= 0)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1485 H5Gclose (data_id);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1486
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4675
diff changeset
1487 if (! retval)
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1488 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
1489
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1490 return retval;
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1491
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1492 #else
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1493 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
1494 #endif
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1495 }
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 // 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
1498 // which must be an hdf5_ofstream, returning true on success.
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1499
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1500 bool
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1501 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
1502 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
1503 bool mark_global, bool save_as_floats)
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1504 {
21355
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1505 #if defined (HAVE_HDF5)
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1506
30007
62f2c0a3982c move check_hdf5_types function inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29572
diff changeset
1507 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
1508
5760
8d7162924bd3 [project @ 2006-04-14 04:01:37 by jwe]
jwe
parents: 5351
diff changeset
1509 hdf5_ofstream& hs = dynamic_cast<hdf5_ofstream&> (os);
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1510
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1511 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
1512 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
1513
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1514 #else
28d9bce20aa7 eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1515 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
1516 #endif
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
1517 }
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 #endif