2376
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
2376
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_struct_h) |
|
24 #define octave_struct_h 1 |
|
25 |
4192
|
26 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) |
2376
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 #include <cstdlib> |
|
31 |
3503
|
32 #include <iostream> |
2376
|
33 #include <string> |
|
34 |
|
35 #include "mx-base.h" |
|
36 #include "str-vec.h" |
|
37 |
|
38 #include "error.h" |
2477
|
39 #include "oct-alloc.h" |
2376
|
40 #include "oct-map.h" |
|
41 #include "ov-base.h" |
|
42 #include "ov-typeinfo.h" |
|
43 |
|
44 class Octave_map; |
|
45 class octave_value_list; |
|
46 |
|
47 class tree_walker; |
|
48 |
2477
|
49 // Data structures. |
2376
|
50 |
|
51 class |
|
52 octave_struct : public octave_base_value |
|
53 { |
|
54 public: |
|
55 |
|
56 octave_struct (void) |
|
57 : octave_base_value () { } |
|
58 |
|
59 octave_struct (const Octave_map& m) |
|
60 : octave_base_value (), map (m) { } |
|
61 |
|
62 octave_struct (const octave_struct& s) |
|
63 : octave_base_value (), map (s.map) { } |
|
64 |
|
65 ~octave_struct (void) { } |
|
66 |
3933
|
67 octave_value *clone (void) const { return new octave_struct (*this); } |
|
68 octave_value *empty_clone (void) const { return new octave_struct (); } |
|
69 |
4513
|
70 Cell dotref (const octave_value_list& idx); |
2376
|
71 |
4247
|
72 octave_value subsref (const std::string& type, |
4219
|
73 const std::list<octave_value_list>& idx); |
2962
|
74 |
4661
|
75 octave_value_list subsref (const std::string&, |
|
76 const std::list<octave_value_list>&, int) |
4271
|
77 { |
|
78 panic_impossible (); |
|
79 return octave_value_list (); |
|
80 } |
|
81 |
4513
|
82 static octave_value numeric_conv (const Cell& val, |
3933
|
83 const std::string& type); |
2376
|
84 |
4247
|
85 octave_value subsasgn (const std::string& type, |
4219
|
86 const std::list<octave_value_list>& idx, |
3933
|
87 const octave_value& rhs); |
2376
|
88 |
4563
|
89 dim_vector dims (void) const { return map.dims (); } |
4200
|
90 |
4791
|
91 size_t byte_size (void) const; |
|
92 |
4567
|
93 octave_value reshape (const dim_vector& new_dims) const |
|
94 { return map.reshape (new_dims); } |
|
95 |
2376
|
96 bool is_defined (void) const { return true; } |
|
97 |
3933
|
98 bool is_constant (void) const { return true; } |
2974
|
99 |
2376
|
100 bool is_map (void) const { return true; } |
|
101 |
|
102 Octave_map map_value (void) const { return map; } |
|
103 |
3933
|
104 string_vector map_keys (void) const { return map.keys (); } |
|
105 |
3523
|
106 void print (std::ostream& os, bool pr_as_read_syntax = false) const; |
2901
|
107 |
3523
|
108 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; |
2901
|
109 |
3523
|
110 bool print_name_tag (std::ostream& os, const std::string& name) const; |
2376
|
111 |
4687
|
112 bool save_ascii (std::ostream& os, bool& infnan_warned, |
|
113 bool strip_nan_and_inf); |
|
114 |
|
115 bool load_ascii (std::istream& is); |
|
116 |
|
117 bool save_binary (std::ostream& os, bool& save_as_floats); |
|
118 |
|
119 bool load_binary (std::istream& is, bool swap, |
|
120 oct_mach_info::float_format fmt); |
|
121 |
|
122 #if defined (HAVE_HDF5) |
|
123 bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats); |
|
124 |
|
125 bool load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug); |
|
126 #endif |
|
127 |
2376
|
128 private: |
|
129 |
2477
|
130 // The associative array used to manage the structure data. |
2376
|
131 Octave_map map; |
|
132 |
3219
|
133 DECLARE_OCTAVE_ALLOCATOR |
2477
|
134 |
3219
|
135 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
2376
|
136 }; |
|
137 |
|
138 #endif |
|
139 |
|
140 /* |
|
141 ;;; Local Variables: *** |
|
142 ;;; mode: C++ *** |
|
143 ;;; End: *** |
|
144 */ |