Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cString.h
Go to the documentation of this file.
1 //
7 //
8 
9 #ifndef _INC_cString_H
10 #define _INC_cString_H
11 #ifndef NO_PRAGMA_ONCE
12 #pragma once
13 #endif
14 
15 #include "cHeapObject.h"
16 #include "cRefPtr.h"
17 #include "StrT.h"
18 #include "cUnitTestDecl.h"
19 
20 #if defined(_MFC_VER) // Only need minimal sub-set if using MFC. __ATLSTR_H__
21 #include <cstringt.h> // __ATLSIMPSTR_H__
22 #endif
23 
24 namespace Gray
25 {
28  class GRAYCORE_LINK cArchive;
29 
30 #if defined(_MFC_VER) // Only need minimal sub-set if using MFC. __ATLSTR_H__
31 #define cStringT_DEF(_TYPE_CH) ATL::CStringT< _TYPE_CH, StrTraitMFC_DLL< _TYPE_CH > >
32 
33 #else
34 
35  class GRAYCORE_LINK CStringData : public cRefBase, public cHeapObject // ref count
36  {
41 
42  private:
44  StrLen_t m_nCharCount;
45  // BaseType m_data[ m_nCharCount * sizeof(BaseType) ];
46  // BaseType m_nullchar; // terminated with '\0' char
47 
48  public:
49  void* GetString() const // char/wchar_* to managed data
50  {
52  return (void*)(this + 1); // const_cast
53  }
54  void* operator new(size_t stAllocateBlock, StrLen_t iStringLengthBytes)
55  {
59  ASSERT(iStringLengthBytes >= 2); // X + '\0'
60  ASSERT(stAllocateBlock == sizeof(CStringData));
61  return cHeap::AllocPtr(stAllocateBlock + iStringLengthBytes);
62  }
63 
64  void operator delete(void* pObj, StrLen_t iStringLengthBytes)
65  {
66  UNREFERENCED_PARAMETER(iStringLengthBytes);
67  cHeap::FreePtr(pObj);
68  }
69  void operator delete(void* pObj)
70  {
71  cHeap::FreePtr(pObj);
72  }
73  StrLen_t get_CharCount() const noexcept
74  {
76  return m_nCharCount;
77  }
78  void put_CharCount(StrLen_t nCount) noexcept
79  {
81  m_nCharCount = nCount;
82  }
83  };
84 
85  // make sure the new length of the string is set correctly on destruct !
87 
88  template< typename _TYPE_CH = char >
90  {
93 
94  typedef CStringT<_TYPE_CH> THIS_t;
95 
96  protected:
97  _TYPE_CH* m_pchData; // points into CStringData[1]
98  static const _TYPE_CH m_Nil; // Use this instead of nullptr. ala MFC. also like _afxDataNil. AKA cStrConst::k_Empty ?
99 
100  public:
101  CStringT() noexcept
102  {
103  Init();
104  }
105  CStringT(const wchar_t* pwText)
106  {
108  Init();
109  Assign(pwText);
110  }
111  CStringT(const wchar_t* pwText, StrLen_t iLenMax)
112  {
115  Init();
116  AssignLen(pwText, iLenMax);
117  }
118  CStringT(const char* pszStr)
119  {
121  Init();
122  Assign(pszStr);
123  }
124  CStringT(const char* pszStr, StrLen_t iLenMax)
125  {
128  Init();
129  AssignLen(pszStr, iLenMax);
130  }
131  CStringT(const THIS_t& ref) noexcept
132  {
133  AssignFirst(ref);
134  }
135  CStringT(THIS_t&& ref) noexcept
136  {
138  m_pchData = ref.m_pchData;
139  ref.Init();
140  }
142  {
143  Empty();
144  }
145 
146  CStringData* GetData() const noexcept
147  {
149  DEBUG_CHECK(m_pchData != &m_Nil);
150  DEBUG_CHECK(m_pchData != nullptr);
151  return (reinterpret_cast<CStringData*>(m_pchData)) - 1;
152  }
153  const _TYPE_CH* GetString() const noexcept
154  {
156  DEBUG_CHECK(isValidString());
157  return m_pchData;
158  }
159 
160  bool isValidString() const noexcept
161  {
163  if (m_pchData == &m_Nil)
164  return true;
165  CStringData* pData = GetData();
166  if (pData == nullptr)
167  return false; // should never happen!
168  StrLen_t iLen = pData->get_CharCount();
169  if (!pData->IsValidInsideN(iLen * sizeof(_TYPE_CH)))
170  return false; // should never happen!
171  if (pData->get_RefCount() <= 0)
172  return false; // should never happen!
173  return m_pchData[iLen] == '\0';
174  }
175 
176  bool IsEmpty() const noexcept
177  {
178  // like MFC.
179  DEBUG_CHECK(isValidString());
180  return m_pchData == &m_Nil;
181  }
182 
183  StrLen_t GetLength() const noexcept
184  {
186  if (m_pchData == &m_Nil)
187  return 0;
188  // DEBUG_CHECK(isValidString());
189  const CStringData* pData = GetData();
190  DEBUG_CHECK(pData != nullptr);
191  return pData->get_CharCount();
192  }
193  void Empty()
194  {
195  if (m_pchData == nullptr) // certain off instances where it could be nullptr. arrays
196  return;
197  if (IsEmpty())
198  return;
199  EmptyValid();
200  }
201 
202  const _TYPE_CH& ReferenceAt(StrLen_t nIndex) const // 0 based
203  {
204  ASSERT(nIndex <= GetLength());
205  return m_pchData[nIndex];
206  }
207  _TYPE_CH GetAt(StrLen_t nIndex) const // 0 based
208  {
209  ASSERT(nIndex <= GetLength()); // allow to get the '\0' char
210  return m_pchData[nIndex];
211  }
212  void SetAt(StrLen_t nIndex, _TYPE_CH ch)
213  {
214  ASSERT(IS_INDEX_GOOD(nIndex, GetLength()));
215  CopyBeforeWrite();
216  m_pchData[nIndex] = ch;
217  ASSERT(isValidString());
218  }
219 
220  _TYPE_CH* GetBuffer(StrLen_t iMinLength);
221  void ReleaseBuffer(StrLen_t nNewLength = k_StrLen_UNK);
222 
223  const THIS_t& operator = (const THIS_t& ref)
224  {
226  Assign(ref);
227  return *this;
228  }
229  const THIS_t& operator = (THIS_t&& ref)
230  {
232  m_pchData = ref.m_pchData;
233  ref.Init();
234  return *this;
235  }
236 
237  void AssignLenT(const _TYPE_CH* pszStr, StrLen_t iLenMax);
238 
239  // UTF8. auto converted
240  void AssignLen(const char* pszStr, StrLen_t iSizeMax = StrT::k_LEN_MAX);
241  const THIS_t& operator = (const char* pStr)
242  {
243  Assign(pStr);
244  return *this;
245  }
246 
247  // UNICODE. auto converted
248  void AssignLen(const wchar_t* pwText, StrLen_t iSizeMax = StrT::k_LEN_MAX);
249  const THIS_t& operator = (const wchar_t* pStr)
250  {
251  Assign(pStr);
252  return *this;
253  }
254 
255  void FormatV(const _TYPE_CH* pszStr, va_list args);
256  void _cdecl Format(const _TYPE_CH* pszStr, ...)
257  {
260  va_list vargs;
261  va_start(vargs, pszStr);
262  FormatV(pszStr, vargs);
263  va_end(vargs);
264  }
265  COMPARE_t Compare(const _TYPE_CH* pszStr) const
266  {
267  return StrT::Cmp(GetString(), pszStr);
268  }
269  COMPARE_t CompareNoCase(const _TYPE_CH* pszStr) const
270  {
271  return StrT::CmpI(GetString(), pszStr);
272  }
273  void MakeUpper(); // MFC like not .NET like.
274  void MakeLower();
275  THIS_t Left(StrLen_t nCount) const;
276  THIS_t Right(StrLen_t nCount) const;
277  THIS_t Mid(StrLen_t nFirst, StrLen_t nCount = StrT::k_LEN_MAX) const;
278 
279  void TrimRight();
280  void TrimLeft();
281  StrLen_t Find(_TYPE_CH ch, StrLen_t nPosStart = 0) const;
282 
283  _TYPE_CH operator[](StrLen_t nIndex) const // same as GetAt
284  {
285  return GetAt(nIndex);
286  }
287  const _TYPE_CH& operator[](StrLen_t nIndex)
288  {
289  return ReferenceAt(nIndex);
290  }
291  operator const _TYPE_CH* () const // as a C string
292  {
293  return GetString();
294  }
295 
296  friend bool operator==(const THIS_t& str1, const _TYPE_CH* str2) THROW_DEF
297  {
298  return str1.Compare(str2) == COMPARE_Equal;
299  }
300  friend bool operator!=(const THIS_t& str1, const _TYPE_CH* str2) THROW_DEF
301  {
302  return str1.Compare(str2) != COMPARE_Equal;
303  }
304 
305  // insert character at zero-based index; concatenates
306  // if index is past end of string
307  StrLen_t Insert(StrLen_t nIndex, _TYPE_CH ch);
308  const THIS_t& operator += (_TYPE_CH ch)
309  {
310  Insert(GetLength(), ch);
311  return *this;
312  }
313 
316  StrLen_t Insert(StrLen_t nIndex, const _TYPE_CH* pszStr, StrLen_t iLenCat);
317  StrLen_t Insert(StrLen_t nIndex, const _TYPE_CH* pszStr)
318  {
319  return Insert(nIndex, pszStr, k_StrLen_UNK);
320  }
321  const THIS_t& operator += (const _TYPE_CH* psz) // like strcat()
322  {
323  Insert(GetLength(), psz, k_StrLen_UNK);
324  return *this;
325  }
326 
327 #if 0
328  THIS_t operator + (const _TYPE_CH* pszStr) const
329  {
330  THIS_t sTmp(*this);
331  sTmp.Insert(GetLength(), pszStr, k_StrLen_UNK);
332  return sTmp;
333  }
334 #endif
335 
336  void Assign(const THIS_t& str)
337  {
338  if (m_pchData == str.GetString()) // already same.
339  return;
340  Empty();
341  AssignFirst(str);
342  }
343  void Assign(const wchar_t* pwText);
344  void Assign(const char* pszStr);
345 
346  protected:
347  void Init() noexcept
348  {
349  m_pchData = const_cast<_TYPE_CH*>(&m_Nil);
350  }
351  void EmptyValid()
352  {
353  // Use m_Nil for empty.
354  ASSERT(isValidString());
355  GetData()->DecRefCount();
356  Init();
357  }
358 
359  void AssignFirst(const THIS_t& s) noexcept
360  {
361  m_pchData = s.m_pchData;
362  if (m_pchData == &m_Nil)
363  return;
364  GetData()->IncRefCount();
365  DEBUG_CHECK(isValidString());
366  }
367 
368  void AllocBuffer(StrLen_t iStrLength);
369  void CopyBeforeWrite();
370  };
371 
372 #define cStringT_DEF(t) CStringT<t>
373 
374 #endif // ! _MFC_VER
375 
376  //***********************************************************************************************************
377 
378  template< typename _TYPE_CH = char >
380  : public cStringT_DEF(_TYPE_CH)
381  {
385 
386  typedef cStringT_DEF(_TYPE_CH) SUPER_t;
387  typedef cStringT<_TYPE_CH> THIS_t;
388 
389  public:
390  typedef _TYPE_CH CharType_t;
391 
392  cStringT() noexcept
393  {}
394  cStringT(SUPER_t & str) noexcept : SUPER_t(str)
395  {}
396  cStringT(const char* pszText) : SUPER_t(pszText)
397  {}
398  cStringT(const char* pszText, StrLen_t iLenMax) : SUPER_t(pszText, iLenMax)
399  {
402  }
403  cStringT(const wchar_t* pwText) : SUPER_t(pwText)
404  {}
405  cStringT(const wchar_t* pwText, StrLen_t iLenMax) : SUPER_t(pwText, iLenMax)
406  {
409  }
410 
411 #if defined(_MFC_VER)
412  CStringData* GetData() const
413  {
415  return(((CStringData*)(const _TYPE_CH*)SUPER_t::GetString()) - 1);
416  }
417 #endif
418 
419  const _TYPE_CH* get_CPtr() const noexcept
420  {
421  return SUPER_t::GetString();
422  }
423 
424  bool isPrintableString() const
425  {
426 #if defined(_MFC_VER)
427  return true;
428 #else
429  if (SUPER_t::m_pchData == &SUPER_t::m_Nil)
430  return true;
431  CStringData* pData = this->GetData();
432  StrLen_t iLen = pData->get_CharCount();
433  ASSERT(pData->IsValidInsideN(iLen * sizeof(_TYPE_CH)));
434  ASSERT(pData->get_RefCount() > 0);
435  return StrT::IsPrintable(SUPER_t::m_pchData, iLen) && (SUPER_t::m_pchData[iLen] == '\0');
436 #endif
437  }
438  bool isValidString() const noexcept
439  {
440 #ifdef _MFC_VER
441  return true;
442 #elif 0 // defined(_DEBUG) && defined(DEBUG_VALIDATE_ALLOC)
443  return IsPrintableString();
444 #else
445  return SUPER_t::isValidString();
446 #endif
447  }
448  bool isValidCheck() const noexcept
449  {
450  return isValidString();
451  }
452  bool IsWhitespace() const
453  {
455  return StrT::IsWhitespace(this->get_CPtr(), this->length());
456  }
457 
458  HRESULT ReadZ(cStreamInput & File, StrLen_t iLenMax);
459  bool WriteZ(cStreamOutput & File) const;
460 
461  HASHCODE_t get_HashCode() const noexcept
462  {
465  return (HASHCODE_t)(UINT_PTR)(void*)get_CPtr() ; // just use the pointer.
466  }
467  size_t GetHeapStats(OUT ITERATE_t & iAllocCount) const
468  {
470  if (SUPER_t::IsEmpty())
471  return 0;
472 #if defined(_MFC_VER) // Only need minimal sub-set if using MFC.
473  iAllocCount++;
474  return cHeap::GetSize(GetData());
475 #else
476  return this->GetData()->GetHeapStatsThis(iAllocCount);
477 #endif
478  }
479  int get_RefCount() const
480  {
481 #if defined(_MFC_VER)
482  return this->GetData()->nRefs;
483 #else
484  return this->GetData()->get_RefCount();
485 #endif
486  }
488  {
490 #if defined(_MFC_VER)
491  this->GetData()->nRefs++;
492 #else
493  this->GetData()->IncRefCount();
494 #endif
495  }
496 
497  StrLen_t SetCodePage(const wchar_t* pwText, CODEPAGE_t uCodePage = CP_UTF8);
498  StrLen_t GetCodePage(OUT wchar_t* pwText, StrLen_t iLenMax, CODEPAGE_t uCodePage = CP_UTF8) const;
499 
500 #ifdef _MFC_VER
501  void Assign(const SUPER_t & str)
502  {
503  // For use with MFC and cAtomRef
504  *static_cast<SUPER_t*>(this) = str;
505  }
506 #endif
507 
508  THIS_t GetTrimWhitespace() const;
509 
510  HRESULT SerializeInput(cStreamInput & File, StrLen_t iLenMax = StrT::k_LEN_MAX);
511  HRESULT SerializeOutput(cStreamOutput & File) const;
512  HRESULT SerializeOutput(cArchive & a) const;
513  HRESULT Serialize(cArchive & a);
514 
515  const THIS_t& operator = (const THIS_t & s)
516  {
517  this->Assign(s);
518  return *this;
519  }
520  const THIS_t& operator = (const char* pszStr)
521  {
522  SUPER_t::operator=(pszStr);
523  return *this;
524  }
525  const THIS_t& operator = (const wchar_t* pwStr)
526  {
527  SUPER_t::operator=(pwStr);
528  return *this;
529  }
530 
531  void SetErase()
532  {
535  SUPER_t::Empty();
536  }
537 
538  bool Contains(const _TYPE_CH * pSubStr)
539  {
540  // Like .NET
541  return StrT::FindStr(get_CPtr(), pSubStr) != nullptr;
542  }
543  bool ContainsI(const _TYPE_CH * pSubStr)
544  {
545  // Like .NET
546  return StrT::FindStrI(get_CPtr(), pSubStr) != nullptr;
547  }
548  bool StartsWithI(const _TYPE_CH * pSubStr)
549  {
550  // Like .NET
551  return StrT::StartsWithI(get_CPtr(), pSubStr);
552  }
553  bool EndsWithI(const _TYPE_CH * pSubStr) const
554  {
555  // Like .NET
556  return StrT::EndsWithI<_TYPE_CH>(get_CPtr(), pSubStr, this->GetLength());
557  }
558 
561  static const int npos = -1; // k_ITERATE_BAD. same name as STL.
562 
563  const _TYPE_CH* c_str() const
564  {
565  return SUPER_t::GetString();
566  }
567  StrLen_t size() const
568  {
569  // basic_string::size
570  return SUPER_t::GetLength();
571  }
572  StrLen_t length() const
573  {
574  // char_traits::length
575  return SUPER_t::GetLength();
576  }
577  bool empty() const
578  {
579  return SUPER_t::IsEmpty();
580  }
581  StrLen_t find(_TYPE_CH ch) const
582  {
584  return SUPER_t::Find(ch, 0);
585  }
586  void assign(const _TYPE_CH * pszStr, StrLen_t iLenCat)
587  {
588  *this = THIS_t(pszStr, iLenCat);
589  }
590  void append(const _TYPE_CH * pszStr, StrLen_t iLenCat)
591  {
592 #ifdef _MFC_VER
593  * this += THIS_t(pszStr, iLenCat);
594 #else
595  this->Insert(this->GetLength(), pszStr, iLenCat);
596 #endif
597  }
598  void push_back(_TYPE_CH ch)
599  {
600  this->Insert(this->GetLength(), ch);
601  }
602 
603 #ifndef _MFC_VER
604  void resize(StrLen_t iSize)
605  {
606  SUPER_t::AllocBuffer(iSize);
607  }
608 #endif
609  void reserve(StrLen_t iSize)
610  {
611  // optimize that this is the end length.
612  UNREFERENCED_PARAMETER(iSize);
613  }
615  {
616  // Like return SUPER_t::Mid(nFirst, nCount)
617  if (nFirst >= this->GetLength())
618  return "";
619  return THIS_t(this->GetString() + nFirst, nCount);
620  }
621 
622  static THIS_t _cdecl GetFormatf(const _TYPE_CH * pszFormat, ...);
623 
624  // TODO MOVE THESE SOME OTHER PLACE >?
625  static THIS_t GRAYCALL GetErrorStringV(HRESULT nFormatID, void* pSource, va_list vargs);
626  static THIS_t GRAYCALL GetErrorString(HRESULT nFormatID, void* pSource = nullptr);
627  static THIS_t _cdecl GetErrorStringf(HRESULT nFormatID, void* pSource, ...);
628 
629  static THIS_t GRAYCALL GetSizeK(UINT64 uVal, UINT nKUnit = 1024, bool bSpace = false);
630 
632  };
633 
637 
638 #if ! defined(_MFC_VER) && ! defined(__CLR_VER)
639  typedef cString CString;
640 #endif
641 
642  cStringA inline operator +(const char* pStr1, const cStringA& s2) // static global
643  {
644  cStringA s1(pStr1);
645  s1 += s2;
646  return s1;
647  }
648  cStringW inline operator +(const wchar_t* pStr1, const cStringW& s2) // static global
649  {
650  cStringW s1(pStr1);
651  s1 += s2;
652  return s1;
653  }
654 
655 #if defined(_MFC_VER) // resolve ambiguity with MFC
656  cStringA inline operator +(cStringA s1, const cStringA& s2) // static global
657  {
658  s1 += s2;
659  return s1;
660  }
661  cStringA inline operator +(cStringA s1, const char* pStr2) // static global
662  {
663  s1 += pStr2;
664  return s1;
665  }
666  cStringW inline operator +(cStringW s1, const cStringW& s2) // static global
667  {
668  s1 += s2;
669  return s1;
670  }
671  cStringW inline operator +(cStringW s1, const wchar_t* pStr2) // static global
672  {
673  s1 += pStr2;
674  return s1;
675  }
676 #else
677  template< typename _TYPE_CH > // "= char" error C4519: default template arguments are only allowed on a class template
678  void inline operator >> (cArchive& ar, cStringT< _TYPE_CH >& pOb) { pOb.Serialize(ar); }
679  template< typename _TYPE_CH >
680  void inline operator << (cArchive& ar, const cStringT< _TYPE_CH >& pOb) { pOb.SerializeOutput(ar); }
681 #endif
682 
683 #undef cStringT_DEF
684 
685 };
686 
687 #endif // _INC_cString_H
#define GRAYCORE_LINK
Definition: GrayCore.h:47
#define GRAYCALL
declare calling convention for static functions so everyone knows the arg passing scheme....
Definition: GrayCore.h:36
#define THROW_DEF
Definition: HResult.h:25
#define IS_INDEX_GOOD(i, q)
cast the (likely) int to unsigned to check for negatives.
Definition: Index.h:35
#define UNREFERENCED_PARAMETER(P)
< _WIN32 type thing. get rid of stupid warning.
Definition: SysTypes.h:299
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
#define ASSERT(exp)
Definition: cDebugAssert.h:87
#define DEBUG_CHECK(exp)
Definition: cDebugAssert.h:90
#define CHEAPOBJECT_IMPL
Definition: cHeapObject.h:32
#define cStringT_DEF(t)
Definition: cString.h:372
#define UNITTEST_FRIEND(n)
Define this in the class body to be unit tested. Allow the unit test to access private/protected stuf...
Definition: cUnitTestDecl.h:17
Definition: cString.h:36
void * GetString() const
Definition: cString.h:49
void put_CharCount(StrLen_t nCount) noexcept
Definition: cString.h:78
StrLen_t get_CharCount() const noexcept
Definition: cString.h:73
Definition: cString.h:90
void _cdecl Format(const _TYPE_CH *pszStr,...)
Definition: cString.h:256
CStringT(const char *pszStr)
Definition: cString.h:118
CStringT(const char *pszStr, StrLen_t iLenMax)
Definition: cString.h:124
CStringT(const wchar_t *pwText, StrLen_t iLenMax)
Definition: cString.h:111
CStringData * GetData() const noexcept
Definition: cString.h:146
~CStringT()
Definition: cString.h:141
void Assign(const THIS_t &str)
Definition: cString.h:336
CStringT() noexcept
Definition: cString.h:101
friend bool operator!=(const THIS_t &str1, const _TYPE_CH *str2)((void) 0)
Definition: cString.h:300
const _TYPE_CH * GetString() const noexcept
Definition: cString.h:153
void Assign(const wchar_t *pwText)
void AssignLen(const wchar_t *pwText, StrLen_t iSizeMax=StrT::k_LEN_MAX)
const _TYPE_CH & ReferenceAt(StrLen_t nIndex) const
Definition: cString.h:202
const _TYPE_CH & operator[](StrLen_t nIndex)
Definition: cString.h:287
_TYPE_CH operator[](StrLen_t nIndex) const
Definition: cString.h:283
static const _TYPE_CH m_Nil
Definition: cString.h:98
void Empty()
Definition: cString.h:193
void EmptyValid()
Definition: cString.h:351
CStringT(THIS_t &&ref) noexcept
Definition: cString.h:135
StrLen_t GetLength() const noexcept
Definition: cString.h:183
bool IsEmpty() const noexcept
Definition: cString.h:176
_TYPE_CH * m_pchData
Definition: cString.h:97
CStringT(const wchar_t *pwText)
Definition: cString.h:105
COMPARE_t CompareNoCase(const _TYPE_CH *pszStr) const
Definition: cString.h:269
void AssignFirst(const THIS_t &s) noexcept
Definition: cString.h:359
CStringT(const THIS_t &ref) noexcept
Definition: cString.h:131
void Init() noexcept
Definition: cString.h:347
friend bool operator==(const THIS_t &str1, const _TYPE_CH *str2)((void) 0)
Definition: cString.h:296
void Assign(const char *pszStr)
void AssignLen(const char *pszStr, StrLen_t iSizeMax=StrT::k_LEN_MAX)
_TYPE_CH GetAt(StrLen_t nIndex) const
Definition: cString.h:207
void SetAt(StrLen_t nIndex, _TYPE_CH ch)
Definition: cString.h:212
bool isValidString() const noexcept
Definition: cString.h:160
StrLen_t Insert(StrLen_t nIndex, const _TYPE_CH *pszStr)
Definition: cString.h:317
COMPARE_t Compare(const _TYPE_CH *pszStr) const
Definition: cString.h:265
Definition: cArchive.h:20
Definition: cHeapObject.h:38
bool IsValidInsideN(INT_PTR index) const
Definition: cHeapObject.h:63
Definition: cRefPtr.h:22
int get_RefCount() const noexcept
Definition: cRefPtr.h:89
Definition: cRefPtr.h:225
Definition: cStream.h:306
Definition: cStream.h:126
Definition: cString.h:381
void SetErase()
Definition: cString.h:531
void reserve(StrLen_t iSize)
Definition: cString.h:609
StrLen_t size() const
Definition: cString.h:567
StrLen_t GetCodePage(OUT wchar_t *pwText, StrLen_t iLenMax, CODEPAGE_t uCodePage=CP_UTF8) const
bool EndsWithI(const _TYPE_CH *pSubStr) const
Definition: cString.h:553
bool ContainsI(const _TYPE_CH *pSubStr)
Definition: cString.h:543
StrLen_t length() const
Definition: cString.h:572
bool isValidString() const noexcept
Definition: cString.h:438
cStringT(const wchar_t *pwText)
Definition: cString.h:403
void push_back(_TYPE_CH ch)
Definition: cString.h:598
HRESULT SerializeOutput(cStreamOutput &File) const
Definition: cString.cpp:619
_TYPE_CH CharType_t
ALA std::string::value_type.
Definition: cString.h:390
int get_RefCount() const
Definition: cString.h:479
StrLen_t find(_TYPE_CH ch) const
Definition: cString.h:581
bool isValidCheck() const noexcept
Definition: cString.h:448
size_t GetHeapStats(OUT ITERATE_t &iAllocCount) const
Definition: cString.h:467
cStringT(const char *pszText)
Definition: cString.h:396
cStringT(SUPER_t &str) noexcept
Definition: cString.h:394
const _TYPE_CH * get_CPtr() const noexcept
Definition: cString.h:419
cStringT(const wchar_t *pwText, StrLen_t iLenMax)
Definition: cString.h:405
bool isPrintableString() const
Definition: cString.h:424
StrLen_t SetCodePage(const wchar_t *pwText, CODEPAGE_t uCodePage=CP_UTF8)
bool StartsWithI(const _TYPE_CH *pSubStr)
Definition: cString.h:548
HASHCODE_t get_HashCode() const noexcept
Definition: cString.h:461
THIS_t substr(StrLen_t nFirst, StrLen_t nCount=StrT::k_LEN_MAX) const
Definition: cString.h:614
void resize(StrLen_t iSize)
Definition: cString.h:604
void append(const _TYPE_CH *pszStr, StrLen_t iLenCat)
Definition: cString.h:590
bool empty() const
Definition: cString.h:577
const _TYPE_CH * c_str() const
Definition: cString.h:563
void SetStringStatic()
Definition: cString.h:487
bool Contains(const _TYPE_CH *pSubStr)
Definition: cString.h:538
HRESULT Serialize(cArchive &a)
Definition: cString.cpp:637
bool IsWhitespace() const
Definition: cString.h:452
cStringT(const char *pszText, StrLen_t iLenMax)
Definition: cString.h:398
cStringT() noexcept
Definition: cString.h:392
void assign(const _TYPE_CH *pszStr, StrLen_t iLenCat)
Definition: cString.h:586
< The main namespace for all Core functions.
Definition: GrayCore.cpp:14
int COMPARE_t
result of compare. 0=same, 1=a>b, -1=a<b
Definition: cValT.h:17
const StrLen_t k_StrLen_UNK
use the default/current length of the string argument.
Definition: StrConst.h:34
int StrLen_t
the length of a string in chars (bytes for UTF8, wchar_t for UNICODE). or offset in characters....
Definition: StrConst.h:32
void operator>>(cArchive &ar, cStringT< _TYPE_CH > &pOb)
Definition: cString.h:678
int ITERATE_t
like size_t but signed
Definition: Index.h:28
cStringT< wchar_t > cStringW
Definition: cString.h:634
cStringT< char > cStringA
Definition: cString.h:635
UINT_PTR HASHCODE_t
could hold a pointer converted to a number? maybe 64 or 32 bit ? same as size_t.
Definition: GrayCore.h:116
CODEPAGE_t
Definition: StrChar.h:33
@ CP_UTF8
UTF-8 translation.
Definition: StrChar.h:36
cRefPtr< CStringData > CStringDataPtr
Pointer to hold a ref to the string data so i can thread lock it.
Definition: cString.h:86
cString CString
Definition: cString.h:639
cStringA operator+(const char *pStr1, const cStringA &s2)
Definition: cString.h:642
void operator<<(cArchive &ar, const cStringT< _TYPE_CH > &pOb)
Definition: cString.h:680
@ COMPARE_Equal
VARCMP_EQ.
Definition: cValT.h:23
cStringT< GChar_t > cString
Definition: cString.h:636
static const StrLen_t k_LEN_MAX
arbitrary max size for Format() etc. NOTE: _MSC_VER says stack frame should be at least 16384
Definition: StrT.h:75
static __DECL_IMPORT bool __stdcall IsPrintable(const TYPE *pStr, StrLen_t iLenChars=StrT::k_LEN_MAX)
static __DECL_IMPORT bool __stdcall StartsWithI(const TYPE *pszStr2, const TYPE *pszPrefix)
static __DECL_IMPORT COMPARE_t __stdcall Cmp(const TYPE *pszStr1, const TYPE *pszStr2)
static __DECL_IMPORT bool __stdcall IsWhitespace(const TYPE *pStr, StrLen_t iLenChars=StrT::k_LEN_MAX)
static __DECL_IMPORT TYPE *__stdcall FindStr(const TYPE *pszStr, const TYPE *pszFind, StrLen_t iLenMax=StrT::k_LEN_MAX)
static __DECL_IMPORT TYPE *__stdcall FindStrI(const TYPE *pszStr, const TYPE *pszFind, StrLen_t iLenMax=StrT::k_LEN_MAX)
static __DECL_IMPORT COMPARE_t __stdcall CmpI(const TYPE *pszStr1, const TYPE *pszStr2)
static void *__stdcall AllocPtr(size_t nSize)
Definition: cHeap.cpp:125
static void __stdcall FreePtr(void *pData)
Definition: cHeap.cpp:103
static size_t __stdcall GetSize(const void *pData) noexcept
Definition: cHeap.cpp:226