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 |
|
32 #include <string> |
|
33 |
|
34 class ostream; |
|
35 |
|
36 #include "mx-base.h" |
|
37 #include "str-vec.h" |
|
38 |
|
39 #include "error.h" |
|
40 #include "ov.h" |
|
41 #include "ov-typeinfo.h" |
|
42 |
3351
|
43 class Cell; |
2376
|
44 class Octave_map; |
|
45 class octave_value_list; |
|
46 |
|
47 class tree_walker; |
|
48 |
2477
|
49 // A base value type, so that derived types only have to redefine what |
|
50 // they need (if they are derived from octave_base_value instead of |
|
51 // octave_value). |
2376
|
52 |
|
53 class |
|
54 octave_base_value : public octave_value |
|
55 { |
|
56 public: |
|
57 |
|
58 octave_base_value (void) |
|
59 : octave_value (octave_xvalue ()) { } |
|
60 |
|
61 octave_base_value (const octave_base_value&) |
|
62 : octave_value (octave_xvalue ()) { } |
|
63 |
|
64 ~octave_base_value (void) { } |
|
65 |
|
66 octave_value *clone (void) { return new octave_base_value (*this); } |
|
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 |
2974
|
74 octave_value do_index_op (const octave_value_list& idx); |
|
75 |
|
76 octave_value_list do_index_op (int nargout, const octave_value_list& idx); |
2376
|
77 |
|
78 idx_vector index_vector (void) const; |
|
79 |
2962
|
80 octave_value |
|
81 do_struct_elt_index_op (const string& nm, const octave_value_list& idx, |
|
82 bool silent); |
|
83 |
|
84 octave_value do_struct_elt_index_op (const string& nm, bool silent); |
2376
|
85 |
2979
|
86 octave_lvalue struct_elt_ref (octave_value *parent, const string& nm); |
2376
|
87 |
3219
|
88 int rows (void) const { return -1; } |
2376
|
89 |
3219
|
90 int columns (void) const { return -1; } |
3212
|
91 |
3219
|
92 int length (void) const { return -1; } |
2376
|
93 |
|
94 bool is_defined (void) const { return false; } |
|
95 |
3351
|
96 bool is_cell (void) const { return false; } |
|
97 |
2376
|
98 bool is_real_scalar (void) const { return false; } |
|
99 |
|
100 bool is_real_matrix (void) const { return false; } |
|
101 |
|
102 bool is_complex_scalar (void) const { return false; } |
|
103 |
|
104 bool is_complex_matrix (void) const { return false; } |
|
105 |
|
106 bool is_char_matrix (void) const { return false; } |
|
107 |
|
108 bool is_string (void) const { return false; } |
|
109 |
|
110 bool is_range (void) const { return false; } |
|
111 |
|
112 bool is_map (void) const { return false; } |
|
113 |
3340
|
114 bool is_stream (void) const { return false; } |
2901
|
115 |
2882
|
116 bool is_list (void) const { return false; } |
|
117 |
2376
|
118 bool is_magic_colon (void) const { return false; } |
|
119 |
|
120 bool is_all_va_args (void) const { return false; } |
|
121 |
|
122 octave_value all (void) const { return 0.0; } |
|
123 |
|
124 octave_value any (void) const { return 0.0; } |
|
125 |
3209
|
126 bool is_bool_type (void) const { return false; } |
|
127 |
2376
|
128 bool is_real_type (void) const { return false; } |
|
129 |
|
130 bool is_complex_type (void) const { return false; } |
|
131 |
|
132 // Would be nice to get rid of the next four functions: |
|
133 |
|
134 bool is_scalar_type (void) const { return false; } |
|
135 |
|
136 bool is_matrix_type (void) const { return false; } |
|
137 |
|
138 bool is_numeric_type (void) const { return false; } |
|
139 |
|
140 bool valid_as_scalar_index (void) const { return false; } |
|
141 |
|
142 bool valid_as_zero_index (void) const { return false; } |
|
143 |
|
144 bool is_true (void) const { return false; } |
|
145 |
|
146 bool is_empty (void) const |
|
147 { return (rows () == 0 || columns () == 0); } |
|
148 |
|
149 bool is_zero_by_zero (void) const |
|
150 { return (rows () == 0 && columns () == 0); } |
|
151 |
2974
|
152 bool is_constant (void) const { return false; } |
|
153 |
|
154 bool is_function (void) const { return false; } |
|
155 |
3325
|
156 bool is_builtin_function (void) const { return false; } |
|
157 |
|
158 bool is_dld_function (void) const { return false; } |
|
159 |
3202
|
160 int int_value (bool = false, bool = false) const; |
|
161 |
|
162 int nint_value (bool = false) const; |
|
163 |
3145
|
164 double double_value (bool = false) const; |
2376
|
165 |
3145
|
166 double scalar_value (bool frc_str_conv = false) const |
|
167 { return double_value (frc_str_conv); } |
2376
|
168 |
3351
|
169 Cell cell_value (bool = false) const; |
|
170 |
3145
|
171 Matrix matrix_value (bool = false) const; |
|
172 |
|
173 Complex complex_value (bool = false) const; |
2376
|
174 |
3145
|
175 ComplexMatrix complex_matrix_value (bool = false) const; |
2376
|
176 |
3145
|
177 charMatrix char_matrix_value (bool = false) const; |
2376
|
178 |
2493
|
179 string_vector all_strings (void) const; |
2376
|
180 |
|
181 string string_value (void) const; |
|
182 |
|
183 Range range_value (void) const; |
|
184 |
|
185 Octave_map map_value (void) const; |
|
186 |
3340
|
187 octave_stream stream_value (void) const; |
2901
|
188 |
|
189 int stream_number (void) const; |
|
190 |
2974
|
191 octave_function *function_value (bool silent); |
|
192 |
2882
|
193 octave_value_list list_value (void) const; |
|
194 |
2825
|
195 bool bool_value (void) const; |
|
196 |
|
197 boolMatrix bool_matrix_value (void) const; |
|
198 |
2376
|
199 octave_value convert_to_str (void) const; |
|
200 |
|
201 void convert_to_row_or_column_vector (void); |
|
202 |
2901
|
203 void print (ostream& os, bool pr_as_read_syntax = false) const; |
|
204 |
|
205 void print_raw (ostream& os, bool pr_as_read_syntax = false) const; |
|
206 |
|
207 bool print_name_tag (ostream& os, const string& name) const; |
2376
|
208 |
|
209 private: |
|
210 |
3219
|
211 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
2376
|
212 }; |
|
213 |
|
214 #endif |
|
215 |
|
216 /* |
|
217 ;;; Local Variables: *** |
|
218 ;;; mode: C++ *** |
|
219 ;;; End: *** |
|
220 */ |