mwString
String class used by the mwArray
API
to pass string data as output from certain methods
Description
The mwString
class is a simple string class
used by the mwArray
API to pass string data as
output from certain methods.
Required Headers
mclcppclass.h
mclmcrrt.h
Tip
MATLAB® Compiler SDK™ automatically includes these header files in the header file generated for your MATLAB functions.
Constructors
mwString()
Create an empty string.
mwString(char* str)
Create a new string and initialize the string’s data with the supplied char buffer.
char* str | Null terminated character buffer |
mwString(mwString& str)
Create a new string and initialize the string’s data with the contents of the supplied string.
mwString& str | Initialized mwString instance |
Methods
int Length() const
Return the number of characters in string.
mwString str("This is a string"); int len = str.Length();
Operators
operator const char* () const
Return a pointer to internal buffer of string.
mwString str("This is a string"); const char* pstr = (const char*)str;
mwString& operator=(const mwString& str)
Copy the contents of one string into a new string.
mwString& str | Initialized mwString instance to copy |
mwString str("This is a string"); mwString new_str = str;
mwString& operator=(const char* str)
Copy the contents of a null terminated character buffer into a new string.
char* str | Null terminated character buffer to copy |
const char* pstr = "This is a string"; mwString str = pstr;
bool operator==(const mwString& str) const
Test two mwString
instances for equality.
If the characters in the string are the same, the instances are equal.
mwString& str | Initialized mwString instance |
mwString str("This is a string"); mwString str2("This is another string"); bool ret = (str == str2);
bool operator!=(const mwString& str) const
Test two mwString
instances for inequality.
If the characters in the string are not the same, the instances are
inequal.
mwString& str | Initialized mwString instance |
mwString str("This is a string"); mwString str2("This is another string"); bool ret = (str != str2);
bool operator<(const mwString& str) const
Compare two strings and return true
if the
first string is lexicographically less than the second string.
mwString& str | Initialized mwString instance |
mwString str("This is a string"); mwString str2("This is another string"); bool ret = (str < str2);
bool operator<=(const mwString& str) const
Compare two strings and return true
if the
first string is lexicographically less than or equal to the second
string.
mwString& str | Initialized mwString instance |
mwString str("This is a string"); mwString str2("This is another string"); bool ret = (str <= str2);
bool operator>(const mwString& str) const
Compare two strings and return true
if the
first string is lexicographically greater than the second string.
mwString& str | Initialized mwString instance |
mwString str("This is a string"); mwString str2("This is another string"); bool ret = (str > str2);
bool operator>=(const mwString& str) const
Compare two strings and return true
if the
first string is lexicographically greater than or equal to the second
string.
mwString& str | Initialized mwString instance |
mwString str("This is a string"); mwString str2("This is another string"); bool ret = (str >= str2);
friend std::ostream& operator<<(std::ostream& os, const mwString& str)
Copy contents of input string to specified ostream
.
std::ostream& os | Initialized ostream instance to copy string
into |
mwString& str | Initialized mwString instance to copy |
#include <ostream> mwString str("This is a string"); std::cout << str << std::endl;
Version History
Introduced in R2013b