uLib  User mode C/C++ extended API library for Win32 programmers.
StrFunc.h
Go to the documentation of this file.
1 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 // Project: uLib - User mode library.
3 // Module: String functions.
4 // Author: Copyright (c) Love Nystrom
5 // License: NNOSL (BSD descendant, see NNOSL.txt in the base directory).
6 // Credits: LefterisE@stackoverflow.com for the neat stristr algorithm.
7 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 
9 #ifndef _StrFunc_h_incl_
10 #define _StrFunc_h_incl_
11 
12 #undef USE_ULIB_NEW_DELETE // Define this to make 'new' use mem_Alloc (not recommended).
13 
14 #include <uLib/MemFunc.h>
15 #include <String.h>
16 #include <Time.h> // Used by SysTimeStr
17 
18 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24 
25 #if defined(_MSC_VER) && (_MSC_VER > 1200)
26  // Note: _MSC_VER 1200 == VC6 (But.. When was __pragma actually introduced?)
28  #define BEGIN_STRSAFE_OVERRIDE __pragma( warning( disable:4996 ))
29  #define END_STRSAFE_OVERRIDE __pragma( warning( default:4996 ))
30 #else // Sorry, I don't know how to squelch that on other compilers..
31  #define BEGIN_STRSAFE_OVERRIDE
32  #define END_STRSAFE_OVERRIDE
33 #endif
34 
36 
40 
41 char* __fastcall strecpy( register char* Dst, register const char* Src );
42 wchar_t* __fastcall wcsecpy( register wchar_t* Dst, register const wchar_t* Src );
43 
45 
46 char* __fastcall strnecpy( register char* Dst, register const char* Src, size_t N );
47 wchar_t* __fastcall wcsnecpy( register wchar_t* Dst, register const wchar_t* Src, size_t N );
48 
53 
54 char* stristr( const char* str, const char* pattern );
55 wchar_t* wcsistr( const wchar_t* str, const wchar_t* pattern );
56 
59 
60 char* __fastcall strncpyz( register char* Dst, register const char* Src, size_t Count );
61 wchar_t* __fastcall wcsncpyz( register wchar_t* Dst, register const wchar_t* Src, size_t Count );
62 
64 
65 size_t wcsbytes( const wchar_t* Src );
66 
67 #ifdef _UNICODE
68  #define _tcsecpy wcsecpy
69  #define _tcsnecpy wcsnecpy
70  #define _tcsistr wcsistr
71  #define _tcsncpyz wcsncpyz
72  #define _tcsnchr (CSTR)wmemchr
73 #else
74  #define _tcsecpy strecpy
75  #define _tcsnecpy strnecpy
76  #define _tcsistr stristr
77  #define _tcsncpyz strncpyz
78  #define _tcsnchr (CSTR)memchr
79 #endif
80 
82 
83 #ifdef __cplusplus
84  bool __forceinline IsString( CSTR Str ) { return (Str && *Str); }
85 #else
86  #define IsString( Str ) ((Str) && *(Str)) // Careful if passing expressions!
87 #endif
88 
90 
91 #ifdef __cplusplus
92 extern "C++" template <typename chrType>
93  INT_PTR CharIndex( const chrType* Buffer, const chrType* Inside )
94  {
95  INT_PTR ix = Inside - Buffer; // Note: C typed ptr arithmetic does auto-div by element size.
96  _ASSERTE( ix >= 0 ); // In case caller messed up...
97  return ix;
98  }
99 #else
100  #ifdef _UNICODE
101  #define CharIndex CharIndexW
102  #else
103  #define CharIndex CharIndexA
104  #endif
105 #endif
106 
107 // Explicit A/W versions
108 
109 INT_PTR CharIndexA( const CHAR* Buffer, const CHAR* Inside );
110 INT_PTR CharIndexW( const WCHAR* Buffer, const WCHAR* Inside );
111 
112 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
121 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
123 
124 CSTR newStr( CSTR Src );
125 TSTR newStrBuf( WORD nChar );
126 CSTR deleteStr( CSTR Dup );
127 
128 WCSTR newWStr( WCSTR Src );
129 WCSTR deleteWStr( WCSTR Dup );
130 
131 ASTR mem_DupAStr( ACSTR Src );
132 WSTR mem_DupWStr( WCSTR Src );
133 ASTR mem_AllocAStr( WORD nChar );
134 WSTR mem_AllocWStr( WORD nChar );
135 CSTR mem_FreeStr( CSTR Dup );
136 
137 #ifdef _UNICODE
138  #define mem_DupStr mem_DupWStr
139  #define mem_AllocStr mem_AllocWStr
140 #else
141  #define mem_DupStr mem_DupAStr
142  #define mem_AllocStr mem_AllocAStr
143 #endif
144 
150 //-! @relatedalso stxlt // fails to appear in stxlt :(
152 
153 ASTR mem_ADupWStr( WCSTR WStr, UINT CodePg DEF_(CP_ACP), UINT ccExtra DEF_(0) );
154 
160 //-! @relatedalso stxlt
162 
163 WSTR mem_WDupAStr( ACSTR AStr, UINT CodePg DEF_(CP_ACP), UINT ccExtra DEF_(0) );
164 
165 #ifndef NO_WINTERNAL // UNICODE_STRING is considered (by MS) as "internal"
166 //-! @relatedalso unist
173 
174 PUNICODE_STRING mem_AllocUniStr( WORD ccStr, OPTOUT PULONG cbAlloc );
175 #endif
176 
178 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
181 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
183 
186 
187 ACSTR _MBStr( WCSTR pWStr );
188 
189 // These belong here as well, but are declared/documented in "salloc"..
190 
191 // ASTR mem_ADupWStr( WCSTR WStr, UINT CodePg DEF_(CP_ACP), UINT ccExtra DEF_(0) );
192 // WSTR mem_WDupAStr( ACSTR AStr, UINT CodePg DEF_(CP_ACP), UINT ccExtra DEF_(0) );
193 
195 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
198 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
200 
206 
207 CSTR LoadStr( HMODULE hModule, UINT Id, TSTR Buf DEF_(NULL), UINT Count DEF_(0) );
208 
225 
226 WCSTR GetResourceStr( HMODULE hModule, UINT Id, PWORD pCount );
227 
231 
232 WCSTR FindResourceStrEx( HMODULE hModule, UINT Id, LANGID Lang, PWORD pCount );
233 
237 
238 CSTR DupResourceStrEx( HMODULE hModule, UINT Id, LANGID Lang, PWORD pCount );
239 CSTR FreeResourceStrEx( CSTR pzRcDupStr );
240 
246 
247 struct RC_STRING
248 {
251 
252  #ifdef __cplusplus
253  RC_STRING() : Length(0), Text(NULL) {}
254  RC_STRING( HMODULE hModule, UINT Id ) { GetResource( hModule, Id ); }
255  WCSTR GetResource( HMODULE hModule, UINT Id ) {
256  return (Text = GetResourceStr( hModule, Id, &Length ));
257  }
258  #endif
259 };
260 
262 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
266 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
268 
269 #ifdef _UNICODE
270  #define EnumerateMultiSz EnumerateMultiSzW
271  #define PFnEnumMultiString PFnEnumMultiStringW
272  #define MultiSzLength MultiSzLengthW
273  #define MultiSzCount MultiSzCountW
274 #else
275  #define EnumerateMultiSz EnumerateMultiSzA
276  #define PFnEnumMultiString PFnEnumMultiStringA
277  #define MultiSzLength MultiSzLengthA
278  #define MultiSzCount MultiSzCountA
279 #endif
280 
285 
286 typedef bool (__stdcall *PFnEnumMultiStringA)( ASTR Str, PVOID Context );
287 typedef bool (__stdcall *PFnEnumMultiStringW)( WSTR Str, PVOID Context );
289 
295 
296 UINT EnumerateMultiSzA( ASTR MultiSz, PFnEnumMultiStringA Action, PVOID Context );
297 UINT EnumerateMultiSzW( WSTR MultiSz, PFnEnumMultiStringW Action, PVOID Context );
299 
301 
302 UINT MultiSzLengthA( ACSTR MultiSz );
303 UINT MultiSzLengthW( WCSTR MultiSz );
304 
306 
307 UINT MultiSzCountA( ACSTR MultiSz );
308 UINT MultiSzCountW( WCSTR MultiSz );
309 
315 
316 TSTR MultiCrLfToLf( TSTR pText );
317 
320 
321 TSTR LinesToMultiSz( TSTR pText, UINT* ccSz );
322 
324 
325 TSTR MultiSzToLines( TSTR pText );
326 
328 
329 TSTR DuplicateMultiSz( CSTR pzMulti );
330 TSTR FreeMultiSz( TSTR pzMulti );
331 
333 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
336 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
338 
348 
349 bool SplitUncPath(
350  IN CSTR UncPath,
351  OUT TSTR Svr, UINT ccSvr, OUT TSTR Share, UINT ccShare,
352  OPTOUT TSTR Path DEF_(NULL), UINT ccPath DEF_(0)
353  );
354 
360 
361 bool SplitNetShareName(
362  IN CSTR ShareName,
363  OUT WSTR Server, UINT ccServer, OUT WSTR Share, UINT ccShare
364  );
365 
369 
370 CSTR WithoutBackslash( CSTR PathName );
371 CSTR WithBackslash( CSTR PathName );
372 
378 
379 bool GetRootOf( IN CSTR PathName, OUT TSTR Root, UINT ccRoot );
380 
385 
386 CSTR __cdecl StrFmt( TSTR Buf, UINT ccBuf, CSTR Fmt, ... );
387 
391 
392 TSTR ReplaceStrChar( TSTR Str, TCHAR From, TCHAR To, OPTOUT UINT* pCount );
393 
396 
397 bool MatchPattern( CSTR String, CSTR Pattern, bool CaseSens );
398 
408 
409 #ifndef _UNICODE
411  INOUT ASTR Text, CHAR Separator, bool caseSens, bool emitSorted
412  );
413 #endif
414 
420 
421 UINT PrependString( INOUT TSTR String, UINT ccBuf, OPTIN TCHAR Sep, CSTR Prolog );
422 
425 
426 UINT AppendString( INOUT TSTR String, UINT ccBuf, OPTIN TCHAR Sep, CSTR Epilog );
427 
429 
430 ULONG GetStringHash( WCSTR Str,
431  ULONG Algorithm DEF_(0), //HASH_STRING_ALGORITHM_DEFAULT
432  bool caseSens DEF_(true)
433  );
434 #ifndef HASH_STRING_ALGORITHM_DEFAULT
435  #define HASH_STRING_ALGORITHM_DEFAULT (0)
436  #define HASH_STRING_ALGORITHM_X65599 (1)
437  #define HASH_STRING_ALGORITHM_INVALID (0xffffffff)
438 #endif
439 
442 
443 CSTR HexString (
444  PBYTE pData, UINT dataLen,
445  TSTR strBuf DEF_(NULL), UINT bufSize DEF_(0),
446  bool tailDots DEF_(false)
447  );
448 
451 
452 CSTR DataSizeStr( UINT64 Size );
453 
456 
457 CSTR IsoDataSizeStr( UINT64 Size );
458 
472 
473 CSTR FileAttribStr( DWORD Attr );
474 
477 
478 #define DEF_DATETIME_FMT _T("%Y-%m-%d %H.%M.%S")
479 
481 
482 CSTR FileTimeStr( FILETIME* FTime, CSTR Fmt DEF_( DEF_DATETIME_FMT ));
483 
511 // N.B: The \% escaping above is for doxygen, e.g \%A is really %A.
512 
513 CSTR SysTimeStr( SYSTEMTIME* Time, CSTR Fmt );
514 
520 
521 CSTR FileTypeStr( CSTR FName );
522 
550 
551 CSTR EngFormat( long double Value, BYTE nDecimals, CSTR Unit DEF_(NULL) );
552 
554 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
561 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
563 
564 CSTR GetGUIDString( REFIID riid, TSTR pzBuf DEF_(NULL), UINT ccBuf DEF_(0) );
566 
567 CSTR GetIIDString( REFIID riid, TSTR pzBuf DEF_(NULL), UINT ccBuf DEF_(0) );
570 
571 CSTR GetCLSIDString( REFIID riid, TSTR pzBuf DEF_(NULL), UINT ccBuf DEF_(0) );
574 
575 CSTR GetCLSIDAppname( REFIID riid, TSTR pzBuf DEF_(NULL), UINT ccBuf DEF_(0) );
577 
579 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
582 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
584 #ifndef NO_WINTERNAL // UNICODE_STRING is "internal" due to where it's declared..
585 
588 
589 PUNICODE_STRING _InitUnicodeString( PUNICODE_STRING puStr, PCWSTR pwzSrc );
590 
593 
594 PSTRING _InitString( PSTRING pStr, LPCSTR pzSrc );
595 
599 
600 bool SetUnicodeString( PUNICODE_STRING puStr, WCSTR wzSrc );
601 
606 
607 #define INIT_PACKED_UNICODE_STRING( pu, bufsize ) \
608  (pu)->Buffer = (PWSTR)( (PBYTE)(pu) + sizeof(UNICODE_STRING) ); \
609  (pu)->MaximumLength = bufsize - sizeof(UNICODE_STRING); \
610  (pu)->Length = 0
611 
616 
617 PUNICODE_STRING InitPackedUnicodeString( PVOID Buffer, USHORT cbBuffer );
618 
619 // mem_AllocUnistr() belong here too, but is declared/documented in "salloc".
620 
621 #endif // NO_WINTERNAL
623 #ifdef __cplusplus
624 
625 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
630 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
631 
632 class UString : public UNICODE_STRING {
633 protected:
636  enum eFlags {
637  UF_OWN_BUFFER = 0x0001
638  };
639  bool _allocBuf( size_t nChar );
640  void _freeBuf();
642 public:
643  UString();
644  UString( WCSTR Src );
645  UString( ACSTR Src );
646  UString( const UNICODE_STRING& Src );
647  UString( size_t Len );
648  void Clear() { _freeBuf(); }
649  virtual ~UString();
650 
651  UString& operator = ( WCSTR Src );
652  UString& operator = ( ACSTR Src );
653  UString& operator = ( const UNICODE_STRING& Src );
654 
655  void Set( WCSTR Src );
656  bool Set( ACSTR Src );
657  bool Set( const UNICODE_STRING& Src );
658 
659  operator PWSTR() { return Buffer; }
660  operator PCWSTR() { return (PCWSTR) Buffer; }
661  operator UNICODE_STRING() { return *this; }
662  operator PUNICODE_STRING() { return this; }
663 };
664 
665 #endif//def __cplusplus
666 #ifdef __cplusplus
668 
669 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
671 // Used internally in uLib here and there..
672 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
673 
675 {
677  UINT_PTR Data;
678 
679  StringEntry( CSTR pzName, UINT_PTR uData ) { Name = newStr( pzName ); Data = uData; }
681 
683 
684  static bool __stdcall _delete( PLIST_ENTRY This, PVOID Ctx ) {
685  delete (StringEntry*) This; return true;
686  }
687 };
688 typedef struct StringEntry* PStringEntry;
689 #ifdef __DOXYGEN__
690 typedef struct StringEntry StringEntry;
691 #endif
692 
693 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
702 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
703 
704 class StringCache {
705 public:
706  char* Storage;
707  //union _uStrg { // Under consideration...
708  //char* a; //!< @dt Multi-string content buffer. Treat as R/O.
709  //wchar_t* w; //!< @dt Multi-string content buffer. Treat as R/O.
710  //} Storage;
711 
715 
716  StringCache( UINT InitSize DEF_(4096), UINT ChunkSize DEF_(4096) );
717 
718  // TODO: Add ctor for existing multi-sz block, eg. ini section..
719 
720  ~StringCache();
721 
722  // NOTE: DupStr may cause a reallocation of Storage which will invalidate
723  // any external string poiters referencing the previous storage block.
724  // WordList handles this case, but user code might not..
725 
726  char* DupStr( char* Str );
727  //wchar_t* DupStr( wchar_t* Str ); //!< @dt Copy *Str* into next available Storage.
728 
729  void Reset();
730  void Free();
731  int StorageSize() { return StgSize; }
732  int StorageUsed() { return StgUsed; }
733 
734 protected:
735  UINT StgSize, StgUsed, StgChunk; // Storage size, used, chunk size
736  bool GrowStorage(); // Grow the string content block.
737 };
738 typedef class StringCache* PStringCache;
739 
740 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
776 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
777 
778 class WordList : public StringCache {
779 public:
780  char** Strings;
781  //union _uStrs { // Under consideration..
782  // char** a;
783  // wchar_t** w;
784  //} Strings; //!< @dt Sorted string list (pointer array). Treat as R/O.
785  UINT Count;
786 
792 
793  WordList( // Default = 128 strings of 32 char average.
794  UINT InitListDim DEF_(128), UINT InitStgSize DEF_(4096),
795  UINT ListGrowBy DEF_(128), UINT StgGrowBy DEF_(4096)
796  );
797 
798  // TODO: Add ctor for existing StringCache, eg. ini section..
799 
800  ~WordList();
801 
805 
806  bool AddString( char* Str, bool caseSens = true );
807  //bool AddString( wchar_t* Str, bool caseSens = true );
808 
812 
813  char* Search( char* Key,
814  int (__stdcall *Compare)( char* Key, char* Str, void* Ctx ),
815  void* Context
816  );
817  //wchar_t* Search( wchar_t* Key,
818  // int (__stdcall *Compare)( wchar_t* Key, wchar_t* Str, void* Ctx ),
819  // void* Context
820  // );
821 
822  void Reset();
823  void Free();
824 
825 protected:
826  UINT Dim; // Dimension of Strings array.
827  UINT ListChunk; // Ptr chunk size.
828  bool Grow(); // Grow the pointer array.
829 };
830 typedef class WordList* PWordList;
831 
832 #endif//def __cplusplus
833 #endif //ndef _StrFunc_h_incl_
835 // EOF
UINT MultiSzLengthW(WCSTR MultiSz)
Definition: StrFunc.cpp:430
UINT ListChunk
Definition: StrFunc.h:827
UINT MultiSzLengthA(ACSTR MultiSz)
Definition: StrFunc.cpp:423
TSTR DuplicateMultiSz(CSTR pzMulti)
Definition: StrFunc.cpp:527
unsigned long DWORD
Definition: Common.h:414
UINT StgChunk
Definition: StrFunc.h:735
ACSTR _MBStr(WCSTR pWStr)
Definition: StrFunc.cpp:281
const char * ACSTR
Definition: Common.h:345
ULONG GetStringHash(WCSTR Str, ULONG Algorithm=0, bool caseSens=true)
Definition: StrFunc.cpp:947
#define CSTR
Definition: Common.h:329
char * Storage
Definition: StrFunc.h:706
WCSTR FindResourceStrEx(HMODULE hModule, UINT Id, LANGID Lang, PWORD pCount)
Definition: StrFunc.cpp:339
CSTR WithoutBackslash(CSTR PathName)
Definition: StrFunc.cpp:668
UINT DeduplicateCharSepText(INOUT ASTR Text, CHAR Separator, bool caseSens, bool emitSorted)
CSTR WithBackslash(CSTR PathName)
Definition: StrFunc.cpp:682
UINT EnumerateMultiSzA(ASTR MultiSz, PFnEnumMultiStringA Action, PVOID Context)
Definition: StrFunc.cpp:392
CSTR mem_FreeStr(CSTR Dup)
Definition: StrFunc.cpp:270
CSTR FileTimeStr(FILETIME *FTime, CSTR Fmt=_T("%Y-%m-%d %H.%M.%S"))
Definition: StrFunc.cpp:1124
unsigned short WORD
Definition: Common.h:413
UINT MultiSzCountA(ACSTR MultiSz)
Definition: StrFunc.cpp:439
CSTR FreeResourceStrEx(CSTR pzRcDupStr)
Definition: StrFunc.cpp:383
PUNICODE_STRING _InitUnicodeString(PUNICODE_STRING puStr, PCWSTR pwzSrc)
Definition: StrFunc.cpp:1340
StringEntry(CSTR pzName, UINT_PTR uData)
Definition: StrFunc.h:679
RC_STRING(HMODULE hModule, UINT Id)
Definition: StrFunc.h:254
UINT_PTR Data
Definition: StrFunc.h:677
ASTR mem_ADupWStr(WCSTR WStr, UINT CodePg=CP_ACP, UINT ccExtra=0)
Definition: StrFunc.cpp:290
TSTR MultiCrLfToLf(TSTR pText)
Definition: StrFunc.cpp:467
CSTR newStr(CSTR Src)
Definition: StrFunc.cpp:167
wchar_t * WSTR
Definition: Common.h:366
#define TSTR
Definition: Common.h:328
unsigned char * PBYTE
Definition: Common.h:412
TSTR ReplaceStrChar(TSTR Str, TCHAR From, TCHAR To, OPTOUT UINT *pCount)
Definition: StrFunc.cpp:699
char * ASTR
Definition: Common.h:344
#define OPTOUT
Definition: Common.h:264
PUNICODE_STRING InitPackedUnicodeString(PVOID Buffer, USHORT cbBuffer)
Definition: StrFunc.cpp:1364
TSTR newStrBuf(WORD nChar)
Definition: StrFunc.cpp:183
CSTR LoadStr(HMODULE hModule, UINT Id, TSTR Buf=NULL, UINT Count=0)
Definition: StrFunc.cpp:310
wchar_t *__fastcall wcsncpyz(register wchar_t *Dst, register const wchar_t *Src, size_t Count)
Definition: StrFunc.cpp:142
void Reset()
Definition: StrFunc.cpp:1773
WORD Flags
Definition: StrFunc.h:634
UINT Count
Definition: StrFunc.h:785
bool SplitNetShareName(IN CSTR ShareName, OUT WSTR Server, UINT ccServer, OUT WSTR Share, UINT ccShare)
Definition: StrFunc.cpp:634
bool(__stdcall * PFnEnumMultiStringW)(WSTR Str, PVOID Context)
Definition: StrFunc.h:287
WSTR mem_WDupAStr(ACSTR AStr, UINT CodePg=CP_ACP, UINT ccExtra=0)
Definition: StrFunc.cpp:298
bool SplitUncPath(IN CSTR UncPath, OUT TSTR Svr, UINT ccSvr, OUT TSTR Share, UINT ccShare, OPTOUT TSTR Path=NULL, UINT ccPath=0)
UINT StgUsed
Definition: StrFunc.h:735
struct _LIST_ENTRY * PLIST_ENTRY
TSTR LinesToMultiSz(TSTR pText, UINT *ccSz)
Definition: StrFunc.cpp:493
void Reset()
Definition: StrFunc.cpp:1577
void Clear()
Definition: StrFunc.h:648
char * stristr(const char *str, const char *pattern)
Definition: StrFunc.cpp:96
char * DupStr(char *Str)
Definition: StrFunc.cpp:1616
~StringEntry()
Definition: StrFunc.h:680
UINT PrependString(INOUT TSTR String, UINT ccBuf, OPTIN TCHAR Sep, CSTR Prolog)
const wchar_t * WCSTR
Definition: Common.h:367
int StorageSize()
Definition: StrFunc.h:731
UINT EnumerateMultiSzW(WSTR MultiSz, PFnEnumMultiStringW Action, PVOID Context)
Definition: StrFunc.cpp:407
bool MatchPattern(CSTR String, CSTR Pattern, bool CaseSens)
Definition: StrFunc.cpp:743
class WordList * PWordList
Definition: StrFunc.h:830
UINT StgSize
Definition: StrFunc.h:735
UINT AppendString(INOUT TSTR String, UINT ccBuf, OPTIN TCHAR Sep, CSTR Epilog)
CSTR GetIIDString(REFIID riid, TSTR pzBuf=NULL, UINT ccBuf=0)
Definition: StrFunc.cpp:1249
ASTR mem_AllocAStr(WORD nChar)
Definition: StrFunc.cpp:258
CSTR GetGUIDString(REFIID riid, TSTR pzBuf=NULL, UINT ccBuf=0)
Definition: StrFunc.cpp:1230
RC_STRING()
Definition: StrFunc.h:253
class StringCache * PStringCache
Definition: StrFunc.h:738
TSTR MultiSzToLines(TSTR pText)
Definition: StrFunc.cpp:514
CSTR GetCLSIDAppname(REFIID riid, TSTR pzBuf=NULL, UINT ccBuf=0)
Definition: StrFunc.cpp:1310
WORD Length
Definition: StrFunc.h:249
char ** Strings
Definition: StrFunc.h:780
WCSTR Text
Definition: StrFunc.h:250
WSTR mem_AllocWStr(WORD nChar)
Definition: StrFunc.cpp:264
char *__fastcall strnecpy(register char *Dst, register const char *Src, size_t N)
Definition: StrFunc.cpp:77
void Set(WCSTR Src)
Definition: StrFunc.cpp:1443
void Free()
Definition: StrFunc.cpp:1779
static bool __stdcall _delete(PLIST_ENTRY This, PVOID Ctx)
Definition: StrFunc.h:684
CSTR EngFormat(long double Value, BYTE nDecimals, CSTR Unit=NULL)
Definition: StrFunc.cpp:1171
StringCache(UINT InitSize=4096, UINT ChunkSize=4096)
Definition: StrFunc.cpp:1558
CSTR __cdecl StrFmt(TSTR Buf, UINT ccBuf, CSTR Fmt,...)
Definition: StrFunc.cpp:545
UString & operator=(WCSTR Src)
Definition: StrFunc.cpp:1501
bool SetUnicodeString(PUNICODE_STRING puStr, WCSTR wzSrc)
Definition: StrFunc.cpp:1370
PUNICODE_STRING mem_AllocUniStr(WORD ccStr, OPTOUT PULONG cbAlloc)
unsigned __int64 UINT64
Definition: Common.h:400
CSTR IsoDataSizeStr(UINT64 Size)
Definition: StrFunc.cpp:1066
bool AddString(char *Str, bool caseSens=true)
Definition: StrFunc.cpp:1803
UINT MultiSzCountW(WCSTR MultiSz)
Definition: StrFunc.cpp:451
wchar_t *__fastcall wcsnecpy(register wchar_t *Dst, register const wchar_t *Src, size_t N)
Definition: StrFunc.cpp:84
WSTR mem_DupWStr(WCSTR Src)
Definition: StrFunc.cpp:250
bool Grow()
Definition: StrFunc.cpp:1786
CSTR DupResourceStrEx(HMODULE hModule, UINT Id, LANGID Lang, PWORD pCount)
Definition: StrFunc.cpp:360
UINT Dim
Definition: StrFunc.h:826
WordList(UINT InitListDim=128, UINT InitStgSize=4096, UINT ListGrowBy=128, UINT StgGrowBy=4096)
Definition: StrFunc.cpp:1758
WCSTR GetResource(HMODULE hModule, UINT Id)
Definition: StrFunc.h:255
INT_PTR CharIndex(const chrType *Buffer, const chrType *Inside)
Definition: StrFunc.h:93
void Free()
Definition: StrFunc.cpp:1582
TSTR FreeMultiSz(TSTR pzMulti)
Definition: StrFunc.cpp:538
#define DEF_(x)
Definition: Common.h:240
wchar_t *__fastcall wcsecpy(register wchar_t *Dst, register const wchar_t *Src)
Definition: StrFunc.cpp:68
#define END_EXTERN_C
Definition: Common.h:221
char * Search(char *Key, int(__stdcall *Compare)(char *Key, char *Str, void *Ctx), void *Context)
Definition: StrFunc.cpp:1875
CSTR GetCLSIDString(REFIID riid, TSTR pzBuf=NULL, UINT ccBuf=0)
Definition: StrFunc.cpp:1278
#define BEGIN_EXTERN_C
Definition: Common.h:220
WCSTR newWStr(WCSTR Src)
Definition: StrFunc.cpp:206
CSTR DataSizeStr(UINT64 Size)
Definition: StrFunc.cpp:1042
int StorageUsed()
Definition: StrFunc.h:732
CSTR Name
Definition: StrFunc.h:676
unsigned short * PWORD
Definition: Common.h:413
bool GrowStorage()
Definition: StrFunc.cpp:1588
size_t wcsbytes(const wchar_t *Src)
Definition: StrFunc.cpp:154
CSTR deleteStr(CSTR Dup)
Definition: StrFunc.cpp:191
WCSTR deleteWStr(WCSTR Dup)
Definition: StrFunc.cpp:219
CSTR FileTypeStr(CSTR FName)
Definition: StrFunc.cpp:1151
PSTRING _InitString(PSTRING pStr, LPCSTR pzSrc)
Definition: StrFunc.cpp:1352
virtual ~UString()
Definition: StrFunc.cpp:1438
WCSTR GetResourceStr(HMODULE hModule, UINT Id, PWORD pCount)
Definition: StrFunc.cpp:324
CSTR HexString(PBYTE pData, UINT dataLen, TSTR strBuf=NULL, UINT bufSize=0, bool tailDots=false)
Definition: StrFunc.cpp:981
INT_PTR CharIndexW(const WCHAR *Buffer, const WCHAR *Inside)
INT_PTR CharIndexA(const CHAR *Buffer, const CHAR *Inside)
bool GetRootOf(IN CSTR PathName, OUT TSTR Root, UINT ccRoot)
Definition: StrFunc.cpp:661
CSTR SysTimeStr(SYSTEMTIME *Time, CSTR Fmt)
Definition: StrFunc.cpp:1131
unsigned char BYTE
Definition: Common.h:412
bool __forceinline IsString(CSTR Str)
Definition: StrFunc.h:84
char *__fastcall strncpyz(register char *Dst, register const char *Src, size_t Count)
Definition: StrFunc.cpp:134
char *__fastcall strecpy(register char *Dst, register const char *Src)
Definition: StrFunc.cpp:37
ASTR mem_DupAStr(ACSTR Src)
Definition: StrFunc.cpp:237
bool(__stdcall * PFnEnumMultiStringA)(ASTR Str, PVOID Context)
Definition: StrFunc.h:286
CSTR FileAttribStr(DWORD Attr)
Definition: StrFunc.cpp:1092
#define DEF_DATETIME_FMT
Definition: StrFunc.h:478
#define OPTIN
Definition: Common.h:263
wchar_t * wcsistr(const wchar_t *str, const wchar_t *pattern)
Definition: StrFunc.cpp:113
#define INOUT
Definition: Common.h:262