26 #if ! defined (octave_ov_base_h)
27 #define octave_ov_base_h 1
29 #include "octave-config.h"
135 template <
typename T>
141 template <builtin_type_t BTYP>
147 #define DEF_BTYP_TRAITS(BTYP, CLASS) \
149 struct class_to_btyp<CLASS> \
151 static const builtin_type_t btyp = BTYP; \
155 struct btyp_to_class<BTYP> \
157 typedef CLASS type; \
179 #define OCTAVE_EMPTY_CPP_ARG
181 #define DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA \
182 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA2 (OCTAVE_EMPTY_CPP_ARG)
184 #define DECLARE_OV_BASE_TYPEID_FUNCTIONS_AND_DATA \
185 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA2(virtual)
187 #define DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA2(VIRTUAL) \
189 VIRTUAL int type_id (void) const { return t_id; } \
190 VIRTUAL std::string type_name (void) const { return t_name; } \
191 VIRTUAL std::string class_name (void) const { return c_name; } \
192 static int static_type_id (void) { return t_id; } \
193 static std::string static_type_name (void) { return t_name; } \
194 static std::string static_class_name (void) { return c_name; } \
195 static void register_type (void); \
196 static void register_type (octave::type_info&); \
200 static const std::string t_name; \
201 static const std::string c_name;
203 #define DECLARE_TEMPLATE_OV_TYPEID_SPECIALIZATIONS(cls, type) \
204 template <> void cls<type>::register_type (void); \
205 template <> void cls<type>::register_type (octave::type_info&); \
206 template <> int cls<type>::t_id; \
207 template <> const std::string cls<type>::t_name; \
208 template <> const std::string cls<type>::c_name;
210 #define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_INTERNAL(tspec, t, n, c) \
211 tspec int t::t_id (-1); \
212 tspec const std::string t::t_name (n); \
213 tspec const std::string t::c_name (c); \
214 tspec void t::register_type (void) \
216 octave::type_info& type_info = octave::__get_type_info__ (); \
218 register_type (type_info); \
220 tspec void t::register_type (octave::type_info& ti) \
222 octave_value v (new t ()); \
223 t_id = ti.register_type (t::t_name, t::c_name, v); \
226 #define DEFINE_TEMPLATE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c) \
227 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_INTERNAL (template <>, t, n, c)
229 #define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c) \
230 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_INTERNAL ( , t, n, c)
249 : m_fcn (
f), m_type_id (t) { }
251 operator type_conv_fcn (
void)
const {
return m_fcn; }
254 {
return (*m_fcn) (v); }
256 int type_id (
void)
const {
return m_type_id; }
287 virtual type_conv_info
291 virtual type_conv_info
324 subsref (
const std::string& type,
325 const std::list<octave_value_list>& idx);
328 subsref (
const std::string& type,
329 const std::list<octave_value_list>& idx,
333 subsref (
const std::string& type,
334 const std::list<octave_value_list>& idx,
344 const std::list<octave_value_list>& idx,
349 const std::list<octave_value_list>& idx,
375 virtual std::size_t
byte_size (
void)
const {
return 0; }
403 virtual bool iscell (
void)
const {
return false; }
429 virtual bool is_range (
void)
const {
return false; }
431 virtual bool isstruct (
void)
const {
return false; }
433 virtual bool isobject (
void)
const {
return false; }
443 virtual bool isjava (
void)
const {
return false; }
461 virtual bool isfloat (
void)
const {
return false; }
483 virtual bool isreal (
void)
const {
return false; }
495 virtual bool issparse (
void)
const {
return false; }
497 virtual bool is_true (
void)
const {
return false; }
501 virtual bool isnull (
void)
const {
return false; }
527 virtual short int short_value (
bool =
false,
bool =
false)
const;
529 virtual unsigned short int ushort_value (
bool =
false,
bool =
false)
const;
531 virtual int int_value (
bool =
false,
bool =
false)
const;
533 virtual unsigned int uint_value (
bool =
false,
bool =
false)
const;
537 virtual long int long_value (
bool =
false,
bool =
false)
const;
539 virtual unsigned long int ulong_value (
bool =
false,
bool =
false)
const;
541 virtual int64_t
int64_value (
bool =
false,
bool =
false)
const;
543 virtual uint64_t
uint64_value (
bool =
false,
bool =
false)
const;
638 virtual std::string
string_value (
bool force =
false)
const;
642 virtual octave::range<double>
range_value (
void)
const;
648 virtual octave::range<float> float_range_value (
void)
const;
650 virtual octave::range<octave_int8> int8_range_value (
void)
const;
652 virtual octave::range<octave_int16> int16_range_value (
void)
const;
654 virtual octave::range<octave_int32> int32_range_value (
void)
const;
656 virtual octave::range<octave_int64> int64_range_value (
void)
const;
658 virtual octave::range<octave_uint8> uint8_range_value (
void)
const;
660 virtual octave::range<octave_uint16> uint16_range_value (
void)
const;
662 virtual octave::range<octave_uint32> uint32_range_value (
void)
const;
664 virtual octave::range<octave_uint64> uint64_range_value (
void)
const;
674 virtual bool isfield (
const std::string&)
const;
676 virtual std::size_t
nparents (
void)
const;
706 char type =
'\'')
const;
719 virtual void print (std::ostream& os,
bool pr_as_read_syntax =
false);
722 print_raw (std::ostream& os,
bool pr_as_read_syntax =
false)
const;
729 bool print_padding =
true);
731 virtual void short_disp (std::ostream& os)
const { os <<
"..."; }
739 virtual void print_info (std::ostream& os,
const std::string& prefix)
const;
745 virtual bool save_binary (std::ostream& os,
bool save_as_floats);
747 virtual bool load_binary (std::istream& is,
bool swap,
757 write (octave::stream& os,
int block_size,
786 virtual void lock (
void);
788 virtual void unlock (
void);
790 virtual bool islocked (
void)
const {
return false; }
860 num_unary_mappers = umap_unknown
890 numeric_assign (
const std::string& type,
891 const std::list<octave_value_list>& idx,
895 { s_curr_print_indent_level = 0; }
898 { s_curr_print_indent_level += 2; }
901 { s_curr_print_indent_level -= 2; }
904 {
return s_curr_print_indent_level; }
906 OCTINTERP_API
void indent (std::ostream& os)
const;
908 OCTINTERP_API
void newline (std::ostream& os)
const;
910 OCTINTERP_API
void reset (
void)
const;
916 octave::refcount<octave_idx_type>
count;
920 OCTINTERP_API
void warn_load (
const char *type)
const;
921 OCTINTERP_API
void warn_save (
const char *type)
const;
925 OCTINTERP_API
void wrong_type_arg_error (
void)
const;
945 m_containing_dynamic_library.delete_later ();
955 OCTAVE_DEPRECATED (8,
"Vsparse_auto_mutate is obsolete and is now always false")
964 const std::
string& who);
Vector representing the dimensions (size) of an Array.
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
bool zero_by_zero(void) const
octave_idx_type ndims(void) const
Number of dimensions.
octave_base_dld_value(const octave_base_dld_value &)=default
octave_base_dld_value(void)=default
~octave_base_dld_value(void)
octave::auto_shlib m_containing_dynamic_library
type_conv_info(type_conv_fcn f=nullptr, int t=-1)
virtual bool is_mex_function(void) const
virtual bool isinteger(void) const
virtual bool is_uint64_type(void) const
virtual ~octave_base_value(void)=default
virtual type_conv_info numeric_conversion_function(void) const
virtual bool isfloat(void) const
virtual type_conv_info numeric_demotion_function(void) const
virtual bool is_real_matrix(void) const
octave_idx_type columns(void) const
octave::refcount< octave_idx_type > count
virtual bool is_classdef_superclass_ref(void) const
void decrement_indent_level(void) const
virtual bool is_classdef_object(void) const
virtual bool is_diag_matrix(void) const
virtual bool is_function(void) const
virtual void short_disp(std::ostream &os) const
static int s_curr_print_indent_level
virtual bool is_user_code(void) const
void increment_indent_level(void) const
virtual bool is_package(void) const
virtual bool issparse(void) const
static bool s_beginning_of_line
virtual bool is_uint16_type(void) const
virtual bool is_constant(void) const
virtual bool is_uint32_type(void) const
virtual bool is_storable(void) const
virtual bool is_user_function(void) const
virtual void erase_subfunctions(void)
int current_print_indent_level(void) const
virtual bool is_string(void) const
virtual octave_base_value * unique_parent_class(const std::string &)
virtual bool is_complex_matrix(void) const
virtual std::size_t byte_size(void) const
virtual bool is_int32_type(void) const
virtual void call_object_destructor(void)
virtual bool isjava(void) const
virtual float float_scalar_value(bool frc_str_conv=false) const
virtual bool is_function_handle(void) const
virtual bool print_as_scalar(void) const
virtual bool is_magic_int(void) const
virtual bool is_true(void) const
virtual bool is_legacy_object(void) const
virtual const void * mex_get_data(void) const
virtual const octave_idx_type * mex_get_ir(void) const
virtual octave_base_value * unique_clone(void)
virtual void assign(const std::string &, const octave_value &)
virtual bool iscellstr(void) const
virtual bool is_uint8_type(void) const
virtual bool is_bool_scalar(void) const
virtual bool is_inline_function(void) const
virtual bool islogical(void) const
virtual bool is_user_script(void) const
bool is_zero_by_zero(void) const
virtual std::string edit_display(const float_display_format &, octave_idx_type, octave_idx_type) const
virtual bool isobject(void) const
virtual bool is_matrix_type(void) const
virtual bool is_complex_scalar(void) const
virtual bool is_bool_matrix(void) const
virtual void maybe_economize(void)
virtual const octave_idx_type * mex_get_jc(void) const
virtual bool is_scalar_type(void) const
void reset_indent_level(void) const
virtual bool is_all_va_args(void) const
virtual bool is_cs_list(void) const
virtual bool is_int16_type(void) const
virtual dim_vector dims(void) const
virtual octave_idx_type numel(void) const
virtual builtin_type_t builtin_type(void) const
virtual bool is_dld_function(void) const
octave_base_value(const octave_base_value &)
virtual bool is_int8_type(void) const
virtual bool isstruct(void) const
virtual octave_base_value * try_narrowing_conversion(void)
octave_idx_type rows(void) const
virtual bool is_double_type(void) const
virtual double scalar_value(bool frc_str_conv=false) const
virtual octave_base_value * find_parent_class(const std::string &)
virtual bool is_char_matrix(void) const
virtual bool is_anonymous_function(void) const
virtual bool is_int64_type(void) const
virtual bool islocked(void) const
virtual bool is_instance_of(const std::string &) const
virtual int ndims(void) const
virtual bool isnull(void) const
virtual bool is_real_scalar(void) const
virtual bool iscomplex(void) const
virtual bool is_perm_matrix(void) const
virtual bool is_classdef_meta(void) const
virtual void break_closure_cycles(const std::shared_ptr< octave::stack_frame > &)
virtual bool is_single_type(void) const
virtual bool is_magic_colon(void) const
virtual bool isreal(void) const
virtual bool isnumeric(void) const
virtual bool is_defined(void) const
virtual bool is_sq_string(void) const
virtual octave_base_value * clone(void) const
virtual bool iscell(void) const
virtual bool is_builtin_function(void) const
virtual bool is_range(void) const
octave::range< double > range_value(void) const
MatrixType matrix_type(void) const
bool isfield(const std::string &field_name) const
OCTINTERP_API octave_user_script * user_script_value(bool silent=false) const
uint64_t uint64_value(bool req_int=false, bool frc_str_conv=false) const
OCTINTERP_API octave_function * function_value(bool silent=false) const
void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
int32NDArray int32_array_value(void) const
boolNDArray bool_array_value(bool warn=false) const
uint16NDArray uint16_array_value(void) const
SparseMatrix sparse_matrix_value(bool frc_str_conv=false) const
bool bool_value(bool warn=false) const
octave_int64 int64_scalar_value(void) const
octave_value convert_to_str_internal(bool pad, bool force, char type) const
OCTINTERP_API octave_value_list list_value(void) const
octave_value subsref(const std::string &type, const std::list< octave_value_list > &idx)
OCTINTERP_API std::string xstring_value(const char *fmt,...) const
charMatrix char_matrix_value(bool frc_str_conv=false) const
octave_uint8 uint8_scalar_value(void) const
DiagMatrix diag_matrix_value(bool force=false) const
bool fast_elem_insert(octave_idx_type n, const octave_value &x)
Assign the n-th element, aka 'val(n) = x'.
octave_uint32 uint32_scalar_value(void) const
int int_value(bool req_int=false, bool frc_str_conv=false) const
void print_with_name(std::ostream &os, const std::string &name) const
octave_idx_type nnz(void) const
OCTINTERP_API bool load_ascii(std::istream &is)
octave::idx_vector index_vector(bool require_integers=false) const
int64_t int64_value(bool req_int=false, bool frc_str_conv=false) const
OCTINTERP_API octave_scalar_map scalar_map_value(void) const
short int short_value(bool req_int=false, bool frc_str_conv=false) const
octave_value permute(const Array< int > &vec, bool inv=false) const
OCTINTERP_API int write(octave::stream &os, int block_size, oct_data_conv::data_type output_type, int skip, octave::mach_info::float_format flt_fmt) const
FloatDiagMatrix float_diag_matrix_value(bool force=false) const
ComplexMatrix complex_matrix_value(bool frc_str_conv=false) const
std::list< std::string > parent_class_name_list(void) const
octave_value dump(void) const
Complex complex_value(bool frc_str_conv=false) const
octave_value as_uint64(void) const
octave_value as_uint16(void) const
FloatComplexDiagMatrix float_complex_diag_matrix_value(bool force=false) const
octave_value as_single(void) const
unsigned short int ushort_value(bool req_int=false, bool frc_str_conv=false) const
bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
octave_value full_value(void) const
octave_value squeeze(void) const
octave_value sort(octave_idx_type dim=0, sortmode mode=ASCENDING) const
void convert_to_row_or_column_vector(void)
ComplexNDArray complex_array_value(bool frc_str_conv=false) const
octave_base_value * empty_clone(void) const
octave_value as_uint32(void) const
octave_int8 int8_scalar_value(void) const
bool save_binary(std::ostream &os, bool save_as_floats)
charNDArray char_array_value(bool frc_str_conv=false) const
octave_int32 int32_scalar_value(void) const
octave_uint16 uint16_scalar_value(void) const
bool save_ascii(std::ostream &os)
Cell cell_value(void) const
FloatComplex float_complex_value(bool frc_str_conv=false) const
octave_idx_type xnumel(const octave_value_list &idx)
int8NDArray int8_array_value(void) const
OCTINTERP_API octave_user_function * user_function_value(bool silent=false) const
OCTINTERP_API octave_user_code * user_code_value(bool silent=false) const
octave_value as_int64(void) const
float float_value(bool frc_str_conv=false) const
int64NDArray int64_array_value(void) const
unsigned long int ulong_value(bool req_int=false, bool frc_str_conv=false) const
uint8NDArray uint8_array_value(void) const
octave_value any(int dim=0) const
octave_value reshape(const dim_vector &dv) const
octave_value as_int16(void) const
octave_value as_uint8(void) const
OCTINTERP_API octave_base_value * clone(void) const
octave_value as_int32(void) const
boolMatrix bool_matrix_value(bool warn=false) const
octave_idx_type nfields(void) const
octave_value fast_elem_extract(octave_idx_type n) const
Extract the n-th element, aka 'val(n)'.
OCTINTERP_API octave_fcn_handle * fcn_handle_value(bool silent=false) const
std::string string_value(bool force=false) const
ComplexDiagMatrix complex_diag_matrix_value(bool force=false) const
int nint_value(bool frc_str_conv=false) const
FloatMatrix float_matrix_value(bool frc_str_conv=false) const
string_vector parent_class_names(void) const
octave_value map(octave_base_value::unary_mapper_t umap) const
octave_idx_type nzmax(void) const
long int long_value(bool req_int=false, bool frc_str_conv=false) const
uint64NDArray uint64_array_value(void) const
string_vector string_vector_value(bool pad=false) const
PermMatrix perm_matrix_value(void) const
sortmode is_sorted_rows(sortmode mode=UNSORTED) const
octave_uint64 uint64_scalar_value(void) const
SparseBoolMatrix sparse_bool_matrix_value(bool warn=false) const
NDArray array_value(bool frc_str_conv=false) const
uint32NDArray uint32_array_value(void) const
octave_value convert_to_str(bool pad=false, bool force=false, char type='\'') const
bool print_name_tag(std::ostream &os, const std::string &name) const
sortmode issorted(sortmode mode=UNSORTED) const
OCTINTERP_API octave_map map_value(void) const
octave_value all(int dim=0) const
std::size_t nparents(void) const
OCTINTERP_API bool load_hdf5(octave_hdf5_id loc_id, const char *name)
FloatComplexNDArray float_complex_array_value(bool frc_str_conv=false) const
octave_value resize(const dim_vector &dv, bool fill=false) const
FloatNDArray float_array_value(bool frc_str_conv=false) const
octave_int16 int16_scalar_value(void) const
mxArray * as_mxArray(bool interleaved=false) const
Array< std::string > cellstr_value(void) const
int16NDArray int16_array_value(void) const
OCTINTERP_API bool load_binary(std::istream &is, bool swap, octave::mach_info::float_format fmt)
OCTINTERP_API octave_value subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
string_vector map_keys(void) const
Matrix matrix_value(bool frc_str_conv=false) const
FloatComplexMatrix float_complex_matrix_value(bool frc_str_conv=false) const
void print(std::ostream &os, bool pr_as_read_syntax=false)
OCTINTERP_API octave_value undef_subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
octave_value diag(octave_idx_type k=0) const
double double_value(bool frc_str_conv=false) const
unsigned int uint_value(bool req_int=false, bool frc_str_conv=false) const
octave_value as_int8(void) const
OCTINTERP_API void print_info(std::ostream &os, const std::string &prefix="") const
dim_vector dims(void) const
SparseComplexMatrix sparse_complex_matrix_value(bool frc_str_conv=false) const
OCTINTERP_API octave_classdef * classdef_object_value(bool silent=false) const
Array< octave_idx_type > sort_rows_idx(sortmode mode=ASCENDING) const
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
octave::idx_vector idx_vector
F77_RET_T const F77_DBLE * x
F77_RET_T const F77_DBLE const F77_DBLE * f
std::complex< double > Complex
std::complex< float > FloatComplex
static double as_double(OCTAVE_TIME_T sec, long usec)
OCTINTERP_API std::string btyp_class_name[]
bool btyp_isnumeric(builtin_type_t btyp)
#define DEF_BTYP_TRAITS(BTYP, CLASS)
bool btyp_isinteger(builtin_type_t btyp)
OCTINTERP_API builtin_type_t btyp_mixed_numeric(builtin_type_t x, builtin_type_t y)
Determine the resulting type for a possible mixed-type operation.
OCTINTERP_API bool called_from_builtin(void)
#define DECLARE_OV_BASE_TYPEID_FUNCTIONS_AND_DATA
bool btyp_isarray(builtin_type_t btyp)
bool btyp_isfloat(builtin_type_t btyp)
OCTINTERP_API octave_value make_idx_args(const std::string &type, const std::list< octave_value_list > &idx, const std::string &who)
OCTINTERP_API bool Vsparse_auto_mutate
OCTINTERP_API type_info & __get_type_info__(void)
static const builtin_type_t btyp
static float_display_format get_edit_display_format(const octave_value &val)