ReactOS 0.4.15-dev-7961-gdcf9eb0
ATL::CSimpleStringT< BaseType, t_bMFCDLL > Class Template Reference

#include <atlsimpstr.h>

Collaboration diagram for ATL::CSimpleStringT< BaseType, t_bMFCDLL >:

Public Types

typedef ChTraitsBase< BaseType >::XCHAR XCHAR
 
typedef ChTraitsBase< BaseType >::PXSTR PXSTR
 
typedef ChTraitsBase< BaseType >::PCXSTR PCXSTR
 
typedef ChTraitsBase< BaseType >::YCHAR YCHAR
 
typedef ChTraitsBase< BaseType >::PYSTR PYSTR
 
typedef ChTraitsBase< BaseType >::PCYSTR PCYSTR
 

Public Member Functions

 CSimpleStringT (_Inout_ IAtlStringMgr *pStringMgr)
 
 CSimpleStringT (_In_ const CSimpleStringT &strSrc)
 
 CSimpleStringT (_In_z_ PCXSTR pszSrc, _Inout_ IAtlStringMgr *pStringMgr)
 
 CSimpleStringT (_In_count_(nLength) const XCHAR *pchSrc, _In_ int nLength, _Inout_ IAtlStringMgr *pStringMgr)
 
 ~CSimpleStringT () noexcept
 
CSimpleStringToperator= (_In_opt_z_ PCXSTR pszSrc)
 
CSimpleStringToperator= (_In_ const CSimpleStringT &strSrc)
 
CSimpleStringToperator+= (_In_ const CSimpleStringT &strSrc)
 
CSimpleStringToperator+= (_In_z_ PCXSTR pszSrc)
 
CSimpleStringToperator+= (XCHAR ch)
 
 operator PCXSTR () const noexcept
 
void Empty () noexcept
 
void Append (_In_count_(nLength) PCXSTR pszSrc, _In_ int nLength)
 
void Append (_In_z_ PCXSTR pszSrc)
 
void Append (_In_ const CSimpleStringT &strSrc)
 
void SetString (_In_opt_z_ PCXSTR pszSrc)
 
void SetString (_In_reads_opt_(nLength) PCXSTR pszSrc, _In_ int nLength)
 
PXSTR GetBuffer ()
 
_Ret_notnull_ _Post_writable_size_ (nMinBufferLength+1) PXSTR GetBuffer(_In_ int nMinBufferLength)
 
int GetAllocLength () const noexcept
 
int GetLength () const noexcept
 
PXSTR GetString () noexcept
 
PCXSTR GetString () const noexcept
 
void Preallocate (_In_ int nLength)
 
void ReleaseBufferSetLength (_In_ int nNewLength)
 
void ReleaseBuffer (_In_ int nNewLength=-1)
 
bool IsEmpty () const noexcept
 
CStringDataGetData () const noexcept
 
IAtlStringMgrGetManager () const noexcept
 

Static Public Member Functions

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
 
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 int __cdecl StringLength (_In_opt_z_ const char *psz) noexcept
 
static int __cdecl StringLength (_In_opt_z_ const wchar_t *psz) noexcept
 

Static Protected Member Functions

static void __cdecl Concatenate (_Inout_ CSimpleStringT &strResult, _In_count_(nLength1) PCXSTR psz1, _In_ int nLength1, _In_count_(nLength2) PCXSTR psz2, _In_ int nLength2)
 
static void ThrowMemoryException ()
 
static void ThrowInvalidArgException ()
 

Private Member Functions

void Attach (_Inout_ CStringData *pData) noexcept
 
 __declspec (noinline) void Fork(_In_ int nLength)
 
PXSTR PrepareWrite (_In_ int nLength)
 
void PrepareWrite2 (_In_ int nLength)
 
void Reallocate (_In_ int nLength)
 
void SetLength (_In_ int nLength)
 

Static Private Member Functions

static CStringData *__cdecl CloneData (_Inout_ CStringData *pData)
 

Private Attributes

PXSTR m_pszData
 

Friends

