World of Rigid Bodies (WoRB)
|
Represents a MATLAB logical value. More...
#include <mexWoRB.h>
Public Member Functions | |
Logical (const mxArray *arg, const char *argDesc, bool defaultValue=false) | |
Constructs the instance from the given MATLAB array of doubles. | |
Logical (const mxArray *obj, mwIndex index, const char *fieldName, bool defaultValue=false) | |
Constructs the instance from the given MATLAB structure field. | |
bool | operator! () const |
operator bool () const | |
mxArray * | toMxArray () |
Converts the instance to MATLAB logical scalar. | |
Logical & | operator= (bool v) |
Sets the new value. | |
Private Member Functions | |
void | Initialize (const mxArray *arg, const char *argDesc, bool defaultValue) |
Initializes the instance from a MATLAB array of doubles. | |
Private Attributes | |
bool | value |
Mex::Logical::Logical | ( | const mxArray * | arg, |
const char * | argDesc, | ||
bool | defaultValue = false |
||
) | [inline] |
Constructs the instance from the given MATLAB array of doubles.
Definition at line 415 of file mexWoRB.h.
References Initialize().
{ Initialize( arg, argDesc, defaultValue ); }
Mex::Logical::Logical | ( | const mxArray * | obj, |
mwIndex | index, | ||
const char * | fieldName, | ||
bool | defaultValue = false |
||
) | [inline] |
Constructs the instance from the given MATLAB structure field.
Definition at line 422 of file mexWoRB.h.
References Initialize().
{ Initialize( mxGetField( obj, index, fieldName ), fieldName, defaultValue ); }
void Mex::Logical::Initialize | ( | const mxArray * | arg, |
const char * | argDesc, | ||
bool | defaultValue | ||
) | [inline, private] |
Initializes the instance from a MATLAB array of doubles.
Definition at line 381 of file mexWoRB.h.
References WoRB::SevereError(), and value.
Referenced by Logical().
{ if ( arg == NULL ) { value = defaultValue; return; } // Parse value from different argument types // int ndim = mxGetNumberOfDimensions( arg ); mwSize len = mxGetNumberOfElements( arg ); if ( mxIsLogicalScalar( arg ) && len >= 1 ) { value = mxGetLogicals( arg )[0]; return; } else if ( mxIsDouble( arg ) && ! mxIsComplex( arg ) && len >= 1 ) { double* data = mxGetPr( arg ); value = data != NULL && data[0] != 0; return; } // If we couldn't parse logical value, return an error WoRB::SevereError( "WoRB:parseLogical:invarg", "'%s' must be a logical value or a real number.", argDesc ); }
Mex::Logical::operator bool | ( | ) | const [inline] |
bool Mex::Logical::operator! | ( | ) | const [inline] |
Logical& Mex::Logical::operator= | ( | bool | v | ) | [inline] |
mxArray* Mex::Logical::toMxArray | ( | ) | [inline] |
bool Mex::Logical::value [private] |
Definition at line 377 of file mexWoRB.h.
Referenced by Initialize(), operator bool(), operator!(), operator=(), and toMxArray().