1#ifndef __ATLSIMPSTR_H__
2#define __ATLSIMPSTR_H__
106template<
typename BaseType =
char >
130template<
typename BaseType,
bool t_bMFCDLL = false>
207 if (pNewData !=
pData)
217 SetString(strSrc.GetString(), strSrc.GetLength());
283 int nNewLength = nOldLength +
nLength;
285 if (nOffset <= (
UINT_PTR)nOldLength)
287 pszSrc = pszBuffer + nOffset;
300 Append(strSrc.GetString(), strSrc.GetLength());
321 if (nOffset <= nOldLength)
337 if (
pData->IsShared())
340 Fork(
pData->nDataLength);
392 return (pStringMgr ? pStringMgr->
Clone() :
NULL);
401 Concatenate(
s, str1, str1.GetLength(), str2, str2.GetLength());
425 _In_ size_t nDestLen,
427 _In_ int nChars)
throw()
434 _In_ size_t nDestLen,
436 _In_ int nChars)
throw()
443 if (psz ==
NULL)
return 0;
449 if (psz ==
NULL)
return 0;
455 static int __cdecl StringLengthN(
457 _In_ size_t sizeInXChar)
throw()
459 if (psz ==
NULL)
return 0;
460 return (
int)strnlen(psz, sizeInXChar);
463 static int __cdecl StringLengthN(
465 _In_ size_t sizeInXChar)
throw()
467 if (psz ==
NULL)
return 0;
468 return (
int)wcsnlen(psz, sizeInXChar);
480 int nNewLength = nLength1 + nLength2;
481 PXSTR pszBuffer = strResult.GetBuffer(nNewLength);
482 CopyChars(pszBuffer, nLength1, psz1, nLength1);
483 CopyChars(pszBuffer + nLength1, nLength2, psz2, nLength2);
484 strResult.ReleaseBufferSetLength(nNewLength);
498 if (pNewData ==
NULL)
502 int nCharsToCopy = ((nOldLength <
nLength) ? nOldLength :
nLength) + 1;
513 int nShared = 1 - pOldData->
nRefs;
515 if ((nShared | nTooShort) < 0)
537 if (nNewLength > 1024 * 1024 * 1024)
539 nNewLength += 1024 * 1024;
543 nNewLength = nNewLength + nNewLength / 2;
563 if (pNewData ==
NULL)
576 if (nLength < 0 || nLength >
GetData()->nAllocLength)
590 if (!
pData->IsLocked() && (pNewStringMgr ==
pData->pStringMgr))
597 pNewData = pNewStringMgr->Allocate(
pData->nDataLength,
sizeof(
XCHAR));
598 if (pNewData ==
NULL)
ACPI_SIZE strlen(const char *String)
void SetManager(_In_ IAtlStringMgr *pMgr)
void Append(_In_count_(nLength) PCXSTR pszSrc, _In_ int nLength)
CSimpleStringT & operator=(_In_ const CSimpleStringT &strSrc)
__declspec(noinline) void Fork(_In_ int nLength)
CSimpleStringT & operator+=(_In_z_ PCXSTR pszSrc)
static void __cdecl Concatenate(_Inout_ CSimpleStringT &strResult, _In_count_(nLength1) PCXSTR psz1, _In_ int nLength1, _In_count_(nLength2) PCXSTR psz2, _In_ int nLength2)
friend CSimpleStringT operator+(_In_ const CSimpleStringT &str1, _In_z_ PCXSTR psz2)
static CStringData *__cdecl CloneData(_Inout_ CStringData *pData)
void Append(_In_ const CSimpleStringT &strSrc)
CSimpleStringT & operator=(_In_opt_z_ PCXSTR pszSrc)
void Reallocate(_In_ int nLength)
static int __cdecl StringLength(_In_opt_z_ const char *psz)
CSimpleStringT(_In_z_ PCXSTR pszSrc, _Inout_ IAtlStringMgr *pStringMgr)
static void __cdecl CopyChars(_Out_writes_to_(nDestLen, nChars) XCHAR *pchDest, _In_ size_t nDestLen, _In_reads_opt_(nChars) const XCHAR *pchSrc, _In_ int nChars)
CSimpleStringT & operator+=(XCHAR ch)
void SetString(_In_reads_opt_(nLength) PCXSTR pszSrc, _In_ int nLength)
CSimpleStringT(_In_count_(nLength) const XCHAR *pchSrc, _In_ int nLength, _Inout_ IAtlStringMgr *pStringMgr)
void Attach(_Inout_ CStringData *pData)
ChTraitsBase< BaseType >::PCXSTR PCXSTR
friend CSimpleStringT operator+(_In_ const CSimpleStringT &str1, _In_ const CSimpleStringT &str2)
IAtlStringMgr * GetManager() const
ChTraitsBase< BaseType >::PCYSTR PCYSTR
_Ret_notnull_ _Post_writable_size_(nMinBufferLength+1) PXSTR GetBuffer(_In_ int nMinBufferLength)
ChTraitsBase< BaseType >::YCHAR YCHAR
ChTraitsBase< BaseType >::PXSTR PXSTR
void ReleaseBufferSetLength(_In_ int nNewLength)
PXSTR PrepareWrite(_In_ int nLength)
static void ThrowInvalidArgException()
static void __cdecl CopyCharsOverlapped(_Out_writes_to_(nDestLen, nDestLen) XCHAR *pchDest, _In_ size_t nDestLen, _In_reads_(nChars) const XCHAR *pchSrc, _In_ int nChars)
CSimpleStringT(_In_ const CSimpleStringT &strSrc)
int GetAllocLength() const
CSimpleStringT(_Inout_ IAtlStringMgr *pStringMgr)
CSimpleStringT & operator+=(_In_ const CSimpleStringT &strSrc)
void PrepareWrite2(_In_ int nLength)
ChTraitsBase< BaseType >::PYSTR PYSTR
void SetString(_In_opt_z_ PCXSTR pszSrc)
void Append(_In_z_ PCXSTR pszSrc)
static int __cdecl StringLength(_In_opt_z_ const wchar_t *psz)
void ReleaseBuffer(_In_ int nNewLength=-1)
void SetLength(_In_ int nLength)
friend CSimpleStringT operator+(_In_z_ PCXSTR psz1, _In_ const CSimpleStringT &str2)
static void ThrowMemoryException()
CStringData * GetData() const
ChTraitsBase< BaseType >::XCHAR XCHAR
virtual void Free(_Inout_ CStringData *pData)=0
virtual _Ret_maybenull_ _In_ int nCharSize
virtual CStringData * GetNilString(void)=0
virtual _Ret_maybenull_ _Post_writable_byte_size_(sizeof(CStringData)+nAllocLength *nCharSize) CStringData *Reallocate(_Inout_ CStringData *pData
virtual _Ret_maybenull_ _Post_writable_byte_size_(sizeof(CStringData)+nAllocLength *nCharSize) CStringData *Allocate(_In_ int nAllocLength
virtual IAtlStringMgr * Clone(void)=0
virtual _Ret_maybenull_ _In_ int nAllocLength
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
long __cdecl _InterlockedIncrement(_Interlocked_operand_ long volatile *_Addend)
long __cdecl _InterlockedDecrement(_Interlocked_operand_ long volatile *_Addend)
#define memcpy(s1, s2, n)
#define memmove(s1, s2, n)
#define _In_opt_z_count_(size)
#define _In_reads_opt_(size)
#define _Out_writes_to_(size, count)
unsigned __int3264 UINT_PTR
CSimpleStringT< CHAR > CSimpleString
IAtlStringMgr * pStringMgr
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
_In_opt_ PALLOCATE_FUNCTION Allocate