49 #if ! defined (octave_mxarray_h)
50 #define octave_mxarray_h 1
52 #include "octave-config.h"
56 #if ! defined (MXARRAY_TYPEDEFS_ONLY)
64 #define DO_MUTABLE_METHOD(RET_T, METHOD_CALL) \
65 RET_T retval = m_rep->METHOD_CALL; \
67 if (m_rep->mutation_needed ()) \
70 retval = m_rep->METHOD_CALL; \
75 #define DO_VOID_MUTABLE_METHOD(METHOD_CALL) \
78 if (m_rep->mutation_needed ()) \
103 virtual
mxArray * as_mxArray ()
const {
return nullptr; }
117 const char *cname = get_class_name ();
119 if (cname && name_arg)
120 retval = !
strcmp (cname, name_arg);
159 return is_logical () && get_number_of_elements () == 1;
204 err_invalid_type (
"set_property");
209 err_invalid_type (
"get_cell");
297 return (m_interleaved
298 ? is_complex () ? 2 * size : size
304 error (
"%s: invalid type for mxArray::%s", get_class_name (), op);
338 OCTINTERP_API
mxArray (
bool interleaved,
const char *str);
340 OCTINTERP_API
mxArray (
bool interleaved,
mwSize m,
const char **str);
346 int num_keys,
const char **keys);
370 retval =
new mxArray (new_rep, m_name);
376 OCTAVE_DISABLE_CONSTRUCT_COPY_MOVE (
mxArray)
450 OCTINTERP_API
void set_name (
const char *name);
601 static OCTINTERP_API
void *
malloc (std::size_t
n);
603 static OCTINTERP_API
void *
calloc (std::size_t
n, std::size_t t);
605 static OCTINTERP_API
void *
alloc (
bool init, std::size_t
n, std::size_t t);
609 char *retval =
nullptr;
618 strcpy (retval, str);
650 create_rep (
bool interleaved,
mxClassID id,
double val);
656 create_rep (
bool interleaved,
const char *str);
659 create_rep (
bool interleaved,
mwSize m,
const char **str);
665 OCTINTERP_API
void maybe_mutate ()
const;
675 #undef DO_MUTABLE_METHOD
676 #undef DO_VOID_MUTABLE_METHOD
Vector representing the dimensions (size) of an Array.
virtual int set_int8s(mxInt8 *data)=0
virtual int set_complex_singles(mxComplexSingle *data)=0
OCTAVE_NORETURN void err_invalid_type(const char *op) const
virtual mxInt8 * get_int8s() const =0
virtual bool is_octave_value() const
virtual void set_n(mwSize n)=0
virtual void set_cell(mwIndex idx, mxArray *val)=0
virtual int add_field(const char *key)=0
virtual mxComplexDouble * get_complex_doubles() const =0
virtual mwIndex * get_jc() const =0
virtual void set_nzmax(mwSize nzmax)=0
virtual int set_uint16s(mxUint16 *data)=0
virtual mxDouble * get_doubles() const =0
virtual int is_logical() const =0
virtual int is_uint64() const =0
virtual char * array_to_string() const =0
virtual int set_uint64s(mxUint64 *data)=0
virtual int get_string(char *buf, mwSize buflen) const =0
virtual bool is_scalar() const =0
virtual mxSingle * get_singles() const =0
virtual mwIndex calc_single_subscript(mwSize nsubs, mwIndex *subs) const =0
virtual mxArray * get_cell(mwIndex) const
virtual int set_doubles(mxDouble *data)=0
virtual int set_int64s(mxInt64 *data)=0
virtual int is_complex() const =0
virtual mxComplexSingle * get_complex_singles() const =0
virtual octave_value as_octave_value() const =0
virtual void set_imag_data(void *pi)=0
virtual int is_numeric() const =0
virtual mxArray * get_field_by_number(mwIndex index, int key_num) const =0
virtual int set_int16s(mxInt16 *data)=0
virtual int is_double() const =0
virtual mwSize * get_dimensions() const =0
virtual int set_singles(mxSingle *data)=0
virtual int is_char() const =0
virtual void set_m(mwSize m)=0
virtual void set_data(void *pr)=0
virtual int is_logical_scalar_true() const =0
virtual void * get_data() const =0
virtual mxInt16 * get_int16s() const =0
virtual int is_uint16() const =0
virtual double get_scalar() const =0
virtual int is_class(const char *name_arg) const
virtual mwSize get_nzmax() const =0
std::size_t get_numeric_element_size(std::size_t size) const
virtual mxArray_base * dup() const =0
virtual int iscell() const =0
virtual void set_property(mwIndex, const char *, const mxArray *)
virtual int set_complex_doubles(mxComplexDouble *data)=0
virtual void * get_imag_data() const =0
virtual int isempty() const =0
virtual mwSize get_number_of_elements() const =0
virtual int is_logical_scalar() const
virtual mxArray * as_mxArray() const
virtual void set_jc(mwIndex *jc)=0
virtual std::size_t get_element_size() const =0
virtual int set_uint32s(mxUint32 *data)=0
virtual mxUint64 * get_uint64s() const =0
virtual mxUint8 * get_uint8s() const =0
virtual int set_uint8s(mxUint8 *data)=0
virtual bool mutation_needed() const
virtual mxInt32 * get_int32s() const =0
virtual mwIndex * get_ir() const =0
virtual int set_dimensions(mwSize *dims_arg, mwSize ndims_arg)=0
virtual mxUint16 * get_uint16s() const =0
virtual int is_int16() const =0
virtual int is_single() const =0
virtual void set_class_name(const char *name_arg)=0
virtual mxUint32 * get_uint32s() const =0
virtual mxArray * mutate() const
virtual mwSize get_number_of_dimensions() const =0
virtual int is_function_handle() const =0
virtual int is_uint8() const =0
virtual mwSize get_m() const =0
virtual int is_int8() const =0
virtual int is_int32() const =0
virtual int get_number_of_fields() const =0
virtual void set_ir(mwIndex *ir)=0
virtual void remove_field(int key_num)=0
virtual int is_uint32() const =0
virtual mxArray * get_property(mwIndex, const char *) const
virtual const char * get_field_name_by_number(int key_num) const =0
virtual int is_int64() const =0
virtual void set_field_by_number(mwIndex index, int key_num, mxArray *val)=0
virtual const char * get_class_name() const =0
virtual int is_struct() const =0
virtual mxInt64 * get_int64s() const =0
virtual int get_field_number(const char *key) const =0
virtual mwSize get_n() const =0
virtual int set_int32s(mxInt32 *data)=0
virtual ~mxArray_base()=default
virtual int is_sparse() const =0
virtual mxClassID get_class_id() const =0
int set_uint8s(mxUint8 *data)
int set_complex_singles(mxComplexSingle *data)
mxUint8 * get_uint8s() const
int is_logical_scalar() const
int set_uint32s(mxUint32 *data)
int get_number_of_fields() const
mxInt64 * get_int64s() const
mxUint64 * get_uint64s() const
double get_scalar() const
void set_name(const char *name)
char * array_to_string() const
void * get_imag_data() const
mwSize get_number_of_dimensions() const
bool mutation_needed() const
void set_property(mwIndex idx, const char *pname, const mxArray *pval)
std::size_t get_element_size() const
int set_singles(mxSingle *data)
mwSize * get_dimensions() const
const char * get_class_name() const
int set_uint16s(mxUint16 *data)
static void * alloc(bool init, std::size_t n, std::size_t t)
mxArray * get_property(mwIndex idx, const char *pname) const
int is_function_handle() const
mxInt16 * get_int16s() const
int set_uint64s(mxUint64 *data)
mwIndex calc_single_subscript(mwSize nsubs, mwIndex *subs) const
mwSize get_number_of_elements() const
int set_dimensions(mwSize *dims_arg, mwSize ndims_arg)
mxUint16 * get_uint16s() const
static char * strsave(const char *str)
mxComplexSingle * get_complex_singles() const
static void * calloc(std::size_t n, std::size_t t)
mxArray(bool interleaved, const octave_value &ov)
int set_complex_doubles(mxComplexDouble *data)
int get_field_number(const char *key) const
mxArray * get_field_by_number(mwIndex index, int key_num) const
int add_field(const char *key)
mxInt32 * get_int32s() const
int set_int32s(mxInt32 *data)
int set_int64s(mxInt64 *data)
int set_doubles(mxDouble *data)
void set_nzmax(mwSize nzmax)
int is_logical_scalar_true() const
bool is_octave_value() const
octave_value as_octave_value() const
int set_int16s(mxInt16 *data)
mxClassID get_class_id() const
mxSingle * get_singles() const
const char * get_field_name_by_number(int key_num) const
mxUint32 * get_uint32s() const
int get_string(char *buf, mwSize buflen) const
int is_class(const char *name_arg) const
int set_int8s(mxInt8 *data)
void set_class_name(const char *name_arg)
mxDouble * get_doubles() const
void set_field_by_number(mwIndex index, int key_num, mxArray *val)
void set_cell(mwIndex idx, mxArray *val)
mxArray * get_cell(mwIndex idx) const
mxComplexDouble * get_complex_doubles() const
static void * malloc(std::size_t n)
void set_imag_data(void *pi)
mxInt8 * get_int8s() const
void remove_field(int key_num)
const char * get_name() const
void() error(const char *fmt,...)
#define DO_VOID_MUTABLE_METHOD(METHOD_CALL)
#define DO_MUTABLE_METHOD(RET_T, METHOD_CALL)
T::size_type strlen(const typename T::value_type *str)
bool strcmp(const T &str_a, const T &str_b)
Octave string utility functions.