2376
|
1 /* |
|
2 |
|
3 Copyright (C) 1996 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 |
|
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 |
|
26 #if defined (__GNUG__) |
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 #include <cstdlib> |
|
31 |
|
32 #include <string> |
|
33 |
|
34 class ostream; |
|
35 |
|
36 #include "mx-base.h" |
|
37 #include "str-vec.h" |
|
38 |
|
39 #include "error.h" |
|
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 |
|
49 // Real scalar values. |
|
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 |
|
67 octave_value *clone (void) { return new octave_struct (*this); } |
|
68 |
|
69 #if 0 |
|
70 void *operator new (size_t size); |
|
71 void operator delete (void *p, size_t size); |
|
72 #endif |
|
73 |
2420
|
74 octave_value struct_elt_val (const string& nm, bool silent) const; |
2376
|
75 |
|
76 octave_value& struct_elt_ref (const string& nm); |
|
77 |
|
78 bool is_defined (void) const { return true; } |
|
79 |
|
80 bool is_map (void) const { return true; } |
|
81 |
|
82 #if 0 |
|
83 double double_value (bool) const |
|
84 Matrix matrix_value (bool frc_str_conv = false) const; |
|
85 Complex complex_value (bool frc_str_conv = false) const; |
|
86 ComplexMatrix complex_matrix_value (bool frc_str_conv = false) const; |
|
87 charMatrix char_matrix_value (bool frc_str_conv = false) const; |
|
88 charMatrix all_strings (void) const; |
|
89 string string_value (void) const; |
|
90 Range range_value (void) const |
|
91 #endif |
|
92 |
|
93 Octave_map map_value (void) const { return map; } |
|
94 |
|
95 #if 0 |
|
96 octave_value& lookup_map_element (const string& name, |
|
97 bool insert = false, |
|
98 bool silent = false); |
|
99 |
|
100 octave_value& lookup_map_element (SLList<string>& name, |
|
101 bool insert = false, |
|
102 bool silent = false); |
|
103 |
|
104 ColumnVector vector_value (bool frc_str_conv = false, |
|
105 bool frc_vec_conv = false) const; |
|
106 |
|
107 ComplexColumnVector |
|
108 complex_vector_value (bool frc_str_conv = false, |
|
109 bool frc_vec_conv = false) const; |
|
110 |
|
111 octave_value convert_to_str (void) const; |
|
112 |
|
113 void convert_to_row_or_column_vector (void); |
|
114 |
|
115 void maybe_mutate (void); |
|
116 #endif |
|
117 |
|
118 void print (ostream& os); |
|
119 |
|
120 int type_id (void) const { return t_id; } |
|
121 |
|
122 string type_name (void) const { return t_name; } |
|
123 |
|
124 static int static_type_id (void) { return t_id; } |
|
125 |
|
126 static void register_type (void) |
|
127 { t_id = octave_value_typeinfo::register_type (t_name); } |
|
128 |
|
129 #if 0 |
|
130 // Binary and unary operations. |
|
131 |
|
132 friend octave_value do_binary_op (octave_value& a, octave_value& b, |
|
133 tree_expression::type t); |
|
134 |
|
135 friend octave_value do_unary_op (octave_value& a, |
|
136 tree_expression::type t); |
|
137 |
|
138 // We want to eliminate this. |
|
139 |
|
140 constant_type const_type (void) const { return type_tag; } |
|
141 |
|
142 // We want to get rid of these too: |
|
143 |
|
144 void force_numeric (bool frc_str_conv = false); |
|
145 octave_value make_numeric (bool frc_str_conv = false) const; |
|
146 |
|
147 // But not this. |
|
148 |
|
149 void convert_to_matrix_type (bool make_complex); |
|
150 |
|
151 // Indexing and assignment. |
|
152 |
|
153 void clear_index (void); |
|
154 |
|
155 // void set_index (double d); |
|
156 void set_index (const Range& r); |
|
157 void set_index (const ColumnVector& v); |
|
158 void set_index (const Matrix& m); |
|
159 void set_index (char c); |
|
160 |
|
161 void set_index (const octave_value_list& args, |
|
162 bool rhs_is_complex = false); |
|
163 |
|
164 octave_value do_index (const octave_value_list& args); |
|
165 |
|
166 void maybe_widen (constant_type t); |
|
167 |
|
168 void assign (octave_value& rhs, const octave_value_list& args); |
|
169 |
|
170 bool print_as_scalar (void); |
|
171 |
|
172 bool print_as_structure (void); |
|
173 #endif |
|
174 |
|
175 private: |
|
176 |
|
177 Octave_map map; |
|
178 |
|
179 static int t_id; |
|
180 |
|
181 static const string t_name; |
|
182 |
|
183 #if 0 |
|
184 // For custom memory management. |
|
185 // XXX FIXME XXX -- maybe this should be inherited (use void* and cast). |
|
186 |
|
187 octave_base_value *freeptr; |
|
188 #endif |
|
189 }; |
|
190 |
|
191 #endif |
|
192 |
|
193 /* |
|
194 ;;; Local Variables: *** |
|
195 ;;; mode: C++ *** |
|
196 ;;; End: *** |
|
197 */ |