9 #ifndef _StrFunc_h_incl_ 10 #define _StrFunc_h_incl_ 12 #undef USE_ULIB_NEW_DELETE // Define this to make 'new' use mem_Alloc (not recommended). 25 #if defined(_MSC_VER) && (_MSC_VER > 1200) 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 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 );
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 );
54 char*
stristr(
const char* str,
const char* pattern );
55 wchar_t*
wcsistr(
const wchar_t* str,
const wchar_t* pattern );
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 );
65 size_t wcsbytes(
const wchar_t* Src );
68 #define _tcsecpy wcsecpy 69 #define _tcsnecpy wcsnecpy 70 #define _tcsistr wcsistr 71 #define _tcsncpyz wcsncpyz 72 #define _tcsnchr (CSTR)wmemchr 74 #define _tcsecpy strecpy 75 #define _tcsnecpy strnecpy 76 #define _tcsistr stristr 77 #define _tcsncpyz strncpyz 78 #define _tcsnchr (CSTR)memchr 86 #define IsString( Str ) ((Str) && *(Str)) // Careful if passing expressions! 92 extern "C++" template <
typename chrType>
93 INT_PTR
CharIndex(
const chrType* Buffer,
const chrType* Inside )
95 INT_PTR ix = Inside - Buffer;
101 #define CharIndex CharIndexW 103 #define CharIndex CharIndexA 109 INT_PTR
CharIndexA(
const CHAR* Buffer,
const CHAR* Inside );
110 INT_PTR
CharIndexW(
const WCHAR* Buffer,
const WCHAR* Inside );
138 #define mem_DupStr mem_DupWStr 139 #define mem_AllocStr mem_AllocWStr 141 #define mem_DupStr mem_DupAStr 142 #define mem_AllocStr mem_AllocAStr 165 #ifndef NO_WINTERNAL // UNICODE_STRING is considered (by MS) as "internal" 270 #define EnumerateMultiSz EnumerateMultiSzW 271 #define PFnEnumMultiString PFnEnumMultiStringW 272 #define MultiSzLength MultiSzLengthW 273 #define MultiSzCount MultiSzCountW 275 #define EnumerateMultiSz EnumerateMultiSzA 276 #define PFnEnumMultiString PFnEnumMultiStringA 277 #define MultiSzLength MultiSzLengthA 278 #define MultiSzCount MultiSzCountA 351 OUT
TSTR Svr, UINT ccSvr, OUT
TSTR Share, UINT ccShare,
363 OUT
WSTR Server, UINT ccServer, OUT
WSTR Share, UINT ccShare
411 INOUT ASTR Text, CHAR Separator,
bool caseSens,
bool emitSorted
431 ULONG Algorithm
DEF_(0),
432 bool caseSens
DEF_(
true)
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) 444 PBYTE pData, UINT dataLen,
446 bool tailDots
DEF_(
false)
478 #define DEF_DATETIME_FMT _T("%Y-%m-%d %H.%M.%S") 584 #ifndef NO_WINTERNAL // UNICODE_STRING is "internal" due to where it's declared.. 607 #define INIT_PACKED_UNICODE_STRING( pu, bufsize ) \ 608 (pu)->Buffer = (PWSTR)( (PBYTE)(pu) + sizeof(UNICODE_STRING) ); \ 609 (pu)->MaximumLength = bufsize - sizeof(UNICODE_STRING); \ 621 #endif // NO_WINTERNAL 637 UF_OWN_BUFFER = 0x0001
639 bool _allocBuf(
size_t nChar );
646 UString(
const UNICODE_STRING& Src );
657 bool Set(
const UNICODE_STRING& Src );
659 operator PWSTR() {
return Buffer; }
660 operator PCWSTR() {
return (PCWSTR) Buffer; }
661 operator UNICODE_STRING() {
return *
this; }
662 operator PUNICODE_STRING() {
return this; }
665 #endif//def __cplusplus 726 char*
DupStr(
char* Str );
794 UINT InitListDim
DEF_(128), UINT InitStgSize
DEF_(4096),
795 UINT ListGrowBy
DEF_(128), UINT StgGrowBy
DEF_(4096)
806 bool AddString(
char* Str,
bool caseSens =
true );
814 int (__stdcall *Compare)(
char* Key,
char* Str,
void* Ctx ),
832 #endif//def __cplusplus 833 #endif //ndef _StrFunc_h_incl_ UINT MultiSzLengthW(WCSTR MultiSz)
UINT MultiSzLengthA(ACSTR MultiSz)
TSTR DuplicateMultiSz(CSTR pzMulti)
ACSTR _MBStr(WCSTR pWStr)
ULONG GetStringHash(WCSTR Str, ULONG Algorithm=0, bool caseSens=true)
WCSTR FindResourceStrEx(HMODULE hModule, UINT Id, LANGID Lang, PWORD pCount)
CSTR WithoutBackslash(CSTR PathName)
UINT DeduplicateCharSepText(INOUT ASTR Text, CHAR Separator, bool caseSens, bool emitSorted)
CSTR WithBackslash(CSTR PathName)
UINT EnumerateMultiSzA(ASTR MultiSz, PFnEnumMultiStringA Action, PVOID Context)
CSTR mem_FreeStr(CSTR Dup)
CSTR FileTimeStr(FILETIME *FTime, CSTR Fmt=_T("%Y-%m-%d %H.%M.%S"))
UINT MultiSzCountA(ACSTR MultiSz)
CSTR FreeResourceStrEx(CSTR pzRcDupStr)
PUNICODE_STRING _InitUnicodeString(PUNICODE_STRING puStr, PCWSTR pwzSrc)
StringEntry(CSTR pzName, UINT_PTR uData)
RC_STRING(HMODULE hModule, UINT Id)
ASTR mem_ADupWStr(WCSTR WStr, UINT CodePg=CP_ACP, UINT ccExtra=0)
TSTR MultiCrLfToLf(TSTR pText)
TSTR ReplaceStrChar(TSTR Str, TCHAR From, TCHAR To, OPTOUT UINT *pCount)
PUNICODE_STRING InitPackedUnicodeString(PVOID Buffer, USHORT cbBuffer)
TSTR newStrBuf(WORD nChar)
CSTR LoadStr(HMODULE hModule, UINT Id, TSTR Buf=NULL, UINT Count=0)
wchar_t *__fastcall wcsncpyz(register wchar_t *Dst, register const wchar_t *Src, size_t Count)
bool SplitNetShareName(IN CSTR ShareName, OUT WSTR Server, UINT ccServer, OUT WSTR Share, UINT ccShare)
bool(__stdcall * PFnEnumMultiStringW)(WSTR Str, PVOID Context)
WSTR mem_WDupAStr(ACSTR AStr, UINT CodePg=CP_ACP, UINT ccExtra=0)
bool SplitUncPath(IN CSTR UncPath, OUT TSTR Svr, UINT ccSvr, OUT TSTR Share, UINT ccShare, OPTOUT TSTR Path=NULL, UINT ccPath=0)
struct _LIST_ENTRY * PLIST_ENTRY
TSTR LinesToMultiSz(TSTR pText, UINT *ccSz)
char * stristr(const char *str, const char *pattern)
UINT PrependString(INOUT TSTR String, UINT ccBuf, OPTIN TCHAR Sep, CSTR Prolog)
UINT EnumerateMultiSzW(WSTR MultiSz, PFnEnumMultiStringW Action, PVOID Context)
bool MatchPattern(CSTR String, CSTR Pattern, bool CaseSens)
class WordList * PWordList
UINT AppendString(INOUT TSTR String, UINT ccBuf, OPTIN TCHAR Sep, CSTR Epilog)
CSTR GetIIDString(REFIID riid, TSTR pzBuf=NULL, UINT ccBuf=0)
ASTR mem_AllocAStr(WORD nChar)
CSTR GetGUIDString(REFIID riid, TSTR pzBuf=NULL, UINT ccBuf=0)
class StringCache * PStringCache
TSTR MultiSzToLines(TSTR pText)
CSTR GetCLSIDAppname(REFIID riid, TSTR pzBuf=NULL, UINT ccBuf=0)
WSTR mem_AllocWStr(WORD nChar)
char *__fastcall strnecpy(register char *Dst, register const char *Src, size_t N)
static bool __stdcall _delete(PLIST_ENTRY This, PVOID Ctx)
CSTR EngFormat(long double Value, BYTE nDecimals, CSTR Unit=NULL)
StringCache(UINT InitSize=4096, UINT ChunkSize=4096)
CSTR __cdecl StrFmt(TSTR Buf, UINT ccBuf, CSTR Fmt,...)
UString & operator=(WCSTR Src)
bool SetUnicodeString(PUNICODE_STRING puStr, WCSTR wzSrc)
PUNICODE_STRING mem_AllocUniStr(WORD ccStr, OPTOUT PULONG cbAlloc)
CSTR IsoDataSizeStr(UINT64 Size)
bool AddString(char *Str, bool caseSens=true)
UINT MultiSzCountW(WCSTR MultiSz)
wchar_t *__fastcall wcsnecpy(register wchar_t *Dst, register const wchar_t *Src, size_t N)
WSTR mem_DupWStr(WCSTR Src)
CSTR DupResourceStrEx(HMODULE hModule, UINT Id, LANGID Lang, PWORD pCount)
WordList(UINT InitListDim=128, UINT InitStgSize=4096, UINT ListGrowBy=128, UINT StgGrowBy=4096)
WCSTR GetResource(HMODULE hModule, UINT Id)
INT_PTR CharIndex(const chrType *Buffer, const chrType *Inside)
TSTR FreeMultiSz(TSTR pzMulti)
wchar_t *__fastcall wcsecpy(register wchar_t *Dst, register const wchar_t *Src)
char * Search(char *Key, int(__stdcall *Compare)(char *Key, char *Str, void *Ctx), void *Context)
CSTR GetCLSIDString(REFIID riid, TSTR pzBuf=NULL, UINT ccBuf=0)
CSTR DataSizeStr(UINT64 Size)
size_t wcsbytes(const wchar_t *Src)
WCSTR deleteWStr(WCSTR Dup)
CSTR FileTypeStr(CSTR FName)
PSTRING _InitString(PSTRING pStr, LPCSTR pzSrc)
WCSTR GetResourceStr(HMODULE hModule, UINT Id, PWORD pCount)
CSTR HexString(PBYTE pData, UINT dataLen, TSTR strBuf=NULL, UINT bufSize=0, bool tailDots=false)
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)
CSTR SysTimeStr(SYSTEMTIME *Time, CSTR Fmt)
bool __forceinline IsString(CSTR Str)
char *__fastcall strncpyz(register char *Dst, register const char *Src, size_t Count)
char *__fastcall strecpy(register char *Dst, register const char *Src)
ASTR mem_DupAStr(ACSTR Src)
bool(__stdcall * PFnEnumMultiStringA)(ASTR Str, PVOID Context)
CSTR FileAttribStr(DWORD Attr)
wchar_t * wcsistr(const wchar_t *str, const wchar_t *pattern)