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_base_value_h) |
|
24 #define octave_base_value_h 1 |
|
25 |
|
26 #include <cstdlib> |
|
27 |
3503
|
28 #include <iostream> |
2376
|
29 #include <string> |
|
30 |
|
31 #include "mx-base.h" |
|
32 #include "str-vec.h" |
|
33 |
|
34 #include "error.h" |
|
35 #include "ov.h" |
|
36 #include "ov-typeinfo.h" |
|
37 |
3351
|
38 class Cell; |
2376
|
39 class Octave_map; |
|
40 class octave_value_list; |
|
41 |
|
42 class tree_walker; |
|
43 |
2477
|
44 // A base value type, so that derived types only have to redefine what |
|
45 // they need (if they are derived from octave_base_value instead of |
|
46 // octave_value). |
2376
|
47 |
|
48 class |
|
49 octave_base_value : public octave_value |
|
50 { |
|
51 public: |
|
52 |
|
53 octave_base_value (void) |
|
54 : octave_value (octave_xvalue ()) { } |
|
55 |
|
56 octave_base_value (const octave_base_value&) |
|
57 : octave_value (octave_xvalue ()) { } |
|
58 |
|
59 ~octave_base_value (void) { } |
|
60 |
3933
|
61 octave_value *clone (void) const { return new octave_base_value (*this); } |
|
62 octave_value *empty_clone (void) const { return new octave_base_value (); } |
2376
|
63 |
2410
|
64 type_conv_fcn numeric_conversion_function (void) const |
2800
|
65 { return static_cast<type_conv_fcn> (0); } |
2410
|
66 |
4532
|
67 octave_value squeeze (void) const; |
|
68 |
2410
|
69 octave_value *try_narrowing_conversion (void) |
2800
|
70 { return static_cast<octave_value *> (0); } |
2376
|
71 |
4247
|
72 octave_value subsref (const std::string& type, |
4219
|
73 const std::list<octave_value_list>& idx); |
3933
|
74 |
4247
|
75 octave_value_list subsref (const std::string& type, |
4219
|
76 const std::list<octave_value_list>& idx, |
3933
|
77 int nargout); |
|
78 |
|
79 octave_value do_index_op (const octave_value_list& idx, int resize_ok); |
|
80 |
|
81 octave_value do_index_op (const octave_value_list& idx) |
|
82 { return do_index_op (idx, 0); } |
2974
|
83 |
3544
|
84 octave_value_list |
|
85 do_multi_index_op (int nargout, const octave_value_list& idx); |
2376
|
86 |
|
87 idx_vector index_vector (void) const; |
|
88 |
4247
|
89 octave_value subsasgn (const std::string& type, |
4219
|
90 const std::list<octave_value_list>& idx, |
3933
|
91 const octave_value& rhs); |
2376
|
92 |
4563
|
93 dim_vector dims (void) const { return dim_vector (-1, -1); } |
4559
|
94 |
5275
|
95 octave_idx_type numel (void) const { return dims ().numel (); } |
5080
|
96 |
5275
|
97 octave_idx_type capacity (void) const { return numel (); } |
5164
|
98 |
4791
|
99 size_t byte_size (void) const { return 0; } |
|
100 |
4567
|
101 octave_value reshape (const dim_vector&) const; |
|
102 |
4593
|
103 octave_value permute (const Array<int>& vec, bool = false) const; |
|
104 |
4933
|
105 octave_value resize (const dim_vector&) const; |
4915
|
106 |
2376
|
107 bool is_defined (void) const { return false; } |
|
108 |
3351
|
109 bool is_cell (void) const { return false; } |
|
110 |
2376
|
111 bool is_real_scalar (void) const { return false; } |
|
112 |
|
113 bool is_real_matrix (void) const { return false; } |
|
114 |
4505
|
115 bool is_real_nd_array (void) const { return false; } |
|
116 |
2376
|
117 bool is_complex_scalar (void) const { return false; } |
|
118 |
|
119 bool is_complex_matrix (void) const { return false; } |
|
120 |
4587
|
121 bool is_bool_matrix (void) const { return false; } |
|
122 |
2376
|
123 bool is_char_matrix (void) const { return false; } |
|
124 |
|
125 bool is_string (void) const { return false; } |
|
126 |
|
127 bool is_range (void) const { return false; } |
|
128 |
|
129 bool is_map (void) const { return false; } |
|
130 |
3340
|
131 bool is_stream (void) const { return false; } |
2901
|
132 |
4643
|
133 bool is_streamoff (void) const { return false; } |
|
134 |
3977
|
135 bool is_cs_list (void) const { return false; } |
|
136 |
2882
|
137 bool is_list (void) const { return false; } |
|
138 |
2376
|
139 bool is_magic_colon (void) const { return false; } |
|
140 |
|
141 bool is_all_va_args (void) const { return false; } |
|
142 |
4017
|
143 octave_value all (int = 0) const { return 0.0; } |
2376
|
144 |
4017
|
145 octave_value any (int = 0) const { return 0.0; } |
2376
|
146 |
3209
|
147 bool is_bool_type (void) const { return false; } |
|
148 |
2376
|
149 bool is_real_type (void) const { return false; } |
|
150 |
|
151 bool is_complex_type (void) const { return false; } |
|
152 |
|
153 // Would be nice to get rid of the next four functions: |
|
154 |
|
155 bool is_scalar_type (void) const { return false; } |
|
156 |
|
157 bool is_matrix_type (void) const { return false; } |
|
158 |
|
159 bool is_numeric_type (void) const { return false; } |
|
160 |
|
161 bool valid_as_scalar_index (void) const { return false; } |
|
162 |
|
163 bool valid_as_zero_index (void) const { return false; } |
|
164 |
|
165 bool is_true (void) const { return false; } |
|
166 |
|
167 bool is_zero_by_zero (void) const |
|
168 { return (rows () == 0 && columns () == 0); } |
|
169 |
2974
|
170 bool is_constant (void) const { return false; } |
|
171 |
4654
|
172 bool is_function_handle (void) const { return false; } |
|
173 |
4954
|
174 bool is_inline_function (void) const { return false; } |
|
175 |
2974
|
176 bool is_function (void) const { return false; } |
|
177 |
3325
|
178 bool is_builtin_function (void) const { return false; } |
|
179 |
|
180 bool is_dld_function (void) const { return false; } |
|
181 |
4254
|
182 short int short_value (bool = false, bool = false) const; |
|
183 |
|
184 unsigned short int ushort_value (bool = false, bool = false) const; |
|
185 |
3202
|
186 int int_value (bool = false, bool = false) const; |
|
187 |
4254
|
188 unsigned int uint_value (bool = false, bool = false) const; |
|
189 |
3202
|
190 int nint_value (bool = false) const; |
|
191 |
4254
|
192 long int long_value (bool = false, bool = false) const; |
|
193 |
|
194 unsigned long int ulong_value (bool = false, bool = false) const; |
|
195 |
3145
|
196 double double_value (bool = false) const; |
2376
|
197 |
3145
|
198 double scalar_value (bool frc_str_conv = false) const |
|
199 { return double_value (frc_str_conv); } |
2376
|
200 |
3539
|
201 Cell cell_value (void) const; |
3351
|
202 |
3145
|
203 Matrix matrix_value (bool = false) const; |
|
204 |
4550
|
205 NDArray array_value (bool = false) const; |
4505
|
206 |
3145
|
207 Complex complex_value (bool = false) const; |
2376
|
208 |
3145
|
209 ComplexMatrix complex_matrix_value (bool = false) const; |
2376
|
210 |
4550
|
211 ComplexNDArray complex_array_value (bool = false) const; |
|
212 |
|
213 bool bool_value (void) const; |
|
214 |
|
215 boolMatrix bool_matrix_value (void) const; |
|
216 |
4580
|
217 boolNDArray bool_array_value (void) const; |
4550
|
218 |
4741
|
219 charMatrix char_matrix_value (bool force = false) const; |
2376
|
220 |
4550
|
221 charNDArray char_array_value (bool = false) const; |
|
222 |
5164
|
223 SparseMatrix sparse_matrix_value (bool = false) const; |
|
224 |
|
225 SparseComplexMatrix sparse_complex_matrix_value (bool = false) const; |
|
226 |
|
227 SparseBoolMatrix sparse_bool_matrix_value (bool = false) const; |
|
228 |
4910
|
229 octave_int8 int8_scalar_value (void) const; |
|
230 |
|
231 octave_int16 int16_scalar_value (void) const; |
|
232 |
|
233 octave_int32 int32_scalar_value (void) const; |
|
234 |
|
235 octave_int64 int64_scalar_value (void) const; |
|
236 |
|
237 octave_uint8 uint8_scalar_value (void) const; |
|
238 |
|
239 octave_uint16 uint16_scalar_value (void) const; |
|
240 |
|
241 octave_uint32 uint32_scalar_value (void) const; |
|
242 |
|
243 octave_uint64 uint64_scalar_value (void) const; |
|
244 |
4906
|
245 int8NDArray int8_array_value (void) const; |
|
246 |
|
247 int16NDArray int16_array_value (void) const; |
|
248 |
|
249 int32NDArray int32_array_value (void) const; |
|
250 |
|
251 int64NDArray int64_array_value (void) const; |
|
252 |
|
253 uint8NDArray uint8_array_value (void) const; |
|
254 |
|
255 uint16NDArray uint16_array_value (void) const; |
|
256 |
|
257 uint32NDArray uint32_array_value (void) const; |
|
258 |
|
259 uint64NDArray uint64_array_value (void) const; |
|
260 |
4457
|
261 string_vector all_strings (bool pad = false, bool force = false) const; |
2376
|
262 |
4457
|
263 std::string string_value (bool force = false) const; |
2376
|
264 |
|
265 Range range_value (void) const; |
|
266 |
|
267 Octave_map map_value (void) const; |
|
268 |
3933
|
269 string_vector map_keys (void) const; |
|
270 |
3340
|
271 octave_stream stream_value (void) const; |
2901
|
272 |
|
273 int stream_number (void) const; |
|
274 |
4645
|
275 std::streamoff streamoff_value (void) const; |
|
276 |
|
277 streamoff_array streamoff_array_value (void) const; |
4643
|
278 |
4654
|
279 octave_function *function_value (bool silent = false); |
2974
|
280 |
4700
|
281 octave_user_function *user_function_value (bool silent = false); |
|
282 |
4654
|
283 octave_fcn_handle *fcn_handle_value (bool silent = false); |
4343
|
284 |
4933
|
285 octave_fcn_inline *fcn_inline_value (bool silent = false); |
|
286 |
2882
|
287 octave_value_list list_value (void) const; |
|
288 |
4457
|
289 octave_value convert_to_str_internal (bool pad, bool force) const; |
2376
|
290 |
|
291 void convert_to_row_or_column_vector (void); |
|
292 |
4604
|
293 bool print_as_scalar (void) const { return false; } |
|
294 |
3523
|
295 void print (std::ostream& os, bool pr_as_read_syntax = false) const; |
2901
|
296 |
3523
|
297 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; |
2901
|
298 |
3523
|
299 bool print_name_tag (std::ostream& os, const std::string& name) const; |
2376
|
300 |
3933
|
301 void print_info (std::ostream& os, const std::string& prefix) const; |
|
302 |
4687
|
303 bool save_ascii (std::ostream& os, bool& infnan_warned, |
|
304 bool strip_nan_and_inf); |
|
305 |
|
306 bool load_ascii (std::istream& is); |
|
307 |
|
308 bool save_binary (std::ostream& os, bool& save_as_floats); |
|
309 |
|
310 bool load_binary (std::istream& is, bool swap, |
|
311 oct_mach_info::float_format fmt); |
|
312 |
|
313 #if defined (HAVE_HDF5) |
|
314 bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats); |
|
315 |
|
316 bool load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug); |
|
317 #endif |
|
318 |
4944
|
319 int write (octave_stream& os, int block_size, |
|
320 oct_data_conv::data_type output_type, int skip, |
|
321 oct_mach_info::float_format flt_fmt) const; |
|
322 |
2376
|
323 private: |
|
324 |
4667
|
325 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
2376
|
326 }; |
|
327 |
|
328 #endif |
|
329 |
|
330 /* |
|
331 ;;; Local Variables: *** |
|
332 ;;; mode: C++ *** |
|
333 ;;; End: *** |
|
334 */ |