UtilsLite
Utilities for C++ programming
Loading...
Searching...
No Matches
mex_utils.hxx File Reference
#include "mex.h"
#include <map>
#include <string>
#include <string_view>
#include <cstring>
#include <vector>
#include <cstdint>
#include <typeinfo>

Go to the source code of this file.

Classes

class  Utils::mex_class_handle< base >
 A class template that manages a C++ object for use with MATLAB. More...
 

Namespaces

namespace  Utils
 

Macros

#define CLASS_HANDLE_SIGNATURE   0xFF00F0A5
 
#define arg_in_0   prhs[0]
 
#define arg_in_1   prhs[1]
 
#define arg_in_2   prhs[2]
 
#define arg_in_3   prhs[3]
 
#define arg_in_4   prhs[4]
 
#define arg_in_5   prhs[5]
 
#define arg_in_6   prhs[6]
 
#define arg_in_7   prhs[7]
 
#define arg_in_8   prhs[8]
 
#define arg_in_9   prhs[9]
 
#define arg_in_10   prhs[10]
 
#define arg_in_11   prhs[11]
 
#define arg_in_12   prhs[12]
 
#define arg_in_13   prhs[13]
 
#define arg_in_14   prhs[14]
 
#define arg_in_15   prhs[15]
 
#define arg_in_16   prhs[16]
 
#define arg_in_17   prhs[17]
 
#define arg_in_18   prhs[18]
 
#define arg_in_19   prhs[19]
 
#define arg_out_0   plhs[0]
 
#define arg_out_1   plhs[1]
 
#define arg_out_2   plhs[2]
 
#define arg_out_3   plhs[3]
 
#define arg_out_4   plhs[4]
 
#define arg_out_5   plhs[5]
 
#define arg_out_6   plhs[6]
 
#define arg_out_7   plhs[7]
 
#define arg_out_8   plhs[8]
 
#define arg_out_9   plhs[9]
 
#define arg_out_10   plhs[10]
 
#define arg_out_11   plhs[11]
 
#define arg_out_12   plhs[12]
 
#define arg_out_13   plhs[13]
 
#define arg_out_14   plhs[14]
 
#define arg_out_15   plhs[14]
 
#define arg_out_16   plhs[16]
 
#define arg_out_17   plhs[17]
 
#define arg_out_18   plhs[18]
 
#define arg_out_19   plhs[19]
 
#define UTILS_MEX_ASSERT0(COND, MSG)
 
#define UTILS_MEX_ASSERT(COND, FMT, ...)
 

Functions

void Utils::mex_error_message (string_view msg)
 Sends an error message to MATLAB.
 
bool Utils::mex_is_scalar (mxArray const *arg, string_view msg)
 Checks if the input argument is a scalar.
 
double Utils::mex_get_scalar_value (mxArray const *arg, string_view msg)
 Gets the scalar value from the input argument.
 
bool Utils::mex_get_bool (mxArray const *arg, string_view msg)
 Gets a boolean value from the input argument.
 
int64_t Utils::mex_get_int64 (mxArray const *arg, string_view msg)
 Gets a 64-bit integer value from the input argument.
 
double const * Utils::mex_vector_pointer (mxArray const *arg, mwSize &sz, string_view msg)
 Gets a pointer to a vector from the input argument.
 
double const * Utils::mex_matrix_pointer (mxArray const *arg, mwSize &nr, mwSize &nc, string_view msg)
 Gets a pointer to a matrix from the input argument.
 
void Utils::mex_set_scalar_value (mxArray *&arg, double value)
 Sets a scalar value in the output argument.
 
void Utils::mex_set_scalar_int32 (mxArray *&arg, int32_t value)
 Sets a scalar integer value in the output argument.
 
void Utils::mex_set_scalar_int64 (mxArray *&arg, int64_t value)
 Sets a scalar 64-bit integer value in the output argument.
 
void Utils::mex_set_scalar_bool (mxArray *&arg, bool value)
 Sets a boolean value in the output argument.
 
int32_t * Utils::mex_create_matrix_int32 (mxArray *&arg, mwSize nrow, mwSize ncol)
 Creates a numeric matrix of type int32 and returns a pointer to its data.
 
int64_t * Utils::mex_create_matrix_int64 (mxArray *&arg, mwSize nrow, mwSize ncol)
 Creates a numeric matrix of type int64 and returns a pointer to its data.
 
double * Utils::mex_create_matrix_value (mxArray *&arg, mwSize nrow, mwSize ncol)
 Creates a numeric matrix of type double and returns a pointer to its data.
 
