26 #if ! defined (octave_ov_base_h)
27 #define octave_ov_base_h 1
29 #include "octave-config.h"
65 OCTAVE_END_NAMESPACE(
octave)
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 () const { return s_t_id; } \
190 VIRTUAL std::string type_name () const { return s_t_name; } \
191 VIRTUAL std::string class_name () const { return s_c_name; } \
192 static int static_type_id () { return s_t_id; } \
193 static std::string static_type_name () { return s_t_name; } \
194 static std::string static_class_name () { return s_c_name; } \
195 static void register_type (); \
196 static void register_type (octave::type_info&); \
200 static const std::string s_t_name; \
201 static const std::string s_c_name;
203 #define DECLARE_TEMPLATE_OV_TYPEID_SPECIALIZATIONS(cls, type) \
204 template <> void cls<type>::register_type (); \
205 template <> void cls<type>::register_type (octave::type_info&); \
206 template <> int cls<type>::s_t_id; \
207 template <> const std::string cls<type>::s_t_name; \
208 template <> const std::string cls<type>::s_c_name;
216 #define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_INTERNAL(tspec, t, n, c) \
217 tspec int t::s_t_id (-1); \
218 tspec const std::string t::s_t_name (n); \
219 tspec const std::string t::s_c_name (c); \
220 tspec void t::register_type () \
222 octave::type_info& type_info = octave::__get_type_info__ (); \
224 register_type (type_info); \
226 tspec void t::register_type (octave::type_info& ti) \
228 octave_value v = (new t ()); \
229 s_t_id = ti.register_type (t::s_t_name, t::s_c_name, v); \
232 #define DEFINE_TEMPLATE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c) \
233 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_INTERNAL (template <>, t, n, c)
235 #define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c) \
236 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_INTERNAL ( , t, n, c)
255 : m_fcn (
f), m_type_id (t) { }
257 operator type_conv_fcn ()
const {
return m_fcn; }
260 {
return (*m_fcn) (v); }
293 virtual type_conv_info
297 virtual type_conv_info
335 subsref (
const std::string& type,
336 const std::list<octave_value_list>& idx);
339 subsref (
const std::string& type,
340 const std::list<octave_value_list>& idx,
344 subsref (
const std::string& type,
345 const std::list<octave_value_list>& idx,
358 const std::list<octave_value_list>& idx,
367 const std::list<octave_value_list>& idx,
421 virtual bool iscell ()
const {
return false; }
461 virtual bool isjava ()
const {
return false; }
479 virtual bool isfloat ()
const {
return false; }
501 virtual bool isreal ()
const {
return false; }
517 virtual bool is_true ()
const {
return false; }
521 virtual bool isnull ()
const {
return false; }
560 virtual short int short_value (
bool =
false,
bool =
false)
const;
562 virtual unsigned short int ushort_value (
bool =
false,
bool =
false)
const;
564 virtual int int_value (
bool =
false,
bool =
false)
const;
566 virtual unsigned int uint_value (
bool =
false,
bool =
false)
const;
570 virtual long int long_value (
bool =
false,
bool =
false)
const;
572 virtual unsigned long int ulong_value (
bool =
false,
bool =
false)
const;
574 virtual int64_t
int64_value (
bool =
false,
bool =
false)
const;
576 virtual uint64_t
uint64_value (
bool =
false,
bool =
false)
const;
671 virtual std::string
string_value (
bool force =
false)
const;
675 virtual octave::range<double>
range_value ()
const;
685 virtual bool isfield (
const std::string&)
const;
687 virtual std::size_t
nparents ()
const;
717 char type =
'\'')
const;
730 virtual void print (std::ostream& os,
bool pr_as_read_syntax =
false);
733 print_raw (std::ostream& os,
bool pr_as_read_syntax =
false)
const;
740 bool print_padding =
true);
742 virtual void short_disp (std::ostream& os)
const { os <<
"..."; }
750 virtual void print_info (std::ostream& os,
const std::string& prefix)
const;
756 virtual bool save_binary (std::ostream& os,
bool save_as_floats);
758 virtual bool load_binary (std::istream& is,
bool swap,
768 write (octave::stream& os,
int block_size,
797 virtual void lock ();
877 num_unary_mappers = umap_unknown
907 numeric_assign (
const std::string& type,
908 const std::list<octave_value_list>& idx,
912 { s_curr_print_indent_level = 0; }
915 { s_curr_print_indent_level += 2; }
918 { s_curr_print_indent_level -= 2; }
921 {
return s_curr_print_indent_level; }
923 OCTINTERP_API
void indent (std::ostream& os)
const;
925 OCTINTERP_API
void newline (std::ostream& os)
const;
927 OCTINTERP_API
void reset ()
const;
937 OCTAVE_DEPRECATED (9,
"use octave_base_value::m_count instead")
942 OCTINTERP_API
void warn_load (const
char *type) const;
943 OCTINTERP_API
void warn_save (const
char *type) const;
947 OCTINTERP_API
void wrong_type_arg_error () const;
951 static
int s_curr_print_indent_level;
952 static
bool s_beginning_of_line;
967 m_containing_dynamic_library.delete_later ();
974 octave::auto_shlib m_containing_dynamic_library;
977 OCTAVE_DEPRECATED (8,
"Vsparse_auto_mutate is obsolete and is now always false")
986 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.
octave_idx_type ndims() const
Number of dimensions.
bool zero_by_zero() const
octave_base_dld_value()=default
octave_base_dld_value(const octave_base_dld_value &)=default
type_conv_info(type_conv_fcn f=nullptr, int t=-1)
virtual bool islocked() const
virtual bool is_uint32_type() const
octave_idx_type rows() const
virtual bool is_uint8_type() const
virtual bool is_function_handle() const
virtual bool is_mex_function() const
virtual bool is_classdef_superclass_ref() const
virtual bool is_package() const
octave_idx_type columns() const
virtual void short_disp(std::ostream &os) const
virtual octave_idx_type numel() const
virtual octave_base_value * clone() const
virtual bool is_scalar_type() const
virtual bool is_double_type() const
virtual builtin_type_t builtin_type() const
virtual bool is_range() const
virtual bool islogical() const
virtual bool is_uint16_type() const
virtual int ndims() const
virtual bool is_constant() const
void increment_indent_level() const
virtual bool is_full_num_matrix() const
int current_print_indent_level() const
virtual bool is_maybe_function() const
virtual bool is_int16_type() const
bool is_zero_by_zero() const
virtual bool isreal() const
virtual const void * mex_get_data() const
virtual octave_base_value * unique_parent_class(const std::string &)
virtual bool is_real_matrix() const
virtual type_conv_info numeric_demotion_function() const
virtual bool is_true() const
virtual bool is_legacy_object() const
virtual bool is_magic_int() const
virtual const octave_idx_type * mex_get_jc() const
virtual float float_scalar_value(bool frc_str_conv=false) const
virtual bool is_anonymous_function() const
virtual bool is_char_matrix() const
virtual bool is_user_code() const
virtual bool is_classdef_meta() const
virtual bool iscell() const
virtual void maybe_economize()
virtual bool isobject() const
virtual octave_base_value * unique_clone()
virtual bool is_user_function() const
virtual bool is_function() const
virtual void assign(const std::string &, const octave_value &)
virtual bool isstruct() const
virtual bool issparse() const
virtual void maybe_call_dtor()
virtual bool isfloat() const
virtual std::string edit_display(const float_display_format &, octave_idx_type, octave_idx_type) const
virtual bool iscomplex() const
void reset_indent_level() const
virtual bool is_real_scalar() const
virtual bool iscellstr() const
octave::refcount< octave_idx_type > m_count
virtual type_conv_info numeric_conversion_function() const
virtual bool is_bool_matrix() const
virtual bool is_int64_type() const
virtual bool is_classdef_object() const
virtual bool is_perm_matrix() const
virtual bool is_bool_scalar() const
virtual octave_function * get_cached_fcn(const octave_value_list &)
virtual bool is_string() const
virtual bool is_user_script() const
virtual dim_vector dims() const
virtual octave_function * get_cached_fcn(void *, void *)
virtual bool is_diag_matrix() const
virtual bool isnull() const
virtual bool is_builtin_function() const
virtual ~octave_base_value()=default
virtual bool is_magic_colon() const
virtual bool is_sq_string() const
void decrement_indent_level() const
octave_base_value(const octave_base_value &)
virtual bool isnumeric() const
virtual bool print_as_scalar() const
virtual std::size_t byte_size() const
virtual bool is_dld_function() const
virtual bool isjava() const
virtual octave_base_value * try_narrowing_conversion()
virtual double scalar_value(bool frc_str_conv=false) const
virtual octave_base_value * find_parent_class(const std::string &)
virtual bool is_int8_type() const
virtual void erase_subfunctions()
virtual bool is_uint64_type() const
virtual bool is_inline_function() const
virtual bool is_instance_of(const std::string &) const
virtual bool is_int32_type() const
virtual bool is_storable() const
virtual bool is_defined() const
virtual bool is_function_cache() const
virtual void call_object_destructor()
virtual bool is_single_type() const
virtual void break_closure_cycles(const std::shared_ptr< octave::stack_frame > &)
virtual bool is_complex_matrix() const
virtual bool has_function_cache() const
virtual bool is_all_va_args() const
virtual const octave_idx_type * mex_get_ir() const
virtual bool isinteger() const
virtual bool is_cs_list() const
virtual bool is_complex_scalar() const
virtual bool is_matrix_type() const
bool isfield(const std::string &field_name) const
octave_value as_uint64() const
octave_value_list list_value() const
uint64_t uint64_value(bool req_int=false, bool frc_str_conv=false) const
octave_int8 int8_scalar_value() const
void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
boolNDArray bool_array_value(bool warn=false) const
SparseMatrix sparse_matrix_value(bool frc_str_conv=false) const
octave_value simple_subsasgn(char type, octave_value_list &idx, const octave_value &rhs)
octave_uint64 uint64_scalar_value() const
bool bool_value(bool warn=false) const
octave_base_value * clone() const
octave_value convert_to_str_internal(bool pad, bool force, char type) const
octave_value subsref(const std::string &type, const std::list< octave_value_list > &idx)
octave_uint16 uint16_scalar_value() const
charMatrix char_matrix_value(bool frc_str_conv=false) const
octave_value as_int32() const
int32NDArray int32_array_value() const
uint16NDArray uint16_array_value() 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_value as_int8() const
int16NDArray int16_array_value() const
octave_user_function * user_function_value(bool silent=false) 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
int8NDArray int8_array_value() const
octave_int64 int64_scalar_value() const
octave::idx_vector index_vector(bool require_integers=false) const
int64_t int64_value(bool req_int=false, bool frc_str_conv=false) const
octave::range< double > range_value() const
short int short_value(bool req_int=false, bool frc_str_conv=false) const
octave_scalar_map scalar_map_value() const
octave_idx_type nzmax() const
octave_value permute(const Array< int > &vec, bool inv=false) const
FloatDiagMatrix float_diag_matrix_value(bool force=false) const
ComplexMatrix complex_matrix_value(bool frc_str_conv=false) const
octave_value_list simple_subsref(char type, octave_value_list &idx, int nargout)
bool load_binary(std::istream &is, bool swap, octave::mach_info::float_format fmt)
octave_value dump() const
Complex complex_value(bool frc_str_conv=false) const
FloatComplexDiagMatrix float_complex_diag_matrix_value(bool force=false) const
octave_value undef_subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
octave_value as_uint8() 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)
MatrixType matrix_type() const
octave_value sort(octave_idx_type dim=0, sortmode mode=ASCENDING) const
octave_value as_int16() const
octave_user_code * user_code_value(bool silent=false) const
ComplexNDArray complex_array_value(bool frc_str_conv=false) const
string_vector parent_class_names() const
octave_value as_single() const
bool save_binary(std::ostream &os, bool save_as_floats)
charNDArray char_array_value(bool frc_str_conv=false) const
void make_storable_value()
octave_uint32 uint32_scalar_value() const
bool save_ascii(std::ostream &os)
string_vector map_keys() const
FloatComplex float_complex_value(bool frc_str_conv=false) const
std::size_t nparents() const
octave_idx_type xnumel(const octave_value_list &idx)
octave_value storable_value() const
float_display_format get_edit_display_format() const
octave_value as_uint32() const
uint64NDArray uint64_array_value() const
float float_value(bool frc_str_conv=false) const
bool load_hdf5(octave_hdf5_id loc_id, const char *name)
octave_function * function_value(bool silent=false) const
unsigned long int ulong_value(bool req_int=false, bool frc_str_conv=false) const
octave_value any(int dim=0) const
octave_idx_type nfields() const
octave_value reshape(const dim_vector &dv) const
bool load_ascii(std::istream &is)
octave_map map_value() const
void convert_to_row_or_column_vector()
octave_fcn_handle * fcn_handle_value(bool silent=false) const
boolMatrix bool_matrix_value(bool warn=false) const
octave_idx_type nnz() const
octave_value fast_elem_extract(octave_idx_type n) const
Extract the n-th element, aka 'val(n)'.
std::string string_value(bool force=false) const
ComplexDiagMatrix complex_diag_matrix_value(bool force=false) const
octave_uint8 uint8_scalar_value() const
int nint_value(bool frc_str_conv=false) const
FloatMatrix float_matrix_value(bool frc_str_conv=false) const
void print_info(std::ostream &os, const std::string &prefix="") const
octave_value map(octave_base_value::unary_mapper_t umap) const
octave_int16 int16_scalar_value() const
octave_base_value * empty_clone() const
long int long_value(bool req_int=false, bool frc_str_conv=false) const
string_vector string_vector_value(bool pad=false) const
sortmode is_sorted_rows(sortmode mode=UNSORTED) const
octave_classdef * classdef_object_value(bool silent=false) const
int64NDArray int64_array_value() const
SparseBoolMatrix sparse_bool_matrix_value(bool warn=false) const
NDArray array_value(bool frc_str_conv=false) const
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
octave_value as_uint16() const
octave_value as_int64() const
octave_value as_double() const
octave_value convert_to_str(bool pad=false, bool force=false, char type='\'') const
uint8NDArray uint8_array_value() const
bool print_name_tag(std::ostream &os, const std::string &name) const
octave_value full_value() const
sortmode issorted(sortmode mode=UNSORTED) const
octave_value all(int dim=0) const
std::string xstring_value(const char *fmt,...) const
octave_int32 int32_scalar_value() const
FloatComplexNDArray float_complex_array_value(bool frc_str_conv=false) const
octave_value resize(const dim_vector &dv, bool fill=false) const
std::list< std::string > parent_class_name_list() const
FloatNDArray float_array_value(bool frc_str_conv=false) const
mxArray * as_mxArray(bool interleaved=false) const
uint32NDArray uint32_array_value() 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)
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
PermMatrix perm_matrix_value() const
octave_value as_double_or_copy() const
SparseComplexMatrix sparse_complex_matrix_value(bool frc_str_conv=false) const
octave_value subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
octave_user_script * user_script_value(bool silent=false) const
Array< std::string > cellstr_value() const
Array< octave_idx_type > sort_rows_idx(sortmode mode=ASCENDING) const
octave_value squeeze() 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
bool btyp_isnumeric(builtin_type_t btyp)
#define DEF_BTYP_TRAITS(BTYP, CLASS)
bool btyp_isinteger(builtin_type_t btyp)
#define DECLARE_OV_BASE_TYPEID_FUNCTIONS_AND_DATA
octave_value make_idx_args(const std::string &type, const std::list< octave_value_list > &idx, const std::string &who)
type_info & __get_type_info__()
bool btyp_isarray(builtin_type_t btyp)
std::string btyp_class_name[]
bool btyp_isfloat(builtin_type_t btyp)
builtin_type_t btyp_mixed_numeric(builtin_type_t x, builtin_type_t y)
Determine the resulting type for a possible mixed-type operation.
bool called_from_builtin()
static const builtin_type_t btyp