class MString

Jump to documentation

Manipulate strings.

public members:

MString ()
MString ( const char* charString )
MString ( const char* charString, int charLength )
MString ( const MString & other )
~MString ()
MString & operator += ( const MString & other )
MString & operator += ( const char * other )
MString & operator += ( double other )
MString & operator += ( int other )
MString & operator += ( unsigned int other )
MString & operator += ( float other )
MString & operator = ( const MString & other )
MString & operator = ( const char * other )
MString & operator = ( double value )
bool operator == ( const MString & other ) const
bool operator == ( const char * other ) const
bool operator != ( const MString & other ) const
bool operator != ( const char * other ) const
MString operator + (const MString & other ) const
MString operator + (const char * other ) const
MString operator + ( double value ) const
MStatus set ( const char * charString )
MStatus set ( const char * charString, int charLength )
MStatus set ( double value )
MStatus set ( double value, int precision )
const char* asChar () const
unsigned int length () const
void clear ()
int index (char) const
int rindex (char) const
MStatus split (char, MStringArray &) const
MString substring (int start, int end) const
MString & toUpperCase ()
MString & toLowerCase ()
bool isShort () const
short asShort () const
bool isInt () const
int asInt () const
bool isUnsigned () const
unsigned int asUnsigned () const
bool isFloat () const
float asFloat () const
bool isDouble () const
double asDouble () const
MString expandEnvironmentVariablesAndTilde ( MStatus * ReturnStatus = NULL )
friend ostream& operator<< (ostream&, const MString & )
friend MString operator+ (const char *, const MString & )

Documentation

Methods for handling strings.
Description

The MString class implements a string class, and is used to pass all string arguments to Maya API methods.

Functions

MString:: MString ()

Description

The Class constructor. Initializes the new MString instance to the empty string.

MString:: MString ( const char* charString )

Description

Class constructor. Create a new instance of an MString and initialize it to the given character string.

Arguments

  • charString the initial string value.

MString:: MString ( const char* charString, int charLength )

Description

Class constructor. Create a new instance of an MString and initialize it to the given character string and specified length.

Arguments

  • charString the initial string value.
  • charLength the initial string length.

MString:: MString ( const MString & other )

Description

Copy constructor. Create a new MString instance and initialize is with the same string as the given one.

Arguments

  • other the MString to copy from.

MString:: ~MString ()
Description

The class destructor.

MString & MString:: operator += (const MString & other )

Description

Addition operator. The addition of 2 MStrings results in their concatenation.

MString & MString:: operator += ( const char * other )

Description

Addition operator. The addition of an MString and a C string results in their concatenation.

MString & MString:: operator += ( double other )

Description

Addition operator. The addition of an MString and a double results in their concatenation.

MString & MString:: operator += ( int other )

Description

Addition operator. The addition of an MString and an int results in their concatenation.

MString & MString:: operator += ( unsigned int other )

Description

Addition operator. The addition of an MString and an unsigned int results in their concatenation.

MString & MString:: operator += ( float other )

Description

Addition operator. The addition of an MString and a float results in their concatenation.

MString MString:: operator + (const MString & other ) const

Description

Addition operator. The addition of 2 MStrings results in their concatenation.

MString MString:: operator + ( const char * other ) const

Description

Addition operator. The addition of an MString and a C string results in their concatenation.

MString MString:: operator + ( double value ) const

Description

Addition operator. The addition of an MString and a number results in their concatenation.

MString operator + (const char *first, const MString & second )

Description

Addition operator. The addition of a C string with an MString results in their concatenation.

MString & MString:: operator = (const MString & other )

Description

Assignment operator. Allows assignment between MString instances.

MString & MString:: operator = (const char * other )

Description

Assignment operator. Allows assignment of a C string to this MString.

MString & MString:: operator = ( double value )

Description

Assignment operator. Allows assignment of a number to this MString.

bool MString:: operator == (const MString & other ) const

Description

Equality operator. Allows 2 MStrings to be compared to see if they contain identical strings.

bool MString:: operator == (const char * other ) const

Description

Equality operator. Allows an MString and a C string to be compared to see if they contain identical strings.

bool MString:: operator != (const MString & other ) const
Description Inequality operator. Allows 2 MStrings to be compared to see if they contain non-identical strings.

bool MString:: operator != (const char * other ) const
Description Inequality operator. Allows an MStrings to be compared with a C string to see if they contain non-identical strings.

MStatus MString:: set ( const char * charString )

Description

Set the value of the string in this MString instance.

Arguments

  • charString new string value.

Return Value

  • MS::kSuccess for success, otherwise MS::kFailure

MStatus MString:: set ( const char * charString, int charLength )

Description

Set the value of the string in this MString instance.

Arguments

  • charString new string value.
  • charLength new string length.

Return Value

  • MS::kSuccess for success, otherwise MS::kFailure

MStatus MString:: set ( double value )

Description

Set the value of the string in this MString instance.

Arguments

  • value new number.

Return Value

  • MS::kSuccess for success, otherwise MS::kFailure

MStatus MString:: set ( double value, int precision )

Description

Set the value of the string in this MString instance, with the given precision.

Arguments

  • value new number.
  • precision the precision (number of decimal places).

Return Value

  • MS::kSuccess for success, otherwise MS::kFailure

