new feature: Data::saveBool & Data::getBool
This commit is contained in:
parent
d0733b01e2
commit
bca9f6f792
|
|
@ -11,26 +11,39 @@ void e2d::Data::saveDouble(const String & key, double value)
|
||||||
::WritePrivateProfileString(L"Default", key, String::toString(value), File::getDefaultSavePath());
|
::WritePrivateProfileString(L"Default", key, String::toString(value), File::getDefaultSavePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void e2d::Data::saveBool(const String & key, bool value)
|
||||||
|
{
|
||||||
|
int nValue = value ? 1 : 0;
|
||||||
|
::WritePrivateProfileString(L"Default", key, String::toString(nValue), File::getDefaultSavePath());
|
||||||
|
}
|
||||||
|
|
||||||
void e2d::Data::saveString(const String & key, const String & value)
|
void e2d::Data::saveString(const String & key, const String & value)
|
||||||
{
|
{
|
||||||
::WritePrivateProfileString(L"Default", key, value, File::getDefaultSavePath());
|
::WritePrivateProfileString(L"Default", key, value, File::getDefaultSavePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
int e2d::Data::getInt(const String & key, int default)
|
int e2d::Data::getInt(const String & key, int defaultValue)
|
||||||
{
|
{
|
||||||
return ::GetPrivateProfileInt(L"Default", key, default, File::getDefaultSavePath());
|
return ::GetPrivateProfileInt(L"Default", key, defaultValue, File::getDefaultSavePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
double e2d::Data::getDouble(const String & key, double default)
|
double e2d::Data::getDouble(const String & key, double defaultValue)
|
||||||
{
|
{
|
||||||
wchar_t temp[32] = { 0 };
|
wchar_t temp[32] = { 0 };
|
||||||
::GetPrivateProfileString(L"Default", key, String::toString(default), temp, 31, File::getDefaultSavePath());
|
::GetPrivateProfileString(L"Default", key, String::toString(defaultValue), temp, 31, File::getDefaultSavePath());
|
||||||
return std::stof(temp);
|
return std::stof(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String e2d::Data::getString(const String & key, const String & default)
|
bool e2d::Data::getBool(const String & key, bool defaultValue)
|
||||||
|
{
|
||||||
|
int nDefaultValue = defaultValue ? 1 : 0;
|
||||||
|
int nValue = ::GetPrivateProfileInt(L"Default", key, nDefaultValue, File::getDefaultSavePath());
|
||||||
|
return nValue != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::String e2d::Data::getString(const String & key, const String & defaultValue)
|
||||||
{
|
{
|
||||||
wchar_t temp[256] = { 0 };
|
wchar_t temp[256] = { 0 };
|
||||||
::GetPrivateProfileString(L"Default", key, default, temp, 255, File::getDefaultSavePath());
|
::GetPrivateProfileString(L"Default", key, defaultValue, temp, 255, File::getDefaultSavePath());
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -140,6 +140,12 @@ public:
|
||||||
double value
|
double value
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// 保存 bool 类型的值
|
||||||
|
static void saveBool(
|
||||||
|
const String & key,
|
||||||
|
bool value
|
||||||
|
);
|
||||||
|
|
||||||
// 保存 字符串 类型的值
|
// 保存 字符串 类型的值
|
||||||
static void saveString(
|
static void saveString(
|
||||||
const String & key,
|
const String & key,
|
||||||
|
|
@ -160,6 +166,13 @@ public:
|
||||||
double defaultValue
|
double defaultValue
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// 获取 bool 类型的值
|
||||||
|
// (若不存在则返回 defaultValue 参数的值)
|
||||||
|
static bool getBool(
|
||||||
|
const String & key,
|
||||||
|
bool defaultValue
|
||||||
|
);
|
||||||
|
|
||||||
// 获取 字符串 类型的值
|
// 获取 字符串 类型的值
|
||||||
// (若不存在则返回 defaultValue 参数的值)
|
// (若不存在则返回 defaultValue 参数的值)
|
||||||
static String getString(
|
static String getString(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue