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