This commit is contained in:
Birunthan Mohanathas 2012-07-17 21:26:55 +03:00
parent 2f543e5dcb
commit 4dc5fe0b31
2 changed files with 14 additions and 19 deletions

View File

@ -60,7 +60,6 @@ void CConfigParser::Initialize(const std::wstring& filename, CMeterWindow* meter
m_Variables.clear(); m_Variables.clear();
m_StyleTemplate.clear(); m_StyleTemplate.clear();
m_LastUsedStyle.clear();
m_LastReplaced = false; m_LastReplaced = false;
m_LastDefaultUsed = false; m_LastDefaultUsed = false;
m_LastValueDefined = false; m_LastValueDefined = false;
@ -568,7 +567,6 @@ const std::wstring& CConfigParser::ReadString(LPCTSTR section, LPCTSTR key, LPCT
static std::wstring result; static std::wstring result;
// Clear last status // Clear last status
m_LastUsedStyle.clear();
m_LastReplaced = false; m_LastReplaced = false;
m_LastDefaultUsed = false; m_LastDefaultUsed = false;
m_LastValueDefined = false; m_LastValueDefined = false;
@ -580,27 +578,26 @@ const std::wstring& CConfigParser::ReadString(LPCTSTR section, LPCTSTR key, LPCT
const std::wstring& strValue = GetValue(strSection, strKey, strDefault); const std::wstring& strValue = GetValue(strSection, strKey, strDefault);
if (&strValue == &strDefault) if (&strValue == &strDefault)
{ {
bool foundStyleValue = false;
// If the template is defined read the value from there. // If the template is defined read the value from there.
if (!m_StyleTemplate.empty()) std::vector<std::wstring>::const_reverse_iterator iter = m_StyleTemplate.rbegin();
for ( ; iter != m_StyleTemplate.rend(); ++iter)
{ {
std::vector<std::wstring>::const_reverse_iterator iter = m_StyleTemplate.rbegin(); const std::wstring& strStyleValue = GetValue((*iter), strKey, strDefault);
for ( ; iter != m_StyleTemplate.rend(); ++iter)
//LogWithArgs(LOG_DEBUG, L"StyleTemplate: [%s] %s (from [%s]) : strDefault=%s (0x%p), strStyleValue=%s (0x%p)",
// section, key, (*iter).c_str(), strDefault.c_str(), &strDefault, strStyleValue.c_str(), &strStyleValue);
if (&strStyleValue != &strDefault)
{ {
const std::wstring& strStyleValue = GetValue((*iter), strKey, strDefault); result = strStyleValue;
foundStyleValue = true;
//LogWithArgs(LOG_DEBUG, L"StyleTemplate: [%s] %s (from [%s]) : strDefault=%s (0x%p), strStyleValue=%s (0x%p)", break;
// section, key, (*iter).c_str(), strDefault.c_str(), &strDefault, strStyleValue.c_str(), &strStyleValue);
if (&strStyleValue != &strDefault)
{
result = strStyleValue;
m_LastUsedStyle = (*iter);
break;
}
} }
} }
if (m_LastUsedStyle.empty()) // No template found if (!foundStyleValue)
{ {
result = strDefault; result = strDefault;
m_LastDefaultUsed = true; m_LastDefaultUsed = true;

View File

@ -61,7 +61,6 @@ public:
void SetStyleTemplate(const std::wstring& strStyle) { static const std::wstring delim(1, L'|'); Tokenize(strStyle, delim).swap(m_StyleTemplate); Shrink(m_StyleTemplate); } void SetStyleTemplate(const std::wstring& strStyle) { static const std::wstring delim(1, L'|'); Tokenize(strStyle, delim).swap(m_StyleTemplate); Shrink(m_StyleTemplate); }
void ClearStyleTemplate() { m_StyleTemplate.clear(); } void ClearStyleTemplate() { m_StyleTemplate.clear(); }
const std::wstring& GetLastUsedStyle() { return m_LastUsedStyle; }
bool GetLastReplaced() { return m_LastReplaced; } bool GetLastReplaced() { return m_LastReplaced; }
bool GetLastDefaultUsed() { return m_LastDefaultUsed; } bool GetLastDefaultUsed() { return m_LastDefaultUsed; }
bool GetLastKeyDefined() { return !m_LastDefaultUsed; } bool GetLastKeyDefined() { return !m_LastDefaultUsed; }
@ -125,7 +124,6 @@ private:
std::vector<std::wstring> m_StyleTemplate; std::vector<std::wstring> m_StyleTemplate;
std::wstring m_LastUsedStyle;
bool m_LastReplaced; bool m_LastReplaced;
bool m_LastDefaultUsed; bool m_LastDefaultUsed;
bool m_LastValueDefined; bool m_LastValueDefined;