mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Code cleanup.
This commit is contained in:
parent
ccd8321e62
commit
3569412464
@ -26,7 +26,7 @@ extern CRainmeter* Rainmeter;
|
|||||||
|
|
||||||
using namespace Gdiplus;
|
using namespace Gdiplus;
|
||||||
|
|
||||||
std::map<std::wstring, std::wstring> CConfigParser::c_MonitorVariables;
|
stdext::hash_map<std::wstring, std::wstring> CConfigParser::c_MonitorVariables;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** CConfigParser
|
** CConfigParser
|
||||||
@ -143,13 +143,11 @@ void CConfigParser::ReadVariables()
|
|||||||
** \param strVariable
|
** \param strVariable
|
||||||
** \param strValue
|
** \param strValue
|
||||||
*/
|
*/
|
||||||
void CConfigParser::SetVariable(std::map<std::wstring, std::wstring>& variables, const std::wstring& strVariable, const std::wstring& strValue)
|
void CConfigParser::SetVariable(stdext::hash_map<std::wstring, std::wstring>& variables, const std::wstring& strVariable, const std::wstring& strValue)
|
||||||
{
|
{
|
||||||
// LogWithArgs(LOG_DEBUG, L"Variable: %s=%s (size=%i)", strVariable.c_str(), strValue.c_str(), (int)m_Variables.size());
|
// LogWithArgs(LOG_DEBUG, L"Variable: %s=%s (size=%i)", strVariable.c_str(), strValue.c_str(), (int)variables.size());
|
||||||
|
|
||||||
std::wstring strTmp(strVariable);
|
variables[StrToLower(strVariable)] = strValue;
|
||||||
std::transform(strTmp.begin(), strTmp.end(), strTmp.begin(), ::towlower);
|
|
||||||
variables[strTmp] = strValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -161,11 +159,10 @@ void CConfigParser::SetVariable(std::map<std::wstring, std::wstring>& variables,
|
|||||||
*/
|
*/
|
||||||
bool CConfigParser::GetVariable(const std::wstring& strVariable, std::wstring& strValue)
|
bool CConfigParser::GetVariable(const std::wstring& strVariable, std::wstring& strValue)
|
||||||
{
|
{
|
||||||
std::wstring strTmp(strVariable);
|
std::wstring strTmp = StrToLower(strVariable);
|
||||||
std::transform(strTmp.begin(), strTmp.end(), strTmp.begin(), ::towlower);
|
|
||||||
|
|
||||||
// #1: Built-in variables
|
// #1: Built-in variables
|
||||||
std::map<std::wstring, std::wstring>::const_iterator iter = m_BuiltInVariables.find(strTmp);
|
stdext::hash_map<std::wstring, std::wstring>::const_iterator iter = m_BuiltInVariables.find(strTmp);
|
||||||
if (iter != m_BuiltInVariables.end())
|
if (iter != m_BuiltInVariables.end())
|
||||||
{
|
{
|
||||||
// Built-in variable found
|
// Built-in variable found
|
||||||
@ -692,19 +689,16 @@ void CConfigParser::AddMeasure(CMeasure* pMeasure)
|
|||||||
{
|
{
|
||||||
if (pMeasure)
|
if (pMeasure)
|
||||||
{
|
{
|
||||||
m_Measures[pMeasure->GetName()] = pMeasure;
|
m_Measures[StrToLower(pMeasure->GetName())] = pMeasure;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CMeasure* CConfigParser::GetMeasure(const std::wstring& name)
|
CMeasure* CConfigParser::GetMeasure(const std::wstring& name)
|
||||||
{
|
{
|
||||||
std::map<std::wstring, CMeasure*>::const_iterator iter = m_Measures.begin();
|
std::map<std::wstring, CMeasure*>::const_iterator iter = m_Measures.find(StrToLower(name));
|
||||||
for ( ; iter != m_Measures.end(); ++iter)
|
if (iter != m_Measures.end())
|
||||||
{
|
{
|
||||||
if (_wcsicmp((*iter).first.c_str(), name.c_str()) == 0)
|
return (*iter).second;
|
||||||
{
|
|
||||||
return (*iter).second;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -1094,8 +1088,7 @@ void CConfigParser::ReadIniFile(const std::vector<std::wstring>& iniFileMappings
|
|||||||
{
|
{
|
||||||
if (*pos)
|
if (*pos)
|
||||||
{
|
{
|
||||||
std::wstring strTmp(pos);
|
std::wstring strTmp = StrToLower(pos);
|
||||||
std::transform(strTmp.begin(), strTmp.end(), strTmp.begin(), ::towlower);
|
|
||||||
if (m_Keys.find(strTmp) == m_Keys.end())
|
if (m_Keys.find(strTmp) == m_Keys.end())
|
||||||
{
|
{
|
||||||
m_Keys[strTmp] = std::vector<std::wstring>();
|
m_Keys[strTmp] = std::vector<std::wstring>();
|
||||||
@ -1193,10 +1186,8 @@ void CConfigParser::SetValue(const std::wstring& strSection, const std::wstring&
|
|||||||
{
|
{
|
||||||
// LogWithArgs(LOG_DEBUG, L"[%s] %s=%s (size: %i)", strSection.c_str(), strKey.c_str(), strValue.c_str(), (int)m_Values.size());
|
// LogWithArgs(LOG_DEBUG, L"[%s] %s=%s (size: %i)", strSection.c_str(), strKey.c_str(), strValue.c_str(), (int)m_Values.size());
|
||||||
|
|
||||||
std::wstring strTmpSection(strSection);
|
std::wstring strTmpSection = StrToLower(strSection);
|
||||||
std::wstring strTmpKey(strKey);
|
std::wstring strTmpKey = StrToLower(strKey);
|
||||||
std::transform(strTmpSection.begin(), strTmpSection.end(), strTmpSection.begin(), ::towlower);
|
|
||||||
std::transform(strTmpKey.begin(), strTmpKey.end(), strTmpKey.begin(), ::towlower);
|
|
||||||
|
|
||||||
stdext::hash_map<std::wstring, std::vector<std::wstring> >::iterator iter = m_Keys.find(strTmpSection);
|
stdext::hash_map<std::wstring, std::vector<std::wstring> >::iterator iter = m_Keys.find(strTmpSection);
|
||||||
if (iter != m_Keys.end())
|
if (iter != m_Keys.end())
|
||||||
@ -1221,11 +1212,10 @@ void CConfigParser::SetValue(const std::wstring& strSection, const std::wstring&
|
|||||||
*/
|
*/
|
||||||
const std::wstring& CConfigParser::GetValue(const std::wstring& strSection, const std::wstring& strKey, const std::wstring& strDefault)
|
const std::wstring& CConfigParser::GetValue(const std::wstring& strSection, const std::wstring& strKey, const std::wstring& strDefault)
|
||||||
{
|
{
|
||||||
std::wstring strTmp(strSection + L"::");
|
std::wstring strTmp = strSection + L"::";
|
||||||
strTmp += strKey;
|
strTmp += strKey;
|
||||||
std::transform(strTmp.begin(), strTmp.end(), strTmp.begin(), ::towlower);
|
|
||||||
|
|
||||||
stdext::hash_map<std::wstring, std::wstring>::const_iterator iter = m_Values.find(strTmp);
|
stdext::hash_map<std::wstring, std::wstring>::const_iterator iter = m_Values.find(StrToLower(strTmp));
|
||||||
if (iter != m_Values.end())
|
if (iter != m_Values.end())
|
||||||
{
|
{
|
||||||
return (*iter).second;
|
return (*iter).second;
|
||||||
@ -1254,10 +1244,7 @@ const std::vector<std::wstring>& CConfigParser::GetSections()
|
|||||||
*/
|
*/
|
||||||
std::vector<std::wstring> CConfigParser::GetKeys(const std::wstring& strSection)
|
std::vector<std::wstring> CConfigParser::GetKeys(const std::wstring& strSection)
|
||||||
{
|
{
|
||||||
std::wstring strTmp(strSection);
|
stdext::hash_map<std::wstring, std::vector<std::wstring> >::const_iterator iter = m_Keys.find(StrToLower(strSection));
|
||||||
std::transform(strTmp.begin(), strTmp.end(), strTmp.begin(), ::towlower);
|
|
||||||
|
|
||||||
stdext::hash_map<std::wstring, std::vector<std::wstring> >::const_iterator iter = m_Keys.find(strTmp);
|
|
||||||
if (iter != m_Keys.end())
|
if (iter != m_Keys.end())
|
||||||
{
|
{
|
||||||
return (*iter).second;
|
return (*iter).second;
|
||||||
|
@ -26,8 +26,10 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <hash_map>
|
#include <hash_map>
|
||||||
|
#include <algorithm>
|
||||||
#include <gdiplus.h>
|
#include <gdiplus.h>
|
||||||
#include "ccalc-0.5.1/mparser.h"
|
#include "ccalc-0.5.1/mparser.h"
|
||||||
|
#include "Litestep.h"
|
||||||
|
|
||||||
class CRainmeter;
|
class CRainmeter;
|
||||||
class CMeterWindow;
|
class CMeterWindow;
|
||||||
@ -44,6 +46,7 @@ public:
|
|||||||
|
|
||||||
void SetVariable(const std::wstring& strVariable, const std::wstring& strValue) { SetVariable(m_Variables, strVariable, strValue); }
|
void SetVariable(const std::wstring& strVariable, const std::wstring& strValue) { SetVariable(m_Variables, strVariable, strValue); }
|
||||||
void SetBuiltInVariable(const std::wstring& strVariable, const std::wstring& strValue) { SetVariable(m_BuiltInVariables, strVariable, strValue); }
|
void SetBuiltInVariable(const std::wstring& strVariable, const std::wstring& strValue) { SetVariable(m_BuiltInVariables, strVariable, strValue); }
|
||||||
|
bool GetVariable(const std::wstring& strVariable, std::wstring& strValue);
|
||||||
|
|
||||||
void SetStyleTemplate(const std::wstring& strStyle) { m_StyleTemplate = Tokenize(strStyle, L"|"); }
|
void SetStyleTemplate(const std::wstring& strStyle) { m_StyleTemplate = Tokenize(strStyle, L"|"); }
|
||||||
void ClearStyleTemplate() { m_StyleTemplate.clear(); }
|
void ClearStyleTemplate() { m_StyleTemplate.clear(); }
|
||||||
@ -83,11 +86,6 @@ public:
|
|||||||
static void ClearMultiMonitorVariables() { c_MonitorVariables.clear(); }
|
static void ClearMultiMonitorVariables() { c_MonitorVariables.clear(); }
|
||||||
static void UpdateWorkareaVariables() { SetMultiMonitorVariables(false); }
|
static void UpdateWorkareaVariables() { SetMultiMonitorVariables(false); }
|
||||||
|
|
||||||
// Updated by Peter Souza IV / psouza4 / 2010.12.13
|
|
||||||
//
|
|
||||||
// Made this public so the plugin bridge can read variables directly
|
|
||||||
bool GetVariable(const std::wstring& strVariable, std::wstring& strValue);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SetBuiltInVariables(CRainmeter* pRainmeter, CMeterWindow* meterWindow);
|
void SetBuiltInVariables(CRainmeter* pRainmeter, CMeterWindow* meterWindow);
|
||||||
|
|
||||||
@ -102,11 +100,13 @@ private:
|
|||||||
|
|
||||||
void SetAutoSelectedMonitorVariables(CMeterWindow* meterWindow);
|
void SetAutoSelectedMonitorVariables(CMeterWindow* meterWindow);
|
||||||
|
|
||||||
static void SetVariable(std::map<std::wstring, std::wstring>& variables, const std::wstring& strVariable, const std::wstring& strValue);
|
static void SetVariable(stdext::hash_map<std::wstring, std::wstring>& variables, const std::wstring& strVariable, const std::wstring& strValue);
|
||||||
|
|
||||||
static void SetMultiMonitorVariables(bool reset);
|
static void SetMultiMonitorVariables(bool reset);
|
||||||
static void SetMonitorVariable(const std::wstring& strVariable, const std::wstring& strValue) { SetVariable(c_MonitorVariables, strVariable, strValue); }
|
static void SetMonitorVariable(const std::wstring& strVariable, const std::wstring& strValue) { SetVariable(c_MonitorVariables, strVariable, strValue); }
|
||||||
|
|
||||||
|
static std::wstring StrToLower(const std::wstring& str) { std::wstring strTmp(str); std::transform(strTmp.begin(), strTmp.end(), strTmp.begin(), ::towlower); return strTmp; }
|
||||||
|
|
||||||
std::wstring m_Filename;
|
std::wstring m_Filename;
|
||||||
|
|
||||||
hqMathParser* m_Parser;
|
hqMathParser* m_Parser;
|
||||||
@ -122,10 +122,10 @@ private:
|
|||||||
stdext::hash_map<std::wstring, std::vector<std::wstring> > m_Keys;
|
stdext::hash_map<std::wstring, std::vector<std::wstring> > m_Keys;
|
||||||
stdext::hash_map<std::wstring, std::wstring> m_Values;
|
stdext::hash_map<std::wstring, std::wstring> m_Values;
|
||||||
|
|
||||||
std::map<std::wstring, std::wstring> m_BuiltInVariables; // Built-in variables
|
stdext::hash_map<std::wstring, std::wstring> m_BuiltInVariables; // Built-in variables
|
||||||
std::map<std::wstring, std::wstring> m_Variables; // User-defined variables
|
stdext::hash_map<std::wstring, std::wstring> m_Variables; // User-defined variables
|
||||||
|
|
||||||
static std::map<std::wstring, std::wstring> c_MonitorVariables; // Monitor variables
|
static stdext::hash_map<std::wstring, std::wstring> c_MonitorVariables; // Monitor variables
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -718,7 +718,7 @@ void CMeterString::FreeFontCache(PrivateFontCollection* collection)
|
|||||||
WCHAR buffer[32];
|
WCHAR buffer[32];
|
||||||
_snwprintf_s(buffer, _TRUNCATE, L"<%p>", collection);
|
_snwprintf_s(buffer, _TRUNCATE, L"<%p>", collection);
|
||||||
prefix = buffer;
|
prefix = buffer;
|
||||||
std::transform(prefix.begin(), prefix.end(), prefix.begin(), ::towlower);
|
StringToLower(prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<std::wstring, Gdiplus::Font*>::iterator iter2 = c_Fonts.begin();
|
std::map<std::wstring, Gdiplus::Font*>::iterator iter2 = c_Fonts.begin();
|
||||||
@ -757,7 +757,7 @@ std::wstring CMeterString::FontFaceToString(const std::wstring& fontFace, Privat
|
|||||||
WCHAR buffer[32];
|
WCHAR buffer[32];
|
||||||
_snwprintf_s(buffer, _TRUNCATE, L"<%p>", collection);
|
_snwprintf_s(buffer, _TRUNCATE, L"<%p>", collection);
|
||||||
std::wstring strTmp = buffer + fontFace;
|
std::wstring strTmp = buffer + fontFace;
|
||||||
std::transform(strTmp.begin(), strTmp.end(), strTmp.begin(), ::towlower);
|
StringToLower(strTmp);
|
||||||
return strTmp;
|
return strTmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user