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++

#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 };
};