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 |
|
71 octave_value *try_narrowing_conversion (void) |
2800
|
72 { return static_cast<octave_value *> (0); } |
2376
|
73 |
4247
|
74 octave_value subsref (const std::string& type, |
4219
|
75 const std::list<octave_value_list>& idx); |
3933
|
76 |
4247
|
77 octave_value_list subsref (const std::string& type, |
4219
|
78 const std::list<octave_value_list>& idx, |
3933
|
79 int nargout); |
|
80 |
|
81 octave_value do_index_op (const octave_value_list& idx, int resize_ok); |
|
82 |
|
83 octave_value do_index_op (const octave_value_list& idx) |
|
84 { return do_index_op (idx, 0); } |
2974
|
85 |
3544
|
86 octave_value_list |
|
87 do_multi_index_op (int nargout, const octave_value_list& idx); |
2376
|
88 |
|
89 idx_vector index_vector (void) const; |
|
90 |
4247
|
91 octave_value subsasgn (const std::string& type, |
4219
|
92 const std::list<octave_value_list>& idx, |
3933
|
93 const octave_value& rhs); |
2376
|
94 |
3219
|
95 int rows (void) const { return -1; } |
2376
|
96 |
3219
|
97 int columns (void) const { return -1; } |
3212
|
98 |
3219
|
99 int length (void) const { return -1; } |
2376
|
100 |
|
101 bool is_defined (void) const { return false; } |
|
102 |
3351
|
103 bool is_cell (void) const { return false; } |
|
104 |
2376
|
105 bool is_real_scalar (void) const { return false; } |
|
106 |
|
107 bool is_real_matrix (void) const { return false; } |
|
108 |
|
109 bool is_complex_scalar (void) const { return false; } |
|
110 |
|
111 bool is_complex_matrix (void) const { return false; } |
|
112 |
|
113 bool is_char_matrix (void) const { return false; } |
|
114 |
|
115 bool is_string (void) const { return false; } |
|
116 |
|
117 bool is_range (void) const { return false; } |
|
118 |
|
119 bool is_map (void) const { return false; } |
|
120 |
3340
|
121 bool is_stream (void) const { return false; } |
2901
|
122 |
3977
|
123 bool is_cs_list (void) const { return false; } |
|
124 |
2882
|
125 bool is_list (void) const { return false; } |
|
126 |
2376
|
127 bool is_magic_colon (void) const { return false; } |
|
128 |
|
129 bool is_all_va_args (void) const { return false; } |
|
130 |
4017
|
131 octave_value all (int = 0) const { return 0.0; } |
2376
|
132 |
4017
|
133 octave_value any (int = 0) const { return 0.0; } |
2376
|
134 |
3209
|
135 bool is_bool_type (void) const { return false; } |
|
136 |
2376
|
137 bool is_real_type (void) const { return false; } |
|
138 |
|
139 bool is_complex_type (void) const { return false; } |
|
140 |
|
141 // Would be nice to get rid of the next four functions: |
|
142 |
|
143 bool is_scalar_type (void) const { return false; } |
|
144 |
|
145 bool is_matrix_type (void) const { return false; } |
|
146 |
|
147 bool is_numeric_type (void) const { return false; } |
|
148 |
|
149 bool valid_as_scalar_index (void) const { return false; } |
|
150 |
|
151 bool valid_as_zero_index (void) const { return false; } |
|
152 |
|
153 bool is_true (void) const { return false; } |
|
154 |
|
155 bool is_empty (void) const |
|
156 { return (rows () == 0 || columns () == 0); } |
|
157 |
|
158 bool is_zero_by_zero (void) const |
|
159 { return (rows () == 0 && columns () == 0); } |
|
160 |
2974
|
161 bool is_constant (void) const { return false; } |
|
162 |
|
163 bool is_function (void) const { return false; } |
|
164 |
3325
|
165 bool is_builtin_function (void) const { return false; } |
|
166 |
|
167 bool is_dld_function (void) const { return false; } |
|
168 |
3202
|
169 int int_value (bool = false, bool = false) const; |
|
170 |
|
171 int nint_value (bool = false) const; |
|
172 |
3145
|
173 double double_value (bool = false) const; |
2376
|
174 |
3145
|
175 double scalar_value (bool frc_str_conv = false) const |
|
176 { return double_value (frc_str_conv); } |
2376
|
177 |
3539
|
178 Cell cell_value (void) const; |
3351
|
179 |
3145
|
180 Matrix matrix_value (bool = false) const; |
|
181 |
|
182 Complex complex_value (bool = false) const; |
2376
|
183 |
3145
|
184 ComplexMatrix complex_matrix_value (bool = false) const; |
2376
|
185 |
3145
|
186 charMatrix char_matrix_value (bool = false) const; |
2376
|
187 |
2493
|
188 string_vector all_strings (void) const; |
2376
|
189 |
3523
|
190 std::string string_value (void) const; |
2376
|
191 |
|
192 Range range_value (void) const; |
|
193 |
|
194 Octave_map map_value (void) const; |
|
195 |
3933
|
196 string_vector map_keys (void) const; |
|
197 |
3340
|
198 octave_stream stream_value (void) const; |
2901
|
199 |
|
200 int stream_number (void) const; |
|
201 |
2974
|
202 octave_function *function_value (bool silent); |
|
203 |
2882
|
204 octave_value_list list_value (void) const; |
|
205 |
2825
|
206 bool bool_value (void) const; |
|
207 |
|
208 boolMatrix bool_matrix_value (void) const; |
|
209 |
2376
|
210 octave_value convert_to_str (void) const; |
|
211 |
|
212 void convert_to_row_or_column_vector (void); |
|
213 |
3523
|
214 void print (std::ostream& os, bool pr_as_read_syntax = false) const; |
2901
|
215 |
3523
|
216 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; |
2901
|
217 |
3523
|
218 bool print_name_tag (std::ostream& os, const std::string& name) const; |
2376
|
219 |
3933
|
220 void print_info (std::ostream& os, const std::string& prefix) const; |
|
221 |
2376
|
222 private: |
|
223 |
3219
|
224 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
2376
|
225 }; |
|
226 |
|
227 #endif |
|
228 |
|
229 /* |
|
230 ;;; Local Variables: *** |
|
231 ;;; mode: C++ *** |
|
232 ;;; End: *** |
|
233 */ |