From 6ceacb0d98c861a5b015415d21bad566f0efc7e9 Mon Sep 17 00:00:00 2001 From: spx Date: Tue, 12 Jul 2011 13:37:31 +0000 Subject: [PATCH] Minor tweaks. --- Library/ConfigParser.cpp | 12 ++++++------ Library/Measure.cpp | 6 +++--- Library/Meter.cpp | 4 ++-- Library/Rainmeter.cpp | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Library/ConfigParser.cpp b/Library/ConfigParser.cpp index 2f9c741e..f10baa3d 100644 --- a/Library/ConfigParser.cpp +++ b/Library/ConfigParser.cpp @@ -469,13 +469,13 @@ bool CConfigParser::ReplaceVariables(std::wstring& result) end = result.find(L'#', pos + 1); if (end != std::wstring::npos) { - std::wstring strVariable(result.begin() + pos + 1, result.begin() + end); + std::wstring strVariable = result.substr(pos + 1, end - (pos + 1)); std::wstring strValue; if (GetVariable(strVariable, strValue)) { // Variable found, replace it with the value - result.replace(result.begin() + pos, result.begin() + end + 1, strValue); + result.replace(pos, end - pos + 1, strValue); start = pos + strValue.length(); replaced = true; } @@ -493,7 +493,7 @@ bool CConfigParser::ReplaceVariables(std::wstring& result) { loop = false; } - } while(loop); + } while (loop); return replaced; } @@ -526,7 +526,7 @@ bool CConfigParser::ReplaceMeasures(std::wstring& result) pos2 = result.find(L'[', pos + 1); if (pos2 == std::wstring::npos || end < pos2) { - std::wstring var(result.begin() + pos + 1, result.begin() + end); + std::wstring var = result.substr(pos + 1, end - (pos + 1)); CMeasure* measure = GetMeasure(var); if (measure) @@ -534,7 +534,7 @@ bool CConfigParser::ReplaceMeasures(std::wstring& result) std::wstring value = measure->GetStringValue(AUTOSCALE_OFF, 1, -1, false); // Measure found, replace it with the value - result.replace(result.begin() + pos, result.begin() + end + 1, value); + result.replace(pos, end - pos + 1, value); start = pos + value.length(); replaced = true; } @@ -557,7 +557,7 @@ bool CConfigParser::ReplaceMeasures(std::wstring& result) { loop = false; } - } while(loop); + } while (loop); } return replaced; diff --git a/Library/Measure.cpp b/Library/Measure.cpp index 665a0a09..ca5e001d 100644 --- a/Library/Measure.cpp +++ b/Library/Measure.cpp @@ -213,10 +213,10 @@ const WCHAR* CMeasure::CheckSubstitute(const WCHAR* buffer) pos = str.find(m_Substitute[i], start); if (pos != std::wstring::npos) { - str.replace(str.begin() + pos, str.begin() + pos + m_Substitute[i].size(), m_Substitute[i + 1]); - start = pos + m_Substitute[i + 1].size(); + str.replace(pos, m_Substitute[i].length(), m_Substitute[i + 1]); + start = pos + m_Substitute[i + 1].length(); } - } while(pos != std::wstring::npos); + } while (pos != std::wstring::npos); } } diff --git a/Library/Meter.cpp b/Library/Meter.cpp index 616faff4..71adcdb0 100644 --- a/Library/Meter.cpp +++ b/Library/Meter.cpp @@ -625,11 +625,11 @@ bool CMeter::ReplaceMeasures(const std::vector& stringValues, std: pos = str.find(buffer, start); if (pos != std::wstring::npos) { - str.replace(str.begin() + pos, str.begin() + pos + wcslen(buffer), stringValues[i - 1]); + str.replace(pos, wcslen(buffer), stringValues[i - 1]); start = pos + stringValues[i - 1].length(); replaced = true; } - } while(pos != std::wstring::npos); + } while (pos != std::wstring::npos); } } diff --git a/Library/Rainmeter.cpp b/Library/Rainmeter.cpp index ad33ff22..e05a4033 100644 --- a/Library/Rainmeter.cpp +++ b/Library/Rainmeter.cpp @@ -97,7 +97,7 @@ std::vector CRainmeter::ParseString(LPCTSTR str) size_t pos = result[i].find(L"\""); while (pos != std::wstring::npos) { - result[i].erase(result[i].begin() + pos, result[i].begin() + pos + 1); + result[i].erase(pos, 1); pos = result[i].find(L"\""); } } @@ -2245,7 +2245,7 @@ void CRainmeter::CreateDefaultConfigFile(const std::wstring& strFile) size_t pos = strFile.find_last_of(L'\\'); if (pos != std::wstring::npos) { - std::wstring strPath(strFile.begin(), strFile.begin() + pos); + std::wstring strPath(strFile, 0, pos); CreateDirectory(strPath.c_str(), NULL); }