template<typename R, typename I>
int Utils::mex_create_sparse_matrix (size_t nnz, size_t nrows, size_t ncols, I i_rows[], I j_cols[], R vals[], mxArray *arg_out[])
 Creates a sparse matrix in MATLAB format.
 
void Utils::mex_create_string_cell_array (mxArray *&arg, vector< string > const &str_vec)
 Creates a MATLAB cell array and fills it with a vector of C++ strings.
 
template<typename base>
mxArray * Utils::mex_convert_ptr_to_mx (base *ptr)
 Converts a pointer to a mex_class_handle into a MATLAB mxArray.
 
template<typename base>
mex_class_handle< base > * Utils::mex_convert_mx_to_handle_ptr (mxArray const *in)
 Converts a MATLAB mxArray back to a mex_class_handle pointer.
 
template<typename base>
base * Utils::mex_convert_mx_to_ptr (mxArray const *in)
 Converts a MATLAB mxArray to a pointer of the wrapped C++ object.
 
template<typename base>
void Utils::mex_destroy_object (mxArray const *&in)
 Destroys the object wrapped by the mex_class_handle.
 

Macro Definition Documentation

◆ arg_in_0

#define arg_in_0   prhs[0]

◆ arg_in_1

#define arg_in_1   prhs[1]

◆ arg_in_10

#define arg_in_10   prhs[10]

◆ arg_in_11

#define arg_in_11   prhs[11]

◆ arg_in_12

#define arg_in_12   prhs[12]

◆ arg_in_13

#define arg_in_13   prhs[13]

◆ arg_in_14

#define arg_in_14   prhs[14]

◆ arg_in_15

#define arg_in_15   prhs[15]

◆ arg_in_16

#define arg_in_16   prhs[16]

◆ arg_in_17

#define arg_in_17   prhs[17]

◆ arg_in_18

#define arg_in_18   prhs[18]

◆ arg_in_19

#define arg_in_19   prhs[19]

◆ arg_in_2

#define arg_in_2   prhs[2]

◆ arg_in_3

#define arg_in_3   prhs[3]

◆ arg_in_4

#define arg_in_4   prhs[4]

◆ arg_in_5

#define arg_in_5   prhs[5]

◆ arg_in_6

#define arg_in_6   prhs[6]

◆ arg_in_7

#define arg_in_7   prhs[7]

◆ arg_in_8

#define arg_in_8   prhs[8]

◆ arg_in_9

#define arg_in_9   prhs[9]

◆ arg_out_0

#define arg_out_0   plhs[0]

◆ arg_out_1

#define arg_out_1   plhs[1]

◆ arg_out_10

#define arg_out_10   plhs[10]

◆ arg_out_11

#define arg_out_11   plhs[11]

◆ arg_out_12

#define arg_out_12   plhs[12]

◆ arg_out_13

#define arg_out_13   plhs[13]

◆ arg_out_14

#define arg_out_14   plhs[14]

◆ arg_out_15

#define arg_out_15   plhs[14]

◆ arg_out_16

#define arg_out_16   plhs[16]

◆ arg_out_17

#define arg_out_17   plhs[17]

◆ arg_out_18

#define arg_out_18   plhs[18]

◆ arg_out_19

#define arg_out_19   plhs[19]

◆ arg_out_2

#define arg_out_2   plhs[2]

◆ arg_out_3

#define arg_out_3   plhs[3]

◆ arg_out_4

#define arg_out_4   plhs[4]

◆ arg_out_5

#define arg_out_5   plhs[5]

◆ arg_out_6

#define arg_out_6   plhs[6]

◆ arg_out_7

#define arg_out_7   plhs[7]

◆ arg_out_8

#define arg_out_8   plhs[8]

◆ arg_out_9

#define arg_out_9   plhs[9]

◆ CLASS_HANDLE_SIGNATURE

#define CLASS_HANDLE_SIGNATURE   0xFF00F0A5

◆ UTILS_MEX_ASSERT

#define UTILS_MEX_ASSERT ( COND,
FMT,
... )
Value:
UTILS_MEX_ASSERT0( COND, fmt::format( FMT,__VA_ARGS__) )
#define UTILS_MEX_ASSERT0(COND, MSG)
Definition mex_utils.hxx:75

◆ UTILS_MEX_ASSERT0

#define UTILS_MEX_ASSERT0 ( COND,
MSG )
Value:
if ( !(COND) ) Utils::mex_error_message( MSG )
void mex_error_message(string_view msg)
Sends an error message to MATLAB.
Definition mex_utils.hxx:98