mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Tweaks
This commit is contained in:
parent
a162451e87
commit
fd111c0657
@ -153,10 +153,10 @@ void CConfigParser::SetVariable(std::unordered_map<std::wstring, std::wstring>&
|
||||
}
|
||||
|
||||
/*
|
||||
** Gets a value for the variable. Returns true if variable found.
|
||||
** Gets a value for the variable. Returns NULL if not found.
|
||||
**
|
||||
*/
|
||||
bool CConfigParser::GetVariable(const std::wstring& strVariable, std::wstring& strValue)
|
||||
const std::wstring* CConfigParser::GetVariable(const std::wstring& strVariable)
|
||||
{
|
||||
const std::wstring strTmp = StrToUpper(strVariable);
|
||||
|
||||
@ -164,31 +164,24 @@ bool CConfigParser::GetVariable(const std::wstring& strVariable, std::wstring& s
|
||||
std::unordered_map<std::wstring, std::wstring>::const_iterator iter = m_BuiltInVariables.find(strTmp);
|
||||
if (iter != m_BuiltInVariables.end())
|
||||
{
|
||||
// Built-in variable found
|
||||
strValue = (*iter).second;
|
||||
return true;
|
||||
return &(*iter).second;
|
||||
}
|
||||
|
||||
// #2: Monitor variables
|
||||
iter = c_MonitorVariables.find(strTmp);
|
||||
if (iter != c_MonitorVariables.end())
|
||||
{
|
||||
// SCREENAREA/WORKAREA variable found
|
||||
strValue = (*iter).second;
|
||||
return true;
|
||||
return &(*iter).second;
|
||||
}
|
||||
|
||||
// #3: User-defined variables
|
||||
iter = m_Variables.find(strTmp);
|
||||
if (iter != m_Variables.end())
|
||||
{
|
||||
// Variable found
|
||||
strValue = (*iter).second;
|
||||
return true;
|
||||
return &(*iter).second;
|
||||
}
|
||||
|
||||
// Not found
|
||||
return false;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -577,13 +570,12 @@ bool CConfigParser::ReplaceVariables(std::wstring& result)
|
||||
else
|
||||
{
|
||||
std::wstring strVariable = result.substr(si, end - si);
|
||||
std::wstring strValue;
|
||||
|
||||
if (GetVariable(strVariable, strValue))
|
||||
const std::wstring* value = GetVariable(strVariable);
|
||||
if (value)
|
||||
{
|
||||
// Variable found, replace it with the value
|
||||
result.replace(start, end - start + 1, strValue);
|
||||
start += strValue.length();
|
||||
result.replace(start, end - start + 1, *value);
|
||||
start += (*value).length();
|
||||
replaced = true;
|
||||
}
|
||||
else
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
void AddMeasure(CMeasure* pMeasure);
|
||||
CMeasure* GetMeasure(const std::wstring& name);
|
||||
|
||||
bool GetVariable(const std::wstring& strVariable, std::wstring& strValue);
|
||||
const std::wstring* GetVariable(const std::wstring& strVariable);
|
||||
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); }
|
||||
|
||||
|
@ -178,9 +178,10 @@ LPCWSTR PluginBridge(LPCWSTR command, LPCWSTR data)
|
||||
{
|
||||
const std::wstring& variable = subStrings[1];
|
||||
|
||||
if (meterWindow->GetParser().GetVariable(variable, g_Buffer))
|
||||
const std::wstring* value = meterWindow->GetParser().GetVariable(variable);
|
||||
if (value)
|
||||
{
|
||||
return g_Buffer.c_str();
|
||||
return (*value).c_str();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -108,9 +108,10 @@ static int GetVariable(lua_State* L)
|
||||
CMeterWindow* self = GetSelf(L);
|
||||
std::wstring strTmp = LuaManager::ToWide(L, 2);
|
||||
|
||||
if (self->GetParser().GetVariable(strTmp, strTmp))
|
||||
const std::wstring* value = self->GetParser().GetVariable(strTmp);
|
||||
if (value)
|
||||
{
|
||||
LuaManager::PushWide(L, strTmp.c_str());
|
||||
LuaManager::PushWide(L, (*value).c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user