diff --git a/gtsam.h b/gtsam.h index e80a37a0b..fcf6f0a9f 100644 --- a/gtsam.h +++ b/gtsam.h @@ -19,7 +19,7 @@ * Arguments to functions any of * - Eigen types: Matrix, Vector * - Eigen types and classes as an optionally const reference - * - C/C++ basic types: string, bool, size_t, int, double + * - C/C++ basic types: string, bool, size_t, int, double, char * - Any class with which be copied with boost::make_shared() (except Eigen) * - boost::shared_ptr of any object type (except Eigen) * Comments can use either C++ or C style, with multiple lines diff --git a/wrap/matlab.h b/wrap/matlab.h index b6d200e43..1a47430b5 100644 --- a/wrap/matlab.h +++ b/wrap/matlab.h @@ -106,6 +106,14 @@ mxArray* wrap(char& value) { return result; } +// specialization to unsigned char +template<> +mxArray* wrap(unsigned char& value) { + mxArray *result = scalar(mxUINT32OR64_CLASS); + *(unsigned char*)mxGetData(result) = value; + return result; +} + // specialization to bool template<> mxArray* wrap(bool& value) { @@ -227,13 +235,20 @@ bool unwrap(const mxArray* array) { return myGetScalar(array); } -// specialization to bool +// specialization to char template<> char unwrap(const mxArray* array) { checkScalar(array,"unwrap"); return myGetScalar(array); } +// specialization to unsigned char +template<> +unsigned char unwrap(const mxArray* array) { + checkScalar(array,"unwrap"); + return myGetScalar(array); +} + // specialization to int template<> int unwrap(const mxArray* array) {