const char * MString:: asChar () const
Description

Return the current string in this MString instance as a C++ char* pointer.

NOTE: The string should be duplicated if it will be re-used.

Return Value

  • the char* pointer to the string in this MString instance.

unsigned int MString:: length () const
Description

Returns the length of the string in this MString instance.

Return Value

  • unsigned integer value of the string length.

void MString:: clear ()

Description

Clears the contents of this MString instance and sets it value to the empty string.

int MString:: index (char searchChar) const

Description

Returns the position of the first occurance of the character searchChar in the string or -1 if the character is not found.

Arguments

  • searchChar the character to search for

Return Value

  • the position of searchChar in the string, or -1 if the searchChar is not found

int MString:: rindex (char searchChar) const

Description

Returns the position of the last occurance of the character searchChar in the string or -1 if the character is not found.

Arguments

  • searchChar the character to search for

Return Value

  • the position of searchChar in the string, or -1 if the searchChar is not found

MStatus MString:: split (char theChar, MStringArray & theArray) const

Description

Split the string up at each occurrence of theChar and place the separate strings into theArray. The current string instance is not modified.

Arguments

  • theChar the character on which to split
  • theArray the MStringArray to populate

Return Value

  • MS::kSuccess on success, and MS::kFailure on failure

MString MString:: substring (int start, int end) const

Description

Return a new MString instance that contains the characters from start to end inclusive.

Arguments

  • start the index of the first character to copy
  • end the index of the last character to copy

Return Value

  • an MString containing the substring.

MString & MString:: toUpperCase ()

Description

Modify the current instance of the string replacing all lower case characters in the corresponding upper case characters.

Return Value

  • a reference to the current, modified MString instance

MString & MString:: toLowerCase ()

Description

Modify the current instance of the string replacing all lower case characters in the corresponding upper case characters.

Return Value

  • a reference to the current, modified MString instance

bool MString:: isShort () const

Description

Returns true if the string represents a valid short, and false otherwise.

Return Value

  • true or false

short MString:: asShort () const

Description

Returns the value of the string in this MString instance converted to a short. If the string does contain a valid string representation of a short, then the results of this operation are undefined.

Return Value

  • the value of the current string converted to a short.

bool MString:: isInt () const

Description

Returns true if the string represents a valid int, and false otherwise.

Return Value

  • true or false

int MString:: asInt () const

Description

Returns the value of the string in this MString instance converted to an integer. If the string does contain a valid string representation of an integer, then the results of this operation are undefined.

Return Value

  • the value of the current string converted to an integer.

bool MString:: isUnsigned () const

Description

Returns true if the string represents a valid unsigned int, and false otherwise.

Return Value

  • true or false

unsigned int MString:: asUnsigned () const

Description

Returns the value of the string in this MString instance converted to an unsigned integer. If the string does contain a valid string representation of an unsigned integer, then the results of this operation are undefined.

Return Value

  • the value of the current string converted to an integer.

bool MString:: isFloat () const

Description

Returns true if the string represents a valid float, and false otherwise.

Return Value

  • true or false

float MString:: asFloat () const

Description

Returns the value of the string in this MString instance converted to a float. If the string does contain a valid string representation of a float, then the results of this operation are undefined.

Return Value

  • the value of the current string converted to a float.

bool MString:: isDouble () const

Description

Returns true if the string represents a valid double, and false otherwise.

Return Value

  • true or false

double MString:: asDouble () const

Description

Returns the value of the string in this MString instance converted to a double. If the string does contain a valid string representation of a double, then the results of this operation are undefined.

Return Value

  • the value of the current string converted to a double.

MString MString:: expandEnvironmentVariablesAndTilde ( MStatus * ReturnStatus )

Description

Returns a new string constructed by duplicating the current string with all environment variables expanded (and on UNIX, tilde characaters ("~") are also expanded. Environment variables may be of the form

$ENV_VAR or
	$
{ENV_VAR}. On Windows, %ENV_VAR, %ENV_VAR% and %{ENV_VAR}% are also accepted. If no environment variable in the system matches that given, the unexpanded variable is copied verbatim into the result string. On UNIX, any tilde characters ("~") will also be expanded according to the standard UNIX convention. If the user name associated with a tilde is undefined, the tilde and name which follows it are copied verbatim into the result string. Notes (1) when any error occurs, processing continues such that all subsequent environment variable and tilde occurences are processed and the resulting string can be displayed to the user to help diagnose the undefined entities (2) escape sequences using backslash characters are not supported.

Arguments

  • MStatus *ReturnStatus status of the operation. MS::kSuccess for success, MS::kNotFound if one or more environment variables or tildes failed to expand.

Return Value

  • returns a new string containing the value of the original string with environment variable (and tilde characters on UNIX) which were defined expanded. All undefined environment variables and tildes are copied into the result string unexpanded.

ostream& operator<< (ostream& s, const MString & str )

Description

Print the contents of the given MString on the given ostream.

Arguments

  • s the ostream to print to
  • str the MString whose value is to be printed

Return Value

  • the ostream reference, s, provided as the first parameter.

This class has no child classes.


Autodesk® Maya® 8.0 © 1997-2006 Autodesk, Inc. All rights reserved. doc++ Copyright