}
-void UString::operator =( const UString &rOther )
+UString& UString::operator =( const UString &rOther )
{
+ if( this == &rOther )
+ return *this;
+
m_length = rOther.m_length;
delete[] m_pString;
m_pString = new uint32_t[size() + 1];
{
m_pString[i] = rOther.m_pString[i];
}
+
+ return *this;
}
-void UString::operator +=( const UString &rOther )
+UString& UString::operator +=( const UString &rOther )
{
+ if( this == &rOther )
+ return *this;
+
int tempLength = this->length() + rOther.length();
uint32_t *pTempString = new uint32_t[tempLength + 1];
// Copy the first string
- memcpy( pTempString, this->m_pString, 4 * this->size() );
+ memcpy( pTempString, this->m_pString, sizeof(uint32_t) * this->size() );
// Append the second string
// memcpy( pTempString + 4 * size(), rOther.m_pString,
// 4 * rOther.size() );
delete[] m_pString;
m_pString = pTempString;
m_length = tempLength;
+
+ return *this;
}
bool operator >( const UString &rOther ) const;
bool operator >=( const UString &rOther ) const;
/// Assignment
- void operator =( const UString &rOther );
+ UString& operator =( const UString &rOther );
/// Concatenation with assignment
- void operator +=( const UString &rOther );
+ UString& operator +=( const UString &rOther );
/// Concatenation
const UString operator +( const UString &rOther ) const;
const UString operator +( const char *pString ) const;