CSimpleStringT operator+ (_In_ const CSimpleStringT &str1, _In_ const CSimpleStringT &str2)
 
CSimpleStringT operator+ (_In_ const CSimpleStringT &str1, _In_z_ PCXSTR psz2)
 
CSimpleStringT operator+ (_In_z_ PCXSTR psz1, _In_ const CSimpleStringT &str2)
 

Detailed Description

template<typename BaseType, bool t_bMFCDLL = false>
class ATL::CSimpleStringT< BaseType, t_bMFCDLL >

Definition at line 137 of file atlsimpstr.h.

Member Typedef Documentation

◆ PCXSTR

template<typename BaseType , bool t_bMFCDLL = false>
typedef ChTraitsBase<BaseType>::PCXSTR ATL::CSimpleStringT< BaseType, t_bMFCDLL >::PCXSTR

Definition at line 142 of file atlsimpstr.h.

◆ PCYSTR

template<typename BaseType , bool t_bMFCDLL = false>
typedef ChTraitsBase<BaseType>::PCYSTR ATL::CSimpleStringT< BaseType, t_bMFCDLL >::PCYSTR

Definition at line 145 of file atlsimpstr.h.

◆ PXSTR

template<typename BaseType , bool t_bMFCDLL = false>
typedef ChTraitsBase<BaseType>::PXSTR ATL::CSimpleStringT< BaseType, t_bMFCDLL >::PXSTR

Definition at line 141 of file atlsimpstr.h.

◆ PYSTR

template<typename BaseType , bool t_bMFCDLL = false>
typedef ChTraitsBase<BaseType>::PYSTR ATL::CSimpleStringT< BaseType, t_bMFCDLL >::PYSTR

Definition at line 144 of file atlsimpstr.h.

◆ XCHAR

template<typename BaseType , bool t_bMFCDLL = false>
typedef ChTraitsBase<BaseType>::XCHAR ATL::CSimpleStringT< BaseType, t_bMFCDLL >::XCHAR

Definition at line 140 of file atlsimpstr.h.

◆ YCHAR

template<typename BaseType , bool t_bMFCDLL = false>
typedef ChTraitsBase<BaseType>::YCHAR ATL::CSimpleStringT< BaseType, t_bMFCDLL >::YCHAR

Definition at line 143 of file atlsimpstr.h.

Constructor & Destructor Documentation

◆ CSimpleStringT() [1/4]

template<typename BaseType , bool t_bMFCDLL = false>
ATL::CSimpleStringT< BaseType, t_bMFCDLL >::CSimpleStringT ( _Inout_ IAtlStringMgr pStringMgr)
inlineexplicit

Definition at line 151 of file atlsimpstr.h.

152 {
153 CStringData* pData = pStringMgr->GetNilString();
154 Attach(pData);
155 }
void Attach(_Inout_ CStringData *pData) noexcept
Definition: atlsimpstr.h:503
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830

◆ CSimpleStringT() [2/4]

template<typename BaseType , bool t_bMFCDLL = false>
ATL::CSimpleStringT< BaseType, t_bMFCDLL >::CSimpleStringT ( _In_ const CSimpleStringT< BaseType, t_bMFCDLL > &  strSrc)
inline

Definition at line 157 of file atlsimpstr.h.

158 {
159 CStringData* pSrcData = strSrc.GetData();
160 CStringData* pNewData = CloneData(pSrcData);
161 Attach(pNewData);
162 }
static CStringData *__cdecl CloneData(_Inout_ CStringData *pData)
Definition: atlsimpstr.h:600

◆ CSimpleStringT() [3/4]

template<typename BaseType , bool t_bMFCDLL = false>
ATL::CSimpleStringT< BaseType, t_bMFCDLL >::CSimpleStringT ( _In_z_ PCXSTR  pszSrc,
_Inout_ IAtlStringMgr pStringMgr 
)
inline

Definition at line 164 of file atlsimpstr.h.

