C++ MEX Development Utilities
Find the full descriptions and the latest files on GitHub @ https://github.com/hokiedsp/matlab-mexutils
This repo contains various C++ header files that are useful in developing C++ MEX functions and also serves to show how to set up CMake to build MEX functions.
C++ Header Files:
* include/mexObjectHandler.h
This file defines 2 main templates: mexObjectHandle class and mexObjectHandler() function.
- mexObjectHandle is an adoptation of Oliver Woodfords' MATLAB class wrapper:
https://www.mathworks.com/matlabcentral/fileexchange/38964
The main difference is that mexObjectHandle manages the instance of wrapped class rather than Oliver's managing the pointer to a wrapped class object.
- mexObjectHandler() is an all-in-one template function to be called in mexFunction() to create a MEX backend to a MATLAB class. This function makes mexObjectHandle completely transparent to the developer. See documentation on GitHub for details.
* include/mexRuntimeError.h defines a custom runtime error based on std::runtime_error to include "id" field so mexErrMsgIdAndTxt() can be called in the catch block.
* include/mexGetString.h converts char string or scalar cellstr mxArray to std::string. Only single-byte encoding is supported.
* include/mexAllocator.h is a custom C++ allocator, which wraps mxMalloc, mxRealloc, and mxFree. It is useful to develop a Matlab-independent template class which must dynamically allocate memory internally and return the data to Matlab (avoiding memcpy). This allocator should only be used to allocate simple data types.
These header files have been developed only in Windows (MSVC+VSCode+Ninja+CMake). Please let me know if there are any issues, especially on other platforms, preferably on GitHub!
Cita come
Kesh Ikuma (2024). C++ MEX Development Utilities (https://github.com/hokiedsp/matlab-mexutils), GitHub. Recuperato .
Compatibilità della release di MATLAB
Compatibilità della piattaforma
Windows macOS LinuxCategorie
- MATLAB > External Language Interfaces > C with MATLAB > Write C Functions Callable from MATLAB (MEX Files) >
Tag
Riconoscimenti
Ispirato da: Example MATLAB class wrapper for a C++ class
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Scopri Live Editor
Crea script con codice, output e testo formattato in un unico documento eseguibile.
+mexcpp
examples
examples/@mexClass
Le versioni che utilizzano il ramo predefinito di GitHub non possono essere scaricate
Versione | Pubblicato | Note della release | |
---|---|---|---|
1.0.0.0 |
|