diff --git a/src/options.cpp b/src/options.cpp index bb980da..26c3b31 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -17,6 +17,8 @@ // along with Pi1541. If not, see . #include "options.h" +#include +#include #include #include #include @@ -158,6 +160,13 @@ Options::Options(void) if ((nValue = GetDecimal(pValue)) != INVALID_VALUE) \ 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) { @@ -267,6 +276,14 @@ unsigned Options::GetDecimal(char* pString) return nResult; } +float Options::GetFloat(char* pString) +{ + if (pString == 0 || *pString == '\0') + return 0; + + return atof(pString); +} + const char* Options::GetRomName(int index) const { switch (index) diff --git a/src/options.h b/src/options.h index 2cd6d37..aa80a2b 100644 --- a/src/options.h +++ b/src/options.h @@ -76,6 +76,7 @@ public: const char* GetLCDName() const { return LCDName; } static unsigned GetDecimal(char* pString); + static float GetFloat(char* pString); private: unsigned int deviceID;