167 {
168 int nLength = StringLength(pszSrc);
169 CStringData* pData = pStringMgr->Allocate(nLength, sizeof(XCHAR));
170 if (pData == NULL)
172
173 Attach(pData);
176 }
static int __cdecl StringLength(_In_opt_z_ const char *psz) noexcept
Definition: atlsimpstr.h:456
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
Definition: atlsimpstr.h:438
void SetLength(_In_ int nLength)
Definition: atlsimpstr.h:586
static void ThrowMemoryException()
Definition: atlsimpstr.h:627
ChTraitsBase< BaseType >::XCHAR XCHAR
Definition: atlsimpstr.h:140
#define NULL
Definition: types.h:112
_In_ DWORD nLength
Definition: wincon.h:473

◆ CSimpleStringT() [4/4]

template<typename BaseType , bool t_bMFCDLL = false>
ATL::CSimpleStringT< BaseType, t_bMFCDLL >::CSimpleStringT ( _In_count_(nLength) const XCHAR pchSrc,
_In_ int  nLength,
_Inout_ IAtlStringMgr pStringMgr 
)
inline

Definition at line 178 of file atlsimpstr.h.

182 {
183 if (pchSrc == NULL && nLength != 0)
185
186 CStringData* pData = pStringMgr->Allocate(nLength, sizeof(XCHAR));
187 if (pData == NULL)
188 {
190 }
191 Attach(pData);
194 }
static void ThrowInvalidArgException()
Definition: atlsimpstr.h:632

◆ ~CSimpleStringT()

template<typename BaseType , bool t_bMFCDLL = false>
ATL::CSimpleStringT< BaseType, t_bMFCDLL >::~CSimpleStringT ( )
inlinenoexcept

Definition at line 196 of file atlsimpstr.h.

197 {
198 CStringData* pData = GetData();
199 pData->Release();
200 }
CStringData * GetData() const noexcept
Definition: atlsimpstr.h:399

Member Function Documentation

◆ __declspec()

template<typename BaseType , bool t_bMFCDLL = false>
ATL::CSimpleStringT< BaseType, t_bMFCDLL >::__declspec ( noinline  )
inlineprivate

Definition at line 508 of file atlsimpstr.h.

509 {
510 CStringData* pOldData = GetData();
511 int nOldLength = pOldData->nDataLength;
512 CStringData* pNewData = pOldData->pStringMgr->Clone()->Allocate(nLength, sizeof(XCHAR));
513 if (pNewData == NULL)
514 {
516 }
517 int nCharsToCopy = ((nOldLength < nLength) ? nOldLength : nLength) + 1;
518 CopyChars(PXSTR(pNewData->data()), nCharsToCopy,
519 PCXSTR(pOldData->data()), nCharsToCopy);
520 pNewData->nDataLength = nOldLength;
521 pOldData->Release();
522 Attach(pNewData);
523 }
ChTraitsBase< BaseType >::PCXSTR PCXSTR
Definition: atlsimpstr.h:142
ChTraitsBase< BaseType >::PXSTR PXSTR
Definition: atlsimpstr.h:141

◆ _Post_writable_size_()

template<typename BaseType , bool t_bMFCDLL = false>
_Ret_notnull_ ATL::CSimpleStringT< BaseType, t_bMFCDLL >::_Post_writable_size_ ( nMinBufferLength+  1)
inline

Definition at line 352 of file atlsimpstr.h.

353 {
354 return PrepareWrite(nMinBufferLength);
355 }
PXSTR PrepareWrite(_In_ int nLength)
Definition: atlsimpstr.h:525

◆ Append() [1/3]

template<typename BaseType , bool t_bMFCDLL = false>
void ATL::CSimpleStringT< BaseType, t_bMFCDLL >::Append ( _In_ const CSimpleStringT< BaseType, t_bMFCDLL > &  strSrc)
inline

Definition at line 304 of file atlsimpstr.h.

305 {
306 Append(strSrc.GetString(), strSrc.GetLength());
307 }
void Append(_In_count_(nLength) PCXSTR pszSrc, _In_ int nLength)
Definition: atlsimpstr.h:271

◆ Append() [2/3]

