Mercurial > hg > octave-avbm
changeset 9657:3c1c3a38ec7b
implement templated octave_value extractor
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Sat, 19 Sep 2009 21:38:30 +0200 |
parents | b29504415a2e |
children | 3429c956de6f |
files | src/ChangeLog src/ov.h |
diffstat | 2 files changed, 64 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2009-09-19 Jaroslav Hajek <highegg@gmail.com> + + * ov.h (octave_value_extract): New template function. + 2009-09-18 John W. Eaton <jwe@octave.org> * DLD-FUNCTIONS/fltk_backend.cc (fltk_backend::redraw_figure):
--- a/src/ov.h +++ b/src/ov.h @@ -1313,6 +1313,66 @@ // of octave_value::rep. #define OV_REP_TYPE octave_base_value +// Templated value extractors. +template<class Value> +inline Value octave_value_extract (const octave_value&) + { assert (false); } + +#define DEF_VALUE_EXTRACTOR(VALUE,MPREFIX) \ +template<> \ +inline VALUE octave_value_extract<VALUE> (const octave_value& v) \ + { return v.MPREFIX ## _value (); } + +DEF_VALUE_EXTRACTOR (double, scalar) +DEF_VALUE_EXTRACTOR (float, float_scalar) +DEF_VALUE_EXTRACTOR (Complex, complex) +DEF_VALUE_EXTRACTOR (FloatComplex, float_complex) +DEF_VALUE_EXTRACTOR (bool, bool) + +DEF_VALUE_EXTRACTOR (octave_int8, int8_scalar) +DEF_VALUE_EXTRACTOR (octave_int16, int16_scalar) +DEF_VALUE_EXTRACTOR (octave_int32, int32_scalar) +DEF_VALUE_EXTRACTOR (octave_int64, int64_scalar) +DEF_VALUE_EXTRACTOR (octave_uint8, uint8_scalar) +DEF_VALUE_EXTRACTOR (octave_uint16, uint16_scalar) +DEF_VALUE_EXTRACTOR (octave_uint32, uint32_scalar) +DEF_VALUE_EXTRACTOR (octave_uint64, uint64_scalar) + + +DEF_VALUE_EXTRACTOR (NDArray, array) +DEF_VALUE_EXTRACTOR (FloatNDArray, float_array) +DEF_VALUE_EXTRACTOR (ComplexNDArray, complex_array) +DEF_VALUE_EXTRACTOR (FloatComplexNDArray, float_complex_array) +DEF_VALUE_EXTRACTOR (boolNDArray, bool_array) + +DEF_VALUE_EXTRACTOR (charNDArray, char_array) +DEF_VALUE_EXTRACTOR (int8NDArray, int8_array) +DEF_VALUE_EXTRACTOR (int16NDArray, int16_array) +DEF_VALUE_EXTRACTOR (int32NDArray, int32_array) +DEF_VALUE_EXTRACTOR (int64NDArray, int64_array) +DEF_VALUE_EXTRACTOR (uint8NDArray, uint8_array) +DEF_VALUE_EXTRACTOR (uint16NDArray, uint16_array) +DEF_VALUE_EXTRACTOR (uint32NDArray, uint32_array) +DEF_VALUE_EXTRACTOR (uint64NDArray, uint64_array) + +DEF_VALUE_EXTRACTOR (Matrix, matrix) +DEF_VALUE_EXTRACTOR (FloatMatrix, float_matrix) +DEF_VALUE_EXTRACTOR (ComplexMatrix, complex_matrix) +DEF_VALUE_EXTRACTOR (FloatComplexMatrix, float_complex_matrix) +DEF_VALUE_EXTRACTOR (boolMatrix, bool_matrix) + +DEF_VALUE_EXTRACTOR (ColumnVector, column_vector) +DEF_VALUE_EXTRACTOR (FloatColumnVector, float_column_vector) +DEF_VALUE_EXTRACTOR (ComplexColumnVector, complex_column_vector) +DEF_VALUE_EXTRACTOR (FloatComplexColumnVector, float_complex_column_vector) + +DEF_VALUE_EXTRACTOR (RowVector, row_vector) +DEF_VALUE_EXTRACTOR (FloatRowVector, float_row_vector) +DEF_VALUE_EXTRACTOR (ComplexRowVector, complex_row_vector) +DEF_VALUE_EXTRACTOR (FloatComplexRowVector, float_complex_row_vector) + +#undef DEF_VALUE_EXTRACTOR + #endif /*