refactored ini management, fixing performance issue and logic error from very low level .

This commit is contained in:
Zero Fanker 2024-03-31 19:57:33 -04:00
parent 13677476df
commit c559292183
3 changed files with 190 additions and 174 deletions

31
MissionEditor/IniHelper.h Normal file
View file

@ -0,0 +1,31 @@
#pragma once
#include <CString>
#include <ctype.h>
class INIHelper
{
public:
static bool StingToBool(const CString& str, bool def)
{
switch (toupper(static_cast<unsigned char>(*str))) {
case '1':
case 'T':
case 'Y':
return true;
case '0':
case 'F':
case 'N':
return false;
default:
return def;
}
}
static int StringToInteger(const CString& str, int def)
{
int ret = 0;
if (sscanf_s(str, "%d", &ret) == 1) {
return ret;
}
return def;
}
};