template<typename BaseType , bool t_bMFCDLL = false>
void ATL::CSimpleStringT< BaseType, t_bMFCDLL >::Append ( _In_count_(nLength) PCXSTR  pszSrc,
_In_ int  nLength 
)
inline

Definition at line 271 of file atlsimpstr.h.

274 {
275 UINT_PTR nOffset = pszSrc - GetString();
276
277 int nOldLength = GetLength();
278 if (nOldLength < 0)
279 nOldLength = 0;
280
281 ATLASSERT(nLength >= 0);
282
283#if 0 // FIXME: See comment for StringLengthN below.
284 nLength = StringLengthN(pszSrc, nLength);
285 if (!(INT_MAX - nLength >= nOldLength))
286 throw;
287#endif
288
289 int nNewLength = nOldLength + nLength;
290 PXSTR pszBuffer = GetBuffer(nNewLength);
291 if (nOffset <= (UINT_PTR)nOldLength)
292 {
293 pszSrc = pszBuffer + nOffset;
294 }
295 CopyChars(pszBuffer + nOldLength, nLength, pszSrc, nLength);
296 ReleaseBufferSetLength(nNewLength);
297 }
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
void ReleaseBufferSetLength(_In_ int nNewLength)
Definition: atlsimpstr.h:381
PXSTR GetString() noexcept
Definition: atlsimpstr.h:367
int GetLength() const noexcept
Definition: atlsimpstr.h:362
#define INT_MAX
Definition: limits.h:40
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274

Referenced by ATL::CSimpleStringT< BaseType, t_bMFCDLL >::Append(), ATL::CSimpleStringT< BaseType, t_bMFCDLL >::operator+=(), and CZipExtract::ShowExtractError().

◆ Append() [3/3]

template<typename BaseType , bool t_bMFCDLL = false>
void ATL::CSimpleStringT< BaseType, t_bMFCDLL >::Append ( _In_z_ PCXSTR  pszSrc)
inline

Definition at line 299 of file atlsimpstr.h.

300 {
301 Append(pszSrc, StringLength(pszSrc));
302 }

◆ Attach()

◆ CloneData()

template<typename BaseType , bool t_bMFCDLL = false>
static CStringData *__cdecl ATL::CSimpleStringT< BaseType, t_bMFCDLL >::CloneData ( _Inout_ CStringData pData)
inlinestaticprivate

Definition at line 600 of file atlsimpstr.h.

601 {
602 CStringData* pNewData = NULL;
603
604 IAtlStringMgr* pNewStringMgr = pData->pStringMgr->Clone();
605 if (!pData->IsLocked() && (pNewStringMgr == pData->pStringMgr))
606 {
607 pNewData = pData;
608 pNewData->AddRef();
609 }
610 else
611 {
612 pNewData = pNewStringMgr->Allocate(pData->nDataLength, sizeof(XCHAR));
613 if (pNewData == NULL)
614 {
616 }
617
618 pNewData->nDataLength = pData->nDataLength;
619 CopyChars(PXSTR(pNewData->data()), pData->nDataLength + 1,
620 PCXSTR(pData->data()), pData->nDataLength + 1);
621 }
622
623 return pNewData;
624 }
nsrefcnt AddRef()

Referenced by ATL::CSimpleStringT< BaseType, t_bMFCDLL >::CSimpleStringT(), and ATL::CSimpleStringT< BaseType, t_bMFCDLL >::operator=().

◆ Concatenate()

template<typename BaseType , bool t_bMFCDLL = false>
static void __cdecl ATL::CSimpleStringT< BaseType, t_bMFCDLL >::Concatenate ( _Inout_ CSimpleStringT< BaseType, t_bMFCDLL > &  strResult,
_In_count_(nLength1) PCXSTR  psz1,
_In_ int  nLength1,
_In_count_(nLength2) PCXSTR  psz2,
_In_ int  nLength2 
)
inlinestaticprotected

Definition at line 488 of file atlsimpstr.h.

494 {
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);
500 }

◆ CopyChars()

