#pragma once
#include <atlcore.h>
-
+#include <atlexcept.h>
namespace ATL
{
return *this;
}
+ CSimpleStringT& operator=(_In_ const CSimpleStringT& strSrc)
+ {
+ CStringData* pData = GetData();
+ CStringData* pNewData = strSrc.GetData();
+
+ if (pNewData != pData)
+ {
+ if (!pData->IsLocked() && (pNewData->pStringMgr == pData->pStringMgr))
+ {
+ pNewData = CloneData(pNewData);
+ pData->Release();
+ Attach(pNewData);
+ }
+ else
+ {
+ SetString(strSrc.GetString(), strSrc.GetLength());
+ }
+ }
+
+ return *this;
+ }
+
CSimpleStringT& operator+=(_In_ const CSimpleStringT& strSrc)
{
Append(strSrc);
CStringData* pNewData = pOldData->pStringMgr->Clone()->Allocate(nLength, sizeof(XCHAR));
if (pNewData == NULL)
{
- throw; // ThrowMemoryException();
+ ThrowMemoryException();
}
int nCharsToCopy = ((nOldLength < nLength) ? nOldLength : nLength) + 1;
CopyChars(PXSTR(pNewData->data()), nCharsToCopy,
if (pOldData->IsShared())
{
Fork(nLength);
- ATLASSERT(FALSE);
+ //ATLASSERT(FALSE);
}
else if (pOldData->nAllocLength < nLength)
{
CStringData* pNewData = pStringMgr->Reallocate(pOldData, nLength, sizeof(XCHAR));
if (pNewData == NULL)
{
- throw; // ThrowMemoryException();
+ ThrowMemoryException();
}
Attach(pNewData);
ATLASSERT(nLength <= GetData()->nAllocLength);
if (nLength < 0 || nLength > GetData()->nAllocLength)
- throw;
+ {
+ AtlThrow(E_INVALIDARG);
+ }
GetData()->nDataLength = nLength;
m_pszData[nLength] = 0;
pNewData = pNewStringMgr->Allocate(pData->nDataLength, sizeof(XCHAR));
if (pNewData == NULL)
{
- throw; // ThrowMemoryException();
+ ThrowMemoryException();
}
pNewData->nDataLength = pData->nDataLength;
return pNewData;
}
+
+ static void ThrowMemoryException()
+ {
+ AtlThrow(E_OUTOFMEMORY);
+ }
+
};
}