/* ** Read the common options specified in the ini file. The inherited classes must ** call this base implementation if they overwrite this method. ** */ void Measure::ReadOptions(ConfigParser& parser, const WCHAR* section) { bool oldOnChangeActionEmpty = m_OnChangeAction.empty(); Section::ReadOptions(parser, section); // Clear substitutes to prevent from being added more than once. if (!m_Substitute.empty()) { m_Substitute.clear(); } m_Invert = parser.ReadBool(section, L"InvertMeasure", false); m_Disabled = parser.ReadBool(section, L"Disabled", false); m_Paused = parser.ReadBool(section, L"Paused", false); m_MinValue = parser.ReadFloat(section, L"MinValue", m_MinValue); m_MaxValue = parser.ReadFloat(section, L"MaxValue", m_MaxValue); // The ifabove/ifbelow define actions that are ran when the value goes above/below the given number. m_IfAboveValue = parser.ReadFloat(section, L"IfAboveValue", 0.0); m_IfAboveAction = parser.ReadString(section, L"IfAboveAction", L"", false); m_IfBelowValue = parser.ReadFloat(section, L"IfBelowValue", 0.0); m_IfBelowAction = parser.ReadString(section, L"IfBelowAction", L"", false); m_IfEqualValue = (int64_t)parser.ReadFloat(section, L"IfEqualValue", 0.0); m_IfEqualAction = parser.ReadString(section, L"IfEqualAction", L"", false); m_OnChangeAction = parser.ReadString(section, L"OnChangeAction", L"", false); m_AverageSize = parser.ReadUInt(section, L"AverageSize", 0); m_RegExpSubstitute = parser.ReadBool(section, L"RegExpSubstitute", false); std::wstring subs = parser.ReadString(section, L"Substitute", L""); if (!subs.empty()) { if ((subs[0] != L'"' || subs[subs.length() - 1] != L'\'') && (subs[0] != L'\'' || subs[subs.length() - 1] != L'"')) { // Add quotes since they are removed by the GetProfileString subs.insert(0, 1, L'"'); subs += L'"'; } if (!ParseSubstitute(subs)) { LogErrorF(this, L"Measure: Invalid Substitute=%s", subs.c_str()); } } if (m_Initialized && oldOnChangeActionEmpty && !m_OnChangeAction.empty()) { DoChangeAction(false); } }
/* ** Read the common options specified in the ini file. The inherited classes must ** call this base implementation if they overwrite this method. ** */ void Measure::ReadOptions(ConfigParser& parser, const WCHAR* section) { bool oldOnChangeActionEmpty = m_OnChangeAction.empty(); Section::ReadOptions(parser, section); // Clear substitutes to prevent from being added more than once. if (!m_Substitute.empty()) { m_Substitute.clear(); } m_Invert = parser.ReadBool(section, L"InvertMeasure", false); m_Disabled = parser.ReadBool(section, L"Disabled", false); m_Paused = parser.ReadBool(section, L"Paused", false); m_MinValue = parser.ReadFloat(section, L"MinValue", m_MinValue); m_MaxValue = parser.ReadFloat(section, L"MaxValue", m_MaxValue); m_IfActions.ReadOptions(parser, section); // The first time around, we read the conditions here. Subsequent rereads will be done in // Update() if needed. if (!m_Initialized) { m_IfActions.ReadConditionOptions(parser, section); } m_OnChangeAction = parser.ReadString(section, L"OnChangeAction", L"", false); m_AverageSize = parser.ReadUInt(section, L"AverageSize", 0); m_RegExpSubstitute = parser.ReadBool(section, L"RegExpSubstitute", false); std::wstring subs = parser.ReadString(section, L"Substitute", L""); if (!subs.empty()) { if ((subs[0] != L'"' || subs[subs.length() - 1] != L'\'') && (subs[0] != L'\'' || subs[subs.length() - 1] != L'"')) { // Add quotes since they are removed by the GetProfileString subs.insert(0, 1, L'"'); subs += L'"'; } if (!ParseSubstitute(subs)) { LogErrorF(this, L"Measure: Invalid Substitute=%s", subs.c_str()); } } if (m_Initialized && oldOnChangeActionEmpty && !m_OnChangeAction.empty()) { DoChangeAction(false); } }