template<typename BaseType , bool t_bMFCDLL = false>
static void __cdecl ATL::CSimpleStringT< BaseType, t_bMFCDLL >::CopyChars ( _Out_writes_to_(nDestLen, nChars) XCHAR pchDest,
_In_ size_t  nDestLen,
_In_reads_opt_(nChars) const XCHAR pchSrc,
_In_ int  nChars 
)
inlinestaticnoexcept

◆ CopyCharsOverlapped()

template<typename BaseType , bool t_bMFCDLL = false>
static void __cdecl ATL::CSimpleStringT< BaseType, t_bMFCDLL >::CopyCharsOverlapped ( _Out_writes_to_(nDestLen, nDestLen) XCHAR pchDest,
_In_ size_t  nDestLen,
_In_reads_(nChars) const XCHAR pchSrc,
_In_ int  nChars 
)
inlinestaticnoexcept

Definition at line 447 of file atlsimpstr.h.

452 {
453 memmove(pchDest, pchSrc, nChars * sizeof(XCHAR));
454 }
#define memmove(s1, s2, n)
Definition: mkisofs.h:881

Referenced by ATL::CSimpleStringT< BaseType, t_bMFCDLL >::SetString().

◆ Empty()

template<typename BaseType , bool t_bMFCDLL = false>
void ATL::CSimpleStringT< BaseType, t_bMFCDLL >::Empty ( )
inlinenoexcept

Definition at line 253 of file atlsimpstr.h.

254 {
255 CStringData* pOldData = GetData();
256 IAtlStringMgr* pStringMgr = pOldData->pStringMgr;
257 if (pOldData->nDataLength == 0) return;
258
259 if (pOldData->IsLocked())
260 {
261 SetLength(0);
262 }
263 else
264 {
265 pOldData->Release();
266 CStringData* pNewData = pStringMgr->GetNilString();
267 Attach(pNewData);
268 }
269 }

Referenced by DoTestCaseB(), CInstalledApplicationInfo::GetApplicationRegString(), GetStorageDirectory(), CConfigParser::GetString(), CAutoComplete::LoadQuickComplete(), CDownloaderProgress::OnSetText(), CAppScrnshotPreview::PreviousDisplayCleanup(), ATL::CSimpleStringT< BaseType, t_bMFCDLL >::SetString(), Test_Exporter(), and Test_Importer().

◆ GetAllocLength()

template<typename BaseType , bool t_bMFCDLL = false>
int ATL::CSimpleStringT< BaseType, t_bMFCDLL >::GetAllocLength ( ) const
inlinenoexcept

Definition at line 357 of file atlsimpstr.h.

358 {
359 return GetData()->nAllocLength;
360 }

Referenced by CCharMapWindow::ChangeMapFont(), and ATL::CSimpleStringT< BaseType, t_bMFCDLL >::SetString().

◆ GetBuffer()

template<typename BaseType , bool t_bMFCDLL = false>
PXSTR ATL::CSimpleStringT< BaseType, t_bMFCDLL >::GetBuffer ( )
inline

◆ GetData()

◆ GetLength()

◆ GetManager()

template<typename BaseType , bool t_bMFCDLL = false>
IAtlStringMgr * ATL::CSimpleStringT< BaseType, t_bMFCDLL >::GetManager ( ) const
inlinenoexcept

Definition at line 404 of file atlsimpstr.h.

405 {
406 IAtlStringMgr* pStringMgr = GetData()->pStringMgr;
407 return (pStringMgr ? pStringMgr->Clone() : NULL);
408 }
IAtlStringMgr * pStringMgr
Definition: atlsimpstr.h:50

◆ GetString() [1/2]

template<typename BaseType , bool t_bMFCDLL = false>
PCXSTR ATL::CSimpleStringT< BaseType, t_bMFCDLL >::GetString ( ) const
inlinenoexcept

Definition at line 371 of file atlsimpstr.h.

372 {
373 return m_pszData;
374 }

◆ GetString() [2/2]

◆ IsEmpty()

◆ operator PCXSTR()

template<typename BaseType , bool t_bMFCDLL = false>
ATL::CSimpleStringT< BaseType, t_bMFCDLL >::operator PCXSTR ( ) const
inlinenoexcept

