You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
2.5 KiB
C
56 lines
2.5 KiB
C
|
3 years ago
|
#pragma once
|
||
|
|
|
||
|
|
#include <string>
|
||
|
|
|
||
|
|
#include "DllDefines.h"
|
||
|
|
|
||
|
|
class UTILITYDLL CIniFile
|
||
|
|
{
|
||
|
|
public:
|
||
|
|
CIniFile(LPCTSTR sFileName = nullptr, LPCTSTR sSectionName = nullptr);
|
||
|
|
virtual ~CIniFile();
|
||
|
|
|
||
|
|
CIniFile& SetFileName(LPCTSTR sFileName);
|
||
|
|
CIniFile& SetSectionName(LPCTSTR m_sSectionName);
|
||
|
|
|
||
|
|
// Get SectionName
|
||
|
|
LPCTSTR GetSectionName();
|
||
|
|
|
||
|
|
// Get FileName
|
||
|
|
LPCTSTR GetFileName();
|
||
|
|
|
||
|
|
BOOL WriteString(LPCTSTR lpKeyName, LPCTSTR lpString);
|
||
|
|
BOOL WriteLong(LPCTSTR lpKeyName, long lLong);
|
||
|
|
BOOL WriteDouble(LPCTSTR lpKeyName, double dDouble);
|
||
|
|
std::string GetString(LPCTSTR lpKeyName, LPCTSTR lpDefaultString, BOOL bCreateIfFail = TRUE);
|
||
|
|
long GetLong(LPCTSTR lpKeyName, long lDefaultLong, BOOL bCreateIfFail = TRUE);
|
||
|
|
double GetDouble(LPCTSTR lpKeyName, double dDefaultDouble, BOOL bCreateIfFail = TRUE);
|
||
|
|
bool GetBool(LPCTSTR lpKeyName, LPCTSTR lpDefaultString, BOOL bCreateIfFail = TRUE);
|
||
|
|
|
||
|
|
// write longlong value to file
|
||
|
|
BOOL WriteLongLong(LPCTSTR lpKeyName, LONGLONG lLong);
|
||
|
|
|
||
|
|
// get longlong value from file
|
||
|
|
LONGLONG GetLongLong(LPCTSTR lpKeyName, LONGLONG lDefaultLong, BOOL bCreateIfFail = TRUE);
|
||
|
|
|
||
|
|
// write longlong value to file
|
||
|
|
static BOOL WriteLongLong(LPCTSTR pszFileName, LPCTSTR pszSectionName, LPCTSTR lpKeyName, LONGLONG lLong);
|
||
|
|
|
||
|
|
// get long long value from file
|
||
|
|
static LONGLONG GetLongLong(LPCTSTR pszFileName, LPCTSTR pszSectionName, LPCTSTR lpKeyName, LONGLONG lDefaultLong, BOOL bCreateIfFail = TRUE);
|
||
|
|
|
||
|
|
static BOOL WriteString(LPCTSTR pszFileName, LPCTSTR pszSectionName, LPCTSTR lpKeyName, LPCTSTR lpString);
|
||
|
|
static BOOL WriteLong(LPCTSTR pszFileName, LPCTSTR pszSectionName, LPCTSTR lpKeyName, long lLong);
|
||
|
|
static BOOL WriteDouble(LPCTSTR pszFileName, LPCTSTR pszSectionName, LPCTSTR lpKeyName, double dDouble);
|
||
|
|
static std::string GetString(LPCTSTR pszFileName, LPCTSTR pszSectionName, LPCTSTR lpKeyName, LPCTSTR lpDefaultString, BOOL bCreateIfFail = TRUE);
|
||
|
|
static long GetLong(LPCTSTR pszFileName, LPCTSTR pszSectionName, LPCTSTR lpKeyName, long lDefaultLong, BOOL bCreateIfFail = TRUE);
|
||
|
|
static double GetDouble(LPCTSTR pszFileName, LPCTSTR pszSectionName, LPCTSTR lpKeyName, double dDefaultDouble, BOOL bCreateIfFail = TRUE);
|
||
|
|
static bool GetBool(LPCTSTR pszFileName, LPCTSTR pszSectionName, LPCTSTR lpKeyName, LPCTSTR lpDefaultString, BOOL bCreateIfFail = TRUE);
|
||
|
|
|
||
|
|
// attributes
|
||
|
|
private:
|
||
|
|
static constexpr int MAX_INI_FILE_PATH = 512;
|
||
|
|
TCHAR m_sFileName[MAX_INI_FILE_PATH]{ 0 };
|
||
|
|
TCHAR m_sSectionName[MAX_INI_FILE_PATH]{ 0 };
|
||
|
|
};
|