This commit is contained in:
Birunthan Mohanathas 2012-05-19 18:16:04 +03:00
parent f15b6723b5
commit 9453780c26
6 changed files with 25 additions and 40 deletions

View File

@ -104,7 +104,7 @@ void CConfigParser::SetBuiltInVariables(CRainmeter* pRainmeter, CMeterWindow* me
SetBuiltInVariable(L"CRLF", L"\n");
const std::wstring CURRENTSECTION = StrToLower(L"CURRENTSECTION");
const std::wstring CURRENTSECTION = L"CURRENTSECTION";
SetBuiltInVariable(CURRENTSECTION, L"");
m_CurrentSection = &((*m_BuiltInVariables.find(CURRENTSECTION)).second); // shortcut
}
@ -131,7 +131,7 @@ void CConfigParser::SetVariable(std::unordered_map<std::wstring, std::wstring>&
{
// LogWithArgs(LOG_DEBUG, L"Variable: %s=%s (size=%i)", strVariable.c_str(), strValue.c_str(), (int)variables.size());
const std::wstring strTmp = StrToLower(strVariable);
const std::wstring strTmp = StrToUpper(strVariable);
variables[strTmp] = strValue;
}
@ -139,7 +139,7 @@ void CConfigParser::SetVariable(std::unordered_map<std::wstring, std::wstring>&
{
// LogWithArgs(LOG_DEBUG, L"Variable: %s=%s (size=%i)", strVariable.c_str(), strValue.c_str(), (int)variables.size());
const std::wstring strTmp = StrToLower(strVariable);
const std::wstring strTmp = StrToUpper(strVariable);
variables[strTmp] = strValue;
}
@ -150,7 +150,7 @@ void CConfigParser::SetVariable(std::unordered_map<std::wstring, std::wstring>&
*/
bool CConfigParser::GetVariable(const std::wstring& strVariable, std::wstring& strValue)
{
const std::wstring strTmp = StrToLower(strVariable);
const std::wstring strTmp = StrToUpper(strVariable);
// #1: Built-in variables
std::unordered_map<std::wstring, std::wstring>::const_iterator iter = m_BuiltInVariables.find(strTmp);
@ -656,13 +656,13 @@ void CConfigParser::AddMeasure(CMeasure* pMeasure)
{
if (pMeasure)
{
m_Measures[StrToLower(pMeasure->GetOriginalName())] = pMeasure;
m_Measures[StrToUpper(pMeasure->GetOriginalName())] = pMeasure;
}
}
CMeasure* CConfigParser::GetMeasure(const std::wstring& name)
{
std::unordered_map<std::wstring, CMeasure*>::const_iterator iter = m_Measures.find(StrToLower(name));
std::unordered_map<std::wstring, CMeasure*>::const_iterator iter = m_Measures.find(StrToUpper(name));
if (iter != m_Measures.end())
{
return (*iter).second;
@ -1223,7 +1223,7 @@ void CConfigParser::ReadIniFile(const std::wstring& iniFile, LPCTSTR config, int
if (*pos)
{
value = pos; // section name
StrToLowerC(key.assign(value));
StrToUpperC(key.assign(value));
if (unique.insert(key).second)
{
if (m_FoundSections.insert(key).second)
@ -1294,7 +1294,7 @@ void CConfigParser::ReadIniFile(const std::wstring& iniFile, LPCTSTR config, int
{
size_t clen = sep - pos; // key's length
StrToLowerC(key.assign(pos, clen));
StrToUpperC(key.assign(pos, clen));
if (unique.insert(key).second)
{
++sep;
@ -1364,7 +1364,7 @@ void CConfigParser::SetValue(const std::wstring& strSection, const std::wstring&
strTmp += L'~';
strTmp += strKey;
m_Values[StrToLowerC(strTmp)] = strValue;
m_Values[StrToUpperC(strTmp)] = strValue;
}
/*
@ -1379,7 +1379,7 @@ void CConfigParser::DeleteValue(const std::wstring& strSection, const std::wstri
strTmp += L'~';
strTmp += strKey;
std::unordered_map<std::wstring, std::wstring>::const_iterator iter = m_Values.find(StrToLowerC(strTmp));
std::unordered_map<std::wstring, std::wstring>::const_iterator iter = m_Values.find(StrToUpperC(strTmp));
if (iter != m_Values.end())
{
m_Values.erase(iter);
@ -1398,6 +1398,6 @@ const std::wstring& CConfigParser::GetValue(const std::wstring& strSection, cons
strTmp += L'~';
strTmp += strKey;
std::unordered_map<std::wstring, std::wstring>::const_iterator iter = m_Values.find(StrToLowerC(strTmp));
std::unordered_map<std::wstring, std::wstring>::const_iterator iter = m_Values.find(StrToUpperC(strTmp));
return (iter != m_Values.end()) ? (*iter).second : strDefault;
}

View File

@ -46,7 +46,6 @@ public:
bool GetVariable(const std::wstring& strVariable, std::wstring& 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 WCHAR* strVariable, const WCHAR* strValue) { SetVariable(m_BuiltInVariables, strVariable, strValue); }
const std::unordered_map<std::wstring, std::wstring>& GetVariables() { return m_Variables; }
@ -119,9 +118,9 @@ private:
static void SetMonitorVariable(const std::wstring& strVariable, const std::wstring& strValue) { SetVariable(c_MonitorVariables, strVariable, strValue); }
static void SetMonitorVariable(const WCHAR* strVariable, const WCHAR* strValue) { SetVariable(c_MonitorVariables, strVariable, strValue); }
static std::wstring StrToLower(const std::wstring& str) { std::wstring strTmp(str); StrToLowerC(strTmp); return strTmp; }
static std::wstring StrToLower(const WCHAR* str) { std::wstring strTmp(str); StrToLowerC(strTmp); return strTmp; }
static std::wstring& StrToLowerC(std::wstring& str) { _wcslwr(&str[0]); return str; }
static std::wstring StrToUpper(const std::wstring& str) { std::wstring strTmp(str); StrToUpperC(strTmp); return strTmp; }
static std::wstring StrToUpper(const WCHAR* str) { std::wstring strTmp(str); StrToUpperC(strTmp); return strTmp; }
static std::wstring& StrToUpperC(std::wstring& str) { _wcsupr(&str[0]); return str; }
std::wstring m_Filename;

View File

@ -59,8 +59,7 @@ std::wstring CGroup::CreateGroup(const std::wstring& str)
// Trim white-space
strTmp.assign(str, pos, str.find_last_not_of(L" \t\r\n") - pos + 1);
// Convert to lower
_wcslwr(&strTmp[0]);
_wcsupr(&strTmp[0]);
}
return strTmp;

View File

@ -765,7 +765,7 @@ void CMeterString::FreeFontCache(PrivateFontCollection* collection)
size_t len = _snwprintf_s(buffer, _TRUNCATE, L"<%p>", collection);
prefix.assign(buffer, len);
StringToLower(prefix);
_wcsupr(&prefix[0]);
}
std::unordered_map<std::wstring, Gdiplus::Font*>::iterator iter2 = c_Fonts.begin();
@ -818,7 +818,7 @@ std::wstring CMeterString::FontFaceToString(const std::wstring& fontFace, Privat
strTmp.reserve(len + fontFace.size());
strTmp.assign(buffer, len);
strTmp += fontFace;
StringToLower(strTmp);
_wcsupr(&strTmp[0]);
return strTmp;
}

View File

@ -2070,9 +2070,8 @@ bool CMeterWindow::ReadSkin()
}
}
// Checking for localfonts
// Load local fonts
const WCHAR* localFont = m_Parser.ReadString(L"Rainmeter", L"LocalFont", L"").c_str();
// If there is a local font we want to load it
if (*localFont)
{
m_FontCollection = new PrivateFontCollection();
@ -2080,26 +2079,15 @@ bool CMeterWindow::ReadSkin()
do
{
// We want to check the fonts folder first
// !!!!!!! - We may want to fix the method in which I get the path to
// Rainmeter/fonts
// Try program folder first
std::wstring szFontFile = Rainmeter->GetPath() + L"Fonts\\";
szFontFile += localFont;
Status nResults = m_FontCollection->AddFontFile(szFontFile.c_str());
// It wasn't found in the fonts folder, check the local folder
if (nResults != Ok)
{
szFontFile = Rainmeter->GetSkinPath(); // Get the local path
szFontFile += m_SkinName;
szFontFile += L'\\';
szFontFile += localFont;
nResults = m_FontCollection->AddFontFile(szFontFile.c_str());
// The font wasn't found, check full path.
if (nResults != Ok)
{
szFontFile = localFont;
MakePathAbsolute(szFontFile);
nResults = m_FontCollection->AddFontFile(szFontFile.c_str());
if (nResults != Ok)
@ -2109,7 +2097,6 @@ bool CMeterWindow::ReadSkin()
Log(LOG_ERROR, error.c_str());
}
}
}
// Here we are checking to see if there are more than one local font
// to be loaded. They will be named LocalFont2, LocalFont3, etc.

View File

@ -42,7 +42,7 @@ public:
{
key = name;
}
_wcslwr(&key[0]);
_wcsupr(&key[0]);
size_t len = _snwprintf_s(buffer, _TRUNCATE, L":%llx:%x", time, size);
key.append(buffer, len);