Definition at line 248 of file atlsimpstr.h.

249 {
250 return m_pszData;
251 }

◆ operator+=() [1/3]

template<typename BaseType , bool t_bMFCDLL = false>
CSimpleStringT & ATL::CSimpleStringT< BaseType, t_bMFCDLL >::operator+= ( _In_ const CSimpleStringT< BaseType, t_bMFCDLL > &  strSrc)
inline

Definition at line 230 of file atlsimpstr.h.

231 {
232 Append(strSrc);
233 return *this;
234 }

◆ operator+=() [2/3]

template<typename BaseType , bool t_bMFCDLL = false>
CSimpleStringT & ATL::CSimpleStringT< BaseType, t_bMFCDLL >::operator+= ( _In_z_ PCXSTR  pszSrc)
inline

Definition at line 236 of file atlsimpstr.h.

237 {
238 Append(pszSrc);
239 return *this;
240 }

◆ operator+=() [3/3]

template<typename BaseType , bool t_bMFCDLL = false>
CSimpleStringT & ATL::CSimpleStringT< BaseType, t_bMFCDLL >::operator+= ( XCHAR  ch)
inline

Definition at line 242 of file atlsimpstr.h.

243 {
244 Append(&ch, 1);
245 return *this;
246 }

◆ operator=() [1/2]

template<typename BaseType , bool t_bMFCDLL = false>
CSimpleStringT & ATL::CSimpleStringT< BaseType, t_bMFCDLL >::operator= ( _In_ const CSimpleStringT< BaseType, t_bMFCDLL > &  strSrc)
inline

Definition at line 208 of file atlsimpstr.h.

209 {
210 CStringData* pData = GetData();
211 CStringData* pNewData = strSrc.GetData();
212
213 if (pNewData != pData)
214 {
215 if (!pData->IsLocked() && (pNewData->pStringMgr == pData->pStringMgr))
216 {
217 pNewData = CloneData(pNewData);
218 pData->Release();
219 Attach(pNewData);
220 }
221 else
222 {
223 SetString(strSrc.GetString(), strSrc.GetLength());
224 }
225 }
226
227 return *this;
228 }
void SetString(_In_opt_z_ PCXSTR pszSrc)
Definition: atlsimpstr.h:309

◆ operator=() [2/2]

template<typename BaseType , bool t_bMFCDLL = false>
CSimpleStringT & ATL::CSimpleStringT< BaseType, t_bMFCDLL >::operator= ( _In_opt_z_ PCXSTR  pszSrc)
inline

Definition at line 202 of file atlsimpstr.h.

203 {
204 SetString(pszSrc);
205 return *this;
206 }

◆ Preallocate()

template<typename BaseType , bool t_bMFCDLL = false>
void ATL::CSimpleStringT< BaseType, t_bMFCDLL >::Preallocate ( _In_ int  nLength)
inline

Definition at line 376 of file atlsimpstr.h.

377 {
379 }

Referenced by CCharMapWindow::ChangeMapFont().

◆ PrepareWrite()

template<typename BaseType , bool t_bMFCDLL = false>
PXSTR ATL::CSimpleStringT< BaseType, t_bMFCDLL >::PrepareWrite ( _In_ int  nLength)
inlineprivate

Definition at line 525 of file atlsimpstr.h.

526 {
527 CStringData* pOldData = GetData();
528 int nShared = 1 - pOldData->nRefs;
529 int nTooShort = pOldData->nAllocLength - nLength;
530 if ((nShared | nTooShort) < 0)
531 {
533 }
534
535 return m_pszData;
536 }
void PrepareWrite2(_In_ int nLength)
Definition: atlsimpstr.h:537

Referenced by ATL::CSimpleStringT< BaseType, t_bMFCDLL >::_Post_writable_size_(), and ATL::CSimpleStringT< BaseType, t_bMFCDLL >::Preallocate().

◆ PrepareWrite2()

template<typename BaseType , bool t_bMFCDLL = false>
void ATL::CSimpleStringT< BaseType, t_bMFCDLL >::PrepareWrite2 ( _In_ int  nLength)
inlineprivate

