Detailed Description
- See also:
- Class WStr, Character Strings.
- Description:
- A simple character string class. This is the standard character
string class used in 3ds Max. Methods and operators are provided
for calculating lengths, concatenation, substring operations,
character searching, case conversion, comparison, and formatted
writing.
This class automatically allocates the proper amount of space for
the string. This is very handy in the case of internationalization
/ localization. For example, if you code something like:
MSTR myString = GetString(IDS_STRING_ID);
then myString's constructor will allocate enough space to
store the resource string no matter how long it is. This is much
better than doing the following:
MCHAR myString[64];
_tcscpy(myString, GetString(IDS_STRING_ID));
because the resource string may turn out to be much longer than 64
bytes once it's translated to German or French (or whatever).
As another example, if you have the following code:
MSTR str1 = _M("This is string1.");
MSTR str2 = _M("This is string2.");
Then
MSTR concatStr = str1 + str2;
will again yield a (concatenated) string will enough space to hold
the concatenated contents of str1 and str2,
automatically.
All methods are implemented by the system.
- Note:
- The memory occupied by a CStr object is cannot be larger than
2Gb.
#include <strclass.h>
List of all members.
Constructor & Destructor Documentation
UtilExport CStr |
( |
const char * |
cs |
) |
|
UtilExport CStr |
( |
const mwchar_t * |
wcstr |
) |
|
Member Function Documentation
UtilExport char* data |
( |
|
) |
|
UtilExport const char* data |
( |
|
) |
const |
UtilExport operator char * |
( |
|
) |
|
UtilExport operator const char * |
( |
|
) |
const |
UtilExport void Resize |
( |
int |
nchars |
) |
|
- Parameters:
- int nchars
Specifies the new number of characters for the string.
UtilExport int Length |
( |
|
) |
const [inline] |
int length |
( |
|
) |
const [inline] |
UtilExport int ByteCount |
( |
|
) |
const |
UtilExport int LanguageCharacterCount |
( |
|
) |
const |
BOOL isNull |
( |
|
) |
const [inline] |
UtilExport CStr& operator= |
( |
const CStr & |
cs |
) |
|
UtilExport CStr& operator= |
( |
const mwchar_t * |
wcstr |
) |
|
UtilExport CStr& operator= |
( |
const char * |
cs |
) |
|
UtilExport CStr operator+ |
( |
const CStr & |
cs |
) |
const |
UtilExport CStr& operator+= |
( |
const CStr & |
cs |
) |
|
CStr& Append |
( |
const CStr & |
cs |
) |
[inline] |
{ return ((*this) += cs); }
CStr& append |
( |
const CStr & |
cs |
) |
[inline] |
{ return ((*this) += cs); }
UtilExport CStr& remove |
( |
int |
pos |
) |
|
- Parameters:
- int pos
Specifies the last position in the string.
UtilExport CStr& remove |
( |
int |
pos, |
|
|
int |
N |
|
) |
|
|
- Parameters:
- int pos
Specifies the position to begin removing characters.
int N
Specifies the number of characters to remove.
UtilExport CStr Substr |
( |
int |
start, |
|
|
int |
nchars |
|
) |
|
const |
UtilExport CStr MultiByteCharacterSubString |
( |
int |
firstCharacterIndex, |
|
|
int |
numberOfMBCharacters |
|
) |
|
const |
UtilExport int
FindMBCharacterFirstByteIndex |
( |
int |
characterIndex |
) |
const |
UtilExport int
FindMBCharacterLastByteIndex |
( |
int |
characterIndex |
) |
const |
UtilExport char& operator[] |
( |
int |
i |
) |
|
UtilExport char operator[] |
( |
int |
i |
) |
const |
UtilExport int first |
( |
char |
c |
) |
const |
UtilExport int last |
( |
char |
c |
) |
const |
UtilExport int operator== |
( |
const CStr & |
cs |
) |
const |
- Returns:
- Nonzero if the strings are equal; otherwise 0.
UtilExport int operator!= |
( |
const CStr & |
cs |
) |
const |
- Returns:
- Zero if the strings are equal; otherwise 1.
UtilExport int operator< |
( |
const CStr & |
cs |
) |
const |
UtilExport int operator<= |
( |
const CStr & |
ws |
) |
const |
UtilExport int operator> |
( |
const CStr & |
ws |
) |
const |
UtilExport int operator>= |
( |
const CStr & |
ws |
) |
const |
UtilExport void toUpper |
( |
|
) |
|
UtilExport void toLower |
( |
|
) |
|
UtilExport int printf |
( |
const char * |
format, |
|
|
|
... |
|
) |
|
|
Write a formatted string into this CStr.
Writes the format string, filled in by the optional arguments
into this CStr. See the
ISO C++ documentation for more information on printf and format
strings.
- Parameters:
-
format |
Specifies how to format the destination string. |
... |
optional arguments to format into the destination string. |
- Precondition:
- format is not null.
- There are the correct number of elliptical arguments to fill
the format string.
- Postcondition:
- This string is replaced with the formatted string.
- Returns:
- The number of characters written to this string, not including
the null terminating character, or a negative value if an error
occurs.
UtilExport int vprintf |
( |
const char * |
format, |
|
|
va_list |
args |
|
) |
|
|
Write a formatted string into this CStr.
This method is similar to CStr::printf.
Instead of taking a variable list of arguments as parameter, it
takes a structure representing a variable list of argument. This
allows CStr objects to be
used to build strings based on a format string and a variable
number of arguments:
void LogMessage(CStr* format, ...) {
va_list args;
va_start(args, format);
CStr buf;
buf.printf(format, args);
va_end(args);
}