2882
|
1 /* |
|
2 |
|
3 Copyright (C) 1996, 1997 John W. Eaton |
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
7016
|
9 Free Software Foundation; either version 3 of the License, or (at your |
|
10 option) any later version. |
2882
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
7016
|
18 along with Octave; see the file COPYING. If not, see |
|
19 <http://www.gnu.org/licenses/>. |
2882
|
20 |
|
21 */ |
|
22 |
|
23 #ifdef HAVE_CONFIG_H |
|
24 #include <config.h> |
|
25 #endif |
|
26 |
3503
|
27 #include <iostream> |
5765
|
28 #include <sstream> |
2882
|
29 |
|
30 #include "lo-utils.h" |
|
31 |
4513
|
32 #include "Cell.h" |
2882
|
33 #include "defun.h" |
|
34 #include "error.h" |
4994
|
35 #include "ov.h" |
2882
|
36 #include "ov-list.h" |
|
37 #include "unwind-prot.h" |
|
38 |
4687
|
39 #include "byte-swap.h" |
|
40 #include "ls-oct-ascii.h" |
|
41 #include "ls-oct-binary.h" |
|
42 #include "ls-hdf5.h" |
|
43 #include "ls-utils.h" |
|
44 |
3219
|
45 DEFINE_OCTAVE_ALLOCATOR (octave_list); |
2882
|
46 |
4612
|
47 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_list, "list", "list"); |
2882
|
48 |
4513
|
49 octave_list::octave_list (const Cell& c) |
4591
|
50 : octave_base_value (), data () |
4513
|
51 { |
5275
|
52 octave_idx_type n = c.length (); |
4513
|
53 |
4591
|
54 data.resize (dim_vector (1, n)); |
4513
|
55 |
5275
|
56 for (octave_idx_type i = 0; i < n; i++) |
4591
|
57 data(i) = c(i); |
4513
|
58 } |
|
59 |
4994
|
60 octave_value_list |
4247
|
61 octave_list::subsref (const std::string& type, |
4994
|
62 const std::list<octave_value_list>& idx, int nargout) |
3933
|
63 { |
4994
|
64 octave_value_list retval; |
3933
|
65 |
|
66 switch (type[0]) |
|
67 { |
|
68 case '(': |
|
69 { |
|
70 octave_value_list tmp_idx = idx.front (); |
|
71 |
|
72 if (tmp_idx.length () == 1) |
|
73 { |
|
74 idx_vector i = tmp_idx (0).index_vector (); |
|
75 |
4842
|
76 Cell tmp = data.index (i); |
|
77 |
4994
|
78 retval(0) = octave_value (new octave_list (tmp)); |
3933
|
79 } |
|
80 else |
|
81 error ("only one index allowed for lists"); |
|
82 } |
|
83 break; |
|
84 |
|
85 case '{': |
|
86 { |
|
87 octave_value_list tmp_idx = idx.front (); |
|
88 |
|
89 if (tmp_idx.length () == 1) |
|
90 { |
|
91 idx_vector i = tmp_idx (0).index_vector (); |
|
92 |
4591
|
93 Cell tmp = data.index (i); |
3933
|
94 |
|
95 if (tmp.length () == 1) |
4994
|
96 retval(0) = tmp(0); |
4842
|
97 else |
4994
|
98 retval(0) = octave_value (tmp, true); |
3933
|
99 } |
|
100 else |
|
101 error ("only one index allowed for lists"); |
|
102 } |
|
103 break; |
|
104 |
|
105 case '.': |
|
106 { |
|
107 std::string nm = type_name (); |
|
108 error ("%s cannot be indexed with %c", nm.c_str (), type[0]); |
|
109 } |
|
110 break; |
|
111 |
|
112 default: |
|
113 panic_impossible (); |
|
114 } |
|
115 |
5775
|
116 // FIXME -- perhaps there should be an |
4994
|
117 // octave_value_list::next_subsref member function? See also |
|
118 // octave_user_function::subsref. |
|
119 |
|
120 if (idx.size () > 1) |
|
121 retval = retval(0).next_subsref (nargout, type, idx); |
|
122 |
|
123 return retval; |
3933
|
124 } |
|
125 |
|
126 octave_value |
5885
|
127 octave_list::do_index_op (const octave_value_list& idx, bool resize_ok) |
2882
|
128 { |
|
129 octave_value retval; |
|
130 |
|
131 if (idx.length () == 1) |
|
132 { |
5759
|
133 idx_vector iidx = idx (0).index_vector (); |
2882
|
134 |
5759
|
135 Cell tcell = data.index (iidx, resize_ok); |
5757
|
136 |
|
137 octave_value_list result; |
|
138 |
|
139 octave_idx_type n = tcell.numel (); |
|
140 |
|
141 result.resize (n); |
|
142 |
|
143 for (octave_idx_type i = 0; i < n; i++) |
|
144 result(i) = tcell(i); |
|
145 |
|
146 retval = result; |
2882
|
147 } |
|
148 else |
5757
|
149 error ("only one index allowed for lists"); |
2882
|
150 |
|
151 return retval; |
|
152 } |
|
153 |
3933
|
154 octave_value |
4247
|
155 octave_list::subsasgn (const std::string& type, |
4219
|
156 const std::list<octave_value_list>& idx, |
3933
|
157 const octave_value& rhs) |
|
158 { |
|
159 octave_value retval; |
|
160 |
5275
|
161 octave_idx_type n = type.length (); |
3933
|
162 |
|
163 octave_value t_rhs = rhs; |
|
164 |
|
165 if (n > 1) |
|
166 { |
|
167 switch (type[0]) |
|
168 { |
|
169 case '(': |
|
170 { |
|
171 octave_value tmp = do_index_op (idx.front (), true); |
|
172 |
|
173 if (! tmp.is_defined ()) |
|
174 tmp = octave_value::empty_conv (type.substr (1), rhs); |
|
175 |
|
176 if (! error_state) |
|
177 { |
4219
|
178 std::list<octave_value_list> next_idx (idx); |
3933
|
179 |
4219
|
180 next_idx.erase (next_idx.begin ()); |
3933
|
181 |
|
182 t_rhs = tmp.subsasgn (type.substr (1), next_idx, rhs); |
|
183 } |
|
184 } |
|
185 break; |
|
186 |
|
187 case '{': |
|
188 case '.': |
|
189 { |
|
190 std::string nm = type_name (); |
|
191 error ("%s cannot be indexed with %c", nm.c_str (), type[0]); |
|
192 } |
|
193 break; |
|
194 |
|
195 default: |
|
196 panic_impossible (); |
|
197 } |
|
198 } |
|
199 |
3940
|
200 if (! error_state) |
3933
|
201 { |
3940
|
202 switch (type[0]) |
|
203 { |
|
204 case '(': |
|
205 { |
|
206 octave_value_list i = idx.front (); |
3933
|
207 |
5275
|
208 octave_idx_type len = i.length (); |
4769
|
209 |
5275
|
210 for (octave_idx_type k = 0; k < len; k++) |
4769
|
211 data.set_index (i(k).index_vector ()); |
|
212 |
|
213 ::assign (data, Cell (t_rhs), Cell::resize_fill_value ()); |
3933
|
214 |
5759
|
215 count++; |
|
216 retval = octave_value (this); |
3940
|
217 } |
|
218 break; |
3933
|
219 |
3940
|
220 case '{': |
|
221 case '.': |
|
222 { |
|
223 std::string nm = type_name (); |
|
224 error ("%s cannot be indexed with %c", nm.c_str (), type[0]); |
|
225 } |
|
226 break; |
3933
|
227 |
3940
|
228 default: |
|
229 panic_impossible (); |
|
230 } |
3933
|
231 } |
|
232 |
|
233 return retval; |
|
234 } |
|
235 |
2882
|
236 void |
3196
|
237 octave_list::assign (const octave_value_list& idx, const octave_value& rhs) |
|
238 { |
|
239 if (idx.length () == 1) |
|
240 { |
3202
|
241 int i = idx(0).int_value (true); |
3196
|
242 |
|
243 if (! error_state) |
|
244 { |
5275
|
245 octave_idx_type n = data.length (); |
3196
|
246 |
4461
|
247 if (i > 0) |
|
248 { |
5781
|
249 if (i > n) |
|
250 warning_with_id ("Octave:resize-on-range-error", |
|
251 "list index = %d out of range", i); |
4461
|
252 |
4591
|
253 data(i-1) = rhs; |
4461
|
254 } |
3196
|
255 else |
3202
|
256 error ("list index = %d out of range", i); |
3196
|
257 } |
3202
|
258 else |
|
259 error ("list index must be an integer"); |
3196
|
260 } |
|
261 else |
|
262 error ("lists may only be indexed by a single scalar"); |
|
263 } |
|
264 |
4791
|
265 size_t |
|
266 octave_list::byte_size (void) const |
|
267 { |
|
268 size_t retval = 0; |
|
269 |
5275
|
270 for (octave_idx_type i = 0; i < numel (); i++) |
4791
|
271 retval += data(i).byte_size (); |
|
272 |
|
273 return retval; |
|
274 } |
|
275 |
4591
|
276 octave_value_list |
|
277 octave_list::list_value (void) const |
|
278 { |
|
279 octave_value_list retval; |
|
280 |
5275
|
281 octave_idx_type n = data.length (); |
4591
|
282 |
|
283 retval.resize (n); |
|
284 |
5275
|
285 for (octave_idx_type i = 0; i < n; i++) |
4591
|
286 retval(i) = data(i); |
|
287 |
|
288 return retval; |
|
289 } |
|
290 |
3196
|
291 void |
3523
|
292 octave_list::print (std::ostream& os, bool) const |
2901
|
293 { |
|
294 print_raw (os); |
|
295 } |
|
296 |
|
297 void |
3523
|
298 octave_list::print_raw (std::ostream& os, bool) const |
2882
|
299 { |
2985
|
300 unwind_protect::begin_frame ("octave_list_print"); |
2882
|
301 |
5275
|
302 octave_idx_type n = data.length (); |
2882
|
303 |
3196
|
304 if (n > 0) |
2882
|
305 { |
3196
|
306 indent (os); |
|
307 os << "("; |
|
308 newline (os); |
|
309 |
|
310 increment_indent_level (); |
2916
|
311 |
5275
|
312 for (octave_idx_type i = 0; i < n; i++) |
3196
|
313 { |
5765
|
314 std::ostringstream buf; |
4051
|
315 |
5765
|
316 buf << "[" << i+1 << "]"; |
2882
|
317 |
4591
|
318 octave_value val = data(i); |
2916
|
319 |
5765
|
320 val.print_with_name (os, buf.str ()); |
3196
|
321 } |
2882
|
322 |
3196
|
323 decrement_indent_level (); |
2882
|
324 |
3196
|
325 indent (os); |
|
326 os << ")"; |
|
327 } |
|
328 else |
|
329 os << "()"; |
|
330 |
2901
|
331 newline (os); |
2882
|
332 |
2985
|
333 unwind_protect::run_frame ("octave_list_print"); |
2882
|
334 } |
|
335 |
2901
|
336 bool |
3523
|
337 octave_list::print_name_tag (std::ostream& os, const std::string& name) const |
2901
|
338 { |
|
339 indent (os); |
4591
|
340 if (data.length () == 0) |
3196
|
341 os << name << " = "; |
|
342 else |
|
343 { |
|
344 os << name << " ="; |
|
345 newline (os); |
|
346 } |
2901
|
347 return false; |
|
348 } |
|
349 |
2993
|
350 DEFUN (list, args, , |
3447
|
351 "-*- texinfo -*-\n\ |
3448
|
352 @deftypefn {Built-in Function} {} list (@var{a1}, @var{a2}, @dots{})\n\ |
3447
|
353 Create a new list with elements given by the arguments @var{a1},\n\ |
|
354 @var{a2}, @dots{}.\n\ |
|
355 @end deftypefn") |
2882
|
356 { |
4591
|
357 static bool warned = false; |
|
358 |
|
359 if (! warned) |
|
360 { |
|
361 warning ("list objects are deprecated; use cell arrays instead"); |
|
362 warned = true; |
|
363 } |
|
364 |
2882
|
365 return octave_value (args); |
|
366 } |
|
367 |
3219
|
368 DEFUN (nth, args, , |
3447
|
369 "-*- texinfo -*-\n\ |
|
370 @deftypefn {Built-in Function} {} nth (@var{list}, @var{n})\n\ |
|
371 Return the @var{n}-th element of @var{list}.\n\ |
|
372 @end deftypefn") |
3219
|
373 { |
|
374 octave_value retval; |
|
375 |
|
376 if (args.length () == 2) |
|
377 { |
|
378 octave_value_list lst = args(0).list_value (); |
|
379 |
|
380 if (! error_state) |
|
381 { |
|
382 int n = args(1).int_value (true); |
|
383 |
|
384 if (! error_state) |
|
385 { |
|
386 if (n > 0 && n <= lst.length ()) |
|
387 retval = lst(n-1); |
|
388 else |
|
389 error ("nth: index = %d out of range", n); |
|
390 } |
|
391 else |
|
392 error ("nth: second argument must be an integer"); |
|
393 } |
|
394 else |
|
395 error ("nth: first argument must be a list"); |
|
396 } |
|
397 else |
5823
|
398 print_usage (); |
3219
|
399 |
|
400 return retval; |
|
401 } |
|
402 |
2882
|
403 DEFUN (append, args, , |
3447
|
404 "-*- texinfo -*-\n\ |
|
405 @deftypefn {Built-in Function} {} append (@var{list}, @var{a1}, @var{a2}, @dots{})\n\ |
6666
|
406 Return a new list created by appending @var{a1}, @var{a2}, @dots{}, to\n\ |
3447
|
407 @var{list}. If any of the arguments to be appended is a list, its\n\ |
|
408 elements are appended individually. For example,\n\ |
2882
|
409 \n\ |
3447
|
410 @example\n\ |
|
411 x = list (1, 2);\n\ |
|
412 y = list (3, 4);\n\ |
|
413 append (x, y);\n\ |
|
414 @end example\n\ |
3219
|
415 \n\ |
3447
|
416 @noindent\n\ |
|
417 results in the list containing the four elements @samp{(1 2 3 4)}, not\n\ |
|
418 a list containing the three elements @samp{(1 2 (3 4))}.\n\ |
|
419 @end deftypefn") |
2882
|
420 { |
|
421 octave_value retval; |
|
422 |
|
423 int nargin = args.length (); |
|
424 |
|
425 if (nargin > 1) |
|
426 { |
|
427 octave_value_list tmp = args(0).list_value (); |
|
428 |
|
429 if (! error_state) |
|
430 { |
|
431 for (int i = 1; i < nargin; i++) |
3219
|
432 { |
|
433 octave_value ov = args(i); |
|
434 |
|
435 if (ov.is_list ()) |
|
436 tmp.append (ov.list_value ()); |
|
437 else |
|
438 tmp.append (ov); |
|
439 } |
2882
|
440 |
4233
|
441 retval = octave_value (tmp); |
2882
|
442 } |
|
443 } |
|
444 else |
5823
|
445 print_usage (); |
2882
|
446 |
|
447 return retval; |
|
448 } |
|
449 |
|
450 DEFUN (reverse, args, , |
3447
|
451 "-*- texinfo -*-\n\ |
|
452 @deftypefn {Built-in Function} {} reverse (@var{list})\n\ |
|
453 Return a new list created by reversing the elements of @var{list}.\n\ |
|
454 @end deftypefn") |
2882
|
455 { |
|
456 octave_value retval; |
|
457 |
|
458 int nargin = args.length (); |
|
459 |
|
460 if (nargin == 1) |
|
461 { |
|
462 octave_value_list tmp = args(0).list_value (); |
|
463 |
|
464 if (! error_state) |
4233
|
465 retval = octave_value (tmp.reverse ()); |
2882
|
466 } |
|
467 else |
5823
|
468 print_usage (); |
2882
|
469 |
|
470 return retval; |
|
471 } |
|
472 |
3196
|
473 DEFUN (splice, args, , |
3447
|
474 "-*- texinfo -*-\n\ |
|
475 @deftypefn {Built-in Function} {} splice (@var{list_1}, @var{offset}, @var{length}, @var{list_2})\n\ |
|
476 Replace @var{length} elements of @var{list_1} beginning at\n\ |
|
477 @var{offset} with the contents of @var{list_2} (if any). If\n\ |
|
478 @var{length} is omitted, all elements from @var{offset} to the end of\n\ |
|
479 @var{list_1} are replaced. As a special case, if @var{offset} is one\n\ |
|
480 greater than the length of @var{list_1} and @var{length} is 0, splice\n\ |
3448
|
481 is equivalent to @code{append (@var{list_1}, @var{list_2})}.\n\ |
3447
|
482 @end deftypefn") |
3196
|
483 { |
|
484 octave_value retval; |
|
485 |
|
486 int nargin = args.length (); |
|
487 |
|
488 if (nargin > 1 && nargin < 5) |
|
489 { |
|
490 octave_value_list list_1 = args(0).list_value (); |
|
491 |
|
492 if (! error_state) |
|
493 { |
3202
|
494 int offset = args(1).int_value (true); |
3196
|
495 |
|
496 if (! error_state) |
|
497 { |
3202
|
498 offset--; |
|
499 |
|
500 int length = 0; |
|
501 |
|
502 octave_value_list list_2; |
3196
|
503 |
3202
|
504 if (nargin < 3) |
|
505 length = list_1.length () - offset; |
|
506 else |
|
507 { |
|
508 length = args(2).int_value (true); |
3196
|
509 |
3202
|
510 if (! error_state) |
3196
|
511 { |
3202
|
512 if (nargin == 4) |
|
513 { |
|
514 list_2 = args(3).list_value (); |
3196
|
515 |
3202
|
516 if (error_state) |
|
517 error ("splice: fourth argument must be a list"); |
3196
|
518 } |
|
519 } |
3202
|
520 else |
|
521 error ("splice: LENGTH must be an integer"); |
|
522 } |
3196
|
523 |
3202
|
524 if (! error_state) |
4233
|
525 retval = octave_value (list_1.splice (offset, length, list_2)); |
3196
|
526 } |
|
527 else |
|
528 error ("splice: OFFSET must be an integer"); |
|
529 } |
|
530 else |
|
531 error ("splice: first argument must be a list"); |
|
532 } |
|
533 else |
5823
|
534 print_usage (); |
3196
|
535 |
|
536 return retval; |
|
537 } |
|
538 |
4687
|
539 bool |
6974
|
540 octave_list::save_ascii (std::ostream& os) |
4687
|
541 { |
|
542 octave_value_list lst = list_value (); |
|
543 os << "# length: " << lst.length () << "\n"; |
|
544 |
|
545 for (int i = 0; i < lst.length (); ++i) |
|
546 { |
|
547 // should we use lst.name_tags () to label the elements? |
5717
|
548 |
5765
|
549 std::ostringstream buf; |
|
550 buf << "_" << i; |
|
551 std::string s = buf.str (); |
5717
|
552 |
6974
|
553 bool b = save_ascii_data (os, lst (i), s.c_str (), false, 0); |
4687
|
554 |
|
555 if (! b) |
|
556 return false; |
|
557 } |
|
558 |
|
559 return true; |
|
560 } |
|
561 |
|
562 bool |
|
563 octave_list::load_ascii (std::istream& is) |
|
564 { |
|
565 int len = 0; |
|
566 bool success = true; |
|
567 |
|
568 if (extract_keyword (is, "length", len) && len >= 0) |
|
569 { |
|
570 if (len > 0) |
|
571 { |
|
572 octave_value_list lst; |
|
573 |
|
574 for (int j = 0; j < len; j++) |
|
575 { |
|
576 octave_value t2; |
|
577 bool dummy; |
|
578 |
|
579 // recurse to read list elements |
|
580 std::string nm |
5757
|
581 = read_ascii_data (is, std::string (), dummy, t2, j); |
4687
|
582 |
|
583 if (!is) |
|
584 break; |
|
585 |
|
586 lst.append (t2); |
|
587 } |
|
588 |
|
589 if (is) |
|
590 data = lst; |
|
591 else |
|
592 { |
|
593 error ("load: failed to load list"); |
|
594 success = false; |
|
595 } |
|
596 } |
|
597 else if (len == 0 ) |
|
598 data = Cell (0, 0); |
|
599 else |
|
600 panic_impossible (); |
|
601 } |
|
602 else { |
|
603 error ("load: failed to extract number of elements in list"); |
|
604 success = false; |
|
605 } |
|
606 |
|
607 return success; |
|
608 } |
|
609 |
|
610 bool |
|
611 octave_list::save_binary (std::ostream& os, bool& save_as_floats) |
|
612 { |
|
613 octave_value_list lst = list_value (); |
|
614 |
5828
|
615 int32_t len = lst.length(); |
5760
|
616 os.write (reinterpret_cast<char *> (&len), 4); |
4687
|
617 |
|
618 for (int i = 0; i < lst.length (); i++) |
|
619 { |
|
620 // should we use lst.name_tags () to label the elements? |
5717
|
621 |
5765
|
622 std::ostringstream buf; |
|
623 buf << "_" << i; |
|
624 std::string s = buf.str (); |
4687
|
625 |
|
626 // Recurse to print sub-value. |
5717
|
627 bool b = save_binary_data (os, lst(i), s.c_str (), "", 0, |
|
628 save_as_floats); |
4687
|
629 |
|
630 if (! b) |
|
631 return false; |
|
632 } |
|
633 |
|
634 return true; |
|
635 } |
|
636 |
|
637 bool |
|
638 octave_list::load_binary (std::istream& is, bool swap, |
5760
|
639 oct_mach_info::float_format fmt) |
4687
|
640 { |
5828
|
641 int32_t len; |
5760
|
642 if (! is.read (reinterpret_cast<char *> (&len), 4)) |
4687
|
643 return false; |
|
644 if (swap) |
4944
|
645 swap_bytes<4> (&len); |
4687
|
646 |
|
647 if (len > 0) |
|
648 { |
|
649 octave_value_list lst; |
|
650 |
5275
|
651 for (octave_idx_type i = 0; i < len; i++) |
4687
|
652 { |
|
653 octave_value t2; |
|
654 bool dummy; |
|
655 std::string doc; |
|
656 |
|
657 // recurse to read list elements |
|
658 std::string nm = read_binary_data (is, swap, fmt, std::string (), |
|
659 dummy, t2, doc); |
|
660 |
|
661 if (!is) |
|
662 return false; |
|
663 |
|
664 lst.append(t2); |
|
665 } |
|
666 |
|
667 if (is) |
|
668 data = lst; |
|
669 else |
|
670 { |
|
671 error ("load: failed to load list"); |
|
672 return false; |
|
673 } |
|
674 |
|
675 } |
|
676 else if (len == 0 ) |
|
677 data = Cell (0, 0); |
|
678 else |
|
679 return false; |
|
680 |
|
681 return true; |
|
682 } |
|
683 |
|
684 #if defined (HAVE_HDF5) |
4944
|
685 |
4687
|
686 bool |
|
687 octave_list::save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats) |
|
688 { |
|
689 hid_t data_hid = -1; |
|
690 |
|
691 data_hid = H5Gcreate (loc_id, name, 0); |
|
692 if (data_hid < 0) return false; |
|
693 |
|
694 // recursively add each element of the list to this group |
|
695 octave_value_list lst = list_value (); |
|
696 |
5275
|
697 for (octave_idx_type i = 0; i < lst.length (); ++i) |
4687
|
698 { |
|
699 // should we use lst.name_tags () to label the elements? |
5717
|
700 |
5765
|
701 std::ostringstream buf; |
|
702 buf << "_" << i; |
|
703 std::string s = buf.str (); |
5717
|
704 |
|
705 bool retval2 = add_hdf5_data (data_hid, lst (i), s.c_str (), "", |
4687
|
706 false, save_as_floats); |
|
707 if (! retval2) |
|
708 break; |
|
709 } |
|
710 |
|
711 H5Gclose (data_hid); |
4837
|
712 |
4687
|
713 return true; |
|
714 } |
|
715 |
|
716 bool |
|
717 octave_list::load_hdf5 (hid_t loc_id, const char *name, |
|
718 bool have_h5giterate_bug) |
|
719 { |
|
720 bool retval = false; |
|
721 |
|
722 hdf5_callback_data dsub; |
|
723 |
4696
|
724 herr_t retval2 = -1; |
4687
|
725 octave_value_list lst; |
|
726 int current_item = 0; |
4696
|
727 #ifdef HAVE_H5GGET_NUM_OBJS |
|
728 hsize_t num_obj = 0; |
5060
|
729 hid_t group_id = H5Gopen (loc_id, name); |
|
730 H5Gget_num_objs (group_id, &num_obj); |
|
731 H5Gclose (group_id); |
4696
|
732 |
|
733 while (current_item < static_cast<int> (num_obj) |
|
734 && (retval2 = H5Giterate (loc_id, name, ¤t_item, |
|
735 hdf5_read_next_data, &dsub)) > 0) |
|
736 #else |
4687
|
737 while ((retval2 = H5Giterate (loc_id, name, ¤t_item, |
|
738 hdf5_read_next_data, &dsub)) > 0) |
4696
|
739 #endif |
4687
|
740 { |
|
741 lst.append (dsub.tc); |
|
742 |
|
743 if (have_h5giterate_bug) |
|
744 current_item++; // H5Giterate returned the last index processed |
|
745 } |
|
746 |
|
747 if (retval2 >= 0) |
|
748 { |
|
749 data = lst; |
|
750 retval = true; |
|
751 } |
|
752 |
|
753 return retval; |
|
754 } |
4944
|
755 |
4687
|
756 #endif |
|
757 |
2882
|
758 /* |
|
759 ;;; Local Variables: *** |
|
760 ;;; mode: C++ *** |
|
761 ;;; End: *** |
|
762 */ |