mirror of
https://github.com/electronicarts/CNC_TS_and_RA2_Mission_Editor.git
synced 2025-05-03 02:11:40 -04:00
31 lines
No EOL
484 B
C++
31 lines
No EOL
484 B
C++
#pragma once
|
|
#include <CString>
|
|
#include <ctype.h>
|
|
|
|
class INIHelper
|
|
{
|
|
public:
|
|
static bool StringToBool(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;
|
|
}
|
|
}; |