Isle
Loading...
Searching...
No Matches
MxString Class Reference

Mindscape custom string class for managing dynamic C-strings within the game engine. More...

#include <mxstring.h>

Inheritance diagram for MxString:
Collaboration diagram for MxString:

Public Member Functions

 MxString ()
 Default constructor which creates an empty string. More...
 
 MxString (const MxString &p_str)
 Copy constructor. More...
 
 MxString (const char *p_str)
 Constructs MxString from a C-style string. More...
 
 MxString (const char *p_str, MxU16 p_maxlen)
 Constructs MxString from a C-style string with maximum length. More...
 
 ~MxString () override
 Destructor. More...
 
void Reverse ()
 Reverses the contents of the string in-place. More...
 
void ToUpperCase ()
 Converts the string contents to uppercase in-place. More...
 
void ToLowerCase ()
 Converts the string contents to lowercase in-place. More...
 
MxStringoperator= (const MxString &p_str)
 Assignment operator from another MxString. More...
 
const MxStringoperator= (const char *p_str)
 Assignment operator from a null-terminated C-string. More...
 
MxString operator+ (const MxString &p_str) const
 Concatenation operator for two MxString instances. More...
 
MxString operator+ (const char *p_str) const
 Concatenation operator for MxString and a C-string. More...
 
MxStringoperator+= (const char *p_str)
 Append a C-string to this MxString. More...
 
char * GetData () const
 Returns a pointer to the internal character buffer. More...
 
const MxU16 GetLength () const
 Returns the length of the string (number of characters, not including null terminator). More...
 
MxBool Equal (const MxString &p_str) const
 Compares this string to another for equality. More...
 
MxS8 Compare (const MxString &p_str) const
 Performs lexicographical comparison to another string. More...
 
- Public Member Functions inherited from MxCore
 MxCore ()
 [AI] Constructs a new MxCore object and assigns it a unique id. More...
 
virtual ~MxCore ()
 [AI] Virtual destructor. Required for correct polymorphic cleanup in derived classes. More...
 
virtual MxLong Notify (MxParam &p_param)
 [AI] Virtual callback notification mechanism. More...
 
virtual MxResult Tickle ()
 [AI] Called by tickle managers to allow the object to update itself. More...
 
virtual const char * ClassName () const
 [AI] Returns the runtime class name of this object. More...
 
virtual MxBool IsA (const char *p_name) const
 [AI] Checks whether this object's class type or parents match the given name. More...
 
MxU32 GetId ()
 [AI] Gets the unique (per-process) id assigned to this object instance. More...
 

Static Public Member Functions

static void CharSwap (char *p_a, char *p_b)
 Utility to swap the values of two characters. More...
 

Detailed Description

Mindscape custom string class for managing dynamic C-strings within the game engine.

[AI]

Provides operations like construction from C-strings or other MxString instances, mutation utilities (reverse, uppercase, lowercase), and concatenation and comparison. Handles dynamic memory for string contents. [AI]

Definition at line 14 of file mxstring.h.

Constructor & Destructor Documentation

◆ MxString() [1/4]

MxString::MxString ( )

Default constructor which creates an empty string.

[AI]

Allocates memory for a null-terminated string of zero length. [AI]

Definition at line 12 of file mxstring.cpp.

◆ MxString() [2/4]

MxString::MxString ( const MxString p_str)

Copy constructor.

[AI]

Parameters
p_strReference to another MxString to copy. [AI]

Definition at line 22 of file mxstring.cpp.

◆ MxString() [3/4]

MxString::MxString ( const char *  p_str)

Constructs MxString from a C-style string.

[AI]

Parameters
p_strNull-terminated input string. [AI]

Definition at line 31 of file mxstring.cpp.

◆ MxString() [4/4]

MxString::MxString ( const char *  p_str,
MxU16  p_maxlen 
)

Constructs MxString from a C-style string with maximum length.

[AI]

