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 |
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" |
|
39 #include "ov.h" |
|
40 #include "ov-typeinfo.h" |
|
41 |
3351
|
42 class Cell; |
2376
|
43 class Octave_map; |
|
44 class octave_value_list; |
|
45 |
|
46 class tree_walker; |
|
47 |
2477
|
48 // A base value type, so that derived types only have to redefine what |
|
49 // they need (if they are derived from octave_base_value instead of |
|
50 // octave_value). |
2376
|
51 |
|
52 class |
|
53 octave_base_value : public octave_value |
|
54 { |
|
55 public: |
|
56 |
|
57 octave_base_value (void) |
|
58 : octave_value (octave_xvalue ()) { } |
|
59 |
|
60 octave_base_value (const octave_base_value&) |
|
61 : octave_value (octave_xvalue ()) { } |
|
62 |
|
63 ~octave_base_value (void) { } |
|
64 |
3933
|
65 octave_value *clone (void) const { return new octave_base_value (*this); } |
|
66 octave_value *empty_clone (void) const { return new octave_base_value (); } |
2376
|
67 |
2410
|
68 type_conv_fcn numeric_conversion_function (void) const |
2800
|
69 { return static_cast<type_conv_fcn> (0); } |
2410
|
70 |
4532
|
71 octave_value squeeze (void) const; |
|
72 |
2410
|
73 octave_value *try_narrowing_conversion (void) |
2800
|
74 { return static_cast<octave_value *> (0); } |
2376
|
75 |
4247
|
76 octave_value subsref (const std::string& type, |
4219
|
77 const std::list<octave_value_list>& idx); |
3933
|
78 |
4247
|
79 octave_value_list subsref (const std::string& type, |
4219
|
80 const std::list<octave_value_list>& idx, |
3933
|
81 int nargout); |
|
82 |
|
83 octave_value do_index_op (const octave_value_list& idx, int resize_ok); |
|
84 |
|
85 octave_value do_index_op (const octave_value_list& idx) |
|
86 { return do_index_op (idx, 0); } |
2974
|
87 |
3544
|
88 octave_value_list |
|
89 do_multi_index_op (int nargout, const octave_value_list& idx); |
2376
|
90 |
|
91 idx_vector index_vector (void) const; |
|
92 |
4247
|
93 octave_value subsasgn (const std::string& type, |
4219
|
94 const std::list<octave_value_list>& idx, |
3933
|
95 const octave_value& rhs); |
2376
|
96 |
4563
|
97 dim_vector dims (void) const { return dim_vector (-1, -1); } |
4559
|
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 |
2376
|
105 bool is_defined (void) const { return false; } |
|
106 |
3351
|
107 bool is_cell (void) const { return false; } |
|
108 |
2376
|
109 bool is_real_scalar (void) const { return false; } |
|
110 |
|
111 bool is_real_matrix (void) const { return false; } |
|
112 |
4505
|
113 bool is_real_nd_array (void) const { return false; } |
|
114 |
2376
|
115 bool is_complex_scalar (void) const { return false; } |
|
116 |
|
117 bool is_complex_matrix (void) const { return false; } |
|
118 |
4587
|
119 bool is_bool_matrix (void) const { return false; } |
|
120 |
2376
|
121 bool is_char_matrix (void) const { return false; } |
|
122 |
|
123 bool is_string (void) const { return false; } |
|
124 |
|
125 bool is_range (void) const { return false; } |
|
126 |
|
127 bool is_map (void) const { return false; } |
|
128 |
3340
|
129 bool is_stream (void) const { return false; } |
2901
|
130 |
4643
|
131 bool is_streamoff (void) const { return false; } |
|
132 |
3977
|
133 bool is_cs_list (void) const { return false; } |
|
134 |
2882
|
135 bool is_list (void) const { return false; } |
|
136 |
2376
|
137 bool is_magic_colon (void) const { return false; } |
|
138 |
|
139 bool is_all_va_args (void) const { return false; } |
|
140 |
4017
|
141 octave_value all (int = 0) const { return 0.0; } |
2376
|
142 |
4017
|
143 octave_value any (int = 0) const { return 0.0; } |
2376
|
144 |
3209
|
145 bool is_bool_type (void) const { return false; } |
|
146 |
2376
|
147 bool is_real_type (void) const { return false; } |
|
148 |
|
149 bool is_complex_type (void) const { return false; } |
|
150 |
|
151 // Would be nice to get rid of the next four functions: |
|
152 |
|
153 bool is_scalar_type (void) const { return false; } |
|
154 |
|
155 bool is_matrix_type (void) const { return false; } |
|
156 |
|
157 bool is_numeric_type (void) const { return false; } |
|
158 |
|
159 bool valid_as_scalar_index (void) const { return false; } |
|
160 |
|
161 bool valid_as_zero_index (void) const { return false; } |
|
162 |
|
163 bool is_true (void) const { return false; } |
|
164 |
|
165 bool is_zero_by_zero (void) const |
|
166 { return (rows () == 0 && columns () == 0); } |
|
167 |
2974
|
168 bool is_constant (void) const { return false; } |
|
169 |
4654
|
170 bool is_function_handle (void) const { return false; } |
|
171 |
2974
|
172 bool is_function (void) const { return false; } |
|
173 |
3325
|
174 bool is_builtin_function (void) const { return false; } |
|
175 |
|
176 bool is_dld_function (void) const { return false; } |
|
177 |
4254
|
178 short int short_value (bool = false, bool = false) const; |
|
179 |
|
180 unsigned short int ushort_value (bool = false, bool = false) const; |
|
181 |
3202
|
182 int int_value (bool = false, bool = false) const; |
|
183 |
4254
|
184 unsigned int uint_value (bool = false, bool = false) const; |
|
185 |
3202
|
186 int nint_value (bool = false) const; |
|
187 |
4254
|
188 long int long_value (bool = false, bool = false) const; |
|
189 |
|
190 unsigned long int ulong_value (bool = false, bool = false) const; |
|
191 |
3145
|
192 double double_value (bool = false) const; |
2376
|
193 |
3145
|
194 double scalar_value (bool frc_str_conv = false) const |
|
195 { return double_value (frc_str_conv); } |
2376
|
196 |
3539
|
197 Cell cell_value (void) const; |
3351
|
198 |
3145
|
199 Matrix matrix_value (bool = false) const; |
|
200 |
4550
|
201 NDArray array_value (bool = false) const; |
4505
|
202 |
3145
|
203 Complex complex_value (bool = false) const; |
2376
|
204 |
3145
|
205 ComplexMatrix complex_matrix_value (bool = false) const; |
2376
|
206 |
4550
|
207 ComplexNDArray complex_array_value (bool = false) const; |
|
208 |
|
209 bool bool_value (void) const; |
|
210 |
|
211 boolMatrix bool_matrix_value (void) const; |
|
212 |
4580
|
213 boolNDArray bool_array_value (void) const; |
4550
|
214 |
4741
|
215 charMatrix char_matrix_value (bool force = false) const; |
2376
|
216 |
4550
|
217 charNDArray char_array_value (bool = false) const; |
|
218 |
4457
|
219 string_vector all_strings (bool pad = false, bool force = false) const; |
2376
|
220 |
4457
|
221 std::string string_value (bool force = false) const; |
2376
|
222 |
|
223 Range range_value (void) const; |
|
224 |
|
225 Octave_map map_value (void) const; |
|
226 |
3933
|
227 string_vector map_keys (void) const; |
|
228 |
3340
|
229 octave_stream stream_value (void) const; |
2901
|
230 |
|
231 int stream_number (void) const; |
|
232 |
4645
|
233 std::streamoff streamoff_value (void) const; |
|
234 |
|
235 streamoff_array streamoff_array_value (void) const; |
4643
|
236 |
4654
|
237 octave_function *function_value (bool silent = false); |
2974
|
238 |
4700
|
239 octave_user_function *user_function_value (bool silent = false); |
|
240 |
4654
|
241 octave_fcn_handle *fcn_handle_value (bool silent = false); |
4343
|
242 |
2882
|
243 octave_value_list list_value (void) const; |
|
244 |
4457
|
245 octave_value convert_to_str_internal (bool pad, bool force) const; |
2376
|
246 |
|
247 void convert_to_row_or_column_vector (void); |
|
248 |
4604
|
249 bool print_as_scalar (void) const { return false; } |
|
250 |
3523
|
251 void print (std::ostream& os, bool pr_as_read_syntax = false) const; |
2901
|
252 |
3523
|
253 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; |
2901
|
254 |
3523
|
255 bool print_name_tag (std::ostream& os, const std::string& name) const; |
2376
|
256 |
3933
|
257 void print_info (std::ostream& os, const std::string& prefix) const; |
|
258 |
4687
|
259 bool save_ascii (std::ostream& os, bool& infnan_warned, |
|
260 bool strip_nan_and_inf); |
|
261 |
|
262 bool load_ascii (std::istream& is); |
|
263 |
|
264 bool save_binary (std::ostream& os, bool& save_as_floats); |
|
265 |
|
266 bool load_binary (std::istream& is, bool swap, |
|
267 oct_mach_info::float_format fmt); |
|
268 |
|
269 #if defined (HAVE_HDF5) |
|
270 bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats); |
|
271 |
|
272 bool load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug); |
|
273 #endif |
|
274 |
2376
|
275 private: |
|
276 |
4667
|
277 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
2376
|
278 }; |
|
279 |
|
280 #endif |
|
281 |
|
282 /* |
|
283 ;;; Local Variables: *** |
|
284 ;;; mode: C++ *** |
|
285 ;;; End: *** |
|
286 */ |