Mercurial > hg > octave-nkf
annotate src/ov-struct.cc @ 7651:443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 26 Mar 2008 22:09:42 -0400 |
parents | c195bd0a5c64 |
children | d9987dbdf91b |
rev | line source |
---|---|
2376 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1996, 1997, 1998, 2000, 2002, 2003, 2004, 2005, 2006, |
4 2007 John W. Eaton | |
2376 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
2376 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
2376 | 21 |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
25 #include <config.h> | |
26 #endif | |
27 | |
3503 | 28 #include <iostream> |
2376 | 29 |
3933 | 30 #include "Cell.h" |
4358 | 31 #include "defun.h" |
2376 | 32 #include "error.h" |
4358 | 33 #include "gripes.h" |
2979 | 34 #include "oct-lvalue.h" |
3932 | 35 #include "ov-list.h" |
2376 | 36 #include "ov-struct.h" |
37 #include "unwind-prot.h" | |
6811 | 38 #include "utils.h" |
2948 | 39 #include "variables.h" |
2376 | 40 |
4750 | 41 #include "Array-util.h" |
42 | |
4687 | 43 #include "byte-swap.h" |
44 #include "ls-oct-ascii.h" | |
45 #include "ls-oct-binary.h" | |
46 #include "ls-hdf5.h" | |
47 #include "ls-utils.h" | |
5759 | 48 #include "pr-output.h" |
4687 | 49 |
3219 | 50 DEFINE_OCTAVE_ALLOCATOR(octave_struct); |
2376 | 51 |
4612 | 52 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(octave_struct, "struct", "struct"); |
2376 | 53 |
4513 | 54 Cell |
3933 | 55 octave_struct::dotref (const octave_value_list& idx) |
2962 | 56 { |
4513 | 57 Cell retval; |
3933 | 58 |
59 assert (idx.length () == 1); | |
2962 | 60 |
3933 | 61 std::string nm = idx(0).string_value (); |
62 | |
4219 | 63 Octave_map::const_iterator p = map.seek (nm); |
2376 | 64 |
4219 | 65 if (p != map.end ()) |
3933 | 66 retval = map.contents (p); |
67 else | |
2376 | 68 error ("structure has no member `%s'", nm.c_str ()); |
69 | |
70 return retval; | |
71 } | |
72 | |
4513 | 73 #if 0 |
3933 | 74 static void |
75 gripe_invalid_index (void) | |
76 { | |
77 error ("invalid index for structure array"); | |
78 } | |
4513 | 79 #endif |
3933 | 80 |
81 static void | |
82 gripe_invalid_index_for_assignment (void) | |
83 { | |
84 error ("invalid index for structure array assignment"); | |
85 } | |
86 | |
87 static void | |
88 gripe_invalid_index_type (const std::string& nm, char t) | |
89 { | |
90 error ("%s cannot be indexed with %c", nm.c_str (), t); | |
91 } | |
92 | |
93 static void | |
94 gripe_failed_assignment (void) | |
95 { | |
96 error ("assignment to structure element failed"); | |
97 } | |
98 | |
7651
443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents:
7622
diff
changeset
|
99 octave_value_list |
4247 | 100 octave_struct::subsref (const std::string& type, |
7651
443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents:
7622
diff
changeset
|
101 const std::list<octave_value_list>& idx, |
443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents:
7622
diff
changeset
|
102 int nargout) |
3933 | 103 { |
7651
443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents:
7622
diff
changeset
|
104 octave_value_list retval; |
3933 | 105 |
106 int skip = 1; | |
107 | |
108 switch (type[0]) | |
109 { | |
110 case '(': | |
111 { | |
112 if (type.length () > 1 && type[1] == '.') | |
113 { | |
4219 | 114 std::list<octave_value_list>::const_iterator p = idx.begin (); |
115 octave_value_list key_idx = *++p; | |
3933 | 116 |
4513 | 117 Cell tmp = dotref (key_idx); |
3933 | 118 |
119 if (! error_state) | |
120 { | |
7460 | 121 Cell t = tmp.index (idx.front (), true); |
3933 | 122 |
7651
443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents:
7622
diff
changeset
|
123 retval(0) = (t.length () == 1) ? t(0) : octave_value (t, true); |
3933 | 124 |
4513 | 125 // We handled two index elements, so tell |
126 // next_subsref to skip both of them. | |
3933 | 127 |
4513 | 128 skip++; |
3933 | 129 } |
130 } | |
131 else | |
7651
443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents:
7622
diff
changeset
|
132 retval(0) = map.index (idx.front (), true); |
3933 | 133 } |
134 break; | |
135 | |
136 case '.': | |
137 { | |
5592 | 138 if (map.numel() > 0) |
139 { | |
140 Cell t = dotref (idx.front ()); | |
3933 | 141 |
7651
443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents:
7622
diff
changeset
|
142 retval(0) = (t.length () == 1) ? t(0) : octave_value (t, true); |
5592 | 143 } |
3933 | 144 } |
145 break; | |
146 | |
147 case '{': | |
148 gripe_invalid_index_type (type_name (), type[0]); | |
149 break; | |
150 | |
151 default: | |
152 panic_impossible (); | |
153 } | |
154 | |
5775 | 155 // FIXME -- perhaps there should be an |
4994 | 156 // octave_value_list::next_subsref member function? See also |
157 // octave_user_function::subsref. | |
158 | |
159 if (idx.size () > 1) | |
7651
443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents:
7622
diff
changeset
|
160 retval = retval(0).next_subsref (nargout, type, idx, skip); |
3933 | 161 |
162 return retval; | |
163 } | |
164 | |
165 octave_value | |
4513 | 166 octave_struct::numeric_conv (const Cell& val, |
3933 | 167 const std::string& type) |
168 { | |
169 octave_value retval; | |
170 | |
171 if (val.length () == 1) | |
172 { | |
173 retval = val(0); | |
174 | |
175 if (type.length () > 0 && type[0] == '.' && ! retval.is_map ()) | |
176 retval = Octave_map (); | |
177 } | |
178 else | |
179 gripe_invalid_index_for_assignment (); | |
180 | |
181 return retval; | |
182 } | |
183 | |
184 octave_value | |
4247 | 185 octave_struct::subsasgn (const std::string& type, |
4219 | 186 const std::list<octave_value_list>& idx, |
3933 | 187 const octave_value& rhs) |
2376 | 188 { |
3933 | 189 octave_value retval; |
190 | |
191 int n = type.length (); | |
192 | |
193 octave_value t_rhs = rhs; | |
194 | |
195 if (n > 1 && ! (type.length () == 2 && type[0] == '(' && type[1] == '.')) | |
196 { | |
197 switch (type[0]) | |
198 { | |
199 case '(': | |
200 { | |
201 if (type.length () > 1 && type[1] == '.') | |
202 { | |
4219 | 203 std::list<octave_value_list>::const_iterator p = idx.begin (); |
204 octave_value_list t_idx = *p; | |
3933 | 205 |
4513 | 206 octave_value_list key_idx = *++p; |
207 | |
208 assert (key_idx.length () == 1); | |
3933 | 209 |
4513 | 210 std::string key = key_idx(0).string_value (); |
3933 | 211 |
4513 | 212 octave_value u; |
3933 | 213 |
4513 | 214 if (! map.contains (key)) |
215 u = octave_value::empty_conv (type.substr (2), rhs); | |
216 else | |
217 { | |
4675 | 218 Cell map_val = map.contents (key); |
3933 | 219 |
4513 | 220 Cell map_elt = map_val.index (idx.front (), true); |
3933 | 221 |
4513 | 222 u = numeric_conv (map_elt, type.substr (2)); |
223 } | |
3933 | 224 |
4513 | 225 if (! error_state) |
226 { | |
227 std::list<octave_value_list> next_idx (idx); | |
3933 | 228 |
4513 | 229 // We handled two index elements, so subsasgn to |
230 // needs to skip both of them. | |
3933 | 231 |
4513 | 232 next_idx.erase (next_idx.begin ()); |
233 next_idx.erase (next_idx.begin ()); | |
4059 | 234 |
4513 | 235 u.make_unique (); |
236 | |
237 t_rhs = u.subsasgn (type.substr (2), next_idx, rhs); | |
3933 | 238 } |
239 } | |
240 else | |
241 gripe_invalid_index_for_assignment (); | |
242 } | |
243 break; | |
244 | |
245 case '.': | |
246 { | |
247 octave_value_list key_idx = idx.front (); | |
248 | |
249 assert (key_idx.length () == 1); | |
250 | |
251 std::string key = key_idx(0).string_value (); | |
252 | |
253 octave_value u; | |
254 | |
255 if (! map.contains (key)) | |
256 u = octave_value::empty_conv (type.substr (1), rhs); | |
257 else | |
258 { | |
4675 | 259 Cell map_val = map.contents (key); |
3933 | 260 |
261 u = numeric_conv (map_val, type.substr (1)); | |
262 } | |
263 | |
264 if (! error_state) | |
265 { | |
4219 | 266 std::list<octave_value_list> next_idx (idx); |
3933 | 267 |
4219 | 268 next_idx.erase (next_idx.begin ()); |
3933 | 269 |
4059 | 270 u.make_unique (); |
271 | |
3933 | 272 t_rhs = u.subsasgn (type.substr (1), next_idx, rhs); |
273 } | |
274 } | |
275 break; | |
276 | |
277 case '{': | |
278 gripe_invalid_index_type (type_name (), type[0]); | |
279 break; | |
280 | |
281 default: | |
282 panic_impossible (); | |
283 } | |
284 } | |
285 | |
286 if (! error_state) | |
287 { | |
288 switch (type[0]) | |
289 { | |
290 case '(': | |
291 { | |
292 if (n > 1 && type[1] == '.') | |
293 { | |
4219 | 294 std::list<octave_value_list>::const_iterator p = idx.begin (); |
295 octave_value_list key_idx = *++p; | |
3933 | 296 |
297 assert (key_idx.length () == 1); | |
298 | |
299 std::string key = key_idx(0).string_value (); | |
300 | |
301 if (! error_state) | |
302 { | |
4513 | 303 map.assign (idx.front (), key, t_rhs); |
3933 | 304 |
4513 | 305 if (! error_state) |
5759 | 306 { |
307 count++; | |
308 retval = octave_value (this); | |
309 } | |
3933 | 310 else |
4513 | 311 gripe_failed_assignment (); |
3933 | 312 } |
313 else | |
314 gripe_failed_assignment (); | |
315 } | |
316 else | |
4197 | 317 { |
5592 | 318 if (t_rhs.is_map()) |
4197 | 319 { |
5592 | 320 Octave_map rhs_map = t_rhs.map_value (); |
4197 | 321 |
322 if (! error_state) | |
5592 | 323 { |
324 map.assign (idx.front (), rhs_map); | |
325 | |
326 if (! error_state) | |
5759 | 327 { |
328 count++; | |
329 retval = octave_value (this); | |
330 } | |
5592 | 331 else |
332 gripe_failed_assignment (); | |
333 } | |
4197 | 334 else |
5592 | 335 error ("invalid structure assignment"); |
4197 | 336 } |
4513 | 337 else |
5592 | 338 { |
339 if (t_rhs.is_empty()) | |
340 { | |
341 map.maybe_delete_elements (idx.front()); | |
342 | |
343 if (! error_state) | |
5759 | 344 { |
345 count++; | |
346 retval = octave_value (this); | |
347 } | |
5592 | 348 else |
349 gripe_failed_assignment (); | |
350 } | |
351 else | |
352 error ("invalid structure assignment"); | |
353 } | |
4197 | 354 } |
3933 | 355 } |
356 break; | |
357 | |
358 case '.': | |
359 { | |
360 octave_value_list key_idx = idx.front (); | |
361 | |
362 assert (key_idx.length () == 1); | |
363 | |
364 std::string key = key_idx(0).string_value (); | |
365 | |
6833 | 366 if (t_rhs.is_cs_list ()) |
367 { | |
368 Cell tmp_cell = Cell (t_rhs.list_value ()); | |
369 | |
7040 | 370 // The shape of the RHS is irrelevant, we just want |
371 // the number of elements to agree and to preserve the | |
372 // shape of the left hand side of the assignment. | |
373 | |
374 if (numel () == tmp_cell.numel ()) | |
375 tmp_cell = tmp_cell.reshape (dims ()); | |
6833 | 376 |
377 map.assign (key, tmp_cell); | |
378 } | |
379 else | |
380 map.assign (key, t_rhs); | |
3933 | 381 |
382 if (! error_state) | |
5759 | 383 { |
384 count++; | |
385 retval = octave_value (this); | |
386 } | |
3933 | 387 else |
388 gripe_failed_assignment (); | |
389 } | |
390 break; | |
391 | |
392 case '{': | |
393 gripe_invalid_index_type (type_name (), type[0]); | |
394 break; | |
395 | |
396 default: | |
397 panic_impossible (); | |
398 } | |
399 } | |
400 else | |
401 gripe_failed_assignment (); | |
402 | |
403 return retval; | |
2376 | 404 } |
405 | |
7046 | 406 octave_value |
407 octave_struct::do_index_op (const octave_value_list& idx, bool resize_ok) | |
408 { | |
409 octave_value retval; | |
410 | |
411 octave_idx_type n_idx = idx.length (); | |
412 | |
413 int nd = map.ndims (); | |
414 | |
415 switch (n_idx) | |
416 { | |
417 case 0: | |
418 retval = map; | |
419 break; | |
420 | |
421 case 1: | |
422 { | |
423 idx_vector i = idx (0).index_vector (); | |
424 | |
425 if (! error_state) | |
426 retval = map.index (i, resize_ok, Cell::resize_fill_value ()); | |
427 } | |
428 break; | |
429 | |
430 default: | |
431 { | |
432 if (n_idx == 2 && nd == 2) | |
433 { | |
434 idx_vector i = idx (0).index_vector (); | |
435 | |
436 if (! error_state) | |
437 { | |
438 idx_vector j = idx (1).index_vector (); | |
439 | |
440 if (! error_state) | |
441 retval = map.index (i, j, resize_ok, | |
442 Cell::resize_fill_value ()); | |
443 } | |
444 } | |
445 else | |
446 { | |
447 Array<idx_vector> idx_vec (n_idx); | |
448 | |
449 for (octave_idx_type i = 0; i < n_idx; i++) | |
450 { | |
451 idx_vec(i) = idx(i).index_vector (); | |
452 | |
453 if (error_state) | |
454 break; | |
455 } | |
456 | |
457 if (! error_state) | |
458 retval = map.index (idx_vec, resize_ok, | |
459 Cell::resize_fill_value ()); | |
460 } | |
461 } | |
462 break; | |
463 } | |
464 | |
465 return retval; | |
466 } | |
467 | |
4791 | 468 size_t |
469 octave_struct::byte_size (void) const | |
470 { | |
471 // Neglect the size of the fieldnames. | |
472 | |
473 size_t retval = 0; | |
474 | |
475 for (Octave_map::const_iterator p = map.begin (); p != map.end (); p++) | |
476 { | |
477 std::string key = map.key (p); | |
478 | |
479 octave_value val = octave_value (map.contents (p)); | |
480 | |
481 retval += val.byte_size (); | |
482 } | |
483 | |
484 return retval; | |
485 } | |
486 | |
2376 | 487 void |
3523 | 488 octave_struct::print (std::ostream& os, bool) const |
2901 | 489 { |
490 print_raw (os); | |
491 } | |
492 | |
493 void | |
3523 | 494 octave_struct::print_raw (std::ostream& os, bool) const |
2376 | 495 { |
2985 | 496 unwind_protect::begin_frame ("octave_struct_print"); |
2376 | 497 |
498 unwind_protect_int (Vstruct_levels_to_print); | |
499 | |
3961 | 500 if (Vstruct_levels_to_print >= 0) |
2376 | 501 { |
7571
c01ff6818f4c
simplify struct array printing
John W. Eaton <jwe@octave.org>
parents:
7460
diff
changeset
|
502 bool print_keys_only = Vstruct_levels_to_print-- == 0; |
3961 | 503 |
2901 | 504 indent (os); |
505 os << "{"; | |
506 newline (os); | |
2376 | 507 |
2901 | 508 increment_indent_level (); |
2376 | 509 |
5598 | 510 octave_idx_type n = map.numel (); |
3932 | 511 |
7571
c01ff6818f4c
simplify struct array printing
John W. Eaton <jwe@octave.org>
parents:
7460
diff
changeset
|
512 if (n != 1 || print_keys_only) |
4604 | 513 { |
514 indent (os); | |
515 dim_vector dv = dims (); | |
516 os << dv.str () << " struct array containing the fields:"; | |
517 newline (os); | |
518 newline (os); | |
519 | |
520 increment_indent_level (); | |
521 } | |
522 | |
5880 | 523 string_vector key_list = map.keys (); |
524 | |
525 for (octave_idx_type i = 0; i < key_list.length (); i++) | |
2376 | 526 { |
5880 | 527 std::string key = key_list[i]; |
528 | |
529 Cell val = map.contents (key); | |
2376 | 530 |
4499 | 531 octave_value tmp = (n == 1) ? val(0) : octave_value (val, true); |
3961 | 532 |
7571
c01ff6818f4c
simplify struct array printing
John W. Eaton <jwe@octave.org>
parents:
7460
diff
changeset
|
533 if (n != 1 || print_keys_only) |
3932 | 534 { |
3961 | 535 indent (os); |
4604 | 536 os << key; |
537 if (n == 1) | |
538 { | |
539 dim_vector dv = tmp.dims (); | |
540 os << ": " << dv.str () << " " << tmp.type_name (); | |
541 } | |
3961 | 542 newline (os); |
3932 | 543 } |
3961 | 544 else |
4121 | 545 tmp.print_with_name (os, key); |
2376 | 546 } |
547 | |
7571
c01ff6818f4c
simplify struct array printing
John W. Eaton <jwe@octave.org>
parents:
7460
diff
changeset
|
548 if (n != 1 || print_keys_only) |
4604 | 549 decrement_indent_level (); |
550 | |
2901 | 551 decrement_indent_level (); |
2376 | 552 |
2901 | 553 indent (os); |
554 os << "}"; | |
555 newline (os); | |
2376 | 556 } |
557 else | |
2901 | 558 { |
3961 | 559 indent (os); |
560 os << "<structure>"; | |
2901 | 561 newline (os); |
562 } | |
2376 | 563 |
2985 | 564 unwind_protect::run_frame ("octave_struct_print"); |
2376 | 565 } |
566 | |
2901 | 567 bool |
3523 | 568 octave_struct::print_name_tag (std::ostream& os, const std::string& name) const |
2901 | 569 { |
3961 | 570 bool retval = false; |
571 | |
2901 | 572 indent (os); |
3961 | 573 |
574 if (Vstruct_levels_to_print < 0) | |
575 os << name << " = "; | |
576 else | |
577 { | |
578 os << name << " ="; | |
579 newline (os); | |
580 retval = true; | |
581 } | |
582 | |
583 return retval; | |
2901 | 584 } |
585 | |
4744 | 586 static bool |
587 scalar (const dim_vector& dims) | |
588 { | |
589 return dims.length () == 2 && dims (0) == 1 && dims (1) == 1; | |
590 } | |
591 | |
592 /* | |
593 %!shared x | |
594 %! x(1).a=1; x(2).a=2; x(1).b=3; x(2).b=3; | |
595 %!assert(struct('a',1,'b',3),x(1)) | |
5592 | 596 %!assert(isempty(x([]))) |
597 %!assert(isempty(struct('a',{},'b',{}))) | |
4744 | 598 %!assert(struct('a',{1,2},'b',{3,3}),x) |
599 %!assert(struct('a',{1,2},'b',3),x) | |
600 %!assert(struct('a',{1,2},'b',{3}),x) | |
601 %!assert(struct('b',3,'a',{1,2}),x) | |
602 %!assert(struct('b',{3},'a',{1,2}),x) | |
603 %!test x=struct([]); | |
604 %!assert(size(x),[0,0]); | |
605 %!assert(isstruct(x)); | |
606 %!assert(isempty(fieldnames(x))); | |
607 %!fail("struct('a',{1,2},'b',{1,2,3})","dimensions of parameter 2 do not match those of parameter 4") | |
5582 | 608 %!fail("struct(1,2,3,4)","struct expects alternating \"field\", VALUE pairs"); |
609 %!fail("struct('1',2,'3')","struct expects alternating \"field\", VALUE pairs"); | |
4744 | 610 */ |
611 | |
612 DEFUN (struct, args, , | |
613 "-*- texinfo -*-\n\ | |
614 @deftypefn {Built-in Function} {} struct (\"field\", @var{value}, \"field\", @var{value}, @dots{})\n\ | |
615 \n\ | |
616 Create a structure and initialize its value.\n\ | |
617 \n\ | |
618 If the values are cell arrays, create a structure array and initialize\n\ | |
619 its values. The dimensions of each cell array of values must match.\n\ | |
620 Singleton cells and non-cell values are repeated so that they fill\n\ | |
621 the entire array. If the cells are empty, create an empty structure\n\ | |
4911 | 622 array with the specified field names.\n\ |
623 @end deftypefn") | |
4744 | 624 { |
6946 | 625 octave_value retval; |
4744 | 626 |
627 int nargin = args.length (); | |
628 | |
5444 | 629 // struct ([]) returns an empty struct. |
630 | |
631 // struct (empty_matrix) returns an empty struct with the same | |
632 // dimensions as the empty matrix. | |
633 | |
634 // Note that struct () creates a 1x1 struct with no fields for | |
635 // compatibility with Matlab. | |
4744 | 636 |
6946 | 637 if ((nargin == 1 || nargin == 2) |
638 && args(0).is_empty () && args(0).is_real_matrix ()) | |
639 { | |
640 Cell fields; | |
641 | |
642 if (nargin == 2) | |
643 { | |
644 if (args(1).is_cellstr ()) | |
645 retval = Octave_map (args(0).dims (), args(1).cell_value ()); | |
646 else | |
647 error ("struct: expecting cell array of field names as second argument"); | |
648 } | |
649 else | |
650 retval = Octave_map (args(0).dims ()); | |
651 | |
652 return retval; | |
653 } | |
4744 | 654 |
655 // Check for "field", VALUE pairs. | |
656 | |
657 for (int i = 0; i < nargin; i += 2) | |
658 { | |
659 if (! args(i).is_string () || i + 1 >= nargin) | |
660 { | |
661 error ("struct expects alternating \"field\", VALUE pairs"); | |
662 return retval; | |
663 } | |
664 } | |
665 | |
666 // Check that the dimensions of the values correspond. | |
667 | |
668 dim_vector dims (1, 1); | |
669 | |
670 int first_dimensioned_value = 0; | |
671 | |
672 for (int i = 1; i < nargin; i += 2) | |
673 { | |
674 if (args(i).is_cell ()) | |
675 { | |
676 dim_vector argdims (args(i).dims ()); | |
677 | |
678 if (! scalar (argdims)) | |
679 { | |
680 if (! first_dimensioned_value) | |
681 { | |
682 dims = argdims; | |
683 first_dimensioned_value = i + 1; | |
684 } | |
685 else if (dims != argdims) | |
686 { | |
687 error ("struct: dimensions of parameter %d do not match those of parameter %d", | |
688 first_dimensioned_value, i+1); | |
689 return retval; | |
690 } | |
691 } | |
692 } | |
693 } | |
694 | |
695 // Create the return value. | |
696 | |
697 Octave_map map (dims); | |
698 | |
699 for (int i = 0; i < nargin; i+= 2) | |
700 { | |
701 // Get key. | |
702 | |
703 std::string key (args(i).string_value ()); | |
704 | |
705 if (error_state) | |
706 return retval; | |
707 | |
6811 | 708 if (! valid_identifier (key)) |
709 { | |
710 error ("struct: invalid structure field name `%s'", key.c_str ()); | |
711 return retval; | |
712 } | |
713 | |
4744 | 714 // Value may be v, { v }, or { v1, v2, ... } |
715 // In the first two cases, we need to create a cell array of | |
716 // the appropriate dimensions filled with v. In the last case, | |
717 // the cell array has already been determined to be of the | |
718 // correct dimensions. | |
719 | |
720 if (args(i+1).is_cell ()) | |
721 { | |
722 const Cell c (args(i+1).cell_value ()); | |
723 | |
724 if (error_state) | |
725 return retval; | |
726 | |
727 if (scalar (c.dims ())) | |
728 map.assign (key, Cell (dims, c(0))); | |
729 else | |
730 map.assign (key, c); | |
731 } | |
732 else | |
733 map.assign (key, Cell (dims, args(i+1))); | |
734 | |
735 if (error_state) | |
736 return retval; | |
737 } | |
6946 | 738 |
4744 | 739 return octave_value (map); |
740 } | |
741 | |
4358 | 742 DEFUN (isstruct, args, , |
743 "-*- texinfo -*-\n\ | |
744 @deftypefn {Built-in Function} {} isstruct (@var{expr})\n\ | |
745 Return 1 if the value of the expression @var{expr} is a structure.\n\ | |
746 @end deftypefn") | |
747 { | |
748 octave_value retval; | |
749 | |
750 if (args.length () == 1) | |
751 retval = args(0).is_map (); | |
752 else | |
5823 | 753 print_usage (); |
4358 | 754 |
755 return retval; | |
756 } | |
757 | |
758 DEFUN (fieldnames, args, , | |
759 "-*- texinfo -*-\n\ | |
760 @deftypefn {Built-in Function} {} fieldnames (@var{struct})\n\ | |
761 Return a cell array of strings naming the elements of the structure\n\ | |
762 @var{struct}. It is an error to call @code{fieldnames} with an\n\ | |
763 argument that is not a structure.\n\ | |
764 @end deftypefn") | |
765 { | |
766 octave_value retval; | |
767 | |
768 int nargin = args.length (); | |
769 | |
770 if (nargin == 1) | |
771 { | |
7336 | 772 octave_value arg = args(0); |
773 | |
774 if (arg.is_map () || arg.is_object ()) | |
4358 | 775 { |
7336 | 776 Octave_map m = arg.map_value (); |
777 | |
4744 | 778 string_vector keys = m.keys (); |
7336 | 779 |
4744 | 780 if (keys.length () == 0) |
781 retval = Cell (0, 1); | |
782 else | |
783 retval = Cell (m.keys ()); | |
4358 | 784 } |
785 else | |
786 gripe_wrong_type_arg ("fieldnames", args(0)); | |
787 } | |
788 else | |
5823 | 789 print_usage (); |
4358 | 790 |
791 return retval; | |
792 } | |
793 | |
794 DEFUN (isfield, args, , | |
795 "-*- texinfo -*-\n\ | |
796 @deftypefn {Built-in Function} {} isfield (@var{expr}, @var{name})\n\ | |
797 Return true if the expression @var{expr} is a structure and it includes an\n\ | |
798 element named @var{name}. The first argument must be a structure and\n\ | |
799 the second must be a string.\n\ | |
800 @end deftypefn") | |
801 { | |
802 octave_value retval; | |
803 | |
804 int nargin = args.length (); | |
805 | |
806 if (nargin == 2) | |
807 { | |
808 retval = false; | |
809 | |
5775 | 810 // FIXME -- should this work for all types that can do |
4358 | 811 // structure reference operations? |
812 | |
813 if (args(0).is_map () && args(1).is_string ()) | |
814 { | |
815 std::string key = args(1).string_value (); | |
816 | |
817 Octave_map m = args(0).map_value (); | |
818 | |
819 retval = m.contains (key) != 0; | |
820 } | |
821 } | |
822 else | |
5823 | 823 print_usage (); |
4358 | 824 |
825 return retval; | |
826 } | |
827 | |
4750 | 828 // Check that the dimensions of the input arguments are correct. |
829 | |
830 static bool | |
831 cell2struct_check_args (const dim_vector& c_dv, const dim_vector& f_dv, | |
832 bool is_cell, int dim) | |
833 { | |
4751 | 834 bool retval = true; |
4750 | 835 |
836 if (dim >= 0 && dim < c_dv.length ()) | |
837 { | |
838 if (is_cell) | |
839 { | |
4752 | 840 if (f_dv.numel () != c_dv(dim)) |
4750 | 841 { |
4751 | 842 error ("cell2struct: numel (FIELD) != size (CELL, DIM)"); |
4750 | 843 |
844 retval = false; | |
845 } | |
846 } | |
847 else | |
848 { | |
849 if (f_dv.length () > 2) | |
850 { | |
4751 | 851 error ("cell2struct: field array must be a 2-d matrix"); |
4750 | 852 |
853 retval = false; | |
854 } | |
855 else if (f_dv(0) != c_dv(dim)) | |
856 { | |
4751 | 857 error ("cell2struct: size (FIELD, 1) != length (C, DIM)"); |
4750 | 858 |
859 retval = false; | |
860 } | |
861 } | |
862 } | |
863 else | |
864 { | |
865 error ("cell2struct: DIM out of range"); | |
866 | |
867 retval = false; | |
868 } | |
869 | |
870 return retval; | |
871 } | |
872 | |
873 static void | |
5275 | 874 cell2struct_construct_idx (Array<octave_idx_type>& ra_idx1, |
875 const Array<octave_idx_type>& ra_idx2, | |
876 octave_idx_type dim, octave_idx_type fill_value) | |
4750 | 877 { |
5275 | 878 octave_idx_type iidx = 0; |
4750 | 879 |
5275 | 880 for (octave_idx_type idx = 0; idx < ra_idx1.length (); idx++) |
4750 | 881 { |
882 if (idx == dim) | |
883 ra_idx1.elem (idx) = fill_value; | |
884 else | |
885 ra_idx1.elem (idx) = ra_idx2(iidx++); | |
886 } | |
887 } | |
888 | |
889 DEFUN (cell2struct, args, , | |
890 "-*- texinfo -*-\n\ | |
4817 | 891 @deftypefn {Built-in Function} {} cell2struct (@var{cell}, @var{fields}, @var{dim})\n\ |
892 Convert @var{cell} to a structure. The number of fields in @var{fields}\n\ | |
893 must match the number of elements in @var{cell} along dimension @var{dim},\n\ | |
894 that is @code{numel (@var{fields}) == size (@var{cell}, @var{dim})}.\n\ | |
4750 | 895 \n\ |
896 @example\n\ | |
897 @group\n\ | |
7031 | 898 A = cell2struct (@{'Peter', 'Hannah', 'Robert';\n\ |
899 185, 170, 168@},\n\ | |
6519 | 900 @{'Name','Height'@}, 1);\n\ |
4750 | 901 A(1)\n\ |
902 @result{} ans =\n\ | |
4780 | 903 @{\n\ |
904 Height = 185\n\ | |
905 Name = Peter\n\ | |
906 @}\n\ | |
4750 | 907 \n\ |
908 @end group\n\ | |
909 @end example\n\ | |
910 @end deftypefn") | |
911 { | |
912 octave_value retval; | |
913 | |
4751 | 914 if (args.length () == 3) |
4750 | 915 { |
4751 | 916 Cell c = args(0).cell_value (); |
4750 | 917 |
4751 | 918 if (! error_state) |
4750 | 919 { |
4751 | 920 octave_value field = args(1); |
4750 | 921 |
4751 | 922 // Field is either cell or character matrix. |
4750 | 923 |
5775 | 924 // FIXME -- this could be simplified if we had |
4752 | 925 // cellstr and iscellstr functions available. |
926 | |
4751 | 927 bool field_is_cell = field.is_cell (); |
4750 | 928 |
4751 | 929 Cell field_cell; |
930 charMatrix field_char; | |
4750 | 931 |
932 if (field_is_cell) | |
4751 | 933 field_cell = field.cell_value (); |
934 else | |
935 field_char = field.char_matrix_value (); | |
936 | |
937 if (! error_state) | |
4750 | 938 { |
4751 | 939 // Retrieve the dimension value. |
940 | |
5775 | 941 // FIXME -- int_value () should print out the |
4751 | 942 // conversions it does to be Matlab compatible. |
943 | |
5275 | 944 octave_idx_type dim = args(2).int_value () - 1; |
4751 | 945 |
946 if (! error_state) | |
947 { | |
948 dim_vector c_dv = c.dims (); | |
949 dim_vector field_dv = field.dims (); | |
950 | |
951 if (cell2struct_check_args (c_dv, field_dv, field_is_cell, | |
952 dim)) | |
953 { | |
5275 | 954 octave_idx_type c_dv_length = c_dv.length (); |
4751 | 955 |
956 // Dimension vector for the Cell arrays to be | |
957 // put into the structure. | |
958 | |
959 dim_vector value_dv; | |
960 | |
961 // Initialize c_value_dv. | |
4750 | 962 |
4751 | 963 if (c_dv_length == 2) |
964 value_dv = dim_vector (1, 1); | |
965 else | |
966 value_dv.resize (c_dv_length - 1); | |
967 | |
5275 | 968 octave_idx_type idx_tmp = 0; |
4751 | 969 |
5275 | 970 for (octave_idx_type i = 0; i < c_dv_length; i++) |
4751 | 971 { |
972 if (i != dim) | |
973 value_dv.elem (idx_tmp++) = c_dv.elem (i); | |
974 } | |
975 | |
976 // All initializing is done, we can start moving | |
977 // values. | |
978 | |
979 Octave_map map; | |
980 | |
981 // If field is a cell array then we use all | |
982 // elements in array, on the other hand when | |
983 // field is a character array the number of | |
984 // elements is equals the number of rows. | |
985 | |
5275 | 986 octave_idx_type field_numel |
4751 | 987 = field_is_cell ? field_dv.numel (): field_dv(0); |
988 | |
989 // For matlab compatibility. | |
990 | |
991 if (field_numel == 0) | |
992 map.reshape (dim_vector (0, 1)); | |
4750 | 993 |
5275 | 994 for (octave_idx_type i = 0; i < field_numel; i++) |
4751 | 995 { |
996 // Construct cell array which goes into the | |
997 // structure together with the appropriate | |
998 // field name. | |
999 | |
1000 Cell c_value (value_dv); | |
1001 | |
5275 | 1002 Array<octave_idx_type> value_idx (value_dv.length (), 0); |
1003 Array<octave_idx_type> c_idx (c_dv_length, 0); | |
4751 | 1004 |
5275 | 1005 for (octave_idx_type j = 0; j < value_dv.numel (); j++) |
4751 | 1006 { |
1007 // Need to do this to construct the | |
1008 // appropriate idx for getting elements | |
1009 // from the original cell array. | |
1010 | |
1011 cell2struct_construct_idx (c_idx, value_idx, | |
1012 dim, i); | |
1013 | |
1014 c_value.elem (value_idx) = c.elem (c_idx); | |
1015 | |
1016 increment_index (value_idx, value_dv); | |
1017 } | |
1018 | |
1019 std::string field_str; | |
4750 | 1020 |
4751 | 1021 if (field_is_cell) |
1022 { | |
1023 // Matlab retrieves the field values | |
1024 // column by column. | |
1025 | |
1026 octave_value field_tmp = field_cell.elem (i); | |
1027 | |
1028 field_str = field_tmp.string_value (); | |
1029 | |
1030 if (error_state) | |
1031 { | |
1032 error ("cell2struct: fields have to be of type string"); | |
1033 break; | |
1034 } | |
1035 } | |
1036 else | |
1037 { | |
1038 field_str = field_char.row_as_string (i); | |
1039 | |
1040 if (error_state) | |
1041 return retval; | |
1042 } | |
1043 | |
6811 | 1044 if (! valid_identifier (field_str)) |
1045 { | |
1046 error ("cell2struct: invalid field name `%s'", | |
1047 field_str.c_str ()); | |
1048 break; | |
1049 } | |
1050 | |
4751 | 1051 map.reshape (value_dv); |
1052 | |
1053 map.assign (field_str, c_value); | |
1054 } | |
1055 | |
1056 if (! error_state) | |
1057 retval = map; | |
1058 } | |
4750 | 1059 } |
4751 | 1060 else |
1061 error ("cell2struct: expecting third argument to be an integer"); | |
4750 | 1062 } |
1063 else | |
4751 | 1064 error ("cell2struct: expecting second argument to be a cell or character array"); |
4750 | 1065 } |
4751 | 1066 else |
1067 error ("cell2struct: expecting first argument to be a cell array"); | |
4750 | 1068 } |
4751 | 1069 else |
5823 | 1070 print_usage (); |
4750 | 1071 |
1072 return retval; | |
1073 } | |
1074 | |
4817 | 1075 // So we can call Fcellstr directly. |
1076 extern octave_value_list Fcellstr (const octave_value_list& args, int); | |
1077 | |
1078 DEFUN (rmfield, args, , | |
1079 "-*- texinfo -*-\n\ | |
1080 @deftypefn {Built-in Function} {} rmfield (@var{s}, @var{f})\n\ | |
1081 Remove field @var{f} from the structure @var{s}. If @var{f} is a\n\ | |
1082 cell array of character strings or a character array, remove the\n\ | |
1083 named fields.\n\ | |
5642 | 1084 @seealso{cellstr, iscellstr, setfield}\n\ |
1085 @end deftypefn") | |
4817 | 1086 { |
1087 octave_value retval; | |
1088 | |
1089 int nargin = args.length (); | |
1090 | |
1091 if (nargin == 2) | |
1092 { | |
1093 Octave_map m = args(0).map_value (); | |
1094 | |
1095 octave_value_list fval = Fcellstr (args(1), 1); | |
1096 | |
1097 if (! error_state) | |
1098 { | |
1099 Cell fcell = fval(0).cell_value (); | |
1100 | |
1101 for (int i = 0; i < fcell.numel (); i++) | |
1102 { | |
1103 std::string key = fcell(i).string_value (); | |
1104 | |
1105 if (m.contains (key)) | |
1106 m.del (key); | |
1107 else | |
1108 { | |
1109 error ("rmfield: structure does not contain field %s", | |
1110 key.c_str ()); | |
1111 | |
1112 break; | |
1113 } | |
1114 } | |
1115 | |
1116 if (! error_state) | |
1117 retval = m; | |
1118 } | |
1119 } | |
1120 else | |
5823 | 1121 print_usage (); |
4817 | 1122 |
1123 return retval; | |
1124 } | |
1125 | |
1126 bool | |
6974 | 1127 octave_struct::save_ascii (std::ostream& os) |
4817 | 1128 { |
1129 Octave_map m = map_value (); | |
6639 | 1130 os << "# length: " << m.nfields () << "\n"; |
4817 | 1131 |
1132 Octave_map::iterator i = m.begin (); | |
1133 while (i != m.end ()) | |
1134 { | |
5341 | 1135 octave_value val = map.contents (i); |
4817 | 1136 |
6974 | 1137 bool b = save_ascii_data (os, val, m.key (i), false, 0); |
4817 | 1138 |
1139 if (! b) | |
1140 return os; | |
1141 | |
1142 i++; | |
1143 } | |
1144 | |
1145 return true; | |
1146 } | |
1147 | |
1148 bool | |
1149 octave_struct::load_ascii (std::istream& is) | |
1150 { | |
5275 | 1151 octave_idx_type len = 0; |
4817 | 1152 bool success = true; |
1153 | |
1154 if (extract_keyword (is, "length", len) && len >= 0) | |
1155 { | |
1156 if (len > 0) | |
1157 { | |
1158 Octave_map m (map); | |
1159 | |
5275 | 1160 for (octave_idx_type j = 0; j < len; j++) |
4817 | 1161 { |
1162 octave_value t2; | |
1163 bool dummy; | |
1164 | |
1165 // recurse to read cell elements | |
1166 std::string nm | |
5756 | 1167 = read_ascii_data (is, std::string (), dummy, t2, j); |
4817 | 1168 |
1169 if (!is) | |
1170 break; | |
1171 | |
6293 | 1172 Cell tcell = t2.is_cell () ? t2.cell_value () : Cell (t2); |
5433 | 1173 |
6293 | 1174 if (error_state) |
1175 { | |
1176 error ("load: internal error loading struct elements"); | |
1177 return false; | |
1178 } | |
5433 | 1179 |
6293 | 1180 m.assign (nm, tcell); |
4817 | 1181 } |
1182 | |
1183 if (is) | |
1184 map = m; | |
1185 else | |
1186 { | |
1187 error ("load: failed to load structure"); | |
1188 success = false; | |
1189 } | |
1190 } | |
1191 else if (len == 0 ) | |
6292 | 1192 map = Octave_map (dim_vector (1, 1)); |
4817 | 1193 else |
1194 panic_impossible (); | |
1195 } | |
1196 else { | |
1197 error ("load: failed to extract number of elements in structure"); | |
1198 success = false; | |
1199 } | |
1200 | |
1201 return success; | |
1202 } | |
1203 | |
1204 bool | |
1205 octave_struct::save_binary (std::ostream& os, bool& save_as_floats) | |
1206 { | |
1207 Octave_map m = map_value (); | |
1208 | |
6639 | 1209 int32_t len = m.nfields (); |
5760 | 1210 os.write (reinterpret_cast<char *> (&len), 4); |
4817 | 1211 |
1212 Octave_map::iterator i = m.begin (); | |
1213 while (i != m.end ()) | |
1214 { | |
5341 | 1215 octave_value val = map.contents (i); |
4817 | 1216 |
5341 | 1217 bool b = save_binary_data (os, val, m.key (i), "", 0, save_as_floats); |
4817 | 1218 |
1219 if (! b) | |
1220 return os; | |
1221 | |
1222 i++; | |
1223 } | |
1224 | |
1225 return true; | |
1226 } | |
1227 | |
1228 bool | |
1229 octave_struct::load_binary (std::istream& is, bool swap, | |
5760 | 1230 oct_mach_info::float_format fmt) |
4817 | 1231 { |
1232 bool success = true; | |
5828 | 1233 int32_t len; |
5760 | 1234 if (! is.read (reinterpret_cast<char *> (&len), 4)) |
4817 | 1235 return false; |
1236 if (swap) | |
4944 | 1237 swap_bytes<4> (&len); |
4817 | 1238 |
1239 if (len > 0) | |
1240 { | |
1241 Octave_map m (map); | |
1242 | |
5275 | 1243 for (octave_idx_type j = 0; j < len; j++) |
4817 | 1244 { |
1245 octave_value t2; | |
1246 bool dummy; | |
1247 std::string doc; | |
1248 | |
1249 // recurse to read cell elements | |
1250 std::string nm = read_binary_data (is, swap, fmt, std::string (), | |
1251 dummy, t2, doc); | |
1252 | |
1253 if (!is) | |
1254 break; | |
1255 | |
6293 | 1256 Cell tcell = t2.is_cell () ? t2.cell_value () : Cell (t2); |
5433 | 1257 |
6293 | 1258 if (error_state) |
1259 { | |
1260 error ("load: internal error loading struct elements"); | |
1261 return false; | |
1262 } | |
5433 | 1263 |
6293 | 1264 m.assign (nm, tcell); |
4817 | 1265 } |
1266 | |
1267 if (is) | |
1268 map = m; | |
1269 else | |
1270 { | |
1271 error ("load: failed to load structure"); | |
1272 success = false; | |
1273 } | |
1274 } | |
1275 else if (len == 0 ) | |
6292 | 1276 map = Octave_map (dim_vector (1, 1)); |
4817 | 1277 else |
1278 panic_impossible (); | |
1279 | |
1280 return success; | |
1281 } | |
1282 | |
1283 #if defined (HAVE_HDF5) | |
1284 | |
1285 bool | |
1286 octave_struct::save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats) | |
1287 { | |
1288 hid_t data_hid = -1; | |
1289 | |
1290 data_hid = H5Gcreate (loc_id, name, 0); | |
1291 if (data_hid < 0) return false; | |
1292 | |
1293 // recursively add each element of the structure to this group | |
1294 Octave_map m = map_value (); | |
1295 Octave_map::iterator i = m.begin (); | |
1296 while (i != m.end ()) | |
1297 { | |
5341 | 1298 octave_value val = map.contents (i); |
4817 | 1299 |
5341 | 1300 bool retval2 = add_hdf5_data (data_hid, val, m.key (i), "", false, |
4817 | 1301 save_as_floats); |
1302 | |
1303 if (! retval2) | |
1304 break; | |
1305 | |
1306 i++; | |
1307 } | |
1308 | |
1309 H5Gclose (data_hid); | |
4837 | 1310 |
4817 | 1311 return true; |
1312 } | |
1313 | |
1314 bool | |
1315 octave_struct::load_hdf5 (hid_t loc_id, const char *name, | |
1316 bool have_h5giterate_bug) | |
1317 { | |
1318 bool retval = false; | |
1319 | |
1320 hdf5_callback_data dsub; | |
1321 | |
1322 herr_t retval2 = 0; | |
6292 | 1323 Octave_map m (dim_vector (1, 1)); |
4817 | 1324 int current_item = 0; |
1325 #ifdef HAVE_H5GGET_NUM_OBJS | |
1326 hsize_t num_obj = 0; | |
5060 | 1327 hid_t group_id = H5Gopen (loc_id, name); |
1328 H5Gget_num_objs (group_id, &num_obj); | |
1329 H5Gclose (group_id); | |
4817 | 1330 |
1331 while (current_item < static_cast<int> (num_obj) | |
1332 && (retval2 = H5Giterate (loc_id, name, ¤t_item, | |
1333 hdf5_read_next_data, &dsub)) > 0) | |
1334 #else | |
1335 while ((retval2 = H5Giterate (loc_id, name, ¤t_item, | |
1336 hdf5_read_next_data, &dsub)) > 0) | |
1337 #endif | |
1338 { | |
5342 | 1339 octave_value t2 = dsub.tc; |
1340 | |
6293 | 1341 Cell tcell = t2.is_cell () ? t2.cell_value () : Cell (t2); |
5433 | 1342 |
6293 | 1343 if (error_state) |
1344 { | |
1345 error ("load: internal error loading struct elements"); | |
1346 return false; | |
1347 } | |
5433 | 1348 |
6293 | 1349 m.assign (dsub.name, tcell); |
5336 | 1350 |
4817 | 1351 if (have_h5giterate_bug) |
1352 current_item++; // H5Giterate returned the last index processed | |
1353 } | |
1354 | |
1355 if (retval2 >= 0) | |
1356 { | |
1357 map = m; | |
1358 retval = true; | |
1359 } | |
1360 | |
1361 return retval; | |
1362 } | |
1363 | |
4687 | 1364 #endif |
1365 | |
5900 | 1366 mxArray * |
1367 octave_struct::as_mxArray (void) const | |
1368 { | |
1369 int nf = nfields (); | |
1370 string_vector kv = map_keys (); | |
6065 | 1371 |
1372 OCTAVE_LOCAL_BUFFER (const char *, f, nf); | |
1373 | |
5900 | 1374 for (int i = 0; i < nf; i++) |
6065 | 1375 f[i] = kv[i].c_str (); |
5900 | 1376 |
1377 mxArray *retval = new mxArray (dims (), nf, f); | |
1378 | |
1379 mxArray **elts = static_cast<mxArray **> (retval->get_data ()); | |
1380 | |
6686 | 1381 mwSize nel = numel (); |
5900 | 1382 |
6686 | 1383 mwSize ntot = nf * nel; |
5900 | 1384 |
1385 for (int i = 0; i < nf; i++) | |
1386 { | |
1387 Cell c = map.contents (kv[i]); | |
1388 | |
1389 const octave_value *p = c.data (); | |
1390 | |
6686 | 1391 mwIndex k = 0; |
1392 for (mwIndex j = i; j < ntot; j += nf) | |
5900 | 1393 elts[j] = new mxArray (p[k++]); |
1394 } | |
1395 | |
1396 return retval; | |
1397 } | |
1398 | |
2376 | 1399 /* |
1400 ;;; Local Variables: *** | |
1401 ;;; mode: C++ *** | |
1402 ;;; End: *** | |
1403 */ |