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 |
3219
|
97 int rows (void) const { return -1; } |
2376
|
98 |
3219
|
99 int columns (void) const { return -1; } |
3212
|
100 |
4513
|
101 dim_vector dims (void) const { return dim_vector (rows (), columns ()); } |
|
102 |
3219
|
103 int length (void) const { return -1; } |
2376
|
104 |
4554
|
105 int ndims (void) const { return -1; } |
|
106 |
4559
|
107 int numel (void) const { return -1; } |
|
108 |
2376
|
109 bool is_defined (void) const { return false; } |
|
110 |
3351
|
111 bool is_cell (void) const { return false; } |
|
112 |
2376
|
113 bool is_real_scalar (void) const { return false; } |
|
114 |
|
115 bool is_real_matrix (void) const { return false; } |
|
116 |
4505
|
117 bool is_real_nd_array (void) const { return false; } |
|
118 |
2376
|
119 bool is_complex_scalar (void) const { return false; } |
|
120 |
|
121 bool is_complex_matrix (void) const { return false; } |
|
122 |
|
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 |
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 |
|
170 bool is_function (void) const { return false; } |
|
171 |
3325
|
172 bool is_builtin_function (void) const { return false; } |
|
173 |
|
174 bool is_dld_function (void) const { return false; } |
|
175 |
4254
|
176 short int short_value (bool = false, bool = false) const; |
|
177 |
|
178 unsigned short int ushort_value (bool = false, bool = false) const; |
|
179 |
3202
|
180 int int_value (bool = false, bool = false) const; |
|
181 |
4254
|
182 unsigned int uint_value (bool = false, bool = false) const; |
|
183 |
3202
|
184 int nint_value (bool = false) const; |
|
185 |
4254
|
186 long int long_value (bool = false, bool = false) const; |
|
187 |
|
188 unsigned long int ulong_value (bool = false, bool = false) const; |
|
189 |
3145
|
190 double double_value (bool = false) const; |
2376
|
191 |
3145
|
192 double scalar_value (bool frc_str_conv = false) const |
|
193 { return double_value (frc_str_conv); } |
2376
|
194 |
3539
|
195 Cell cell_value (void) const; |
3351
|
196 |
3145
|
197 Matrix matrix_value (bool = false) const; |
|
198 |
4550
|
199 NDArray array_value (bool = false) const; |
4505
|
200 |
3145
|
201 Complex complex_value (bool = false) const; |
2376
|
202 |
3145
|
203 ComplexMatrix complex_matrix_value (bool = false) const; |
2376
|
204 |
4550
|
205 ComplexNDArray complex_array_value (bool = false) const; |
|
206 |
|
207 bool bool_value (void) const; |
|
208 |
|
209 boolMatrix bool_matrix_value (void) const; |
|
210 |
|
211 boolNDArray bool_array_value (bool = false) const; |
|
212 |
3145
|
213 charMatrix char_matrix_value (bool = false) const; |
2376
|
214 |
4550
|
215 charNDArray char_array_value (bool = false) const; |
|
216 |
4457
|
217 string_vector all_strings (bool pad = false, bool force = false) const; |
2376
|
218 |
4457
|
219 std::string string_value (bool force = false) const; |
2376
|
220 |
|
221 Range range_value (void) const; |
|
222 |
|
223 Octave_map map_value (void) const; |
|
224 |
3933
|
225 string_vector map_keys (void) const; |
|
226 |
3340
|
227 octave_stream stream_value (void) const; |
2901
|
228 |
|
229 int stream_number (void) const; |
|
230 |
2974
|
231 octave_function *function_value (bool silent); |
|
232 |
4346
|
233 octave_fcn_handle *fcn_handle_value (bool silent); |
4343
|
234 |
2882
|
235 octave_value_list list_value (void) const; |
|
236 |
4457
|
237 octave_value convert_to_str_internal (bool pad, bool force) const; |
2376
|
238 |
|
239 void convert_to_row_or_column_vector (void); |
|
240 |
3523
|
241 void print (std::ostream& os, bool pr_as_read_syntax = false) const; |
2901
|
242 |
3523
|
243 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; |
2901
|
244 |
3523
|
245 bool print_name_tag (std::ostream& os, const std::string& name) const; |
2376
|
246 |
3933
|
247 void print_info (std::ostream& os, const std::string& prefix) const; |
|
248 |
2376
|
249 private: |
|
250 |
3219
|
251 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
2376
|
252 }; |
|
253 |
|
254 #endif |
|
255 |
|
256 /* |
|
257 ;;; Local Variables: *** |
|
258 ;;; mode: C++ *** |
|
259 ;;; End: *** |
|
260 */ |