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