Audio Processing Framework (APF) version 0.5.0
Functions
apf::mex Namespace Reference

Helper functions for creating MEX files. More...

Functions

bool convert (const mxArray *in, std::string &out)
 Convert mxArray to std::string. More...
 
bool convert (const mxArray *in, double &out)
 Convert mxArray to double. More...
 
bool convert (const mxArray *in, int &out)
 Convert mxArray to int. More...
 
bool convert (const mxArray *in, long int &out)
 Convert mxArray to long int More...
 
bool convert (const mxArray *in, bool &out)
 Convert mxArray to bool. More...
 
bool convert (const mxArray *in, size_t &out)
 Convert mxArray to size_t. More...
 
bool convert (const mxArray *in, std::map< std::string, std::string > &out)
 Convert mxArray to a std::map of std::strings. More...
 
bool convert (const mxArray *in, std::vector< std::string > &out)
 Convert mxArray to a std::vector of std::strings. More...
 
template<typename T >
bool next_arg (int &n, const mxArray **&p, T &data)
 Get next argument, converted to T. More...
 
template<typename T >
bool next_optarg (int &n, const mxArray **&p, T &data)
 Get next optional argument, converted to T. More...
 
template<typename T >
void next_arg (int &n, const mxArray **&p, T &data, const std::string &error)
 Get next argument, converted to T. More...
 
template<typename T >
void next_optarg (int &n, const mxArray **&p, T &data, const std::string &error)
 Get next optional argument, converted to T. More...
 

Detailed Description

Helper functions for creating MEX files.

Function Documentation

◆ convert() [1/8]

bool apf::mex::convert ( const mxArray *  in,
std::string &  out 
)

Convert mxArray to std::string.

Definition at line 112 of file mextools.h.

Referenced by convert().

◆ convert() [2/8]

bool apf::mex::convert ( const mxArray *  in,
double &  out 
)

Convert mxArray to double.

Definition at line 124 of file mextools.h.

◆ convert() [3/8]

bool apf::mex::convert ( const mxArray *  in,
int &  out 
)

Convert mxArray to int.

Definition at line 133 of file mextools.h.

◆ convert() [4/8]

bool apf::mex::convert ( const mxArray *  in,
long int &  out 
)

Convert mxArray to long int

Definition at line 144 of file mextools.h.

◆ convert() [5/8]

bool apf::mex::convert ( const mxArray *  in,
bool &  out 
)

Convert mxArray to bool.

Definition at line 155 of file mextools.h.

◆ convert() [6/8]

bool apf::mex::convert ( const mxArray *  in,
size_t &  out 
)

Convert mxArray to size_t.

Definition at line 164 of file mextools.h.

◆ convert() [7/8]

bool apf::mex::convert ( const mxArray *  in,
std::map< std::string, std::string > &  out 
)

Convert mxArray to a std::map of std::strings.

This expects a scalar structure! Values must be real scalar numbers or strings!

Warning
In case of a conversion error, the map may be partially filled!

Definition at line 179 of file mextools.h.

References apf::str::A2S(), and convert().

◆ convert() [8/8]

bool apf::mex::convert ( const mxArray *  in,
std::vector< std::string > &  out 
)

Convert mxArray to a std::vector of std::strings.

This expects a cell array of strings!

Warning
In case of a conversion error, the vector may be partly filled!

Definition at line 217 of file mextools.h.

References convert().

◆ next_arg() [1/2]

template<typename T >
bool apf::mex::next_arg ( int &  n,
const mxArray **&  p,
T &  data 
)

Get next argument, converted to T.

Parameters
[in,out]nNumber of arguments, typically nrhs
[in,out]pPointer to arguments, typically prhs
[out]dataIf conversion is successful, the result is stored here
Returns
true if argument was available and if conversion was successful
Postcondition
If conversion was successful, n is decremented and p is incremented. If not, n and p are unchanged, data may be corrupted.

Definition at line 265 of file mextools.h.

Referenced by next_arg().

◆ next_optarg() [1/2]

template<typename T >
bool apf::mex::next_optarg ( int &  n,
const mxArray **&  p,
T &  data 
)

Get next optional argument, converted to T.

Parameters
[in,out]dataDefault value. If there is an argument left and if the conversion is successful, the result is stored here.
Returns
true if no argument available or if conversion was successful
Postcondition
If an argument was available and its conversion was successful, the result is stored in data, n is decremented and p is incremented. If the conversion failed, n and p are unchanged, data may be corrupted. If there was no argument available, n, p and data are unchanged.
See also
next_arg()

Definition at line 281 of file mextools.h.

Referenced by next_optarg().

◆ next_arg() [2/2]

template<typename T >
void apf::mex::next_arg ( int &  n,
const mxArray **&  p,
T &  data,
const std::string &  error 
)

Get next argument, converted to T.

See also
next_arg()
Parameters
errorMessage to be displayed on error

Definition at line 290 of file mextools.h.

References next_arg().

◆ next_optarg() [2/2]

template<typename T >
void apf::mex::next_optarg ( int &  n,
const mxArray **&  p,
T &  data,
const std::string &  error 
)

Get next optional argument, converted to T.

See also
next_optarg()
Parameters
errorMessage to be displayed on error

Definition at line 299 of file mextools.h.

References next_optarg().