Definition at line 537 of file atlsimpstr.h.

538 {
539 CStringData* pOldData = GetData();
540 if (pOldData->nDataLength > nLength)
541 {
542 nLength = pOldData->nDataLength;
543 }
544 if (pOldData->IsShared())
545 {
546 Fork(nLength);
547 //ATLASSERT(FALSE);
548 }
549 else if (pOldData->nAllocLength < nLength)
550 {
551 int nNewLength = pOldData->nAllocLength;
552 if (nNewLength > 1024 * 1024 * 1024)
553 {
554 nNewLength += 1024 * 1024;
555 }
556 else
557 {
558 nNewLength = nNewLength + nNewLength / 2;
559 }
560 if (nNewLength < nLength)
561 {
562 nNewLength = nLength;
563 }
564 Reallocate(nNewLength);
565 }
566 }
void Reallocate(_In_ int nLength)
Definition: atlsimpstr.h:568

Referenced by ATL::CSimpleStringT< BaseType, t_bMFCDLL >::PrepareWrite().

◆ Reallocate()

template<typename BaseType , bool t_bMFCDLL = false>
void ATL::CSimpleStringT< BaseType, t_bMFCDLL >::Reallocate ( _In_ int  nLength)
inlineprivate

Definition at line 568 of file atlsimpstr.h.

569 {
570 CStringData* pOldData = GetData();
571 ATLASSERT(pOldData->nAllocLength < nLength);
572 IAtlStringMgr* pStringMgr = pOldData->pStringMgr;
573 if (pOldData->nAllocLength >= nLength || nLength <= 0)
574 {
575 return;
576 }
577 CStringData* pNewData = pStringMgr->Reallocate(pOldData, nLength, sizeof(XCHAR));
578 if (pNewData == NULL)
579 {
581 }
582
583 Attach(pNewData);
584 }

Referenced by ATL::CSimpleStringT< BaseType, t_bMFCDLL >::PrepareWrite2().

◆ ReleaseBuffer()

◆ ReleaseBufferSetLength()

template<typename BaseType , bool t_bMFCDLL = false>
void ATL::CSimpleStringT< BaseType, t_bMFCDLL >::ReleaseBufferSetLength ( _In_ int  nNewLength)
inline

◆ SetLength()

template<typename BaseType , bool t_bMFCDLL = false>
void ATL::CSimpleStringT< BaseType, t_bMFCDLL >::SetLength ( _In_ int  nLength)
inlineprivate

Definition at line 586 of file atlsimpstr.h.

587 {
588 ATLASSERT(nLength >= 0);
589 ATLASSERT(nLength <= GetData()->nAllocLength);
590
591 if (nLength < 0 || nLength > GetData()->nAllocLength)
592 {
594 }
595
597 m_pszData[nLength] = 0;
598 }
#define AtlThrow(x)
Definition: atldef.h:20
#define E_INVALIDARG
Definition: ddrawi.h:101

Referenced by ATL::CSimpleStringT< BaseType, t_bMFCDLL >::CSimpleStringT(), ATL::CSimpleStringT< BaseType, t_bMFCDLL >::Empty(), and ATL::CSimpleStringT< BaseType, t_bMFCDLL >::ReleaseBufferSetLength().

◆ SetString() [1/2]

template<typename BaseType , bool t_bMFCDLL = false>
void ATL::CSimpleStringT< BaseType, t_bMFCDLL >::SetString ( _In_opt_z_ PCXSTR  pszSrc)
inline

◆ SetString() [2/2]

template<typename BaseType , bool t_bMFCDLL = false>
void ATL::CSimpleStringT< BaseType, t_bMFCDLL >::SetString ( _In_reads_opt_(nLength) PCXSTR  pszSrc,
_In_ int  nLength 
)
inline

Definition at line 314 of file atlsimpstr.h.

