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 |
|
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 |
2962
|
73 octave_value do_index_op (const octave_value_list& idx) const; |
2376
|
74 |
|
75 idx_vector index_vector (void) const; |
|
76 |
2962
|
77 octave_value |
|
78 do_struct_elt_index_op (const string& nm, const octave_value_list& idx, |
|
79 bool silent); |
|
80 |
|
81 octave_value do_struct_elt_index_op (const string& nm, bool silent); |
2376
|
82 |
2948
|
83 octave_variable_reference |
|
84 struct_elt_ref (octave_value *parent, const string& nm); |
2376
|
85 |
|
86 int rows (void) const { return -1; } |
|
87 |
|
88 int columns (void) const { return -1; } |
|
89 |
|
90 bool is_defined (void) const { return false; } |
|
91 |
|
92 bool is_real_scalar (void) const { return false; } |
|
93 |
|
94 bool is_real_matrix (void) const { return false; } |
|
95 |
|
96 bool is_complex_scalar (void) const { return false; } |
|
97 |
|
98 bool is_complex_matrix (void) const { return false; } |
|
99 |
|
100 bool is_char_matrix (void) const { return false; } |
|
101 |
|
102 bool is_string (void) const { return false; } |
|
103 |
|
104 bool is_range (void) const { return false; } |
|
105 |
|
106 bool is_map (void) const { return false; } |
|
107 |
2901
|
108 bool is_file (void) const { return false; } |
|
109 |
2882
|
110 bool is_list (void) const { return false; } |
|
111 |
2376
|
112 bool is_magic_colon (void) const { return false; } |
|
113 |
|
114 bool is_all_va_args (void) const { return false; } |
|
115 |
|
116 octave_value all (void) const { return 0.0; } |
|
117 |
|
118 octave_value any (void) const { return 0.0; } |
|
119 |
|
120 bool is_real_type (void) const { return false; } |
|
121 |
|
122 bool is_complex_type (void) const { return false; } |
|
123 |
|
124 // Would be nice to get rid of the next four functions: |
|
125 |
|
126 bool is_scalar_type (void) const { return false; } |
|
127 |
|
128 bool is_matrix_type (void) const { return false; } |
|
129 |
|
130 bool is_numeric_type (void) const { return false; } |
|
131 |
|
132 bool valid_as_scalar_index (void) const { return false; } |
|
133 |
|
134 bool valid_as_zero_index (void) const { return false; } |
|
135 |
|
136 bool is_true (void) const { return false; } |
|
137 |
|
138 bool is_empty (void) const |
|
139 { return (rows () == 0 || columns () == 0); } |
|
140 |
|
141 bool is_zero_by_zero (void) const |
|
142 { return (rows () == 0 && columns () == 0); } |
|
143 |
|
144 double double_value (bool) const; |
|
145 |
2916
|
146 double scalar_value (bool) const { return double_value (); } |
|
147 |
2376
|
148 Matrix matrix_value (bool frc_str_conv = false) const; |
|
149 |
|
150 Complex complex_value (bool frc_str_conv = false) const; |
|
151 |
|
152 ComplexMatrix complex_matrix_value (bool frc_str_conv = false) const; |
|
153 |
|
154 charMatrix char_matrix_value (bool frc_str_conv = false) const; |
|
155 |
2493
|
156 string_vector all_strings (void) const; |
2376
|
157 |
|
158 string string_value (void) const; |
|
159 |
|
160 Range range_value (void) const; |
|
161 |
|
162 Octave_map map_value (void) const; |
|
163 |
2901
|
164 octave_stream *stream_value (void) const; |
|
165 |
|
166 int stream_number (void) const; |
|
167 |
2882
|
168 octave_value_list list_value (void) const; |
|
169 |
2825
|
170 bool bool_value (void) const; |
|
171 |
|
172 boolMatrix bool_matrix_value (void) const; |
|
173 |
2376
|
174 octave_value not (void) const; |
|
175 |
|
176 octave_value uminus (void) const; |
|
177 |
|
178 octave_value transpose (void) const; |
|
179 |
|
180 octave_value hermitian (void) const; |
|
181 |
|
182 void increment (void); |
|
183 |
|
184 void decrement (void); |
|
185 |
|
186 octave_value convert_to_str (void) const; |
|
187 |
|
188 void convert_to_row_or_column_vector (void); |
|
189 |
2901
|
190 void print (ostream& os, bool pr_as_read_syntax = false) const; |
|
191 |
|
192 void print_raw (ostream& os, bool pr_as_read_syntax = false) const; |
|
193 |
|
194 bool print_name_tag (ostream& os, const string& name) const; |
2376
|
195 |
|
196 int type_id (void) const { return t_id; } |
|
197 |
|
198 string type_name (void) const { return t_name; } |
|
199 |
|
200 static int static_type_id (void) { return t_id; } |
|
201 |
|
202 static void register_type (void) |
|
203 { t_id = octave_value_typeinfo::register_type (t_name); } |
|
204 |
|
205 private: |
|
206 |
2477
|
207 // Type id of base value objects, set by register_type(). |
2376
|
208 static int t_id; |
|
209 |
2477
|
210 // Type name of base value objects, defined in ov-base.cc. |
2376
|
211 static const string t_name; |
|
212 }; |
|
213 |
|
214 #endif |
|
215 |
|
216 /* |
|
217 ;;; Local Variables: *** |
|
218 ;;; mode: C++ *** |
|
219 ;;; End: *** |
|
220 */ |