-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIniFile.cpp
More file actions
executable file
·35 lines (29 loc) · 1.08 KB
/
IniFile.cpp
File metadata and controls
executable file
·35 lines (29 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "IniFile.h"
CIniFile::CIniFile(const wchar_t *wszFileName, const wchar_t *wszSection)
{
Init(wszFileName, wszSection);
}
void CIniFile::Init(const wchar_t *wszFileName, const wchar_t *wszSection)
{
if(wszFileName) wscFileName_ = wszFileName;
if(wszSection) wscSection_ = wszSection;
}
void CIniFile::SetSection(const wchar_t *wszSection)
{
if(wszSection) wscSection_ = wszSection;
}
std::ci_wstring CIniFile::GetString(const wchar_t *wszName, const wchar_t *wszDefault) const
{
wchar_t wszBuffer[10240];
GetPrivateProfileString(wscSection_.c_str(), wszName, wszDefault, wszBuffer, sizeof(wszBuffer)/sizeof(wchar_t), wscFileName_.c_str());
return wszBuffer;
}
int CIniFile::GetInt(const wchar_t *wszName, int nDefault) const
{
return GetPrivateProfileInt(wscSection_.c_str(), wszName, nDefault, wscFileName_.c_str());
}
bool CIniFile::GetBool(const wchar_t *wszName, bool bDefault) const
{
std::ci_wstring value = GetString(wszName);
return value.empty()? bDefault : ((value == L"1") || (value == L"y") || (value == L"yes") || (value == L"true"));
}