316 {
317 if (nLength == 0)
318 {
319 Empty();
320 }
321 else
322 {
323 UINT nOldLength = GetLength();
324 UINT_PTR nOffset = pszSrc - GetString();
325
326 PXSTR pszBuffer = GetBuffer(nLength);
327 if (nOffset <= nOldLength)
328 {
330 pszBuffer + nOffset, nLength);
331 }
332 else
333 {
334 CopyChars(pszBuffer, GetAllocLength(), pszSrc, nLength);
335 }
337 }
338 }
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
Definition: atlsimpstr.h:447
int GetAllocLength() const noexcept
Definition: atlsimpstr.h:357
void Empty() noexcept
Definition: atlsimpstr.h:253
unsigned int UINT
Definition: ndis.h:50

◆ StringLength() [1/2]

template<typename BaseType , bool t_bMFCDLL = false>
static int __cdecl ATL::CSimpleStringT< BaseType, t_bMFCDLL >::StringLength ( _In_opt_z_ const char psz)
inlinestaticnoexcept

◆ StringLength() [2/2]

template<typename BaseType , bool t_bMFCDLL = false>
static int __cdecl ATL::CSimpleStringT< BaseType, t_bMFCDLL >::StringLength ( _In_opt_z_ const wchar_t psz)
inlinestaticnoexcept

Definition at line 462 of file atlsimpstr.h.

463 {
464 if (psz == NULL) return 0;
465 return (int)wcslen(psz);
466 }
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

◆ ThrowInvalidArgException()

template<typename BaseType , bool t_bMFCDLL = false>
static void ATL::CSimpleStringT< BaseType, t_bMFCDLL >::ThrowInvalidArgException ( )
inlinestaticprotected

Definition at line 632 of file atlsimpstr.h.

633 {
635 }

Referenced by ATL::CSimpleStringT< BaseType, t_bMFCDLL >::CSimpleStringT().

◆ ThrowMemoryException()

template<typename BaseType , bool t_bMFCDLL = false>
static void ATL::CSimpleStringT< BaseType, t_bMFCDLL >::ThrowMemoryException ( )
inlinestaticprotected

Friends And Related Function Documentation

◆ operator+ [1/3]

template<typename BaseType , bool t_bMFCDLL = false>
CSimpleStringT operator+ ( _In_ const CSimpleStringT< BaseType, t_bMFCDLL > &  str1,
_In_ const CSimpleStringT< BaseType, t_bMFCDLL > &  str2 
)
friend

Definition at line 411 of file atlsimpstr.h.

414 {
415 CSimpleStringT s(str1.GetManager());
416 Concatenate(s, str1, str1.GetLength(), str2, str2.GetLength());
417 return s;
418 }
static void __cdecl Concatenate(_Inout_ CSimpleStringT &strResult, _In_count_(nLength1) PCXSTR psz1, _In_ int nLength1, _In_count_(nLength2) PCXSTR psz2, _In_ int nLength2)
Definition: atlsimpstr.h:488
CSimpleStringT(_Inout_ IAtlStringMgr *pStringMgr)
Definition: atlsimpstr.h:151
GLdouble s
Definition: gl.h:2039

◆ operator+ [2/3]

template<typename BaseType , bool t_bMFCDLL = false>
CSimpleStringT operator+ ( _In_ const CSimpleStringT< BaseType, t_bMFCDLL > &  str1,
_In_z_ PCXSTR  psz2 
)
friend

Definition at line 420 of file atlsimpstr.h.

423 {
424 CSimpleStringT s(str1.GetManager());
425 Concatenate(s, str1, str1.GetLength(), psz2, StringLength(psz2));
426 return s;
427 }

◆ operator+ [3/3]

template<typename BaseType , bool t_bMFCDLL = false>
CSimpleStringT operator+ ( _In_z_ PCXSTR  psz1,
_In_ const CSimpleStringT< BaseType, t_bMFCDLL > &  str2 
)
friend

Definition at line 429 of file atlsimpstr.h.

432 {
433 CSimpleStringT s(str2.GetManager());
434 Concatenate(s, psz1, StringLength(psz1), str2, str2.GetLength());
435 return s;
436 }

Member Data Documentation

◆ m_pszData


The documentation for this class was generated from the following file: