uLib
User mode C/C++ extended API library for Win32 programmers.
|
Special formatting (e.g DataSizeStr()), et cetera...
Macros | |
#define | HASH_STRING_ALGORITHM_DEFAULT (0) |
#define | HASH_STRING_ALGORITHM_X65599 (1) |
#define | HASH_STRING_ALGORITHM_INVALID (0xffffffff) |
#define | DEF_DATETIME_FMT _T("%Y-%m-%d %H.%M.%S") |
Functions | |
bool | SplitUncPath (IN CSTR UncPath, OUT TSTR Svr, UINT ccSvr, OUT TSTR Share, UINT ccShare, OPTOUT TSTR Path=NULL, UINT ccPath=0) |
bool | SplitNetShareName (IN CSTR ShareName, OUT WSTR Server, UINT ccServer, OUT WSTR Share, UINT ccShare) |
CSTR | WithoutBackslash (CSTR PathName) |
CSTR | WithBackslash (CSTR PathName) |
bool | GetRootOf (IN CSTR PathName, OUT TSTR Root, UINT ccRoot) |
CSTR __cdecl | StrFmt (TSTR Buf, UINT ccBuf, CSTR Fmt,...) |
TSTR | ReplaceStrChar (TSTR Str, TCHAR From, TCHAR To, OPTOUT UINT *pCount) |
bool | MatchPattern (CSTR String, CSTR Pattern, bool CaseSens) |
UINT | DeduplicateCharSepText (INOUT ASTR Text, CHAR Separator, bool caseSens, bool emitSorted) |
UINT | PrependString (INOUT TSTR String, UINT ccBuf, OPTIN TCHAR Sep, CSTR Prolog) |
UINT | AppendString (INOUT TSTR String, UINT ccBuf, OPTIN TCHAR Sep, CSTR Epilog) |
ULONG | GetStringHash (WCSTR Str, ULONG Algorithm=0, bool caseSens=true) |
CSTR | HexString (PBYTE pData, UINT dataLen, TSTR strBuf=NULL, UINT bufSize=0, bool tailDots=false) |
CSTR | DataSizeStr (UINT64 Size) |
CSTR | IsoDataSizeStr (UINT64 Size) |
CSTR | FileAttribStr (DWORD Attr) |
CSTR | FileTimeStr (FILETIME *FTime, CSTR Fmt=_T("%Y-%m-%d %H.%M.%S")) |
CSTR | SysTimeStr (SYSTEMTIME *Time, CSTR Fmt) |
CSTR | FileTypeStr (CSTR FName) |
CSTR | EngFormat (long double Value, BYTE nDecimals, CSTR Unit=NULL) |
#define DEF_DATETIME_FMT _T("%Y-%m-%d %H.%M.%S") |
Default date/time format used by FileTimeStr().
Output fmt = yyyy-mm-dd hh.mm.ss
bool SplitUncPath | ( | IN CSTR | UncPath, |
OUT TSTR | Svr, | ||
UINT | ccSvr, | ||
OUT TSTR | Share, | ||
UINT | ccShare, | ||
OPTOUT TSTR | Path = NULL , |
||
UINT | ccPath = 0 |
||
) |
SplitUncPath() separates an UNC path into it's constituent parts.
UncPath | An UNC entity. Must contain at least server and share components. Any prefixes (e.g "\\?\UNC\") are discarded. NT device paths produce undefined results. |
Svr | Buffer that recieves the server name. ccSvr is it's length, in TCHARs. |
Share | Svr Buffer that recieves the share name. ccShare is it's length. |
Path | [optional] Buffer that recieves the path component, if any. |
bool SplitNetShareName | ( | IN CSTR | ShareName, |
OUT WSTR | Server, | ||
UINT | ccServer, | ||
OUT WSTR | Share, | ||
UINT | ccShare | ||
) |
SplitNetShareName() extracts Server and Share names suitable for LM calls.
ShareName | A transmutable UNC "\\Server\Share" specification. |
Server,Share | Wide-string buffers recieving the components, directly suitable for calls to e.g. NetShareGetInfo(). |
Definition at line 634 of file StrFunc.cpp.
If PathName has a trailing backslash, the string is copied to a MAX_PATH
thread-local buffer, the backslash removed, and the modified string returned,
otherwise PathName is returned verbatim. See also WithBackslash().
Definition at line 668 of file StrFunc.cpp.
See WithoutBackslash().
Definition at line 682 of file StrFunc.cpp.
[preliminary] Get the root component of PathName
.
It may be an X:\ DOS volume or a UNC \Server\Share.
Any path prefix in PathName is discarded from the result.
Note: UNC paths w/o leading \ and NT device paths produce undefined results.
Definition at line 661 of file StrFunc.cpp.
StrFmt() uses _vstprintf_s() to format the text, and returns the buffer.
If Buf == NULL and ccBuf == 0, an internal static MAX_PATH buffer is used.
If Buf == NULL and ccBuf != 0, a buffer is allocated with newStrBuf().
If Buf != NULL, then it and ccBuf are used verbatim.
Definition at line 545 of file StrFunc.cpp.
ReplaceStrChar() replaces all ocurrences of From with To.
It returns a pointer to the terminating null char in Str.
Optionally it returns nr of chars replaced, in *pCount.
Definition at line 699 of file StrFunc.cpp.
Wildcard pattern match, including char set matching (e.g. [aex-z]).
If CaseSens is false, char sets are also treated as case insensitive.
String | The text to analyze. |
Pattern | A wildcard pattern to look for in String. The pattern may include one or more *, ?, and char sets (e.g. [ax-z]). |
CaseSens | True if the matching should be case sensitive. If CaseSens if false, char sets will also be treated as case insensitive. |
Definition at line 743 of file StrFunc.cpp.
DeduplicateCharSepText() removes duplicate entries from a char separated list.
Text | Buffer containing the text to be culled. Note: The buffer must have room for one extra char at the Text end, due to temporary in-place conversion to multi-sz. |
Separator | Separator char in Text, f.ex. SEMICOLON or COMMA. |
caseSens | Specify whether the comparator should be case sensitive or not. |
emitSorted | Specify whether the result should be sorted or not. |
The function returns the length of the culled text, or zero on failure.
Note: This function is currently not available in _UNICODE builds.
PrependString() prepends a string in-place.
String | Buffer containing the text to be prepended. |
ccBuf | Length of the buffer, in TCHARs. |
Sep | Optional separator char to insert (0 == none). |
Prolog | The text to precede the current buffer content. |
AppendString() appends a string in-place.
See PrependString() for parameter details.
ULONG GetStringHash | ( | WCSTR | Str, |
ULONG | Algorithm = 0 , |
||
bool | caseSens = true |
||
) |
GetStringHash() provides a handy wrap for RtlHashUnicodeString().
Definition at line 947 of file StrFunc.cpp.
CSTR HexString | ( | PBYTE | pData, |
UINT | dataLen, | ||
TSTR | strBuf = NULL , |
||
UINT | bufSize = 0 , |
||
bool | tailDots = false |
||
) |
HexString() builds a readable hex string from the given data.
If strBuf is NULL or bufSize is zero, a static buffer of MAX_PATH is used.
Definition at line 981 of file StrFunc.cpp.
DataSizeStr() returns e.g. "2.3 MB" (B,kB,MB,GB,TB,PB,EB,ZB,YB).
Note: Uses an internal static buffer.
Definition at line 1042 of file StrFunc.cpp.
IsoDataSizeStr() returns e.g. "2.2 MiB" (B,kiB,MiB,GiB,TiB,PiB,EiB,ZiB,YiB).
Note: Uses an internal static buffer.
Definition at line 1066 of file StrFunc.cpp.
FileAttribStr() returns all of the applicable [DAHRSCEOPZT], or a blank string.
Definition at line 1092 of file StrFunc.cpp.
FileTimeStr() returns a formatted file time string. See SysTimeStr().
Definition at line 1124 of file StrFunc.cpp.
SysTimeStr() formats a SYSTEMTIME into a human readable string with strftime().
Note that time zone reports the current system locale since Time doesn't have one.
Fmt | Formatting specifications for strftime() / wcsftime().
|
Definition at line 1131 of file StrFunc.cpp.
FileTypeStr() gets a file type string from the shell.
Note: If you call FileTypeStr repeatedly, you should call InitShellFunc()
before the first call. Not doing so will result in poor performance, since it would
force FileTypeStr to call InitShellFunc() and DoneShellFunc() each time.
The function uses an internal static buffer of 80 chars.
Definition at line 1151 of file StrFunc.cpp.
EngFormat() formats a value with a scientific/engineering SI prefix unit.
The output format is f.ex. "12.345 kHz", formatted into an internal static buffer.
nDecimals | Nr of decimals to output. |
Unit | Optional suffix to append to output, e.g. "Hz". |
Note: The function uses an internal static buffer of 50 chars.
Definition at line 1171 of file StrFunc.cpp.