MStatus Class Reference

+ Related help topics:

#include <MStatus.h>

Class Description

Manipulate Maya Status codes.

This class facilitates API level error handling. It encapsulates the status code and the internal MAYA error code as return by API functions. The user can query, set, print the error code along with the error description.

+ Examples:

Public Types

enum  MStatusCode {
  kSuccess = 0, kFailure, kInsufficientMemory, kInvalidParameter,
  kLicenseFailure, kUnknownParameter, kNotImplemented, kNotFound,
  kEndOfFile
}
 Available Status Codes. More...
 

Public Member Functions

 MStatus ()
 The default class constructor. More...
 
 MStatus (MStatusCode)
 The constructor that takes a MStatus::MStatusCode. More...
 
 MStatus (const MStatus &)
 The copy constructor of the class. More...
 
MStatusoperator= (const MStatus &rhs)
 The copy operator of the class. More...
 
bool operator== (const MStatus &rhs) const
 The equivalence operator that takes another MStatus object. More...
 
bool operator== (const MStatusCode rhs) const
 The equivalence operator that takes a MStatus::MStatusCode. More...
 
bool operator!= (const MStatus &rhs) const
 The not equal operator for MStatus. More...
 
bool operator!= (const MStatusCode rhs) const
 The not equal operator that takes a MStatus::MStatusCode. More...
 
bool error () const
 Determines whether there is an error. More...
 
void clear ()
 Clear error codes from the MStatus instance. More...
 
MStatusCode statusCode () const
 Retrieve the type of error that occurred, as specified in the MStatusCode enumeration. More...
 
MString errorString () const
 This method returns the internal error message as a MString object. More...
 
void perror (const char *) const
 This method prints the error string preceded by a string supplied by the user to the standard error stream. More...
 
void perror (const MString &) const
 The second version of the perror() method. More...
 
void set (bool status, unsigned char statusCode, unsigned char internalStatusCode)
 Internal use only. More...
 
void setSuccess ()
 The method is called interally by Maya to set the status as success. More...
 
 operator bool () const
 NO SCRIPT SUPPORT. More...
 

Friends

OPENMAYA_EXPORT std::ostream & operator<< (std::ostream &, MStatus &)
 NO SCRIPT SUPPORT. More...
 
OPENMAYA_EXPORT bool operator== (const MStatus::MStatusCode code, const MStatus &status)
 NO SCRIPT SUPPORT.
 
OPENMAYA_EXPORT bool operator!= (const MStatus::MStatusCode code, const MStatus &status)
 NO SCRIPT SUPPORT.
 

Member Enumeration Documentation

Available Status Codes.

Enumerator
kSuccess 

The operation was successful.

kFailure 

The operation failed.

kInsufficientMemory 

The operation failed due to insufficient memory.

kInvalidParameter 

An invalid parameter was provided.

kLicenseFailure 

Application is not licensed for the attempted operation.

kUnknownParameter 

Returned by MPxNode::compute for unrecognised plugs.

kNotImplemented 

 

kNotFound 

 

kEndOfFile 

 

Constructor & Destructor Documentation

MStatus ( )
inline

The default class constructor.

It initializes the internal detailed status code to kSuccess.

The constructor that takes a MStatus::MStatusCode.

Initializes the internal detailed status code to status

Parameters
[in]statusThe initial detailed status code.
MStatus ( const MStatus status)
inline

The copy constructor of the class.

Initialize a new MStatus object with the values from another MStatus object.

Parameters
[in]statusThe target MStatus object.

Member Function Documentation

MStatus & operator= ( const MStatus rhs)
inline

The copy operator of the class.

Parameters
[in]rhsThe MStatus object to copy from.
Returns
A reference to the MStatus object that has been initialized.
bool operator== ( const MStatus rhs) const
inline

The equivalence operator that takes another MStatus object.

Parameters
[in]rhsA reference to the target object.
Returns
  • true the two MStatus objects are equal.
  • false the two MStatus objects are not equal.
bool operator== ( const MStatusCode  rhs) const
inline

The equivalence operator that takes a MStatus::MStatusCode.

Parameters
[in]rhsa MStatus::MStatusCode, e.g. MS::kSuccess.
Returns
  • true the object has the given detailed status code.
  • false the object does not have the given detailed status code.
bool operator!= ( const MStatus rhs) const
inline

The not equal operator for MStatus.

Parameters
[in]rhsa reference to the target object for comparison.
Returns
  • true the two MStatus objects are not equal.
  • false the two MStatus objects are equal.
bool operator!= ( const MStatusCode  rhs) const
inline

The not equal operator that takes a MStatus::MStatusCode.

Parameters
[in]rhsa MStatus::MStatusCode, e.g. MS::kSuccess.
Returns
  • true the object does not have the given detailed status code.
  • false the object has the given detailed status code.
bool error ( ) const
inline

Determines whether there is an error.

Returns
  • true an error has occured.
  • false the operation was successful
+ Examples:
MStatus::MStatusCode statusCode ( ) const
inline

Retrieve the type of error that occurred, as specified in the MStatusCode enumeration.

Returns
The type of error that occurred.
+ Examples:
void perror ( const char *  preString) const

This method prints the error string preceded by a string supplied by the user to the standard error stream.

Parameters
[in]preStringA pointer to char that points to a null terminated string.
+ Examples:
void perror ( const MString preString) const

The second version of the perror() method.

This method takes a reference to a MString as the parameter. It prints the error string preceded by the string supplied by the user to the standard error stream.

Parameters
[in]preStringa reference to a MString object that contains the prefix string.
void set ( bool  status,
unsigned char  statusCode,
unsigned char  internalStatusCode 
)
inline

Internal use only.

The method is called interally by Maya to construct MStatus objects.

It should not be called from plugins.

Parameters
[in]statustrue or false
[in]statusCodean element of MStatusCode
[in]internalStatusCodean internal Maya error code
+ Examples:
void setSuccess ( )
inline

The method is called interally by Maya to set the status as success.

It should not be called from plugins.

operator bool ( ) const
inline

NO SCRIPT SUPPORT.

The conversion operator that converts a MStatus object to bool.

The result it returns will be true if the MStatus does not contain an error, and false if it does.

Friends And Related Function Documentation

OPENMAYA_EXPORT std::ostream& operator<< ( std::ostream &  out,
MStatus status 
)
friend

NO SCRIPT SUPPORT.

This method outputs the detailed status code as well as the internal error description. The format of the output is "(errNumber): errorDescriptiveText".

Parameters
[in]outThe ostream object that the output should be directed to.
[in]statusThe MStatus object.
Returns
A reference to the ostream object.

The documentation for this class was generated from the following files:
  • MStatus.h
  • MStatus.cpp