Parameters
p_strNull-terminated input string. [AI]
p_maxlenMaximum number of characters to copy. [AI]

If the input string is longer than p_maxlen, only the first p_maxlen characters are used. [AI]

Definition at line 46 of file mxstring.cpp.

◆ ~MxString()

MxString::~MxString ( )
override

Destructor.

[AI]

Releases allocated memory for string buffer. [AI]

Definition at line 70 of file mxstring.cpp.

Member Function Documentation

◆ CharSwap()

void MxString::CharSwap ( char *  p_a,
char *  p_b 
)
static

Utility to swap the values of two characters.

[AI]

Parameters
p_aPointer to first character. [AI]
p_bPointer to second character. [AI]

Used internally for string reversal. [AI]

Definition at line 182 of file mxstring.cpp.

◆ Compare()

MxS8 MxString::Compare ( const MxString p_str) const
inline

Performs lexicographical comparison to another string.

[AI]

Parameters
p_strString to compare against. [AI]
Returns
0 if equal; <0 if this < p_str; >0 if this > p_str (using strcmp convention). [AI]

Definition at line 129 of file mxstring.h.

◆ Equal()

MxBool MxString::Equal ( const MxString p_str) const
inline

Compares this string to another for equality.

[AI]

Parameters
p_strString to compare against. [AI]
Return values
TRUEif the contents are exactly equal, FALSE otherwise ([AI], returns MxBool). [AI]

Definition at line 122 of file mxstring.h.

◆ GetData()

char * MxString::GetData ( ) const
inline

Returns a pointer to the internal character buffer.

[AI]

The returned pointer is owned by MxString and should not be freed by the caller. [AI]

Definition at line 110 of file mxstring.h.

◆ GetLength()

const MxU16 MxString::GetLength ( ) const
inline

Returns the length of the string (number of characters, not including null terminator).

[AI]

Definition at line 115 of file mxstring.h.

◆ operator+() [1/2]

MxString MxString::operator+ ( const char *  p_str) const

Concatenation operator for MxString and a C-string.

[AI]

Parameters
p_strC-style string to append to this instance. [AI]

Returns a new MxString containing the concatenation result. [AI]

Definition at line 149 of file mxstring.cpp.

◆ operator+() [2/2]

MxString MxString::operator+ ( const MxString p_str) const

Concatenation operator for two MxString instances.

[AI]

Parameters
p_strInput string to concatenate. [AI]

Returns a new MxString containing the concatenation result. [AI]

Definition at line 131 of file mxstring.cpp.

◆ operator+=()

MxString & MxString::operator+= ( const char *  p_str)

Append a C-string to this MxString.

[AI]

Parameters
p_strC-style null-terminated string to append. [AI]

Adjusts the internal buffer and length. [AI]

Definition at line 166 of file mxstring.cpp.

◆ operator=() [1/2]

const MxString & MxString::operator= ( const char *  p_str)

Assignment operator from a null-terminated C-string.

[AI]

Parameters
p_strSource C-string to copy from. [AI]

Allocates a new buffer and copies the input string. Handles self-assignment check. [AI]

Definition at line 118 of file mxstring.cpp.

◆ operator=() [2/2]

MxString & MxString::operator= ( const MxString p_str)

Assignment operator from another MxString.

[AI]

Parameters
p_strSource MxString to copy from. [AI]

Allocates a new buffer and copies the string data. Handles self-assignment check. [AI]

Definition at line 104 of file mxstring.cpp.

◆ Reverse()

void MxString::Reverse ( )

Reverses the contents of the string in-place.

[AI]

Definition at line 76 of file mxstring.cpp.

◆ ToLowerCase()

void MxString::ToLowerCase ( )

Converts the string contents to lowercase in-place.

[AI]

Definition at line 97 of file mxstring.cpp.

◆ ToUpperCase()

void MxString::ToUpperCase ( )

Converts the string contents to uppercase in-place.

[AI]

Definition at line 90 of file mxstring.cpp.


The documentation for this class was generated from the following files: