2023-06-23 12:17:41 -04:00
|
|
|
#include "mxstring.h"
|
2023-10-24 19:38:27 -04:00
|
|
|
|
2023-09-26 07:24:28 -04:00
|
|
|
#include "decomp.h"
|
|
|
|
|
2023-06-23 12:17:41 -04:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2023-09-26 07:24:28 -04:00
|
|
|
DECOMP_SIZE_ASSERT(MxString, 0x10)
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100ae200
|
2023-06-23 12:17:41 -04:00
|
|
|
MxString::MxString()
|
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
// Set string to one char in length and set that char to null terminator
|
|
|
|
this->m_data = new char[1];
|
|
|
|
this->m_data[0] = 0;
|
|
|
|
this->m_length = 0;
|
2023-06-23 12:17:41 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100ae2a0
|
2023-12-13 05:48:14 -05:00
|
|
|
MxString::MxString(const MxString& p_str)
|
2023-06-23 12:17:41 -04:00
|
|
|
{
|
2023-12-13 05:48:14 -05:00
|
|
|
this->m_length = p_str.m_length;
|
2023-10-24 19:38:27 -04:00
|
|
|
this->m_data = new char[this->m_length + 1];
|
2023-12-13 05:48:14 -05:00
|
|
|
strcpy(this->m_data, p_str.m_data);
|
2023-06-23 12:17:41 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100ae350
|
2023-12-13 05:48:14 -05:00
|
|
|
MxString::MxString(const char* p_str)
|
2023-06-23 12:17:41 -04:00
|
|
|
{
|
2023-12-13 05:48:14 -05:00
|
|
|
if (p_str) {
|
|
|
|
this->m_length = strlen(p_str);
|
2023-10-24 19:38:27 -04:00
|
|
|
this->m_data = new char[this->m_length + 1];
|
2023-12-13 05:48:14 -05:00
|
|
|
strcpy(this->m_data, p_str);
|
2023-10-24 19:38:27 -04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
this->m_data = new char[1];
|
|
|
|
this->m_data[0] = 0;
|
|
|
|
this->m_length = 0;
|
|
|
|
}
|
2023-06-23 12:17:41 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100ae420
|
2023-06-23 12:17:41 -04:00
|
|
|
MxString::~MxString()
|
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
delete[] this->m_data;
|
2023-06-23 12:17:41 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100ae490
|
2023-06-23 12:17:41 -04:00
|
|
|
void MxString::ToUpperCase()
|
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
strupr(this->m_data);
|
2023-06-23 12:17:41 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100ae4a0
|
2023-06-23 12:17:41 -04:00
|
|
|
void MxString::ToLowerCase()
|
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
strlwr(this->m_data);
|
2023-06-23 12:17:41 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100ae4b0
|
2023-12-13 05:48:14 -05:00
|
|
|
MxString& MxString::operator=(const MxString& p_str)
|
2023-06-23 12:17:41 -04:00
|
|
|
{
|
2023-12-13 05:48:14 -05:00
|
|
|
if (this->m_data != p_str.m_data) {
|
2023-10-24 19:38:27 -04:00
|
|
|
delete[] this->m_data;
|
2023-12-13 05:48:14 -05:00
|
|
|
this->m_length = p_str.m_length;
|
2023-10-24 19:38:27 -04:00
|
|
|
this->m_data = new char[this->m_length + 1];
|
2023-12-13 05:48:14 -05:00
|
|
|
strcpy(this->m_data, p_str.m_data);
|
2023-10-24 19:38:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return *this;
|
2023-06-23 12:17:41 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100ae510
|
2023-12-13 05:48:14 -05:00
|
|
|
const MxString& MxString::operator=(const char* p_data)
|
2023-06-23 12:17:41 -04:00
|
|
|
{
|
2023-12-13 05:48:14 -05:00
|
|
|
if (this->m_data != p_data) {
|
2023-10-24 19:38:27 -04:00
|
|
|
delete[] this->m_data;
|
2023-12-13 05:48:14 -05:00
|
|
|
this->m_length = strlen(p_data);
|
2023-10-24 19:38:27 -04:00
|
|
|
this->m_data = new char[this->m_length + 1];
|
2023-12-13 05:48:14 -05:00
|
|
|
strcpy(this->m_data, p_data);
|
2023-10-24 19:38:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return *this;
|
2023-06-23 12:17:41 -04:00
|
|
|
}
|
2023-06-27 22:57:30 -04:00
|
|
|
|
|
|
|
// Return type is intentionally just MxString, not MxString&.
|
|
|
|
// This forces MSVC to add $ReturnUdt$ to the stack for 100% match.
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100ae580
|
2023-12-13 05:48:14 -05:00
|
|
|
MxString MxString::operator+(const char* p_str)
|
2023-06-27 22:57:30 -04:00
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
// MxString constructor allocates 1 byte for m_data, so free that first
|
|
|
|
MxString tmp;
|
|
|
|
delete[] tmp.m_data;
|
|
|
|
|
2023-12-13 05:48:14 -05:00
|
|
|
tmp.m_length = strlen(p_str) + this->m_length;
|
2023-10-24 19:38:27 -04:00
|
|
|
tmp.m_data = new char[tmp.m_length + 1];
|
2023-06-27 22:57:30 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
strcpy(tmp.m_data, this->m_data);
|
2023-12-13 05:48:14 -05:00
|
|
|
strcpy(tmp.m_data + this->m_length, p_str);
|
2023-06-27 22:57:30 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
return MxString(tmp);
|
2023-06-27 22:57:30 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100ae690
|
2023-12-13 05:48:14 -05:00
|
|
|
MxString& MxString::operator+=(const char* p_str)
|
2023-06-27 22:57:30 -04:00
|
|
|
{
|
2023-12-13 05:48:14 -05:00
|
|
|
int newlen = this->m_length + strlen(p_str);
|
2023-10-24 19:38:27 -04:00
|
|
|
|
|
|
|
char* tmp = new char[newlen + 1];
|
|
|
|
strcpy(tmp, this->m_data);
|
2023-12-13 05:48:14 -05:00
|
|
|
strcpy(tmp + this->m_length, p_str);
|
2023-06-27 22:57:30 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
delete[] this->m_data;
|
|
|
|
this->m_length = newlen;
|
|
|
|
this->m_data = tmp;
|
2023-06-27 22:57:30 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
return *this;
|
2023-06-27 22:57:30 -04:00
|
|
|
}
|