uLib
User mode C/C++ extended API library for Win32 programmers.
|
#include <uLib/IniFile.h>
IniFile encapsulates the Get/WritePrivateProfile function family.
It also provides some additional functionality not provided by the system.
IniFile uses an internal data buffer for data retrieval and formatting.
After instanciation, use AllocBuffer() if you need to resize the buffer.
Do size the buffer to fit the biggest block you expect. The default is 4 kB.
Public Data | |
TCHAR | Filename [MAX_PATH] |
UINT_PTR | UserData |
Public Functions | |
IniFile (CSTR FName=NULL, UINT BufSize=4096) | |
virtual | ~IniFile () |
void | SetFilename (CSTR FName) |
bool | AllocBuffer (UINT Size) |
UINT | BufSize () |
PBYTE | GetBuffer () |
operator LPCSTR () | |
operator LPSTR () | |
INT | ValSize () |
UINT | GetInt (CSTR Section, CSTR KeyName, INT Default) |
INT | GetString (CSTR Section, CSTR KeyName, CSTR Default, TSTR Buf, UINT BufLen) |
TSTR | GetString (CSTR Section, CSTR KeyName, CSTR Default, OPTOUT INT *Size=NULL) |
TSTR | GetSection (CSTR Section, OPTOUT INT *Size=NULL) |
TSTR | GetSectionNames (OPTOUT INT *Size=NULL) |
PBYTE | GetBinary (CSTR Section, CSTR Key, OUT INT *pSize) |
PBYTE | GetStruct (CSTR Section, CSTR Key, UINT cbStruct) |
BOOL | WriteRawSection (CSTR Section, CSTR MultiSz) |
BOOL | WriteSection (CSTR Section, CSTR Strings) |
BOOL | WriteString (CSTR Section, CSTR KeyName, CSTR Text) |
BOOL | WriteStringFmt (CSTR Section, CSTR KeyName, CSTR Fmt,...) |
BOOL | WriteInt (CSTR Section, CSTR KeyName, LONG Value, BYTE Radix=10) |
BOOL | WriteStruct (CSTR Section, CSTR Key, PVOID pStruct, UINT Size) |
BOOL | DeleteString (CSTR Section, CSTR KeyName) |
BOOL | DeleteSection (CSTR Section) |
BOOL | SaveWndRect (HWND hWnd, CSTR Section, CSTR Key) |
BOOL | RestoreWndRect (HWND hWnd, CSTR Section, CSTR Key) |
IniFile::IniFile | ( | CSTR | FName = NULL , |
UINT | BufSize = 4096 |
||
) |
Initialize Filename and allocate a buffer. Calls SetFilename().
Definition at line 15 of file IniFile.cpp.
|
virtual |
Dispose the internal buffer.
Definition at line 22 of file IniFile.cpp.
void IniFile::SetFilename | ( | CSTR | FName | ) |
SetFilename sets the INI Filename to use.
If FName is NULL, GetModuleFileName() is used, replacing .exe with .ini.
Definition at line 27 of file IniFile.cpp.
bool IniFile::AllocBuffer | ( | UINT | Size | ) |
AllocBuffer (re)allocates the internal buffer.
Definition at line 43 of file IniFile.cpp.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Return the size of the last GetString(), GetSection(), or GetSectionNames().
If the value is negative, the buffer was too small, and the abs value indicate the required buffer size.
GetInt can handle radix 10 and 16.
Definition at line 66 of file IniFile.cpp.
GetPrivateProfileString().
Definition at line 71 of file IniFile.cpp.
GetPrivateProfileString().
Returns a multi-sz with all key/value pairs.
Definition at line 95 of file IniFile.cpp.
Returns a multi-sz with all section names.
Definition at line 110 of file IniFile.cpp.
GetBinary is a variant of GetStruct() that doesn't need a specified size.
Instead, the whole hex string is read and processed, and the function
returns both the parsed binary data and it's size.
In case of a checksum error, the return value is NULL.
Definition at line 147 of file IniFile.cpp.
GetStruct simply uses GetPrivateProfileStruct() with the internal buffer.
Definition at line 125 of file IniFile.cpp.
WriteRawSection() replaces a section verbatim (no key/value parsing).
Definition at line 202 of file IniFile.cpp.
WritePrivateProfileSection()
Definition at line 173 of file IniFile.cpp.
WritePrivateProfileString()
Definition at line 295 of file IniFile.cpp.
Format the arguments with _vstprintf_s() into the internal buffer
and write it out as a string value.
Definition at line 300 of file IniFile.cpp.
Radix = 10 or 16.
Definition at line 283 of file IniFile.cpp.
WritePrivateProfileStruct().
Definition at line 313 of file IniFile.cpp.
Delete the KeyName value.
Definition at line 318 of file IniFile.cpp.
Delete the entire Section.
Definition at line 323 of file IniFile.cpp.
Save the window rect.
Definition at line 330 of file IniFile.cpp.
Restore the window rect.
Definition at line 342 of file IniFile.cpp.