mirror of
https://github.com/electronicarts/CNC_TS_and_RA2_Mission_Editor.git
synced 2025-07-17 19:56:38 -04:00
refactored ini management, fixing performance issue and logic error from very low level .
This commit is contained in:
parent
13677476df
commit
c559292183
3 changed files with 190 additions and 174 deletions
31
MissionEditor/IniHelper.h
Normal file
31
MissionEditor/IniHelper.h
Normal 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;
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue