1#ifndef __ATLSIMPSTR_H__
2#define __ATLSIMPSTR_H__
11 #define _In_count_(nLength)
112template<
typename BaseType =
char >
136template<
typename BaseType,
bool t_bMFCDLL = false>
213 if (pNewData !=
pData)
223 SetString(strSrc.GetString(), strSrc.GetLength());
289 int nNewLength = nOldLength +
nLength;
291 if (nOffset <= (
UINT_PTR)nOldLength)
293 pszSrc = pszBuffer + nOffset;
306 Append(strSrc.GetString(), strSrc.GetLength());
327 if (nOffset <= nOldLength)
343 if (
pData->IsShared())
346 Fork(
pData->nDataLength);
407 return (pStringMgr ? pStringMgr->
Clone() :
NULL);
416 Concatenate(
s, str1, str1.GetLength(), str2, str2.GetLength());
440 _In_ size_t nDestLen,
442 _In_ int nChars)
noexcept
449 _In_ size_t nDestLen,
451 _In_ int nChars)
noexcept
458 if (psz ==
NULL)
return 0;
464 if (psz ==
NULL)
return 0;
470 static int __cdecl StringLengthN(
472 _In_ size_t sizeInXChar)
noexcept
474 if (psz ==
NULL)
return 0;
475 return (
int)strnlen(psz, sizeInXChar);
478 static int __cdecl StringLengthN(
480 _In_ size_t sizeInXChar)
noexcept
482 if (psz ==
NULL)
return 0;
483 return (
int)wcsnlen(psz, sizeInXChar);
495 int nNewLength = nLength1 + nLength2;
496 PXSTR pszBuffer = strResult.GetBuffer(nNewLength);
497 CopyChars(pszBuffer, nLength1, psz1, nLength1);
498 CopyChars(pszBuffer + nLength1, nLength2, psz2, nLength2);
499 strResult.ReleaseBufferSetLength(nNewLength);
513 if (pNewData ==
NULL)
517 int nCharsToCopy = ((nOldLength <
nLength) ? nOldLength :
nLength) + 1;
528 int nShared = 1 - pOldData->
nRefs;
530 if ((nShared | nTooShort) < 0)
552 if (nNewLength > 1024 * 1024 * 1024)
554 nNewLength += 1024 * 1024;
558 nNewLength = nNewLength + nNewLength / 2;
578 if (pNewData ==
NULL)
591 if (nLength < 0 || nLength >
GetData()->nAllocLength)
605 if (!
pData->IsLocked() && (pNewStringMgr ==
pData->pStringMgr))
612 pNewData = pNewStringMgr->Allocate(
pData->nDataLength,
sizeof(
XCHAR));
613 if (pNewData ==
NULL)
ACPI_SIZE strlen(const char *String)
CNilStringData() noexcept
void SetManager(_In_ IAtlStringMgr *pMgr) noexcept
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)
CStringData * GetData() const noexcept
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)
static int __cdecl StringLength(_In_opt_z_ const wchar_t *psz) noexcept
void Append(_In_ const CSimpleStringT &strSrc)
CSimpleStringT & operator=(_In_opt_z_ PCXSTR pszSrc)
void Reallocate(_In_ int nLength)
void Preallocate(_In_ int nLength)
CSimpleStringT(_In_z_ PCXSTR pszSrc, _Inout_ IAtlStringMgr *pStringMgr)
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)
static int __cdecl StringLength(_In_opt_z_ const char *psz) noexcept
void Attach(_Inout_ CStringData *pData) noexcept
ChTraitsBase< BaseType >::PCXSTR PCXSTR
friend CSimpleStringT operator+(_In_ const CSimpleStringT &str1, _In_ const CSimpleStringT &str2)
~CSimpleStringT() noexcept
ChTraitsBase< BaseType >::PCYSTR PCYSTR
static void __cdecl CopyCharsOverlapped(_Out_writes_to_(nDestLen, nDestLen) XCHAR *pchDest, _In_ size_t nDestLen, _In_reads_(nChars) const XCHAR *pchSrc, _In_ int nChars) noexcept
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) noexcept
PCXSTR GetString() const noexcept
bool IsEmpty() const noexcept
_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)
IAtlStringMgr * GetManager() const noexcept
static void ThrowInvalidArgException()
int GetAllocLength() const noexcept
CSimpleStringT(_In_ const CSimpleStringT &strSrc)
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)
void ReleaseBuffer(_In_ int nNewLength=-1)
void SetLength(_In_ int nLength)
friend CSimpleStringT operator+(_In_z_ PCXSTR psz1, _In_ const CSimpleStringT &str2)
PXSTR GetString() noexcept
static void ThrowMemoryException()
int GetLength() const noexcept
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)
unsigned __int3264 UINT_PTR
CSimpleStringT< CHAR > CSimpleString
#define _In_reads_opt_(s)
#define _Out_writes_to_(s, c)
bool IsLocked() const noexcept
bool IsShared() const noexcept
IAtlStringMgr * pStringMgr
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
_In_opt_ PALLOCATE_FUNCTION Allocate