mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
- Switched from size()>0 to empty().
- Code cleanup.
This commit is contained in:
parent
f2f97743ef
commit
569a151c6c
@ -599,7 +599,7 @@ const std::wstring& CConfigParser::ReadString(LPCTSTR section, LPCTSTR key, LPCT
|
||||
if (&strValue == &strDefault)
|
||||
{
|
||||
// If the template is defined read the value from there.
|
||||
if (m_StyleTemplate.size() > 0)
|
||||
if (!m_StyleTemplate.empty())
|
||||
{
|
||||
std::vector<std::wstring>::const_reverse_iterator iter = m_StyleTemplate.rbegin();
|
||||
for ( ; iter != m_StyleTemplate.rend(); ++iter)
|
||||
@ -618,7 +618,7 @@ const std::wstring& CConfigParser::ReadString(LPCTSTR section, LPCTSTR key, LPCT
|
||||
}
|
||||
}
|
||||
|
||||
if (m_LastUsedStyle.size() == 0) // No template found
|
||||
if (m_LastUsedStyle.empty()) // No template found
|
||||
{
|
||||
result = strDefault;
|
||||
m_LastDefaultUsed = true;
|
||||
@ -630,7 +630,7 @@ const std::wstring& CConfigParser::ReadString(LPCTSTR section, LPCTSTR key, LPCT
|
||||
result = strValue;
|
||||
}
|
||||
|
||||
if (result.size() > 0)
|
||||
if (!result.empty())
|
||||
{
|
||||
m_LastValueDefined = true;
|
||||
|
||||
@ -662,7 +662,7 @@ bool CConfigParser::IsKeyDefined(LPCTSTR section, LPCTSTR key)
|
||||
bool CConfigParser::IsValueDefined(LPCTSTR section, LPCTSTR key)
|
||||
{
|
||||
const std::wstring& result = ReadString(section, key, L"", false);
|
||||
return (!m_LastDefaultUsed && result.size() > 0);
|
||||
return (!m_LastDefaultUsed && !result.empty());
|
||||
}
|
||||
|
||||
void CConfigParser::AddMeasure(CMeasure* pMeasure)
|
||||
@ -695,7 +695,7 @@ std::vector<Gdiplus::REAL> CConfigParser::ReadFloats(LPCTSTR section, LPCTSTR ke
|
||||
{
|
||||
std::vector<Gdiplus::REAL> result;
|
||||
const std::wstring& string = ReadString(section, key, L"");
|
||||
if (string.size() > 0)
|
||||
if (!string.empty())
|
||||
{
|
||||
std::wstring tmp = string;
|
||||
if (tmp[tmp.length() - 1] != L';')
|
||||
@ -734,7 +734,7 @@ double CConfigParser::ReadFormula(LPCTSTR section, LPCTSTR key, double defValue)
|
||||
const std::wstring& result = ReadString(section, key, L"");
|
||||
|
||||
// Formulas must be surrounded by parenthesis
|
||||
if (result.size() > 0 && result[0] == L'(' && result[result.size() - 1] == L')')
|
||||
if (!result.empty() && result[0] == L'(' && result[result.size() - 1] == L')')
|
||||
{
|
||||
double resultValue = defValue;
|
||||
char* errMsg = MathParser_Parse(m_Parser, ConvertToAscii(result.c_str()).c_str(), &resultValue);
|
||||
@ -761,7 +761,7 @@ double CConfigParser::ReadFormula(LPCTSTR section, LPCTSTR key, double defValue)
|
||||
bool CConfigParser::ReadFormula(const std::wstring& result, double* resultValue)
|
||||
{
|
||||
// Formulas must be surrounded by parenthesis
|
||||
if (result.size() > 0 && result[0] == L'(' && result[result.size() - 1] == L')')
|
||||
if (!result.empty() && result[0] == L'(' && result[result.size() - 1] == L')')
|
||||
{
|
||||
char* errMsg = MathParser_Parse(m_Parser, ConvertToAscii(result.c_str()).c_str(), resultValue);
|
||||
if (errMsg != NULL)
|
||||
@ -833,7 +833,7 @@ std::vector<std::wstring> CConfigParser::Tokenize(const std::wstring& str, const
|
||||
*/
|
||||
void CConfigParser::Shrink(std::vector<std::wstring>& vec)
|
||||
{
|
||||
if (vec.size() > 0)
|
||||
if (!vec.empty())
|
||||
{
|
||||
std::vector<std::wstring>::iterator iter = vec.begin();
|
||||
while (iter != vec.end())
|
||||
@ -1059,7 +1059,7 @@ void CConfigParser::ReadIniFile(const std::vector<std::wstring>& iniFileMappings
|
||||
|
||||
// Avoid "IniFileMapping"
|
||||
std::wstring iniRead = CSystem::GetTemporaryFile(iniFileMappings, iniFile);
|
||||
bool temporary = (iniRead.size() > 0 && iniRead != L"<>");
|
||||
bool temporary = (!iniRead.empty() && (iniRead.size() != 1 || iniRead[0] != L'?'));
|
||||
|
||||
if (temporary)
|
||||
{
|
||||
|
@ -27,12 +27,12 @@
|
||||
*/
|
||||
void CGroup::InitializeGroup(const std::wstring& groups)
|
||||
{
|
||||
if (groups != m_OldGroups)
|
||||
if (wcscmp(groups.c_str(), m_OldGroups.c_str()) != 0)
|
||||
{
|
||||
m_OldGroups = groups;
|
||||
m_Groups.clear();
|
||||
|
||||
if (groups.size() > 0)
|
||||
if (!groups.empty())
|
||||
{
|
||||
std::vector<std::wstring> vGroups = CConfigParser::Tokenize(groups, L"|");
|
||||
|
||||
@ -40,7 +40,7 @@ void CGroup::InitializeGroup(const std::wstring& groups)
|
||||
for ( ; iter != vGroups.end(); ++iter)
|
||||
{
|
||||
std::wstring group = CreateGroup(*iter);
|
||||
if (group.size() > 0)
|
||||
if (!group.empty())
|
||||
{
|
||||
m_Groups.insert(group);
|
||||
}
|
||||
|
@ -349,16 +349,16 @@ bool CMeasure::ParseSubstitute(std::wstring buffer)
|
||||
{
|
||||
std::wstring word1 = ExtractWord(buffer);
|
||||
std::wstring sep = ExtractWord(buffer);
|
||||
if (sep != L":") return false;
|
||||
if (sep.size() != 1 || sep[0] != L':') return false;
|
||||
std::wstring word2 = ExtractWord(buffer);
|
||||
|
||||
if (word1 != word2)
|
||||
if (wcscmp(word1.c_str(), word2.c_str()) != 0)
|
||||
{
|
||||
m_Substitute.push_back(std::pair<std::wstring, std::wstring>(word1, word2));
|
||||
}
|
||||
|
||||
sep = ExtractWord(buffer);
|
||||
if (!sep.empty() && sep != L",") return false;
|
||||
std::wstring sep2 = ExtractWord(buffer);
|
||||
if (!sep2.empty() && (sep2.size() != 1 || sep2[0] != L',')) return false;
|
||||
}
|
||||
while (!buffer.empty());
|
||||
|
||||
@ -374,12 +374,10 @@ bool CMeasure::ParseSubstitute(std::wstring buffer)
|
||||
*/
|
||||
std::wstring CMeasure::ExtractWord(std::wstring& buffer)
|
||||
{
|
||||
std::wstring::size_type end, len;
|
||||
std::wstring::size_type end, len = buffer.size();
|
||||
std::wstring ret;
|
||||
|
||||
if (buffer.empty()) return ret;
|
||||
|
||||
len = buffer.size();
|
||||
if (len == 0) return ret;
|
||||
|
||||
// Remove whitespaces
|
||||
end = 0;
|
||||
|
@ -113,7 +113,7 @@ bool CMeasureTime::Update()
|
||||
|
||||
m_Time.QuadPart += m_DeltaTime.QuadPart;
|
||||
|
||||
if (m_Format.size() > 0)
|
||||
if (!m_Format.empty())
|
||||
{
|
||||
// If there is some date format, parse the value from it instead
|
||||
WCHAR* tmpSz = new WCHAR[MAX_LINE_LENGTH];
|
||||
@ -195,7 +195,7 @@ const WCHAR* CMeasureTime::GetStringValue(AUTOSCALE autoScale, double scale, int
|
||||
today.tm_year = sysToday.wYear - 1900;
|
||||
|
||||
// Create the string
|
||||
if (m_Format.size() > 0)
|
||||
if (!m_Format.empty())
|
||||
{
|
||||
if (_wcsicmp(L"locale-time", m_Format.c_str()) == 0)
|
||||
{
|
||||
|
@ -2563,17 +2563,14 @@ bool CMeterWindow::ResizeWindow(bool reset)
|
||||
|
||||
SetWindowSizeVariables(m_WindowW, m_WindowH);
|
||||
|
||||
// If Background is not set, take a copy from the desktop
|
||||
if (m_Background == NULL)
|
||||
{
|
||||
if (m_BackgroundMode == BGMODE_COPY)
|
||||
{
|
||||
if (!m_NativeTransparency)
|
||||
{
|
||||
// If Background is not set, take a copy from the desktop
|
||||
if (m_Background == NULL && m_BackgroundMode == BGMODE_COPY)
|
||||
{
|
||||
m_Background = GrabDesktop(m_ScreenX, m_ScreenY, m_WindowW, m_WindowH);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -344,7 +344,7 @@ std::vector<std::wstring> CRainmeter::ParseString(LPCTSTR str)
|
||||
}
|
||||
}
|
||||
|
||||
if (arg.size() > 0)
|
||||
if (!arg.empty())
|
||||
{
|
||||
// Strip quotes
|
||||
while ((pos = arg.find(L'"')) != std::wstring::npos)
|
||||
@ -652,7 +652,7 @@ void CRainmeter::RainmeterWriteKeyValue(const WCHAR* arg)
|
||||
std::vector<std::wstring> iniFileMappings;
|
||||
CSystem::GetIniFileMappingList(iniFileMappings);
|
||||
std::wstring iniWrite = CSystem::GetTemporaryFile(iniFileMappings, iniFile);
|
||||
if (iniWrite == L"<>") // error occurred
|
||||
if (iniWrite.size() == 1 && iniWrite[0] == L'?') // error occurred
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -1229,7 +1229,7 @@ void CSystem::GetIniFileMappingList(std::vector<std::wstring>& iniFileMappings)
|
||||
** GetTemporaryFile
|
||||
**
|
||||
** Prepares a temporary file if iniFile is included in the "IniFileMapping" entries.
|
||||
** If iniFile is not included, returns a empty string. If error occurred, returns "<>".
|
||||
** If iniFile is not included, returns a empty string. If error occurred, returns "?".
|
||||
** Note that a temporary file must be deleted by caller.
|
||||
**
|
||||
*/
|
||||
@ -1272,14 +1272,14 @@ std::wstring CSystem::GetTemporaryFile(const std::vector<std::wstring>& iniFileM
|
||||
else // temporary is reserved or failed
|
||||
{
|
||||
RemoveFile(temporary);
|
||||
if (tmp.empty()) tmp = L"<>";
|
||||
if (tmp.empty()) tmp = L"?";
|
||||
return tmp;
|
||||
}
|
||||
}
|
||||
else // failed
|
||||
{
|
||||
LogWithArgs(LOG_ERROR, L"Unable to create temporary file to: %s", temporary.c_str());
|
||||
return L"<>";
|
||||
return L"?";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -205,9 +205,9 @@ HICON CTrayWindow::CreateTrayIcon(double value)
|
||||
trayBitmap.GetHICON(&icon);
|
||||
return icon;
|
||||
}
|
||||
else if (m_MeterType == TRAY_METER_TYPE_BITMAP && (m_Bitmap || m_TrayIcons.size() > 0))
|
||||
else if (m_MeterType == TRAY_METER_TYPE_BITMAP && (m_Bitmap || !m_TrayIcons.empty()))
|
||||
{
|
||||
if (m_TrayIcons.size() > 0)
|
||||
if (!m_TrayIcons.empty())
|
||||
{
|
||||
size_t frame = 0;
|
||||
size_t frameCount = m_TrayIcons.size();
|
||||
|
Loading…
Reference in New Issue
Block a user