Purpose: Set this string equal to the operand. If the internal address of this string instance is already equal to that of the operand, this function does nothing. Otherwise this string is cleared, the copy count of the operand string is incremented, then the internal address is set to that of the operand.
| Return Type | Function name | Arguments |
|---|---|---|
| hzString& | hzString::operator= | (hzString&,) |
Declared in file: hzString.h
Defined in file : hzString.cpp
Function Logic:
Function body:
hzString& hzString::operator= (hzString& op)
{
// Purpose: Set this string equal to the operand.
//
// If the internal address of this string instance is already equal to that of the operand, this function does nothing. Otherwise this string is cleared, the copy count of the
// operand string is incremented, then the internal address is set to that of the operand.
//
// Argument: op Reference to the operand hzString instance.
//
// Returns: Reference to this string instance
_hzfunc("hzString::operator=(hzString&)") ;
_strItem* suppCtl ; // Supplied string's control area
if (!this)
hzerr(E_CORRUPT, "No instance") ;
// It the this string's internal pointer and that of the operand already point to the same internal structure in memory, do nothing
if (m_addr == op.m_addr)
return *this ;
// If this string has a value, clear it.
if (m_addr)
Clear() ;
// If the operand has content, increment the copy count and make this string address equal to that of the supplied.
if (op.m_addr)
{
suppCtl = _strXlate(op.m_addr) ;
if (suppCtl->m_copy < 50)
{
if (_hzGlobal_MT)
// __sync_add_and_fetch((uint32_t*)&(suppCtl->m_copy), 1) ;
suppCtl->m_copy++ ;
else
suppCtl->m_copy++ ;
}
m_addr = op.m_addr ;
}
return *this ;
}