Mercurial > hg > octave-lyh
annotate src/ov.h @ 7528:26d8a92644de
try to avoid ctype macro problems
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 25 Feb 2008 15:57:49 -0500 |
parents | 8c32f95c2639 |
children | 7ebdc99a0bab |
rev | line source |
---|---|
2376 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, |
4 2006, 2007 John W. Eaton | |
2376 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
2376 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
2376 | 21 |
22 */ | |
23 | |
24 #if !defined (octave_value_h) | |
25 #define octave_value_h 1 | |
26 | |
27 #include <cstdlib> | |
28 | |
3503 | 29 #include <iostream> |
2376 | 30 #include <string> |
4219 | 31 #include <list> |
2376 | 32 |
4687 | 33 #if defined (HAVE_HDF5) |
34 #include <hdf5.h> | |
35 #endif | |
4507 | 36 |
2376 | 37 #include "Range.h" |
5828 | 38 #include "data-conv.h" |
2376 | 39 #include "idx-vector.h" |
5828 | 40 #include "mach-info.h" |
5900 | 41 #include "mxarray.h" |
2376 | 42 #include "mx-base.h" |
2477 | 43 #include "oct-alloc.h" |
4254 | 44 #include "oct-time.h" |
2942 | 45 #include "str-vec.h" |
46 | |
7433 | 47 #include "oct-sort.h" |
48 | |
3351 | 49 class Cell; |
4643 | 50 class streamoff_array; |
2376 | 51 class Octave_map; |
2903 | 52 class octave_stream; |
4643 | 53 class octave_streamoff; |
2974 | 54 class octave_function; |
4700 | 55 class octave_user_function; |
4342 | 56 class octave_fcn_handle; |
4933 | 57 class octave_fcn_inline; |
2376 | 58 class octave_value_list; |
2979 | 59 class octave_lvalue; |
2376 | 60 |
5759 | 61 #include "ov-base.h" |
2376 | 62 |
5759 | 63 // Constants. |
2376 | 64 |
2427 | 65 class octave_value; |
66 | |
2376 | 67 class |
6109 | 68 OCTINTERP_API |
2974 | 69 octave_value |
2376 | 70 { |
71 public: | |
72 | |
3203 | 73 enum unary_op |
74 { | |
6518 | 75 op_not, // not |
76 op_uplus, // uplus | |
77 op_uminus, // uminus | |
78 op_transpose, // transpose | |
79 op_hermitian, // ctranspose | |
3525 | 80 op_incr, |
81 op_decr, | |
3203 | 82 num_unary_ops, |
83 unknown_unary_op | |
84 }; | |
85 | |
2376 | 86 enum binary_op |
87 { | |
6518 | 88 op_add, // plus |
89 op_sub, // minus | |
90 op_mul, // mtimes | |
91 op_div, // mrdivide | |
92 op_pow, // mpower | |
93 op_ldiv, // mldivide | |
3525 | 94 op_lshift, |
95 op_rshift, | |
6518 | 96 op_lt, // lt |
97 op_le, // le | |
98 op_eq, // eq | |
99 op_ge, // ge | |
100 op_gt, // gt | |
101 op_ne, // ne | |
102 op_el_mul, // times | |
103 op_el_div, // rdivide | |
104 op_el_pow, // power | |
105 op_el_ldiv, // ldivide | |
106 op_el_and, // and | |
107 op_el_or, // or | |
3525 | 108 op_struct_ref, |
2376 | 109 num_binary_ops, |
110 unknown_binary_op | |
111 }; | |
112 | |
2880 | 113 enum assign_op |
114 { | |
3525 | 115 op_asn_eq, |
116 op_add_eq, | |
117 op_sub_eq, | |
118 op_mul_eq, | |
119 op_div_eq, | |
120 op_ldiv_eq, | |
4018 | 121 op_pow_eq, |
3525 | 122 op_lshift_eq, |
123 op_rshift_eq, | |
124 op_el_mul_eq, | |
125 op_el_div_eq, | |
126 op_el_ldiv_eq, | |
4018 | 127 op_el_pow_eq, |
3525 | 128 op_el_and_eq, |
129 op_el_or_eq, | |
2880 | 130 num_assign_ops, |
131 unknown_assign_op | |
132 }; | |
133 | |
3523 | 134 static std::string unary_op_as_string (unary_op); |
7336 | 135 static std::string unary_op_fcn_name (unary_op); |
3203 | 136 |
3523 | 137 static std::string binary_op_as_string (binary_op); |
7336 | 138 static std::string binary_op_fcn_name (binary_op); |
2376 | 139 |
3523 | 140 static std::string assign_op_as_string (assign_op); |
2880 | 141 |
3933 | 142 static octave_value empty_conv (const std::string& type, |
143 const octave_value& rhs = octave_value ()); | |
144 | |
2376 | 145 enum magic_colon { magic_colon_t }; |
146 | |
147 octave_value (void); | |
4254 | 148 octave_value (short int i); |
149 octave_value (unsigned short int i); | |
4233 | 150 octave_value (int i); |
4254 | 151 octave_value (unsigned int i); |
152 octave_value (long int i); | |
153 octave_value (unsigned long int i); | |
4353 | 154 |
5775 | 155 // FIXME -- these are kluges. They turn into doubles |
4353 | 156 // internally, which will break for very large values. We just use |
157 // them to store things like 64-bit ino_t, etc, and hope that those | |
158 // values are never actually larger than can be represented exactly | |
159 // in a double. | |
160 | |
161 #if defined (HAVE_LONG_LONG_INT) | |
162 octave_value (long long int i); | |
163 #endif | |
4356 | 164 #if defined (HAVE_UNSIGNED_LONG_LONG_INT) |
4353 | 165 octave_value (unsigned long long int i); |
166 #endif | |
167 | |
4254 | 168 octave_value (octave_time t); |
2376 | 169 octave_value (double d); |
5147 | 170 octave_value (const ArrayN<octave_value>& a, bool is_cs_list = false); |
4532 | 171 octave_value (const Cell& c, bool is_cs_list = false); |
5785 | 172 octave_value (const Matrix& m, const MatrixType& t = MatrixType()); |
4513 | 173 octave_value (const NDArray& nda); |
4911 | 174 octave_value (const ArrayN<double>& m); |
2376 | 175 octave_value (const DiagMatrix& d); |
3418 | 176 octave_value (const RowVector& v); |
177 octave_value (const ColumnVector& v); | |
2376 | 178 octave_value (const Complex& C); |
5785 | 179 octave_value (const ComplexMatrix& m, const MatrixType& t = MatrixType()); |
4513 | 180 octave_value (const ComplexNDArray& cnda); |
4478 | 181 octave_value (const ArrayN<Complex>& m); |
2376 | 182 octave_value (const ComplexDiagMatrix& d); |
3418 | 183 octave_value (const ComplexRowVector& v); |
184 octave_value (const ComplexColumnVector& v); | |
2825 | 185 octave_value (bool b); |
5785 | 186 octave_value (const boolMatrix& bm, const MatrixType& t = MatrixType()); |
4513 | 187 octave_value (const boolNDArray& bnda); |
7433 | 188 octave_value (const ArrayN<bool>& bnda); |
5279 | 189 octave_value (char c, char type = '"'); |
190 octave_value (const char *s, char type = '"'); | |
191 octave_value (const std::string& s, char type = '"'); | |
192 octave_value (const string_vector& s, char type = '"'); | |
193 octave_value (const charMatrix& chm, bool is_string = false, | |
194 char type = '"'); | |
195 octave_value (const charNDArray& chnda, bool is_string = false, | |
196 char type = '"'); | |
197 octave_value (const ArrayN<char>& chnda, bool is_string = false, | |
198 char type = '"'); | |
5785 | 199 octave_value (const SparseMatrix& m, const MatrixType& t = MatrixType ()); |
6863 | 200 octave_value (const Sparse<double>& m, const MatrixType& t = MatrixType ()); |
5164 | 201 octave_value (const SparseComplexMatrix& m, |
5785 | 202 const MatrixType& t = MatrixType ()); |
6863 | 203 octave_value (const Sparse<Complex>& m, const MatrixType& t = MatrixType ()); |
5164 | 204 octave_value (const SparseBoolMatrix& bm, |
5785 | 205 const MatrixType& t = MatrixType ()); |
7433 | 206 octave_value (const Sparse<bool>& m, const MatrixType& t = MatrixType ()); |
4901 | 207 octave_value (const octave_int8& i); |
4910 | 208 octave_value (const octave_int16& i); |
209 octave_value (const octave_int32& i); | |
210 octave_value (const octave_int64& i); | |
4901 | 211 octave_value (const octave_uint8& i); |
212 octave_value (const octave_uint16& i); | |
213 octave_value (const octave_uint32& i); | |
214 octave_value (const octave_uint64& i); | |
215 octave_value (const int8NDArray& inda); | |
7064 | 216 octave_value (const ArrayN<octave_int8>& inda); |
4910 | 217 octave_value (const int16NDArray& inda); |
7064 | 218 octave_value (const ArrayN<octave_int16>& inda); |
4910 | 219 octave_value (const int32NDArray& inda); |
7064 | 220 octave_value (const ArrayN<octave_int32>& inda); |
4910 | 221 octave_value (const int64NDArray& inda); |
7064 | 222 octave_value (const ArrayN<octave_int64>& inda); |
4901 | 223 octave_value (const uint8NDArray& inda); |
7064 | 224 octave_value (const ArrayN<octave_uint8>& inda); |
4901 | 225 octave_value (const uint16NDArray& inda); |
7064 | 226 octave_value (const ArrayN<octave_uint16>& inda); |
4901 | 227 octave_value (const uint32NDArray& inda); |
7064 | 228 octave_value (const ArrayN<octave_uint32>& inda); |
4901 | 229 octave_value (const uint64NDArray& inda); |
7064 | 230 octave_value (const ArrayN<octave_uint64>& inda); |
2376 | 231 octave_value (double base, double limit, double inc); |
232 octave_value (const Range& r); | |
233 octave_value (const Octave_map& m); | |
7336 | 234 octave_value (const Octave_map& m, const std::string& id); |
4643 | 235 octave_value (const streamoff_array& off); |
7433 | 236 octave_value (const ArrayN<std::streamoff>& inda); |
3977 | 237 octave_value (const octave_value_list& m, bool is_cs_list = false); |
2376 | 238 octave_value (octave_value::magic_colon); |
239 | |
5759 | 240 octave_value (octave_base_value *new_rep); |
7336 | 241 octave_value (octave_base_value *new_rep, int xcount); |
2376 | 242 |
243 // Copy constructor. | |
244 | |
245 octave_value (const octave_value& a) | |
246 { | |
247 rep = a.rep; | |
248 rep->count++; | |
249 } | |
250 | |
3933 | 251 // This should only be called for derived types. |
252 | |
5759 | 253 octave_base_value *clone (void) const; |
3933 | 254 |
5759 | 255 octave_base_value *empty_clone (void) const |
3933 | 256 { return rep->empty_clone (); } |
257 | |
2376 | 258 // Delete the representation of this constant if the count drops to |
259 // zero. | |
260 | |
6338 | 261 ~octave_value (void) |
262 { | |
263 if (--rep->count == 0) | |
264 delete rep; | |
265 } | |
2376 | 266 |
267 void make_unique (void) | |
268 { | |
269 if (rep->count > 1) | |
270 { | |
271 --rep->count; | |
272 rep = rep->clone (); | |
273 rep->count = 1; | |
274 } | |
275 } | |
276 | |
277 // Simple assignment. | |
278 | |
279 octave_value& operator = (const octave_value& a) | |
280 { | |
281 if (rep != a.rep) | |
282 { | |
283 if (--rep->count == 0) | |
284 delete rep; | |
285 | |
286 rep = a.rep; | |
287 rep->count++; | |
288 } | |
289 | |
290 return *this; | |
291 } | |
292 | |
3933 | 293 int get_count (void) const { return rep->count; } |
3239 | 294 |
5759 | 295 octave_base_value::type_conv_fcn numeric_conversion_function (void) const |
2376 | 296 { return rep->numeric_conversion_function (); } |
297 | |
2409 | 298 void maybe_mutate (void); |
299 | |
5759 | 300 octave_value squeeze (void) const |
4532 | 301 { return rep->squeeze (); } |
302 | |
5759 | 303 octave_base_value *try_narrowing_conversion (void) |
2410 | 304 { return rep->try_narrowing_conversion (); } |
2409 | 305 |
4271 | 306 octave_value single_subsref (const std::string& type, |
307 const octave_value_list& idx); | |
308 | |
5759 | 309 octave_value subsref (const std::string& type, |
4219 | 310 const std::list<octave_value_list>& idx) |
3933 | 311 { return rep->subsref (type, idx); } |
312 | |
5759 | 313 octave_value_list subsref (const std::string& type, |
4219 | 314 const std::list<octave_value_list>& idx, |
3933 | 315 int nargout); |
316 | |
4247 | 317 octave_value next_subsref (const std::string& type, const |
4219 | 318 std::list<octave_value_list>& idx, |
4233 | 319 size_t skip = 1); |
3933 | 320 |
4994 | 321 octave_value_list next_subsref (int nargout, |
322 const std::string& type, const | |
323 std::list<octave_value_list>& idx, | |
324 size_t skip = 1); | |
325 | |
5759 | 326 octave_value do_index_op (const octave_value_list& idx, |
5885 | 327 bool resize_ok = false) |
3933 | 328 { return rep->do_index_op (idx, resize_ok); } |
329 | |
5759 | 330 octave_value_list |
3544 | 331 do_multi_index_op (int nargout, const octave_value_list& idx); |
2974 | 332 |
5759 | 333 octave_value subsasgn (const std::string& type, |
4219 | 334 const std::list<octave_value_list>& idx, |
3933 | 335 const octave_value& rhs); |
2376 | 336 |
4247 | 337 octave_value assign (assign_op op, const std::string& type, |
4219 | 338 const std::list<octave_value_list>& idx, |
3933 | 339 const octave_value& rhs); |
2948 | 340 |
3933 | 341 const octave_value& assign (assign_op, const octave_value& rhs); |
2948 | 342 |
5759 | 343 idx_vector index_vector (void) const |
2376 | 344 { return rep->index_vector (); } |
345 | |
346 // Size. | |
347 | |
5759 | 348 dim_vector dims (void) const |
4513 | 349 { return rep->dims (); } |
350 | |
5759 | 351 octave_idx_type rows (void) const { return rep->rows (); } |
4563 | 352 |
5759 | 353 octave_idx_type columns (void) const { return rep->columns (); } |
3195 | 354 |
5275 | 355 octave_idx_type length (void) const; |
4554 | 356 |
5759 | 357 int ndims (void) const { return rep->ndims (); } |
4563 | 358 |
5164 | 359 bool all_zero_dims (void) const { return dims().all_zero (); } |
360 | |
5759 | 361 octave_idx_type numel (void) const |
5080 | 362 { return rep->numel (); } |
4559 | 363 |
5759 | 364 octave_idx_type capacity (void) const |
5164 | 365 { return rep->capacity (); } |
366 | |
5659 | 367 Matrix size (void) const; |
368 | |
5759 | 369 size_t byte_size (void) const |
4791 | 370 { return rep->byte_size (); } |
371 | |
5759 | 372 octave_idx_type nnz (void) const { return rep->nnz (); } |
5602 | 373 |
5759 | 374 octave_idx_type nzmax (void) const { return rep->nzmax (); } |
5604 | 375 |
5900 | 376 octave_idx_type nfields (void) const { return rep->nfields (); } |
377 | |
5759 | 378 octave_value reshape (const dim_vector& dv) const |
4587 | 379 { return rep->reshape (dv); } |
4567 | 380 |
5759 | 381 octave_value permute (const Array<int>& vec, bool inv = false) const |
4593 | 382 { return rep->permute (vec, inv); } |
383 | |
384 octave_value ipermute (const Array<int>& vec) const | |
385 { return rep->permute (vec, true); } | |
386 | |
5759 | 387 octave_value resize (const dim_vector& dv, bool fill = false) const |
388 { return rep->resize (dv, fill);} | |
4915 | 389 |
5785 | 390 MatrixType matrix_type (void) const |
391 { return rep->matrix_type (); } | |
392 | |
393 MatrixType matrix_type (const MatrixType& typ) const | |
394 { return rep->matrix_type (typ); } | |
395 | |
2376 | 396 // Does this constant have a type? Both of these are provided since |
397 // it is sometimes more natural to write is_undefined() instead of | |
398 // ! is_defined(). | |
399 | |
5759 | 400 bool is_defined (void) const |
2376 | 401 { return rep->is_defined (); } |
402 | |
403 bool is_undefined (void) const | |
404 { return ! is_defined (); } | |
405 | |
4559 | 406 bool is_empty (void) const |
5759 | 407 { return rep->is_empty (); } |
4559 | 408 |
5759 | 409 bool is_cell (void) const |
3351 | 410 { return rep->is_cell (); } |
411 | |
6116 | 412 bool is_cellstr (void) const |
413 { return rep->is_cellstr (); } | |
414 | |
5759 | 415 bool is_real_scalar (void) const |
2376 | 416 { return rep->is_real_scalar (); } |
417 | |
5759 | 418 bool is_real_matrix (void) const |
2376 | 419 { return rep->is_real_matrix (); } |
420 | |
5759 | 421 bool is_real_nd_array (void) const |
4505 | 422 { return rep->is_real_nd_array (); } |
423 | |
5759 | 424 bool is_complex_scalar (void) const |
2376 | 425 { return rep->is_complex_scalar (); } |
426 | |
5759 | 427 bool is_complex_matrix (void) const |
2376 | 428 { return rep->is_complex_matrix (); } |
429 | |
5881 | 430 bool is_bool_scalar (void) const |
431 { return rep->is_bool_scalar (); } | |
432 | |
5759 | 433 bool is_bool_matrix (void) const |
4587 | 434 { return rep->is_bool_matrix (); } |
435 | |
5759 | 436 bool is_char_matrix (void) const |
2376 | 437 { return rep->is_char_matrix (); } |
438 | |
5759 | 439 bool is_string (void) const |
2376 | 440 { return rep->is_string (); } |
441 | |
5759 | 442 bool is_sq_string (void) const |
5279 | 443 { return rep->is_sq_string (); } |
444 | |
5280 | 445 bool is_dq_string (void) const |
446 { return rep->is_string () && ! rep->is_sq_string (); } | |
447 | |
5759 | 448 bool is_range (void) const |
2376 | 449 { return rep->is_range (); } |
450 | |
5759 | 451 bool is_map (void) const |
2376 | 452 { return rep->is_map (); } |
453 | |
7336 | 454 bool is_object (void) const |
455 { return rep->is_object (); } | |
456 | |
5759 | 457 bool is_streamoff (void) const |
4643 | 458 { return rep->is_streamoff (); } |
459 | |
5759 | 460 bool is_cs_list (void) const |
3977 | 461 { return rep->is_cs_list (); } |
462 | |
5759 | 463 bool is_list (void) const |
2880 | 464 { return rep->is_list (); } |
465 | |
5759 | 466 bool is_magic_colon (void) const |
2376 | 467 { return rep->is_magic_colon (); } |
468 | |
469 // Are any or all of the elements in this constant nonzero? | |
470 | |
5759 | 471 octave_value all (int dim = 0) const |
4015 | 472 { return rep->all (dim); } |
2376 | 473 |
5759 | 474 octave_value any (int dim = 0) const |
4015 | 475 { return rep->any (dim); } |
2376 | 476 |
5895 | 477 // Floating point types. |
478 | |
479 bool is_double_type (void) const | |
480 { return rep->is_double_type (); } | |
481 | |
482 bool is_single_type (void) const | |
483 { return rep->is_single_type (); } | |
484 | |
485 // Integer types. | |
486 | |
487 bool is_int8_type (void) const | |
488 { return rep->is_int8_type (); } | |
489 | |
490 bool is_int16_type (void) const | |
491 { return rep->is_int16_type (); } | |
492 | |
493 bool is_int32_type (void) const | |
494 { return rep->is_int32_type (); } | |
495 | |
496 bool is_int64_type (void) const | |
497 { return rep->is_int64_type (); } | |
498 | |
499 bool is_uint8_type (void) const | |
500 { return rep->is_uint8_type (); } | |
501 | |
502 bool is_uint16_type (void) const | |
503 { return rep->is_uint16_type (); } | |
504 | |
505 bool is_uint32_type (void) const | |
506 { return rep->is_uint32_type (); } | |
507 | |
508 bool is_uint64_type (void) const | |
509 { return rep->is_uint64_type (); } | |
510 | |
2376 | 511 // Other type stuff. |
512 | |
5759 | 513 bool is_bool_type (void) const |
3209 | 514 { return rep->is_bool_type (); } |
515 | |
6223 | 516 bool is_integer_type (void) const |
517 { return rep->is_integer_type (); } | |
518 | |
5759 | 519 bool is_real_type (void) const |
2376 | 520 { return rep->is_real_type (); } |
521 | |
5759 | 522 bool is_complex_type (void) const |
2376 | 523 { return rep->is_complex_type (); } |
524 | |
5759 | 525 bool is_scalar_type (void) const |
2376 | 526 { return rep->is_scalar_type (); } |
527 | |
5759 | 528 bool is_matrix_type (void) const |
2376 | 529 { return rep->is_matrix_type (); } |
530 | |
5759 | 531 bool is_numeric_type (void) const |
2376 | 532 { return rep->is_numeric_type (); } |
533 | |
5759 | 534 bool is_sparse_type (void) const |
5631 | 535 { return rep->is_sparse_type (); } |
536 | |
5759 | 537 bool valid_as_scalar_index (void) const |
2376 | 538 { return rep->valid_as_scalar_index (); } |
539 | |
5759 | 540 bool valid_as_zero_index (void) const |
2376 | 541 { return rep->valid_as_zero_index (); } |
542 | |
543 // Does this constant correspond to a truth value? | |
544 | |
5759 | 545 bool is_true (void) const |
2376 | 546 { return rep->is_true (); } |
547 | |
548 // Are the dimensions of this constant zero by zero? | |
549 | |
5759 | 550 bool is_zero_by_zero (void) const |
551 { return (rows () == 0 && columns () == 0); } | |
2376 | 552 |
5759 | 553 bool is_constant (void) const |
2974 | 554 { return rep->is_constant (); } |
555 | |
5759 | 556 bool is_function_handle (void) const |
4654 | 557 { return rep->is_function_handle (); } |
558 | |
5759 | 559 bool is_inline_function (void) const |
4954 | 560 { return rep->is_inline_function (); } |
561 | |
5759 | 562 bool is_function (void) const |
2974 | 563 { return rep->is_function (); } |
2891 | 564 |
7336 | 565 bool is_user_script (void) const |
566 { return rep->is_user_script (); } | |
567 | |
568 bool is_user_function (void) const | |
569 { return rep->is_user_function (); } | |
570 | |
5759 | 571 bool is_builtin_function (void) const |
3325 | 572 { return rep->is_builtin_function (); } |
573 | |
5759 | 574 bool is_dld_function (void) const |
3325 | 575 { return rep->is_dld_function (); } |
576 | |
5864 | 577 bool is_mex_function (void) const |
578 { return rep->is_mex_function (); } | |
579 | |
2376 | 580 // Values. |
581 | |
2891 | 582 octave_value eval (void) { return *this; } |
583 | |
5759 | 584 short int |
4254 | 585 short_value (bool req_int = false, bool frc_str_conv = false) const |
586 { return rep->short_value (req_int, frc_str_conv); } | |
587 | |
5759 | 588 unsigned short int |
4254 | 589 ushort_value (bool req_int = false, bool frc_str_conv = false) const |
590 { return rep->ushort_value (req_int, frc_str_conv); } | |
591 | |
5759 | 592 int int_value (bool req_int = false, bool frc_str_conv = false) const |
3202 | 593 { return rep->int_value (req_int, frc_str_conv); } |
594 | |
5759 | 595 unsigned int |
4254 | 596 uint_value (bool req_int = false, bool frc_str_conv = false) const |
597 { return rep->uint_value (req_int, frc_str_conv); } | |
598 | |
5759 | 599 int nint_value (bool frc_str_conv = false) const |
3202 | 600 { return rep->nint_value (frc_str_conv); } |
601 | |
5759 | 602 long int |
4254 | 603 long_value (bool req_int = false, bool frc_str_conv = false) const |
604 { return rep->long_value (req_int, frc_str_conv); } | |
605 | |
5759 | 606 unsigned long int |
4254 | 607 ulong_value (bool req_int = false, bool frc_str_conv = false) const |
608 { return rep->ulong_value (req_int, frc_str_conv); } | |
609 | |
6133 | 610 octave_idx_type |
611 idx_type_value (bool req_int = false, bool frc_str_conv = false) const | |
612 { | |
613 #if SIZEOF_OCTAVE_IDX_TYPE == SIZEOF_LONG | |
614 return long_value (req_int, frc_str_conv); | |
615 #elif SIZEOF_OCTAVE_IDX_TYPE == SIZEOF_INT | |
616 return int_value (req_int, frc_str_conv); | |
617 #else | |
618 #error "no octave_value extractor for octave_idx_type" | |
619 #endif | |
620 } | |
621 | |
5759 | 622 double double_value (bool frc_str_conv = false) const |
2376 | 623 { return rep->double_value (frc_str_conv); } |
624 | |
5759 | 625 double scalar_value (bool frc_str_conv = false) const |
2916 | 626 { return rep->scalar_value (frc_str_conv); } |
627 | |
5759 | 628 Cell cell_value (void) const; |
3351 | 629 |
5759 | 630 Matrix matrix_value (bool frc_str_conv = false) const |
2376 | 631 { return rep->matrix_value (frc_str_conv); } |
632 | |
5759 | 633 NDArray array_value (bool frc_str_conv = false) const |
4550 | 634 { return rep->array_value (frc_str_conv); } |
4505 | 635 |
5759 | 636 Complex complex_value (bool frc_str_conv = false) const |
2376 | 637 { return rep->complex_value (frc_str_conv); } |
638 | |
5759 | 639 ComplexMatrix complex_matrix_value (bool frc_str_conv = false) const |
2376 | 640 { return rep->complex_matrix_value (frc_str_conv); } |
641 | |
5759 | 642 ComplexNDArray complex_array_value (bool frc_str_conv = false) const |
4550 | 643 { return rep->complex_array_value (frc_str_conv); } |
644 | |
5943 | 645 bool bool_value (bool warn = false) const |
646 { return rep->bool_value (warn); } | |
4550 | 647 |
5943 | 648 boolMatrix bool_matrix_value (bool warn = false) const |
649 { return rep->bool_matrix_value (warn); } | |
4550 | 650 |
5943 | 651 boolNDArray bool_array_value (bool warn = false) const |
652 { return rep->bool_array_value (warn); } | |
4550 | 653 |
5759 | 654 charMatrix char_matrix_value (bool frc_str_conv = false) const |
2376 | 655 { return rep->char_matrix_value (frc_str_conv); } |
656 | |
5759 | 657 charNDArray char_array_value (bool frc_str_conv = false) const |
4550 | 658 { return rep->char_array_value (frc_str_conv); } |
659 | |
5759 | 660 SparseMatrix sparse_matrix_value (bool frc_str_conv = false) const |
661 { return rep->sparse_matrix_value (frc_str_conv); } | |
5164 | 662 |
5759 | 663 SparseComplexMatrix sparse_complex_matrix_value (bool frc_str_conv = false) const |
664 { return rep->sparse_complex_matrix_value (frc_str_conv); } | |
5164 | 665 |
5759 | 666 SparseBoolMatrix sparse_bool_matrix_value (bool frc_str_conv = false) const |
667 { return rep->sparse_bool_matrix_value (frc_str_conv); } | |
5164 | 668 |
5759 | 669 octave_int8 int8_scalar_value (void) const |
4910 | 670 { return rep->int8_scalar_value (); } |
671 | |
5759 | 672 octave_int16 int16_scalar_value (void) const |
4910 | 673 { return rep->int16_scalar_value (); } |
674 | |
5759 | 675 octave_int32 int32_scalar_value (void) const |
4910 | 676 { return rep->int32_scalar_value (); } |
677 | |
5759 | 678 octave_int64 int64_scalar_value (void) const |
4910 | 679 { return rep->int64_scalar_value (); } |
680 | |
5759 | 681 octave_uint8 uint8_scalar_value (void) const |
4910 | 682 { return rep->uint8_scalar_value (); } |
683 | |
5759 | 684 octave_uint16 uint16_scalar_value (void) const |
4910 | 685 { return rep->uint16_scalar_value (); } |
686 | |
5759 | 687 octave_uint32 uint32_scalar_value (void) const |
4910 | 688 { return rep->uint32_scalar_value (); } |
689 | |
5759 | 690 octave_uint64 uint64_scalar_value (void) const |
4910 | 691 { return rep->uint64_scalar_value (); } |
692 | |
5759 | 693 int8NDArray int8_array_value (void) const |
4906 | 694 { return rep->int8_array_value (); } |
695 | |
5759 | 696 int16NDArray int16_array_value (void) const |
4906 | 697 { return rep->int16_array_value (); } |
698 | |
5759 | 699 int32NDArray int32_array_value (void) const |
4906 | 700 { return rep->int32_array_value (); } |
701 | |
5759 | 702 int64NDArray int64_array_value (void) const |
4906 | 703 { return rep->int64_array_value (); } |
704 | |
5759 | 705 uint8NDArray uint8_array_value (void) const |
4906 | 706 { return rep->uint8_array_value (); } |
707 | |
5759 | 708 uint16NDArray uint16_array_value (void) const |
4906 | 709 { return rep->uint16_array_value (); } |
710 | |
5759 | 711 uint32NDArray uint32_array_value (void) const |
4906 | 712 { return rep->uint32_array_value (); } |
713 | |
5759 | 714 uint64NDArray uint64_array_value (void) const |
4906 | 715 { return rep->uint64_array_value (); } |
716 | |
5759 | 717 string_vector all_strings (bool pad = false) const |
5715 | 718 { return rep->all_strings (pad); } |
2376 | 719 |
5759 | 720 std::string string_value (bool force = false) const |
4665 | 721 { return rep->string_value (force); } |
2376 | 722 |
5759 | 723 Range range_value (void) const |
2376 | 724 { return rep->range_value (); } |
725 | |
5759 | 726 Octave_map map_value (void) const; |
2376 | 727 |
5759 | 728 string_vector map_keys (void) const |
3933 | 729 { return rep->map_keys (); } |
730 | |
5759 | 731 std::streamoff streamoff_value (void) const; |
4645 | 732 |
5759 | 733 streamoff_array streamoff_array_value (void) const; |
4643 | 734 |
5759 | 735 octave_function *function_value (bool silent = false); |
2974 | 736 |
5759 | 737 octave_user_function *user_function_value (bool silent = false); |
4700 | 738 |
5759 | 739 octave_fcn_handle *fcn_handle_value (bool silent = false); |
4343 | 740 |
5759 | 741 octave_fcn_inline *fcn_inline_value (bool silent = false); |
4933 | 742 |
5759 | 743 octave_value_list list_value (void) const; |
2880 | 744 |
3419 | 745 ColumnVector column_vector_value (bool frc_str_conv = false, |
2376 | 746 bool frc_vec_conv = false) const; |
747 | |
748 ComplexColumnVector | |
3419 | 749 complex_column_vector_value (bool frc_str_conv = false, |
2376 | 750 bool frc_vec_conv = false) const; |
751 | |
3419 | 752 RowVector row_vector_value (bool frc_str_conv = false, |
753 bool frc_vec_conv = false) const; | |
754 | |
755 ComplexRowVector | |
756 complex_row_vector_value (bool frc_str_conv = false, | |
757 bool frc_vec_conv = false) const; | |
758 | |
4044 | 759 Array<int> int_vector_value (bool req_int = false, |
760 bool frc_str_conv = false, | |
761 bool frc_vec_conv = false) const; | |
762 | |
3419 | 763 Array<double> vector_value (bool frc_str_conv = false, |
764 bool frc_vec_conv = false) const; | |
765 | |
766 Array<Complex> complex_vector_value (bool frc_str_conv = false, | |
767 bool frc_vec_conv = false) const; | |
768 | |
2376 | 769 // Conversions. These should probably be private. If a user of this |
770 // class wants a certain kind of constant, he should simply ask for | |
771 // it, and we should convert it if possible. | |
772 | |
5279 | 773 octave_value convert_to_str (bool pad = false, bool force = false, |
5759 | 774 char type = '"') const |
775 { return rep->convert_to_str (pad, force, type); } | |
4452 | 776 |
5759 | 777 octave_value |
5279 | 778 convert_to_str_internal (bool pad, bool force, char type) const |
779 { return rep->convert_to_str_internal (pad, force, type); } | |
2376 | 780 |
5759 | 781 void convert_to_row_or_column_vector (void) |
2376 | 782 { rep->convert_to_row_or_column_vector (); } |
783 | |
5759 | 784 bool print_as_scalar (void) const |
4604 | 785 { return rep->print_as_scalar (); } |
786 | |
5759 | 787 void print (std::ostream& os, bool pr_as_read_syntax = false) const |
2466 | 788 { rep->print (os, pr_as_read_syntax); } |
2376 | 789 |
5759 | 790 void print_raw (std::ostream& os, |
4457 | 791 bool pr_as_read_syntax = false) const |
2903 | 792 { rep->print_raw (os, pr_as_read_syntax); } |
793 | |
5759 | 794 bool print_name_tag (std::ostream& os, const std::string& name) const |
2903 | 795 { return rep->print_name_tag (os, name); } |
2376 | 796 |
3523 | 797 void print_with_name (std::ostream& os, const std::string& name, |
5759 | 798 bool print_padding = true) const |
799 { rep->print_with_name (os, name, print_padding); } | |
2376 | 800 |
5759 | 801 int type_id (void) const { return rep->type_id (); } |
2376 | 802 |
5759 | 803 std::string type_name (void) const { return rep->type_name (); } |
804 | |
805 std::string class_name (void) const { return rep->class_name (); } | |
4612 | 806 |
3203 | 807 // Unary and binary operations. |
808 | |
6109 | 809 friend OCTINTERP_API octave_value do_unary_op (unary_op op, |
3933 | 810 const octave_value& a); |
3203 | 811 |
3933 | 812 const octave_value& do_non_const_unary_op (unary_op op); |
813 | |
814 void do_non_const_unary_op (unary_op op, const octave_value_list& idx); | |
2376 | 815 |
4247 | 816 octave_value do_non_const_unary_op (unary_op op, const std::string& type, |
4219 | 817 const std::list<octave_value_list>& idx); |
3205 | 818 |
6109 | 819 friend OCTINTERP_API octave_value do_binary_op (binary_op op, |
3933 | 820 const octave_value& a, |
821 const octave_value& b); | |
2376 | 822 |
6109 | 823 friend OCTINTERP_API octave_value do_cat_op (const octave_value& a, |
4915 | 824 const octave_value& b, |
6867 | 825 const Array<octave_idx_type>& ra_idx); |
4915 | 826 |
5759 | 827 const octave_base_value& get_rep (void) const { return *rep; } |
3301 | 828 |
5759 | 829 void print_info (std::ostream& os, |
3933 | 830 const std::string& prefix = std::string ()) const; |
831 | |
6974 | 832 bool save_ascii (std::ostream& os) { return rep->save_ascii (os); } |
4687 | 833 |
6974 | 834 bool load_ascii (std::istream& is) { return rep->load_ascii (is); } |
4687 | 835 |
5759 | 836 bool save_binary (std::ostream& os, bool& save_as_floats) |
4687 | 837 { return rep->save_binary (os, save_as_floats); } |
838 | |
5759 | 839 bool load_binary (std::istream& is, bool swap, |
4687 | 840 oct_mach_info::float_format fmt) |
841 { return rep->load_binary (is, swap, fmt); } | |
842 | |
843 #if defined (HAVE_HDF5) | |
5759 | 844 bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats) |
4687 | 845 { return rep->save_hdf5 (loc_id, name, save_as_floats); } |
846 | |
5759 | 847 bool load_hdf5 (hid_t loc_id, const char *name, |
4687 | 848 bool have_h5giterate_bug) |
849 { return rep->load_hdf5 (loc_id, name, have_h5giterate_bug); } | |
850 #endif | |
851 | |
5759 | 852 int write (octave_stream& os, int block_size, |
4944 | 853 oct_data_conv::data_type output_type, int skip, |
854 oct_mach_info::float_format flt_fmt) const; | |
855 | |
5759 | 856 octave_base_value *internal_rep (void) const { return rep; } |
4901 | 857 |
5900 | 858 // Unsafe. These functions exist to support the MEX interface. |
859 // You should not use them anywhere else. | |
860 void *mex_get_data (void) const { return rep->mex_get_data (); } | |
861 | |
862 octave_idx_type *mex_get_ir (void) const { return rep->mex_get_ir (); } | |
863 | |
864 octave_idx_type *mex_get_jc (void) const { return rep->mex_get_jc (); } | |
865 | |
866 mxArray *as_mxArray (void) const { return rep->as_mxArray (); } | |
867 | |
7463
2467639bd8c0
eliminate UNDEFINED sort mode
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
868 octave_value sort (octave_idx_type dim = 0, sortmode mode = ASCENDING) const |
7433 | 869 { return rep->sort (dim, mode); } |
870 octave_value sort (Array<octave_idx_type> &sidx, octave_idx_type dim = 0, | |
7463
2467639bd8c0
eliminate UNDEFINED sort mode
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
871 sortmode mode = ASCENDING) const |
7433 | 872 { return rep->sort (sidx, dim, mode); } |
873 | |
7489
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7463
diff
changeset
|
874 void lock (void) { rep->lock (); } |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7463
diff
changeset
|
875 |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7463
diff
changeset
|
876 void unlock (void) { rep->unlock (); } |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7463
diff
changeset
|
877 |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7463
diff
changeset
|
878 bool islocked (void) const { return rep->islocked (); } |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7463
diff
changeset
|
879 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
880 #define MAPPER_FORWARD(F) \ |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
881 octave_value F (void) const { return rep->F (); } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
882 |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
883 MAPPER_FORWARD (abs) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
884 MAPPER_FORWARD (acos) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
885 MAPPER_FORWARD (acosh) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
886 MAPPER_FORWARD (angle) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
887 MAPPER_FORWARD (arg) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
888 MAPPER_FORWARD (asin) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
889 MAPPER_FORWARD (asinh) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
890 MAPPER_FORWARD (atan) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
891 MAPPER_FORWARD (atanh) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
892 MAPPER_FORWARD (ceil) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
893 MAPPER_FORWARD (conj) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
894 MAPPER_FORWARD (cos) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
895 MAPPER_FORWARD (cosh) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
896 MAPPER_FORWARD (erf) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
897 MAPPER_FORWARD (erfc) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
898 MAPPER_FORWARD (exp) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
899 MAPPER_FORWARD (finite) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
900 MAPPER_FORWARD (fix) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
901 MAPPER_FORWARD (floor) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
902 MAPPER_FORWARD (gamma) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
903 MAPPER_FORWARD (imag) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
904 MAPPER_FORWARD (isinf) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
905 MAPPER_FORWARD (isna) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
906 MAPPER_FORWARD (isnan) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
907 MAPPER_FORWARD (lgamma) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
908 MAPPER_FORWARD (log) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
909 MAPPER_FORWARD (log10) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
910 MAPPER_FORWARD (real) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
911 MAPPER_FORWARD (round) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
912 MAPPER_FORWARD (signum) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
913 MAPPER_FORWARD (sin) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
914 MAPPER_FORWARD (sinh) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
915 MAPPER_FORWARD (sqrt) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
916 MAPPER_FORWARD (tan) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
917 MAPPER_FORWARD (tanh) |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
918 |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
919 // These functions are prefixed with X to avoid potential macro |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
920 // conflicts. |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
921 |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
922 MAPPER_FORWARD (xisalnum) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
923 MAPPER_FORWARD (xisalpha) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
924 MAPPER_FORWARD (xisascii) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
925 MAPPER_FORWARD (xiscntrl) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
926 MAPPER_FORWARD (xisdigit) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
927 MAPPER_FORWARD (xisgraph) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
928 MAPPER_FORWARD (xislower) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
929 MAPPER_FORWARD (xisprint) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
930 MAPPER_FORWARD (xispunct) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
931 MAPPER_FORWARD (xisspace) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
932 MAPPER_FORWARD (xisupper) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
933 MAPPER_FORWARD (xisxdigit) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
934 MAPPER_FORWARD (xtoascii) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
935 MAPPER_FORWARD (xtolower) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
936 MAPPER_FORWARD (xtoupper) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
937 |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
938 #undef MAPPER_FORWARD |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
939 |
2376 | 940 protected: |
941 | |
5759 | 942 // The real representation. |
943 octave_base_value *rep; | |
2413 | 944 |
3933 | 945 private: |
2903 | 946 |
3205 | 947 assign_op unary_op_to_assign_op (unary_op op); |
948 | |
3204 | 949 binary_op op_eq_to_binary_op (assign_op op); |
950 | |
3219 | 951 DECLARE_OCTAVE_ALLOCATOR |
2376 | 952 }; |
953 | |
5508 | 954 // Publish externally used friend functions. |
955 | |
6109 | 956 extern OCTINTERP_API octave_value |
5508 | 957 do_unary_op (octave_value::unary_op op, const octave_value& a); |
958 | |
6109 | 959 extern OCTINTERP_API octave_value |
5508 | 960 do_binary_op (octave_value::binary_op op, |
961 const octave_value& a, const octave_value& b); | |
962 | |
3203 | 963 #define OV_UNOP_FN(name) \ |
964 inline octave_value \ | |
965 name (const octave_value& a) \ | |
966 { \ | |
967 return do_unary_op (octave_value::name, a); \ | |
968 } | |
969 | |
970 #define OV_UNOP_OP(name, op) \ | |
971 inline octave_value \ | |
972 operator op (const octave_value& a) \ | |
973 { \ | |
974 return name (a); \ | |
975 } | |
976 | |
977 #define OV_UNOP_FN_OP(name, op) \ | |
978 OV_UNOP_FN (name) \ | |
979 OV_UNOP_OP (name, op) | |
980 | |
3525 | 981 OV_UNOP_FN_OP (op_not, !) |
6518 | 982 OV_UNOP_FN_OP (op_uplus, +) |
3525 | 983 OV_UNOP_FN_OP (op_uminus, -) |
3203 | 984 |
3525 | 985 OV_UNOP_FN (op_transpose) |
986 OV_UNOP_FN (op_hermitian) | |
3203 | 987 |
988 // No simple way to define these for prefix and suffix ops? | |
989 // | |
990 // incr | |
991 // decr | |
992 | |
993 #define OV_BINOP_FN(name) \ | |
994 inline octave_value \ | |
995 name (const octave_value& a1, const octave_value& a2) \ | |
996 { \ | |
997 return do_binary_op (octave_value::name, a1, a2); \ | |
998 } | |
999 | |
1000 #define OV_BINOP_OP(name, op) \ | |
1001 inline octave_value \ | |
1002 operator op (const octave_value& a1, const octave_value& a2) \ | |
1003 { \ | |
1004 return name (a1, a2); \ | |
1005 } | |
1006 | |
1007 #define OV_BINOP_FN_OP(name, op) \ | |
1008 OV_BINOP_FN (name) \ | |
1009 OV_BINOP_OP (name, op) | |
1010 | |
3525 | 1011 OV_BINOP_FN_OP (op_add, +) |
1012 OV_BINOP_FN_OP (op_sub, -) | |
1013 OV_BINOP_FN_OP (op_mul, *) | |
1014 OV_BINOP_FN_OP (op_div, /) | |
3203 | 1015 |
3525 | 1016 OV_BINOP_FN (op_pow) |
1017 OV_BINOP_FN (op_ldiv) | |
1018 OV_BINOP_FN (op_lshift) | |
1019 OV_BINOP_FN (op_rshift) | |
3203 | 1020 |
3525 | 1021 OV_BINOP_FN_OP (op_lt, <) |
1022 OV_BINOP_FN_OP (op_le, <=) | |
1023 OV_BINOP_FN_OP (op_eq, ==) | |
1024 OV_BINOP_FN_OP (op_ge, >=) | |
1025 OV_BINOP_FN_OP (op_gt, >) | |
1026 OV_BINOP_FN_OP (op_ne, !=) | |
3203 | 1027 |
3525 | 1028 OV_BINOP_FN (op_el_mul) |
1029 OV_BINOP_FN (op_el_div) | |
1030 OV_BINOP_FN (op_el_pow) | |
1031 OV_BINOP_FN (op_el_ldiv) | |
1032 OV_BINOP_FN (op_el_and) | |
1033 OV_BINOP_FN (op_el_or) | |
3203 | 1034 |
3525 | 1035 OV_BINOP_FN (op_struct_ref) |
3203 | 1036 |
6109 | 1037 extern OCTINTERP_API void install_types (void); |
2376 | 1038 |
5775 | 1039 // FIXME -- these trait classes probably belong somehwere else... |
4946 | 1040 |
1041 template <typename T> | |
1042 class | |
1043 octave_type_traits | |
1044 { | |
1045 public: | |
1046 typedef T val_type; | |
1047 }; | |
1048 | |
1049 #define OCTAVE_TYPE_TRAIT(T, VAL_T) \ | |
1050 template <> \ | |
1051 class \ | |
1052 octave_type_traits<T> \ | |
1053 { \ | |
1054 public: \ | |
1055 typedef VAL_T val_type; \ | |
1056 } | |
1057 | |
1058 OCTAVE_TYPE_TRAIT (octave_int8, octave_int8::val_type); | |
1059 OCTAVE_TYPE_TRAIT (octave_uint8, octave_uint8::val_type); | |
1060 OCTAVE_TYPE_TRAIT (octave_int16, octave_int16::val_type); | |
1061 OCTAVE_TYPE_TRAIT (octave_uint16, octave_uint16::val_type); | |
1062 OCTAVE_TYPE_TRAIT (octave_int32, octave_int32::val_type); | |
1063 OCTAVE_TYPE_TRAIT (octave_uint32, octave_uint32::val_type); | |
1064 OCTAVE_TYPE_TRAIT (octave_int64, octave_int64::val_type); | |
1065 OCTAVE_TYPE_TRAIT (octave_uint64, octave_uint64::val_type); | |
1066 | |
1067 template <typename T> | |
1068 class octave_array_type_traits | |
1069 { | |
1070 public: | |
1071 typedef T element_type; | |
1072 }; | |
1073 | |
1074 #define OCTAVE_ARRAY_TYPE_TRAIT(T, ELT_T) \ | |
1075 template <> \ | |
1076 class \ | |
1077 octave_array_type_traits<T> \ | |
1078 { \ | |
1079 public: \ | |
1080 typedef ELT_T element_type; \ | |
1081 } | |
1082 | |
1083 OCTAVE_ARRAY_TYPE_TRAIT (charNDArray, char); | |
4970 | 1084 OCTAVE_ARRAY_TYPE_TRAIT (boolNDArray, bool); |
4946 | 1085 OCTAVE_ARRAY_TYPE_TRAIT (int8NDArray, octave_int8); |
1086 OCTAVE_ARRAY_TYPE_TRAIT (uint8NDArray, octave_uint8); | |
1087 OCTAVE_ARRAY_TYPE_TRAIT (int16NDArray, octave_int16); | |
1088 OCTAVE_ARRAY_TYPE_TRAIT (uint16NDArray, octave_uint16); | |
1089 OCTAVE_ARRAY_TYPE_TRAIT (int32NDArray, octave_int32); | |
1090 OCTAVE_ARRAY_TYPE_TRAIT (uint32NDArray, octave_uint32); | |
1091 OCTAVE_ARRAY_TYPE_TRAIT (int64NDArray, octave_int64); | |
1092 OCTAVE_ARRAY_TYPE_TRAIT (uint64NDArray, octave_uint64); | |
1093 OCTAVE_ARRAY_TYPE_TRAIT (NDArray, double); | |
1094 | |
5759 | 1095 // This will eventually go away, but for now it can be used to |
1096 // simplify the transition to the new octave_value class hierarchy, | |
1097 // which uses octave_base_value instead of octave_value for the type | |
1098 // of octave_value::rep. | |
1099 #define OV_REP_TYPE octave_base_value | |
1100 | |
2376 | 1101 #endif |
1102 | |
1103 /* | |
6705 | 1104 ;;; Local Variables: *** |
1105 ;;; mode: C++ *** | |
1106 ;;; End: *** | |
2376 | 1107 */ |