/* ** Read the options specified in the ini file. ** */ void CMeasureCalc::ReadOptions(CConfigParser& parser, const WCHAR* section) { CMeasure::ReadOptions(parser, section); // Store the current values so we know if the value needs to be updated int oldLowBound = m_LowBound; int oldHighBound = m_HighBound; bool oldUpdateRandom = m_UpdateRandom; std::wstring oldFormula = m_Formula; m_Formula = parser.ReadString(section, L"Formula", L""); m_LowBound = parser.ReadInt(section, L"LowBound", 0); m_HighBound = parser.ReadInt(section, L"HighBound", 100); m_UpdateRandom = 0!=parser.ReadInt(section, L"UpdateRandom", 0); if (!m_Initialized || wcscmp(m_Formula.c_str(), oldFormula.c_str()) != 0 || oldLowBound != m_LowBound || oldHighBound != m_HighBound || oldUpdateRandom != m_UpdateRandom) { if (!m_UpdateRandom) { FormulaReplace(); } const WCHAR* errMsg = MathParser::Check(m_Formula.c_str()); if (errMsg != NULL) { LogWithArgs(LOG_ERROR, L"Calc: %s in [%s]", errMsg, m_Name.c_str()); m_Formula.clear(); } } }
/* ** Read the options specified in the ini file. ** */ void MeasureCalc::ReadOptions(ConfigParser& parser, const WCHAR* section) { Measure::ReadOptions(parser, section); // Store the current values so we know if the value needs to be updated int oldLowBound = m_LowBound; int oldHighBound = m_HighBound; bool oldUpdateRandom = m_UpdateRandom; bool oldUniqueRandom = m_UniqueRandom; std::wstring oldFormula = m_Formula; m_Formula = parser.ReadString(section, L"Formula", L""); m_LowBound = parser.ReadInt(section, L"LowBound", DEFAULT_LOWER_BOUND); m_HighBound = parser.ReadInt(section, L"HighBound", DEFAULT_UPPER_BOUND); m_UpdateRandom = parser.ReadBool(section, L"UpdateRandom", false); m_UniqueRandom = parser.ReadBool(section, L"UniqueRandom", false); if (!m_UniqueRandom) { m_UniqueNumbers.clear(); } if (!m_Initialized || wcscmp(m_Formula.c_str(), oldFormula.c_str()) != 0 || oldLowBound != m_LowBound || oldHighBound != m_HighBound || oldUpdateRandom != m_UpdateRandom || oldUniqueRandom != m_UniqueRandom) { // Reset bounds if |m_LowBound| is greater than |m_HighBound| if (m_LowBound > m_HighBound) { LogErrorF(this, L"\"LowBound\" (%i) must be less then or equal to \"HighBound\" (%i)", m_LowBound, m_HighBound); m_HighBound = m_LowBound; } // Reset the list if the bounds are changed if (m_UniqueRandom && ( oldLowBound != m_LowBound || oldHighBound != m_HighBound)) { UpdateUniqueNumberList(); } if (!m_UpdateRandom) { FormulaReplace(); } const WCHAR* errMsg = MathParser::Check(m_Formula.c_str()); if (errMsg != nullptr) { LogErrorF(this, L"Calc: %s", errMsg); m_Formula.clear(); } } }