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