| 
    World of Rigid Bodies (WoRB)
   
    
   
   | 
  
  
  
 
Represents a MATLAB character string value. More...
#include <mexWoRB.h>
Public Member Functions | |
| String (const mxArray *arg, const char *argDesc) | |
| Constructs the instance from the given MATLAB character array.   | |
| String (const mxArray *obj, mwIndex index, const char *fieldName) | |
| Constructs the instance from the given MATLAB structure field.   | |
| ~String () | |
| Destructor.   | |
| operator const char * () const | |
| Gets pointer to internal character string.   | |
| mxArray * | toMxArray () | 
| Converts the instance to MATLAB string.   | |
| bool | operator== (const char *v) | 
| Returns true if this instance has the same contents as the given string.   | |
| bool | operator!= (const char *v) | 
| Returns true if this instance does not have the same contents as the given string.   | |
Private Member Functions | |
| void | Initialize (const mxArray *arg, const char *argDesc) | 
Initializes the instance from a MATLAB mxArray.   | |
Private Attributes | |
| char * | value | 
| Mex::String::String | ( | const mxArray * | arg, | 
| const char * | argDesc | ||
| ) |  [inline] | 
        
Constructs the instance from the given MATLAB character array.
Definition at line 481 of file mexWoRB.h.
References Initialize().
        {
            Initialize( arg, argDesc );
        }
| Mex::String::String | ( | const mxArray * | obj, | 
| mwIndex | index, | ||
| const char * | fieldName | ||
| ) |  [inline] | 
        
Constructs the instance from the given MATLAB structure field.
Definition at line 488 of file mexWoRB.h.
References Initialize().
        {
            Initialize( mxGetField( obj, index, fieldName ), fieldName );
        }
| Mex::String::~String | ( | ) |  [inline] | 
        
| void Mex::String::Initialize | ( | const mxArray * | arg, | 
| const char * | argDesc | ||
| ) |  [inline, private] | 
        
Initializes the instance from a MATLAB mxArray. 
Definition at line 462 of file mexWoRB.h.
References WoRB::SevereError(), and value.
Referenced by String().
        {
            if ( arg == NULL || ! mxIsChar( arg ) ) {
                // If we couldn't parse character string, return an error
                WoRB::SevereError( "WoRB:parseString:invarg",
                    "'%s' must be a character array.", 
                    argDesc
                );
            }
            mwSize len = mxGetNumberOfElements( arg );
            value = (char*)mxMalloc( len + 1 );
            mxGetString( arg, value, len + 1 );
        }
| Mex::String::operator const char * | ( | ) |  const [inline] | 
        
| bool Mex::String::operator!= | ( | const char * | v | ) |  [inline] | 
        
Returns true if this instance does not have the same contents as the given string.
Definition at line 528 of file mexWoRB.h.
References operator==().
        {
            return ! operator ==( v );
        }
| bool Mex::String::operator== | ( | const char * | v | ) |  [inline] | 
        
Returns true if this instance has the same contents as the given string.
Definition at line 516 of file mexWoRB.h.
References value.
Referenced by operator!=().
        {
            for ( const char* p = value; *p && *v; ++p, ++v ) {
                if ( *p != *v ) {
                    return false;
                }
            }
            return true;
        }
| mxArray* Mex::String::toMxArray | ( | ) |  [inline] | 
        
char* Mex::String::value [private] | 
        
Definition at line 458 of file mexWoRB.h.
Referenced by Initialize(), operator const char *(), operator==(), and toMxArray().