Added the ability to have floating point values in the options.txt file.
This commit is contained in:
parent
113653a1ce
commit
ee289159b6
2 changed files with 18 additions and 0 deletions
|
@ -17,6 +17,8 @@
|
||||||
// along with Pi1541. If not, see <http://www.gnu.org/licenses/>.
|
// along with Pi1541. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
@ -158,6 +160,13 @@ Options::Options(void)
|
||||||
if ((nValue = GetDecimal(pValue)) != INVALID_VALUE) \
|
if ((nValue = GetDecimal(pValue)) != INVALID_VALUE) \
|
||||||
Name = nValue; \
|
Name = nValue; \
|
||||||
}
|
}
|
||||||
|
#define ELSE_CHECK_FLOAT_OPTION(Name) \
|
||||||
|
else if (strcasecmp(pOption, #Name) == 0) \
|
||||||
|
{ \
|
||||||
|
unsigned nValue = 0; \
|
||||||
|
if ((nValue = GetFloat(pValue)) != INVALID_VALUE) \
|
||||||
|
Name = nValue; \
|
||||||
|
}
|
||||||
|
|
||||||
void Options::Process(char* buffer)
|
void Options::Process(char* buffer)
|
||||||
{
|
{
|
||||||
|
@ -267,6 +276,14 @@ unsigned Options::GetDecimal(char* pString)
|
||||||
return nResult;
|
return nResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float Options::GetFloat(char* pString)
|
||||||
|
{
|
||||||
|
if (pString == 0 || *pString == '\0')
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return atof(pString);
|
||||||
|
}
|
||||||
|
|
||||||
const char* Options::GetRomName(int index) const
|
const char* Options::GetRomName(int index) const
|
||||||
{
|
{
|
||||||
switch (index)
|
switch (index)
|
||||||
|
|
|
@ -76,6 +76,7 @@ public:
|
||||||
const char* GetLCDName() const { return LCDName; }
|
const char* GetLCDName() const { return LCDName; }
|
||||||
|
|
||||||
static unsigned GetDecimal(char* pString);
|
static unsigned GetDecimal(char* pString);
|
||||||
|
static float GetFloat(char* pString);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned int deviceID;
|
unsigned int deviceID;
|
||||||
|
|
Loading…
Reference in a new issue