[ATL][SHELL32] Add basic support for _ATL_NO_EXCEPTIONS in CString, use it in shell32...
[reactos.git] / reactos / sdk / lib / atl / atlsimpstr.h
index f55dae5..1132e60 100644 (file)
@@ -4,7 +4,7 @@
 #pragma once
 
 #include <atlcore.h>
-
+#include <atlexcept.h>
 
 namespace ATL
 {
@@ -200,6 +200,28 @@ public:
         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);
@@ -463,7 +485,7 @@ private:
         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,
@@ -495,7 +517,7 @@ private:
         if (pOldData->IsShared())
         {
             Fork(nLength);
-            ATLASSERT(FALSE);
+            //ATLASSERT(FALSE);
         }
         else if (pOldData->nAllocLength < nLength)
         {
@@ -528,7 +550,7 @@ private:
         CStringData* pNewData = pStringMgr->Reallocate(pOldData, nLength, sizeof(XCHAR));
         if (pNewData == NULL)
         {
-            throw; // ThrowMemoryException();
+            ThrowMemoryException();
         }
 
         Attach(pNewData);
@@ -540,7 +562,9 @@ private:
         ATLASSERT(nLength <= GetData()->nAllocLength);
 
         if (nLength < 0 || nLength > GetData()->nAllocLength)
-            throw;
+        {
+            AtlThrow(E_INVALIDARG);
+        }
 
         GetData()->nDataLength = nLength;
         m_pszData[nLength] = 0;
@@ -561,7 +585,7 @@ private:
             pNewData = pNewStringMgr->Allocate(pData->nDataLength, sizeof(XCHAR));
             if (pNewData == NULL)
             {
-                throw; // ThrowMemoryException();
+                ThrowMemoryException();
             }
 
             pNewData->nDataLength = pData->nDataLength;
@@ -572,6 +596,12 @@ private:
         return pNewData;
     }
 
+
+    static void ThrowMemoryException()
+    {
+        AtlThrow(E_OUTOFMEMORY);
+    }
+
 };
 }