From 8512413d4655d595fc4cfb6b38cb18ffff98effb Mon Sep 17 00:00:00 2001 From: Takashi Sawanaka Date: Mon, 2 Jan 2017 19:54:25 +0900 Subject: [PATCH] Replace string_* with strutils::* --- Src/7zCommon.cpp | 6 +- Src/Common/ClipBoard.h | 2 +- Src/Common/PreferencesDlg.cpp | 2 +- Src/Common/RegKey.cpp | 2 +- Src/Common/RegOptionsMgr.cpp | 2 +- Src/Common/UnicodeString.cpp | 35 +++++---- Src/Common/UnicodeString.h | 49 ++++++------ Src/Common/version.cpp | 2 +- Src/ConfigLog.cpp | 6 +- Src/DiffContext.cpp | 2 +- Src/DiffFileData.cpp | 4 +- Src/DiffTextBuffer.cpp | 4 +- Src/DiffWrapper.cpp | 6 +- Src/DirActions.cpp | 28 +++---- Src/DirActions.h | 2 +- Src/DirCmpReport.cpp | 22 +++--- Src/DirDoc.cpp | 4 +- Src/DirView.cpp | 24 +++--- Src/DirViewColItems.cpp | 34 ++++---- Src/DirViewColItems.h | 2 +- Src/Environment.cpp | 2 +- Src/FileFilterHelper.cpp | 24 +++--- Src/FileFilterMgr.cpp | 16 ++-- Src/FileFiltersDlg.cpp | 14 ++-- Src/FileTextEncoding.cpp | 2 +- Src/FileVersion.cpp | 2 +- Src/FilterCommentsManager.cpp | 4 +- Src/FolderCmp.cpp | 16 ++-- Src/HexMergeDoc.cpp | 6 +- Src/HexMergeView.cpp | 4 +- Src/ImgMergeFrm.cpp | 36 ++++----- Src/LineFiltersList.cpp | 16 ++-- Src/LoadSaveCodepageDlg.cpp | 2 +- Src/LocationView.cpp | 4 +- Src/MainFrm.cpp | 20 ++--- Src/Merge.cpp | 20 ++--- Src/MergeApp.cpp | 8 +- Src/MergeCmdLineInfo.cpp | 4 +- Src/MergeDoc.cpp | 46 +++++------ Src/MergeEditView.cpp | 6 +- Src/OpenView.cpp | 14 ++-- Src/OptionsCustomColors.cpp | 4 +- Src/OptionsSyntaxColors.cpp | 8 +- Src/PatchDlg.cpp | 6 +- Src/PatchTool.cpp | 2 +- Src/Plugins.cpp | 12 +-- Src/ProjectFilePathsDlg.cpp | 10 +-- Src/PropBackups.cpp | 2 +- Src/PropCodepage.cpp | 6 +- Src/PropEditor.cpp | 4 +- Src/PropRegistry.cpp | 6 +- Src/PropShell.cpp | 8 +- Src/SourceControl.cpp | 6 +- Src/TestFilterDlg.cpp | 2 +- Src/VSSHelper.cpp | 28 +++---- Src/codepage_detect.cpp | 2 +- Src/paths.cpp | 2 +- .../UnicodeString/UnicodeString_test.cpp | 90 +++++++++++----------- 58 files changed, 356 insertions(+), 346 deletions(-) diff --git a/Src/7zCommon.cpp b/Src/7zCommon.cpp index 939698b59..8e2010463 100644 --- a/Src/7zCommon.cpp +++ b/Src/7zCommon.cpp @@ -638,7 +638,7 @@ DecompressResult DecompressArchive(HWND hWnd, const PathContext& files) break; if (res.files[0].find(path) == 0) { - VERIFY(::DeleteFile(res.files[0].c_str()) || (LogErrorString(string_format(_T("DeleteFile(%s) failed"), res.files[0].c_str())), false)); + VERIFY(::DeleteFile(res.files[0].c_str()) || (LogErrorString(strutils::format(_T("DeleteFile(%s) failed"), res.files[0].c_str())), false)); } BSTR pTmp = piHandler->GetDefaultName(hWnd, res.files[0].c_str()); res.files[0] = OLE2T(pTmp); @@ -663,7 +663,7 @@ DecompressResult DecompressArchive(HWND hWnd, const PathContext& files) break;; if (res.files[1].find(path) == 0) { - VERIFY(::DeleteFile(res.files[1].c_str()) || (LogErrorString(string_format(_T("DeleteFile(%s) failed"), res.files[1].c_str())), false)); + VERIFY(::DeleteFile(res.files[1].c_str()) || (LogErrorString(strutils::format(_T("DeleteFile(%s) failed"), res.files[1].c_str())), false)); } BSTR pTmp = piHandler->GetDefaultName(hWnd, res.files[1].c_str()); res.files[1] = OLE2T(pTmp); @@ -688,7 +688,7 @@ DecompressResult DecompressArchive(HWND hWnd, const PathContext& files) break;; if (res.files[2].find(path) == 0) { - VERIFY(::DeleteFile(res.files[2].c_str()) || (LogErrorString(string_format(_T("DeleteFile(%s) failed"), res.files[2].c_str())), false)); + VERIFY(::DeleteFile(res.files[2].c_str()) || (LogErrorString(strutils::format(_T("DeleteFile(%s) failed"), res.files[2].c_str())), false)); } BSTR pTmp = piHandler->GetDefaultName(hWnd, res.files[1].c_str()); res.files[2] = OLE2T(pTmp); diff --git a/Src/Common/ClipBoard.h b/Src/Common/ClipBoard.h index 5ddba14d7..c74c2b5fc 100644 --- a/Src/Common/ClipBoard.h +++ b/Src/Common/ClipBoard.h @@ -31,7 +31,7 @@ void PutFilesToClipboard(const Container& list, HWND currentWindowHandle) } strPaths += _T('\0'); - strPathsSepSpc = string_trim_ws_end(strPathsSepSpc); + strPathsSepSpc = strutils::trim_ws_end(strPathsSepSpc); // CF_HDROP HGLOBAL hDrop = GlobalAlloc(GHND, sizeof(DROPFILES) + sizeof(TCHAR) * strPaths.length()); diff --git a/Src/Common/PreferencesDlg.cpp b/Src/Common/PreferencesDlg.cpp index a1e5991f4..d8057528a 100644 --- a/Src/Common/PreferencesDlg.cpp +++ b/Src/Common/PreferencesDlg.cpp @@ -213,7 +213,7 @@ void CPreferencesDlg::OnSelchangedPages(NMHDR* pNMHDR, LRESULT* pResult) m_pphost.SetActivePage(pPage, FALSE); // update caption - String sCaption = string_format_string1(_("Options (%1)"), (LPCTSTR)GetItemPath(htiSel)); + String sCaption = strutils::format_string1(_("Options (%1)"), (LPCTSTR)GetItemPath(htiSel)); SetWindowText(sCaption.c_str()); } diff --git a/Src/Common/RegKey.cpp b/Src/Common/RegKey.cpp index a037e7783..3e31e1f42 100644 --- a/Src/Common/RegKey.cpp +++ b/Src/Common/RegKey.cpp @@ -144,7 +144,7 @@ LONG CRegKeyEx::WriteFloat(LPCTSTR pszKey, float fVal) { assert(m_hKey); assert(pszKey); - String s = string_to_str(fVal); + String s = strutils::to_str(fVal); return RegSetValueEx(m_hKey, pszKey, 0L, REG_SZ, (const LPBYTE) s.c_str(), static_cast((s.length() + 1))*sizeof(TCHAR) ); } diff --git a/Src/Common/RegOptionsMgr.cpp b/Src/Common/RegOptionsMgr.cpp index c8b97738d..900e7c162 100644 --- a/Src/Common/RegOptionsMgr.cpp +++ b/Src/Common/RegOptionsMgr.cpp @@ -533,7 +533,7 @@ int CRegOptionsMgr::ExportOptions(const String& filename) const } else if (value.GetType() == varprop::VT_INT) { - strVal = string_to_str(value.GetInt()); + strVal = strutils::to_str(value.GetInt()); } else if (value.GetType() == varprop::VT_STRING) { diff --git a/Src/Common/UnicodeString.cpp b/Src/Common/UnicodeString.cpp index 223815c86..ad16c9b21 100644 --- a/Src/Common/UnicodeString.cpp +++ b/Src/Common/UnicodeString.cpp @@ -32,12 +32,15 @@ #include #include +namespace strutils +{ + /** * @brief Convert a string to lower case string. * @param [in] str String to convert to lower case. * @return Lower case string. */ -String string_makelower(const String &str) +String makelower(const String &str) { String ret(str); String::size_type i = 0; @@ -51,7 +54,7 @@ String string_makelower(const String &str) * @param [in] str String to convert to upper case. * @return upper case string. */ -String string_makeupper(const String &str) +String makeupper(const String &str) { String ret(str); String::size_type i = 0; @@ -69,7 +72,7 @@ String string_makeupper(const String &str) * @param [in] find A string to search and replace with another (@p replace). * @param [in] replace A string used to replace original (@p find). */ -void string_replace(String &target, const String &find, const String &replace) +void replace(String &target, const String &find, const String &replace) { const String::size_type find_len = find.length(); const String::size_type replace_len = replace.length(); @@ -87,7 +90,7 @@ void string_replace(String &target, const String &find, const String &replace) * @param [in] str2 Second string to compare. * @return As strcmp(), 0 if strings match. */ -int string_compare_nocase(const String &str1, const String &str2) +int compare_nocase(const String &str1, const String &str2) { return _tcsicoll(str1.c_str(), str2.c_str()); } @@ -97,7 +100,7 @@ int string_compare_nocase(const String &str1, const String &str2) * @param [in] str the original string. * @return Trimmed string. */ -String string_trim_ws(const String & str) +String trim_ws(const String & str) { if (str.empty()) return str; @@ -127,7 +130,7 @@ String string_trim_ws(const String & str) * @param [in] str the original string. * @return Trimmed string. */ -String string_trim_ws_begin(const String & str) +String trim_ws_begin(const String & str) { if (str.empty()) return str; @@ -147,7 +150,7 @@ String string_trim_ws_begin(const String & str) * @param [in] str the original string. * @return Trimmed string. */ -String string_trim_ws_end(const String & str) +String trim_ws_end(const String & str) { if (str.empty()) return str; @@ -162,7 +165,7 @@ String string_trim_ws_end(const String & str) return result; } -String string_format_arg_list(const TCHAR *fmt, va_list args) +String format_arg_list(const TCHAR *fmt, va_list args) { if (!fmt) return _T(""); @@ -183,16 +186,16 @@ String string_format_arg_list(const TCHAR *fmt, va_list args) * @brief printf()-style formatting for STL string. * Use this function to format String:s in printf() style. */ -String string_format(const TCHAR *fmt, ...) +String format(const TCHAR *fmt, ...) { va_list args; va_start(args, fmt); - String s = string_format_arg_list(fmt, args); + String s = format_arg_list(fmt, args); va_end(args); return s; } -String string_format_strings(const String& fmt, const String *args[], size_t nargs) +String format_strings(const String& fmt, const String *args[], size_t nargs) { String str; str.reserve(fmt.length() * 2); @@ -218,14 +221,16 @@ String string_format_strings(const String& fmt, const String *args[], size_t nar return str; } -String string_format_string1(const String& fmt, const String& arg1) +String format_string1(const String& fmt, const String& arg1) { const String* args[] = {&arg1}; - return string_format_strings(fmt, args, 1); + return format_strings(fmt, args, 1); } -String string_format_string2(const String& fmt, const String& arg1, const String& arg2) +String format_string2(const String& fmt, const String& arg1, const String& arg2) { const String* args[] = {&arg1, &arg2}; - return string_format_strings(fmt, args, 2); + return format_strings(fmt, args, 2); +} + } diff --git a/Src/Common/UnicodeString.h b/Src/Common/UnicodeString.h index 90fca60b1..e63717033 100644 --- a/Src/Common/UnicodeString.h +++ b/Src/Common/UnicodeString.h @@ -55,28 +55,31 @@ typedef char TCHAR; typedef std_tchar(string) String; -String string_makelower(const String &str); -String string_makeupper(const String &str); +namespace strutils +{ + +String makelower(const String &str); +String makeupper(const String &str); -void string_replace(String &target, const String &find, const String &replace); +void replace(String &target, const String &find, const String &replace); // Comparing -int string_compare_nocase(const String &str1, const String &str2); +int compare_nocase(const String &str1, const String &str2); // Trimming -String string_trim_ws(const String & str); -String string_trim_ws_begin(const String & str); -String string_trim_ws_end(const String & str); +String trim_ws(const String & str); +String trim_ws_begin(const String & str); +String trim_ws_end(const String & str); // Formatting -String string_format_arg_list(const TCHAR *fmt, va_list args); -String string_format(const TCHAR *fmt, ...); -String string_format_strings(const String& fmt, const String *args[], size_t nargs); -String string_format_string1(const String& fmt, const String& arg1); -String string_format_string2(const String& fmt, const String& arg1, const String& arg2); +String format_arg_list(const TCHAR *fmt, va_list args); +String format(const TCHAR *fmt, ...); +String format_strings(const String& fmt, const String *args[], size_t nargs); +String format_string1(const String& fmt, const String& arg1); +String format_string2(const String& fmt, const String& arg1, const String& arg2); template -String string_join(const InputIterator& begin, const InputIterator& end, const String& delim) +String join(const InputIterator& begin, const InputIterator& end, const String& delim) { size_t sum = 0, delim_len = delim.length(); for (InputIterator it = begin; it != end; ++it) @@ -95,7 +98,7 @@ String string_join(const InputIterator& begin, const InputIterator& end, const S } template -String string_join(const InputIterator& begin, const InputIterator& end, const String& delim, Formatter func) +String join(const InputIterator& begin, const InputIterator& end, const String& delim, Formatter func) { String result; for (InputIterator it = begin; it != end; ++it) @@ -106,11 +109,13 @@ String string_join(const InputIterator& begin, const InputIterator& end, const S return result; } -inline String string_to_str(int val) { return string_format(_T("%d"), val); } -inline String string_to_str(unsigned val) { return string_format(_T("%u"), val); } -inline String string_to_str(long val) { return string_format(_T("%ld"), val); } -inline String string_to_str(unsigned long val) { return string_format(_T("%lu"), val); } -inline String string_to_str(long long val) { return string_format(_T("%I64d"), val); } -inline String string_to_str(unsigned long long val) { return string_format(_T("%I64u"), val); } -inline String string_to_str(float val) { return string_format(_T("%f"), val); } -inline String string_to_str(double val) { return string_format(_T("%f"), val); } +inline String to_str(int val) { return strutils::format(_T("%d"), val); } +inline String to_str(unsigned val) { return strutils::format(_T("%u"), val); } +inline String to_str(long val) { return strutils::format(_T("%ld"), val); } +inline String to_str(unsigned long val) { return strutils::format(_T("%lu"), val); } +inline String to_str(long long val) { return strutils::format(_T("%I64d"), val); } +inline String to_str(unsigned long long val) { return strutils::format(_T("%I64u"), val); } +inline String to_str(float val) { return strutils::format(_T("%f"), val); } +inline String to_str(double val) { return strutils::format(_T("%f"), val); } + +} diff --git a/Src/Common/version.cpp b/Src/Common/version.cpp index f6bbca74e..10fc06987 100644 --- a/Src/Common/version.cpp +++ b/Src/Common/version.cpp @@ -387,7 +387,7 @@ void CVersionInfo::QueryValue(LPCTSTR szId, String& s) { s = lpVersion; if (!s.empty()) - s = string_trim_ws(s); + s = strutils::trim_ws(s); } else s.clear(); diff --git a/Src/ConfigLog.cpp b/Src/ConfigLog.cpp index f31601c0a..a4c44e0d6 100644 --- a/Src/ConfigLog.cpp +++ b/Src/ConfigLog.cpp @@ -99,7 +99,7 @@ static String GetLocaleString(LCID locid, LCTYPE lctype) */ void CConfigLog::WriteItem(int indent, const String& key, LPCTSTR value) { - String text = string_format(value ? _T("%*.0s%s: %s\r\n") : _T("%*.0s%s:\r\n"), indent, key.c_str(), key.c_str(), value); + String text = strutils::format(value ? _T("%*.0s%s: %s\r\n") : _T("%*.0s%s:\r\n"), indent, key.c_str(), key.c_str(), value); m_pfile->WriteString(text); } @@ -116,7 +116,7 @@ void CConfigLog::WriteItem(int indent, const String& key, const String &str) */ void CConfigLog::WriteItem(int indent, const String& key, long value) { - String text = string_format(_T("%*.0s%s: %ld\r\n"), indent, key.c_str(), key.c_str(), value); + String text = strutils::format(_T("%*.0s%s: %ld\r\n"), indent, key.c_str(), key.c_str(), value); m_pfile->WriteString(text); } @@ -141,7 +141,7 @@ void CConfigLog::WriteVersionOf1(int indent, const String& path) { String name = paths::FindFileName(path); CVersionInfo vi(path.c_str(), TRUE); - String text = string_format + String text = strutils::format ( name == path ? _T("%*s%-20s %s=%u.%02u %s=%04u\r\n") diff --git a/Src/DiffContext.cpp b/Src/DiffContext.cpp index d7a39cd30..eb099f443 100644 --- a/Src/DiffContext.cpp +++ b/Src/DiffContext.cpp @@ -124,7 +124,7 @@ bool CDiffContext::UpdateInfoFromDiskHalf(DIFFITEM & di, int nIndex) */ static bool CheckFileForVersion(const String& ext) { - String lower_ext = string_makelower(ext); + String lower_ext = strutils::makelower(ext); if (lower_ext == _T(".exe") || lower_ext == _T(".dll") || lower_ext == _T(".sys") || lower_ext == _T(".drv") || lower_ext == _T(".ocx") || lower_ext == _T(".cpl") || lower_ext == _T(".scr") || lower_ext == _T(".lang")) diff --git a/Src/DiffFileData.cpp b/Src/DiffFileData.cpp index c03b241b7..b18d7f6be 100644 --- a/Src/DiffFileData.cpp +++ b/Src/DiffFileData.cpp @@ -100,7 +100,7 @@ bool DiffFileData::DoOpenFiles() return false; } - if (string_compare_nocase(m_FileLocation[0].filepath, + if (strutils::compare_nocase(m_FileLocation[0].filepath, m_FileLocation[1].filepath) == 0) { m_inf[1].desc = m_inf[0].desc; @@ -165,7 +165,7 @@ bool DiffFileData::Filepath_Transform(bool bForceUTF8, { // fourth step : prepare for diffing // may overwrite if we've already copied to temp file - bool bMayOverwrite = 0 != string_compare_nocase(filepathTransformed, filepath); + bool bMayOverwrite = 0 != strutils::compare_nocase(filepathTransformed, filepath); if (!FileTransform_AnyCodepageToUTF8(encoding.m_codepage, filepathTransformed, bMayOverwrite)) return false; } diff --git a/Src/DiffTextBuffer.cpp b/Src/DiffTextBuffer.cpp index 5abc5d356..55fdf36f1 100644 --- a/Src/DiffTextBuffer.cpp +++ b/Src/DiffTextBuffer.cpp @@ -530,10 +530,10 @@ int CDiffTextBuffer::SaveToFile (const String& pszFileName, { sError = uniErr.GetError(); if (bTempFile) - LogErrorString(string_format(_T("Opening file %s failed: %s"), + LogErrorString(strutils::format(_T("Opening file %s failed: %s"), pszFileName.c_str(), sError.c_str())); else - LogErrorString(string_format(_T("Opening file %s failed: %s"), + LogErrorString(strutils::format(_T("Opening file %s failed: %s"), sIntermediateFilename.c_str(), sError.c_str())); } return SAVE_FAILED; diff --git a/Src/DiffWrapper.cpp b/Src/DiffWrapper.cpp index 739f77e08..aac1bdcc5 100644 --- a/Src/DiffWrapper.cpp +++ b/Src/DiffWrapper.cpp @@ -127,7 +127,7 @@ void CDiffWrapper::SetCreatePatchFile(const String &filename) { m_bCreatePatchFile = true; m_sPatchFile = filename; - string_replace(m_sPatchFile, _T("/"), _T("\\")); + strutils::replace(m_sPatchFile, _T("/"), _T("\\")); } } @@ -712,7 +712,7 @@ bool CDiffWrapper::RunFileDiff() if (!FileTransform_Prediffing(m_infoPrediffer.get(), strFileTemp[file], m_sToFindPrediffer, m_bPathsAreTemp)) { // display a message box - String sError = string_format( + String sError = strutils::format( _T("An error occurred while prediffing the file '%s' with the plugin '%s'. The prediffing is not applied any more."), strFileTemp[file].c_str(), m_infoPrediffer->pluginName.c_str()); @@ -889,7 +889,7 @@ bool CDiffWrapper::RunFileDiff() // Delete temp files transformation functions possibly created for (file = 0; file < files.GetSize(); file++) { - if (string_compare_nocase(files[file], strFileTemp[file]) != 0) + if (strutils::compare_nocase(files[file], strFileTemp[file]) != 0) { try { diff --git a/Src/DirActions.cpp b/Src/DirActions.cpp index 74fbe4330..48ea17023 100644 --- a/Src/DirActions.cpp +++ b/Src/DirActions.cpp @@ -32,7 +32,7 @@ static void ThrowConfirmationNeededException(const CDiffContext& ctxt, const Str const String& src, const String& dest, bool destIsSide); ContentsChangedException::ContentsChangedException(const String& failpath) - : m_msg(string_format_string1( + : m_msg(strutils::format_string1( _("Operation aborted!\n\nFolder contents at disks has changed, path\n%1\nwas not found.\n\nPlease refresh the compare."), failpath)) { @@ -56,7 +56,7 @@ static void ThrowConfirmCopy(const CDiffContext& ctxt, int origin, int destinati { String caption = _("Confirm Copy"); String strQuestion = count == 1 ? _("Are you sure you want to copy:") : - string_format(_("Are you sure you want to copy %d items:").c_str(), count); + strutils::format(_("Are you sure you want to copy %d items:").c_str(), count); ThrowConfirmationNeededException(ctxt, caption, strQuestion, origin, destination, count, src, dest, destIsSide); @@ -80,7 +80,7 @@ static void ThrowConfirmMove(const CDiffContext& ctxt, int origin, int destinati { String caption = _("Confirm Move"); String strQuestion = count == 1 ? _("Are you sure you want to move:") : - string_format(_("Are you sure you want to move %d items:").c_str(), count); + strutils::format(_("Are you sure you want to move %d items:").c_str(), count); ThrowConfirmationNeededException(ctxt, caption, strQuestion, origin, destination, count, src, dest, destIsSide); @@ -294,7 +294,7 @@ uintptr_t FindItemFromPaths(const CDiffContext& ctxt, const String& pathLeft, co String file2 = paths::FindFileName(pathRight); // Filenames must be identical - if (string_compare_nocase(file1, file2) != 0) + if (strutils::compare_nocase(file1, file2) != 0) return NULL; String path1(pathLeft, 0, pathLeft.length() - file1.length()); // include trailing backslash @@ -415,7 +415,7 @@ bool AreItemsOpenable(const CDiffContext& ctxt, SELECTIONTYPE selectionType, con // Allow to compare items if left & right path refer to same directory // (which means there is effectively two files involved). No need to check // side flags. If files weren't on both sides, we'd have no DIFFITEMs. - if (string_compare_nocase(sLeftBasePath, sRightBasePath) == 0) + if (strutils::compare_nocase(sLeftBasePath, sRightBasePath) == 0) return true; return false; @@ -473,7 +473,7 @@ bool AreItemsOpenable(const CDiffContext& ctxt, const DIFFITEM & di1, const DIFF // Allow to compare items if left & right path refer to same directory // (which means there is effectively two files involved). No need to check // side flags. If files weren't on both sides, we'd have no DIFFITEMs. - if (string_compare_nocase(sLeftBasePath, sMiddleBasePath) == 0 && string_compare_nocase(sLeftBasePath, sRightBasePath) == 0) + if (strutils::compare_nocase(sLeftBasePath, sMiddleBasePath) == 0 && strutils::compare_nocase(sLeftBasePath, sRightBasePath) == 0) return true; return false; @@ -673,7 +673,7 @@ bool GetOpenOneItem(const CDiffContext& ctxt, uintptr_t pos1, const DIFFITEM *pd if (path1Exists != paths::IS_EXISTING_DIR || path2Exists != paths::IS_EXISTING_DIR) { String invalid = path1Exists == paths::IS_EXISTING_DIR ? paths[0] : paths[1]; - errmsg = string_format_string1( + errmsg = strutils::format_string1( _("Operation aborted!\n\nFolder contents at disks has changed, path\n%1\nwas not found.\n\nPlease refresh the compare."), invalid); return false; @@ -1089,17 +1089,17 @@ void MarkForRescan(DIFFITEM &di) String FormatFilesAffectedString(int nFilesAffected, int nFilesTotal) { if (nFilesAffected == nFilesTotal) - return string_format_string1(_("(%1 Files Affected)"), NumToStr(nFilesTotal)); + return strutils::format_string1(_("(%1 Files Affected)"), NumToStr(nFilesTotal)); else - return string_format_string2(_("(%1 of %2 Files Affected)"), NumToStr(nFilesAffected), NumToStr(nFilesTotal)); + return strutils::format_string2(_("(%1 of %2 Files Affected)"), NumToStr(nFilesAffected), NumToStr(nFilesTotal)); } String FormatMenuItemString(const String& fmt1, const String& fmt2, int count, int total) { if (count == total) - return string_format_string1(fmt1, NumToStr(total)); + return strutils::format_string1(fmt1, NumToStr(total)); else - return string_format_string2(fmt2, NumToStr(count), NumToStr(total)); + return strutils::format_string2(fmt2, NumToStr(count), NumToStr(total)); } String FormatMenuItemString(SIDE_TYPE src, SIDE_TYPE dst, int count, int total) @@ -1368,14 +1368,14 @@ CheckAllowUpwardDirectory(const CDiffContext& ctxt, const CTempPathContext *pTem return AllowUpwardDirectory::Never; } if (path.size() == 2 && - string_compare_nocase(name[0], _T("ORIGINAL")) == 0 && - string_compare_nocase(name[1], _T("ALTERED")) == 0) + strutils::compare_nocase(name[0], _T("ORIGINAL")) == 0 && + strutils::compare_nocase(name[1], _T("ALTERED")) == 0) { for (int i = 0; i < path.size(); ++i) pathsParent[i] = paths::GetParentPath(pathsParent[i]); for (int i = 0; i < path.size(); ++i) name[i] = paths::FindFileName(pathsParent[i]); - if (string_compare_nocase(name[0], name[1]) == 0) + if (strutils::compare_nocase(name[0], name[1]) == 0) { if (paths::GetPairComparability(pathsParent) != paths::IS_EXISTING_DIR) return AllowUpwardDirectory::Never; diff --git a/Src/DirActions.h b/Src/DirActions.h index 371067d21..297d6916b 100644 --- a/Src/DirActions.h +++ b/Src/DirActions.h @@ -688,7 +688,7 @@ std::pair CountPredifferYesNo(const InputIterator& begin, const InputI && !di.diffcode.isResultFiltered()) { PathContext files = GetItemFileNames(ctxt, di); - String filteredFilenames = string_join(files.begin(), files.end(), _T("|")); + String filteredFilenames = strutils::join(files.begin(), files.end(), _T("|")); PackingInfo * unpacker; PrediffingInfo * prediffer; const_cast(ctxt).FetchPluginInfos(filteredFilenames, &unpacker, &prediffer); diff --git a/Src/DirCmpReport.cpp b/Src/DirCmpReport.cpp index 32b4d1b3e..54a75b054 100644 --- a/Src/DirCmpReport.cpp +++ b/Src/DirCmpReport.cpp @@ -41,9 +41,9 @@ static String GetCurrentTimeString() static String BeginEl(const String& elName, const String& attr = _T("")) { if (attr.empty()) - return string_format(_T("<%s>"), elName.c_str()); + return strutils::format(_T("<%s>"), elName.c_str()); else - return string_format(_T("<%s %s>"), elName.c_str(), attr.c_str()); + return strutils::format(_T("<%s %s>"), elName.c_str(), attr.c_str()); } /** @@ -53,7 +53,7 @@ static String BeginEl(const String& elName, const String& attr = _T("")) */ static String EndEl(const String& elName) { - return string_format(_T(""), elName.c_str()); + return strutils::format(_T(""), elName.c_str()); } /** @@ -85,7 +85,7 @@ void DirCmpReport::SetRootPaths(const PathContext &paths) { m_rootPaths.SetLeft(paths.GetLeft()); m_rootPaths.SetRight(paths.GetRight()); - m_sTitle = string_format_string2(_("Compare %1 with %2"), + m_sTitle = strutils::format_string2(_("Compare %1 with %2"), m_rootPaths.GetLeft(), m_rootPaths.GetRight()); } @@ -358,11 +358,11 @@ void DirCmpReport::GenerateHTMLHeader() enc.rdbuf()->setLineLength(0); enc << m_pList->GetIconPNGData(i); enc.close(); - WriteString(string_format(_T("\t\t.icon%d { background-image: url('data:image/png;base64,%s'); background-repeat: no-repeat; background-size: 16px 16px; }\n"), i, ucr::toTString(stream.str()).c_str())); + WriteString(strutils::format(_T("\t\t.icon%d { background-image: url('data:image/png;base64,%s'); background-repeat: no-repeat; background-size: 16px 16px; }\n"), i, ucr::toTString(stream.str()).c_str())); } } for (int i = 0; i < maxIndent + 1; ++i) - WriteString(string_format(_T("\t\t.indent%d { padding-left: %dpx; background-position: %dpx center; }\n"), i, 2 * 2 + 16 + 8 * i, 2 + 8 * i)); + WriteString(strutils::format(_T("\t\t.indent%d { padding-left: %dpx; background-position: %dpx center; }\n"), i, 2 * 2 + 16 + 8 * i, 2 + 8 * i)); WriteString(_T("\t-->\n\t\n")); WriteString(_T("\n\n")); GenerateHTMLHeaderBodyPortion(); @@ -396,9 +396,9 @@ void DirCmpReport::GenerateXmlHeader() { WriteString(_T("")); // @todo xml declaration WriteString(_T("\n")); - WriteString(string_format(_T("%s\n"), m_rootPaths.GetLeft().c_str())); - WriteString(string_format(_T("%s\n"), m_rootPaths.GetRight().c_str())); - WriteString(string_format(_T("\n"), GetCurrentTimeString().c_str())); + WriteString(strutils::format(_T("%s\n"), m_rootPaths.GetLeft().c_str())); + WriteString(strutils::format(_T("%s\n"), m_rootPaths.GetRight().c_str())); + WriteString(strutils::format(_T("\n"), GetCurrentTimeString().c_str())); // Add column headers const String rowEl = _T("column_name"); @@ -443,7 +443,7 @@ void DirCmpReport::GenerateXmlHtmlContent(bool xml) else { COLORREF color = m_pList->GetBackColor(currRow); - String attr = string_format(_T("style='background-color: #%02x%02x%02x'"), + String attr = strutils::format(_T("style='background-color: #%02x%02x%02x'"), GetRValue(color), GetGValue(color), GetBValue(color)); WriteString(BeginEl(rowEl, attr)); } @@ -458,7 +458,7 @@ void DirCmpReport::GenerateXmlHtmlContent(bool xml) else { if (currCol == 0) - WriteString(BeginEl(colEl, string_format(_T("class=\"icon%d indent%d\""), m_pList->GetIconIndex(currRow), m_pList->GetIndent(currRow)))); + WriteString(BeginEl(colEl, strutils::format(_T("class=\"icon%d indent%d\""), m_pList->GetIconIndex(currRow), m_pList->GetIndent(currRow)))); else WriteString(BeginEl(colEl)); } diff --git a/Src/DirDoc.cpp b/Src/DirDoc.cpp index fbe3b163b..96e31d082 100644 --- a/Src/DirDoc.cpp +++ b/Src/DirDoc.cpp @@ -613,9 +613,9 @@ void CDirDoc::SetTitle(LPCTSTR lpszTitle) sDirName[index] = paths::FindFileName(strPath); } if (std::count(&sDirName[0], &sDirName[0] + m_nDirs, sDirName[0]) == m_nDirs) - sTitle = sDirName[0] + string_format(_T(" x %d"), m_nDirs); + sTitle = sDirName[0] + strutils::format(_T(" x %d"), m_nDirs); else - sTitle = string_join(&sDirName[0], &sDirName[0] + m_nDirs, _T(" - ")); + sTitle = strutils::join(&sDirName[0], &sDirName[0] + m_nDirs, _T(" - ")); CDocument::SetTitle(sTitle.c_str()); } } diff --git a/Src/DirView.cpp b/Src/DirView.cpp index 87f11a868..00e1c32e6 100644 --- a/Src/DirView.cpp +++ b/Src/DirView.cpp @@ -2095,7 +2095,7 @@ LRESULT CDirView::OnUpdateUIMessage(WPARAM wParam, LPARAM lParam) // If compare took more than TimeToSignalCompare seconds, notify user clock_t elapsed = clock() - m_compareStart; GetParentFrame()->SetMessageText( - string_format(_("Elapsed time: %ld ms").c_str(), elapsed).c_str() + strutils::format(_("Elapsed time: %ld ms").c_str(), elapsed).c_str() ); if (elapsed > TimeToSignalCompare * CLOCKS_PER_SEC) MessageBeep(IDOK); @@ -2260,7 +2260,7 @@ void CDirView::OnTimer(UINT_PTR nIDEvent) else if (nIDEvent == STATUSBAR_UPDATE) { int items = GetSelectedCount(); - String msg = (items == 1) ? _("1 item selected") : string_format_string1(_("%1 items selected"), string_to_str(items)); + String msg = (items == 1) ? _("1 item selected") : strutils::format_string1(_("%1 items selected"), strutils::to_str(items)); GetParentFrame()->SetStatus(msg.c_str()); } @@ -2408,7 +2408,7 @@ struct FileCmpReport: public IFileCmpReport sLinkPath = di.diffFileInfo[0].GetFile(); - string_replace(sLinkPath, _T("\\"), _T("_")); + strutils::replace(sLinkPath, _T("\\"), _T("_")); sLinkPath += _T(".html"); m_pDirView->MoveFocus(m_pDirView->GetFirstSelectedInd(), nIndex, m_pDirView->GetSelectedCount()); @@ -2478,7 +2478,7 @@ void CDirView::OnToolsGenerateReport() } else { - String msg = string_format_string1( + String msg = strutils::format_string1( _("Error creating the report:\n%1"), errStr); AfxMessageBox(msg.c_str(), MB_OK | MB_ICONSTOP); @@ -2723,14 +2723,14 @@ void CDirView::OnCopyPathnames() { std::list list; CopyPathnames(SelBegin(), SelEnd(), std::back_inserter(list), stype, GetDiffContext()); - PutToClipboard(string_join(list.begin(), list.end(), _T("\r\n")), GetMainFrame()->GetSafeHwnd()); + PutToClipboard(strutils::join(list.begin(), list.end(), _T("\r\n")), GetMainFrame()->GetSafeHwnd()); } void CDirView::OnCopyBothPathnames() { std::list list; CopyBothPathnames(SelBegin(), SelEnd(), std::back_inserter(list), GetDiffContext()); - PutToClipboard(string_join(list.begin(), list.end(), _T("\r\n")), GetMainFrame()->GetSafeHwnd()); + PutToClipboard(strutils::join(list.begin(), list.end(), _T("\r\n")), GetMainFrame()->GetSafeHwnd()); } /** @@ -2740,7 +2740,7 @@ void CDirView::OnCopyFilenames() { std::list list; CopyFilenames(SelBegin(), SelEnd(), std::back_inserter(list)); - PutToClipboard(string_join(list.begin(), list.end(), _T("\r\n")), GetMainFrame()->GetSafeHwnd()); + PutToClipboard(strutils::join(list.begin(), list.end(), _T("\r\n")), GetMainFrame()->GetSafeHwnd()); } /** @@ -2876,7 +2876,7 @@ void CDirView::OnItemChanged(NMHDR* pNMHDR, LRESULT* pResult) (pNMListView->uNewState & LVIS_SELECTED)) { int items = GetSelectedCount(); - String msg = (items == 1) ? _("1 item selected") : string_format_string1(_("%1 items selected"), string_to_str(items)); + String msg = (items == 1) ? _("1 item selected") : strutils::format_string1(_("%1 items selected"), strutils::to_str(items)); GetParentFrame()->SetStatus(msg.c_str()); } *pResult = 0; @@ -2983,7 +2983,7 @@ void CDirView::OnUpdateStatusNum(CCmdUI* pCmdUI) { // No item has focus // "Items: %1" - s = string_format_string1(_("Items: %1"), string_to_str(count)); + s = strutils::format_string1(_("Items: %1"), strutils::to_str(count)); } else { @@ -2999,8 +2999,8 @@ void CDirView::OnUpdateStatusNum(CCmdUI* pCmdUI) --count; } // "Item %1 of %2" - s = string_format_string2(_("Item %1 of %2"), - string_to_str(focusItem + 1), string_to_str(count)); + s = strutils::format_string2(_("Item %1 of %2"), + strutils::to_str(focusItem + 1), strutils::to_str(count)); } } pCmdUI->SetText(s.c_str()); @@ -3580,7 +3580,7 @@ void CDirView::OnBeginDrag(NMHDR* pNMHDR, LRESULT* pResult) std::list list; CopyPathnamesForDragAndDrop(SelBegin(), SelEnd(), std::back_inserter(list), GetDiffContext()); - String filesForDroping = string_join(list.begin(), list.end(), _T("\n")); + String filesForDroping = strutils::join(list.begin(), list.end(), _T("\n")); CSharedFile file(GMEM_DDESHARE | GMEM_MOVEABLE | GMEM_ZEROINIT); file.Write(filesForDroping.data(), static_cast(filesForDroping.length() * sizeof(TCHAR))); diff --git a/Src/DirViewColItems.cpp b/Src/DirViewColItems.cpp index 442c5b714..a56d2416b 100644 --- a/Src/DirViewColItems.cpp +++ b/Src/DirViewColItems.cpp @@ -156,7 +156,7 @@ static String MakeShortSize(int64_t size) { TCHAR buffer[48]; if (size < 1024) - return string_format(_T("%d B"), static_cast(size)); + return strutils::format(_T("%d B"), static_cast(size)); else StrFormatByteSize64(size, buffer, _countof(buffer)); return buffer; @@ -280,40 +280,40 @@ static String ColStatusGet(const CDiffContext *pCtxt, const void *p) } else if (di.diffcode.isSideFirstOnly()) { - s = string_format_string1(_("Left only: %1"), + s = strutils::format_string1(_("Left only: %1"), di.getFilepath(0, pCtxt->GetNormalizedLeft())); } else if (di.diffcode.isSideSecondOnly()) { if (nDirs < 3) { - s = string_format_string1(_("Right only: %1"), + s = strutils::format_string1(_("Right only: %1"), di.getFilepath(1, pCtxt->GetNormalizedRight())); } else { - s = string_format_string1(_("Middle only: %1"), + s = strutils::format_string1(_("Middle only: %1"), di.getFilepath(1, pCtxt->GetNormalizedMiddle())); } } else if (di.diffcode.isSideThirdOnly()) { - s = string_format_string1(_("Right only: %1"), + s = strutils::format_string1(_("Right only: %1"), di.getFilepath(2, pCtxt->GetNormalizedRight())); } else if (nDirs > 2 && !di.diffcode.existsFirst()) { - s = string_format_string1(_("Does not exist in %1"), + s = strutils::format_string1(_("Does not exist in %1"), pCtxt->GetNormalizedLeft()); } else if (nDirs > 2 && !di.diffcode.existsSecond()) { - s = string_format_string1(_("Does not exist in %1"), + s = strutils::format_string1(_("Does not exist in %1"), pCtxt->GetNormalizedMiddle()); } else if (nDirs > 2 && !di.diffcode.existsThird()) { - s = string_format_string1(_("Does not exist in %1"), + s = strutils::format_string1(_("Does not exist in %1"), pCtxt->GetNormalizedRight()); } else if (di.diffcode.isResultSame()) @@ -649,7 +649,7 @@ static String GetEOLType(const CDiffContext *, const void *p, int index) } else { - return string_format(_T("%s:%d/%d/%d"), + return strutils::format(_T("%s:%d/%d/%d"), _("Mixed").c_str(), stats.ncrlfs, stats.ncrs, stats.nlfs); } @@ -716,7 +716,7 @@ static int ColFileNameSort(const CDiffContext *pCtxt, const void *p, const void return -1; if (!ldi.diffcode.isDirectory() && rdi.diffcode.isDirectory()) return 1; - return string_compare_nocase(ColFileNameGet >(pCtxt, p), ColFileNameGet >(pCtxt, q)); + return strutils::compare_nocase(ColFileNameGet >(pCtxt, p), ColFileNameGet >(pCtxt, q)); } /** @@ -734,7 +734,7 @@ static int ColExtSort(const CDiffContext *pCtxt, const void *p, const void *q) return -1; if (!ldi.diffcode.isDirectory() && rdi.diffcode.isDirectory()) return 1; - return string_compare_nocase(ColExtGet(pCtxt, p), ColExtGet(pCtxt, q)); + return strutils::compare_nocase(ColExtGet(pCtxt, p), ColExtGet(pCtxt, q)); } /** @@ -746,7 +746,7 @@ static int ColExtSort(const CDiffContext *pCtxt, const void *p, const void *q) */ static int ColPathSort(const CDiffContext *pCtxt, const void *p, const void *q) { - return string_compare_nocase(ColPathGet(pCtxt, p), ColPathGet(pCtxt, q)); + return strutils::compare_nocase(ColPathGet(pCtxt, p), ColPathGet(pCtxt, q)); } /** @@ -986,12 +986,12 @@ DirViewColItems::GetColRegValueNameBase(int col) const if (m_nDirs < 3) { assert(col>=0 && col=0 && col(m_colorder.begin(), m_colorder.end(), _T(" "), string_to_str); + return strutils::join(m_colorder.begin(), m_colorder.end(), _T(" "), strutils::to_str); } diff --git a/Src/DirViewColItems.h b/Src/DirViewColItems.h index dac14aeec..8a7058762 100644 --- a/Src/DirViewColItems.h +++ b/Src/DirViewColItems.h @@ -107,7 +107,7 @@ public: if (phy >= 0) { if (!result.empty()) result += ' '; - result += string_to_str(getcolwidth(phy)); + result += strutils::to_str(getcolwidth(phy)); } } return result; diff --git a/Src/Environment.cpp b/Src/Environment.cpp index 13aadcfb3..bb3f1d53d 100644 --- a/Src/Environment.cpp +++ b/Src/Environment.cpp @@ -81,7 +81,7 @@ String GetTempChildPath() String path; do { - path = paths::ConcatPath(GetTemporaryPath(), string_format(_T("%08x"), rand())); + path = paths::ConcatPath(GetTemporaryPath(), strutils::format(_T("%08x"), rand())); } while (paths::IsDirectory(path) || !paths::CreateIfNeeded(path)); return path; } diff --git a/Src/FileFilterHelper.cpp b/Src/FileFilterHelper.cpp index 877f16e19..9ebe2f477 100644 --- a/Src/FileFilterHelper.cpp +++ b/Src/FileFilterHelper.cpp @@ -221,7 +221,7 @@ bool FileFilterHelper::includeFile(const String& szFileName) const } // preprend a backslash if there is none - String strFileName = string_makelower(szFileName); + String strFileName = strutils::makelower(szFileName); if (strFileName.empty() || strFileName[0] != '\\') strFileName = _T("\\") + strFileName; // append a point if there is no extension @@ -301,14 +301,14 @@ String FileFilterHelper::ParseExtensions(const String &extensions) const { bFilterAdded = true; String strRegex = token; - string_replace(strRegex, _T("."), _T("\\.")); - string_replace(strRegex, _T("?"), _T(".")); - string_replace(strRegex, _T("("), _T("\\(")); - string_replace(strRegex, _T(")"), _T("\\)")); - string_replace(strRegex, _T("["), _T("\\[")); - string_replace(strRegex, _T("]"), _T("\\]")); - string_replace(strRegex, _T("$"), _T("\\$")); - string_replace(strRegex, _T("*"), _T(".*")); + strutils::replace(strRegex, _T("."), _T("\\.")); + strutils::replace(strRegex, _T("?"), _T(".")); + strutils::replace(strRegex, _T("("), _T("\\(")); + strutils::replace(strRegex, _T(")"), _T("\\)")); + strutils::replace(strRegex, _T("["), _T("\\[")); + strutils::replace(strRegex, _T("]"), _T("\\]")); + strutils::replace(strRegex, _T("$"), _T("\\$")); + strutils::replace(strRegex, _T("*"), _T(".*")); strRegex += _T("$"); strPattern += _T("(^|\\\\)") + strRegex; } @@ -325,7 +325,7 @@ String FileFilterHelper::ParseExtensions(const String &extensions) const else { - strPattern = string_makelower(strPattern); + strPattern = strutils::makelower(strPattern); strParsed = strPattern; //+ _T("$"); } return strParsed; @@ -378,7 +378,7 @@ bool FileFilterHelper::SetFilter(const String &filter) } // Remove leading and trailing whitespace characters from the string. - String flt = string_trim_ws(filter); + String flt = strutils::trim_ws(filter); // Star means we have a file extension mask if (filter.find_first_of(_T("*?")) != -1) @@ -459,7 +459,7 @@ void FileFilterHelper::LoadAllFileFilters() String pattern(_T("*")); pattern += FileFilterExt; LoadFileFilterDirPattern(m_sGlobalFilterPath, pattern); - if (string_compare_nocase(m_sGlobalFilterPath, m_sUserSelFilterPath) != 0) + if (strutils::compare_nocase(m_sGlobalFilterPath, m_sUserSelFilterPath) != 0) LoadFileFilterDirPattern(m_sUserSelFilterPath, pattern); } diff --git a/Src/FileFilterMgr.cpp b/Src/FileFilterMgr.cpp index 6a879f6cf..5cabee1f5 100644 --- a/Src/FileFilterMgr.cpp +++ b/Src/FileFilterMgr.cpp @@ -113,7 +113,7 @@ void FileFilterMgr::RemoveFilter(const String& szFilterFile) vector::iterator iter = m_filters.begin(); while (iter != m_filters.end()) { - if (string_compare_nocase((*iter)->fullpath, szFilterFile) == 0) + if (strutils::compare_nocase((*iter)->fullpath, szFilterFile) == 0) { m_filters.erase(iter); break; @@ -139,7 +139,7 @@ void FileFilterMgr::DeleteAllFilters() static void AddFilterPattern(vector *filterList, String & str) { const String& commentLeader = _T("##"); // Starts comment - str = string_trim_ws_begin(str); + str = strutils::trim_ws_begin(str); // Ignore lines beginning with '##' size_t pos = str.find(commentLeader); @@ -153,7 +153,7 @@ static void AddFilterPattern(vector *filterList, String & // Remove comment and whitespaces before it if (pos != std::string::npos) str = str.substr(0, pos); - str = string_trim_ws_end(str); + str = strutils::trim_ws_end(str); if (str.empty()) return; @@ -203,13 +203,13 @@ FileFilter * FileFilterMgr::LoadFilterFile(const String& szFilepath, int & error String tmpLine; bLinesLeft = file.ReadString(tmpLine, &lossy); sLine = tmpLine; - sLine = string_trim_ws(sLine); + sLine = strutils::trim_ws(sLine); if (0 == sLine.compare(0, 5, _T("name:"), 5)) { // specifies display name String str = sLine.substr(5); - str = string_trim_ws_begin(str); + str = strutils::trim_ws_begin(str); if (!str.empty()) pfilter->name = str; } @@ -217,7 +217,7 @@ FileFilter * FileFilterMgr::LoadFilterFile(const String& szFilepath, int & error { // specifies display name String str = sLine.substr(5); - str = string_trim_ws_begin(str); + str = strutils::trim_ws_begin(str); if (!str.empty()) pfilter->description = str; } @@ -225,7 +225,7 @@ FileFilter * FileFilterMgr::LoadFilterFile(const String& szFilepath, int & error { // specifies default String str = sLine.substr(4); - str = string_trim_ws_begin(str); + str = strutils::trim_ws_begin(str); if (str == _T("0") || str == _T("no") || str == _T("exclude")) pfilter->default_include = false; else if (str == _T("1") || str == _T("yes") || str == _T("include")) @@ -260,7 +260,7 @@ FileFilter * FileFilterMgr::GetFilterByPath(const String& szFilterPath) vector::const_iterator iter = m_filters.begin(); while (iter != m_filters.end()) { - if (string_compare_nocase((*iter)->fullpath, szFilterPath) == 0) + if (strutils::compare_nocase((*iter)->fullpath, szFilterPath) == 0) return (*iter).get(); ++iter; } diff --git a/Src/FileFiltersDlg.cpp b/Src/FileFiltersDlg.cpp index 130cd31a9..145259c2b 100644 --- a/Src/FileFiltersDlg.cpp +++ b/Src/FileFiltersDlg.cpp @@ -182,7 +182,7 @@ BOOL FileFiltersDlg::OnInitDialog() for (int i = 0; i < count; i++) { String desc = m_listFilters.GetItemText(i, 2); - if (string_compare_nocase(desc, m_sFileFilterPath) == 0) + if (strutils::compare_nocase(desc, m_sFileFilterPath) == 0) { SelectFilterByIndex(i); } @@ -275,7 +275,7 @@ bool FileFiltersDlg::IsFilterItemNone(int item) const String txtNone = _(""); String txt = m_listFilters.GetItemText(item, 0); - return (string_compare_nocase(txt, txtNone) == 0); + return (strutils::compare_nocase(txt, txtNone) == 0); } /** @@ -295,7 +295,7 @@ void FileFiltersDlg::OnLvnItemchangedFilterfileList(NMHDR *pNMHDR, LRESULT *pRes String txtNone = _(""); String txt = m_listFilters.GetItemText(pNMLV->iItem, 0); - bool isNone = string_compare_nocase(txt, txtNone) == 0; + bool isNone = strutils::compare_nocase(txt, txtNone) == 0; EnableDlgItem(IDC_FILTERFILE_TEST_BTN, !isNone); EnableDlgItem(IDC_FILTERFILE_EDITBTN, !isNone); @@ -402,7 +402,7 @@ void FileFiltersDlg::OnBnClickedFilterfileNewbutton() if (paths::DoesPathExist(templatePath) != paths::IS_EXISTING_FILE) { - String msg = string_format_string2( + String msg = strutils::format_string2( _("Cannot find file filter template file!\n\nPlease copy file %1 to WinMerge/Filters -folder:\n%2."), FILE_FILTER_TEMPLATE, templatePath); AfxMessageBox(msg.c_str(), MB_ICONERROR); @@ -451,7 +451,7 @@ void FileFiltersDlg::OnBnClickedFilterfileNewbutton() // user has already allowed it. if (!CopyFile(templatePath.c_str(), s.c_str(), FALSE)) { - String msg = string_format_string1( + String msg = strutils::format_string1( _( "Cannot copy filter template file to filter folder:\n%1\n\nPlease make sure the folder exists and is writable."), templatePath); AfxMessageBox(msg.c_str(), MB_ICONERROR); @@ -488,7 +488,7 @@ void FileFiltersDlg::OnBnClickedFilterfileDelete() { path = m_listFilters.GetItemText(sel, 2); - String sConfirm = string_format_string1(_("Are you sure you want to delete\n\n%1 ?"), path); + String sConfirm = strutils::format_string1(_("Are you sure you want to delete\n\n%1 ?"), path); int res = AfxMessageBox(sConfirm.c_str(), MB_ICONWARNING | MB_YESNO); if (res == IDYES) { @@ -506,7 +506,7 @@ void FileFiltersDlg::OnBnClickedFilterfileDelete() } else { - String msg = string_format_string1( + String msg = strutils::format_string1( _("Failed to delete the filter file:\n%1\n\nMaybe the file is read-only?"), path); AfxMessageBox(msg.c_str(), MB_ICONSTOP); diff --git a/Src/FileTextEncoding.cpp b/Src/FileTextEncoding.cpp index 33f86be71..cbc046276 100644 --- a/Src/FileTextEncoding.cpp +++ b/Src/FileTextEncoding.cpp @@ -100,7 +100,7 @@ String FileTextEncoding::GetName() const return _T("UTF-8"); } - return string_to_str(m_codepage); + return strutils::to_str(m_codepage); } int FileTextEncoding::Collate(const FileTextEncoding & fte1, const FileTextEncoding & fte2) diff --git a/Src/FileVersion.cpp b/Src/FileVersion.cpp index c4d3fbbee..9177d167f 100644 --- a/Src/FileVersion.cpp +++ b/Src/FileVersion.cpp @@ -50,7 +50,7 @@ String FileVersion::GetFileVersionString() const if (m_fileVersionMS == 0xffffffff && m_fileVersionLS >= 0xfffffffe) return _T(""); - return string_format(_T("%u.%u.%u.%u"), HIWORD(m_fileVersionMS), + return strutils::format(_T("%u.%u.%u.%u"), HIWORD(m_fileVersionMS), LOWORD(m_fileVersionMS), HIWORD(m_fileVersionLS), LOWORD(m_fileVersionLS)); } diff --git a/Src/FilterCommentsManager.cpp b/Src/FilterCommentsManager.cpp index 090b7b37c..d1e597177 100644 --- a/Src/FilterCommentsManager.cpp +++ b/Src/FilterCommentsManager.cpp @@ -59,7 +59,7 @@ void FilterCommentsManager::Load() for(SectionNo = 0;;++SectionNo) {//Get each set of markers FilterCommentsSet filtercommentsset; - std::string SectionName = "set" + ucr::toUTF8(string_to_str(SectionNo)); + std::string SectionName = "set" + ucr::toUTF8(strutils::to_str(SectionNo)); filtercommentsset.StartMarker = pConf->getString(SectionName + ".StartMarker", ""); filtercommentsset.EndMarker = pConf->getString(SectionName + ".EndMarker", ""); filtercommentsset.InlineMarker = pConf->getString(SectionName + ".InlineMarker", ""); @@ -72,7 +72,7 @@ void FilterCommentsManager::Load() int FileTypeNo = 0; for(FileTypeNo = 0;;++FileTypeNo) {//Get each file type associated with current set of markers - std::string FileTypeFieldName = ".FileType" + ucr::toUTF8(string_to_str(FileTypeNo)); + std::string FileTypeFieldName = ".FileType" + ucr::toUTF8(strutils::to_str(FileTypeNo)); std::string FileTypeExtensionName = pConf->getString(SectionName + FileTypeFieldName, ""); if (FileTypeExtensionName.empty()) break; diff --git a/Src/FolderCmp.cpp b/Src/FolderCmp.cpp index 569891f91..8a33a26a6 100644 --- a/Src/FolderCmp.cpp +++ b/Src/FolderCmp.cpp @@ -90,7 +90,7 @@ int FolderCmp::prepAndCompareFiles(CDiffContext * pCtxt, DIFFITEM &di) // Transformation happens here // text used for automatic mode : plugin filter must match it - String filteredFilenames = string_join(files.begin(), files.end(), _T("|")); + String filteredFilenames = strutils::join(files.begin(), files.end(), _T("|")); PackingInfo * infoUnpacker=0; PrediffingInfo * infoPrediffer=0; @@ -110,7 +110,7 @@ int FolderCmp::prepAndCompareFiles(CDiffContext * pCtxt, DIFFITEM &di) //DiffFileData diffdata; //(filepathTransformed1, filepathTransformed2); // Invoke unpacking plugins - if (infoUnpacker && string_compare_nocase(filepathUnpacked[nIndex], _T("NUL")) != 0) + if (infoUnpacker && strutils::compare_nocase(filepathUnpacked[nIndex], _T("NUL")) != 0) { if (!FileTransform_Unpacking(infoUnpacker, filepathUnpacked[nIndex], filteredFilenames)) goto exitPrepAndCompare; @@ -362,17 +362,17 @@ exitPrepAndCompare: // delete the temp files after comparison if (filepathTransformed[0] != filepathUnpacked[0]) - try { TFile(filepathTransformed[0]).remove(); } catch (...) { LogErrorString(string_format(_T("DeleteFile(%s) failed"), filepathTransformed[0].c_str())); } + try { TFile(filepathTransformed[0]).remove(); } catch (...) { LogErrorString(strutils::format(_T("DeleteFile(%s) failed"), filepathTransformed[0].c_str())); } if (filepathTransformed[1] != filepathUnpacked[1]) - try { TFile(filepathTransformed[1]).remove(); } catch (...) { LogErrorString(string_format(_T("DeleteFile(%s) failed"), filepathTransformed[1].c_str())); } + try { TFile(filepathTransformed[1]).remove(); } catch (...) { LogErrorString(strutils::format(_T("DeleteFile(%s) failed"), filepathTransformed[1].c_str())); } if (nDirs > 2 && filepathTransformed[2] != filepathUnpacked[2]) - try { TFile(filepathTransformed[2]).remove(); } catch (...) { LogErrorString(string_format(_T("DeleteFile(%s) failed"), filepathTransformed[2].c_str())); } + try { TFile(filepathTransformed[2]).remove(); } catch (...) { LogErrorString(strutils::format(_T("DeleteFile(%s) failed"), filepathTransformed[2].c_str())); } if (filepathUnpacked[0] != files[0]) - try { TFile(filepathUnpacked[0]).remove(); } catch (...) { LogErrorString(string_format(_T("DeleteFile(%s) failed"), filepathUnpacked[0].c_str())); } + try { TFile(filepathUnpacked[0]).remove(); } catch (...) { LogErrorString(strutils::format(_T("DeleteFile(%s) failed"), filepathUnpacked[0].c_str())); } if (filepathUnpacked[1] != files[1]) - try { TFile(filepathUnpacked[1]).remove(); } catch (...) { LogErrorString(string_format(_T("DeleteFile(%s) failed"), filepathUnpacked[1].c_str())); } + try { TFile(filepathUnpacked[1]).remove(); } catch (...) { LogErrorString(strutils::format(_T("DeleteFile(%s) failed"), filepathUnpacked[1].c_str())); } if (nDirs > 2 && filepathUnpacked[2] != files[2]) - try { TFile(filepathUnpacked[2]).remove(); } catch (...) { LogErrorString(string_format(_T("DeleteFile(%s) failed"), filepathUnpacked[2].c_str())); } + try { TFile(filepathUnpacked[2]).remove(); } catch (...) { LogErrorString(strutils::format(_T("DeleteFile(%s) failed"), filepathUnpacked[2].c_str())); } if (!pCtxt->m_bIgnoreCodepage && (code & DIFFCODE::COMPAREFLAGS) == DIFFCODE::SAME && diff --git a/Src/HexMergeDoc.cpp b/Src/HexMergeDoc.cpp index 3fe6c0222..cea992956 100644 --- a/Src/HexMergeDoc.cpp +++ b/Src/HexMergeDoc.cpp @@ -564,7 +564,7 @@ void CHexMergeDoc::CheckFileChanged(void) { if (m_pView[pane]->IsFileChangedOnDisk(m_filePaths[pane].c_str())) { - String msg = string_format_string1(_("Another application has updated file\n%1\nsince WinMerge scanned it last time.\n\nDo you want to reload the file?"), m_filePaths[pane]); + String msg = strutils::format_string1(_("Another application has updated file\n%1\nsince WinMerge scanned it last time.\n\nDo you want to reload the file?"), m_filePaths[pane]); if (AfxMessageBox(msg.c_str(), MB_YESNO | MB_ICONWARNING) == IDYES) { OnFileReload(); @@ -668,9 +668,9 @@ void CHexMergeDoc::SetTitle(LPCTSTR lpszTitle) for (int nBuffer = 0; nBuffer < m_filePaths.GetSize(); nBuffer++) sFileName[nBuffer] = !m_strDesc[nBuffer].empty() ? m_strDesc[nBuffer] : paths::FindFileName(m_filePaths[nBuffer]); if (std::count(&sFileName[0], &sFileName[0] + m_nBuffers, sFileName[0]) == m_nBuffers) - sTitle = sFileName[0] + string_format(_T(" x %d"), m_nBuffers); + sTitle = sFileName[0] + strutils::format(_T(" x %d"), m_nBuffers); else - sTitle = string_join(&sFileName[0], &sFileName[0] + m_nBuffers, _T(" - ")); + sTitle = strutils::join(&sFileName[0], &sFileName[0] + m_nBuffers, _T(" - ")); } CDocument::SetTitle(sTitle.c_str()); } diff --git a/Src/HexMergeView.cpp b/Src/HexMergeView.cpp index c741062dc..8de265493 100644 --- a/Src/HexMergeView.cpp +++ b/Src/HexMergeView.cpp @@ -297,7 +297,7 @@ HRESULT CHexMergeView::SaveFile(LPCTSTR path) // Warn user in case file has been changed by someone else if (IsFileChangedOnDisk(path)) { - String msg = string_format_string1(_("Another application has updated file\n%1\nsince WinMerge loaded it.\n\nOverwrite changed file?"), path); + String msg = strutils::format_string1(_("Another application has updated file\n%1\nsince WinMerge loaded it.\n\nOverwrite changed file?"), path); if (AfxMessageBox(msg.c_str(), MB_ICONWARNING | MB_YESNO) == IDNO) return S_OK; } @@ -340,7 +340,7 @@ HRESULT CHexMergeView::SaveFile(LPCTSTR path) hr = SE(DeleteFile(sIntermediateFilename.c_str())); if (hr != S_OK) { - LogErrorString(string_format(_T("DeleteFile(%s) failed: %s"), + LogErrorString(strutils::format(_T("DeleteFile(%s) failed: %s"), sIntermediateFilename.c_str(), GetSysError(hr).c_str())); } return S_OK; diff --git a/Src/ImgMergeFrm.cpp b/Src/ImgMergeFrm.cpp index 80affb5f2..85a39d7b1 100644 --- a/Src/ImgMergeFrm.cpp +++ b/Src/ImgMergeFrm.cpp @@ -281,10 +281,10 @@ void CImgMergeFrame::DoAutoMerge(int dstPane) m_pImgMergeWindow->FirstConflict(); AfxMessageBox( - string_format_string2( + strutils::format_string2( _T("The number of automatically merged changes: %1\nThe number of unresolved conflicts: %2"), - string_format(_T("%d"), autoMergedCount), - string_format(_T("%d"), m_pImgMergeWindow->GetConflictCount())).c_str(), + strutils::format(_T("%d"), autoMergedCount), + strutils::format(_T("%d"), m_pImgMergeWindow->GetConflictCount())).c_str(), MB_ICONINFORMATION); } @@ -317,7 +317,7 @@ void CImgMergeFrame::CheckFileChanged(void) { if (IsFileChangedOnDisk(pane)) { - String msg = string_format_string1(_("Another application has updated file\n%1\nsince WinMerge scanned it last time.\n\nDo you want to reload the file?"), m_filePaths[pane]); + String msg = strutils::format_string1(_("Another application has updated file\n%1\nsince WinMerge scanned it last time.\n\nDo you want to reload the file?"), m_filePaths[pane]); if (AfxMessageBox(msg.c_str(), MB_YESNO | MB_ICONWARNING) == IDYES) { OnFileReload(); @@ -947,9 +947,9 @@ void CImgMergeFrame::SetTitle(LPCTSTR lpszTitle) } const int nBuffers = m_filePaths.GetSize(); if (std::count(&sFileName[0], &sFileName[0] + nBuffers, sFileName[0]) == nBuffers) - sTitle = sFileName[0] + string_format(_T(" x %d"), nBuffers); + sTitle = sFileName[0] + strutils::format(_T(" x %d"), nBuffers); else - sTitle = string_join(&sFileName[0], &sFileName[0] + nBuffers, _T(" - ")); + sTitle = strutils::join(&sFileName[0], &sFileName[0] + nBuffers, _T(" - ")); } CMDIChildWnd::SetTitle(sTitle.c_str()); if (m_hWnd) @@ -1278,15 +1278,15 @@ void CImgMergeFrame::OnIdleUpdateCmdUI() pt.y < m_pImgMergeWindow->GetImageHeight(pane)) { POINT ptOffset = m_pImgMergeWindow->GetImageOffset(pane); - text += string_format(_T("Pt:(%d,%d) RGBA:(%d,%d,%d,%d) "), pt.x - ptOffset.x, pt.y - ptOffset.y, + text += strutils::format(_T("Pt:(%d,%d) RGBA:(%d,%d,%d,%d) "), pt.x - ptOffset.x, pt.y - ptOffset.y, color[pane].rgbRed, color[pane].rgbGreen, color[pane].rgbBlue, color[pane].rgbReserved); if (pane == 1 && m_pImgMergeWindow->GetPaneCount() == 3) - text += string_format(_T("Dist:%g,%g "), colorDistance01, colorDistance12); + text += strutils::format(_T("Dist:%g,%g "), colorDistance01, colorDistance12); else - text += string_format(_T("Dist:%g "), colorDistance01); + text += strutils::format(_T("Dist:%g "), colorDistance01); } - text += string_format(_T("Page:%d/%d Zoom:%d%% %dx%dpx %dbpp"), + text += strutils::format(_T("Page:%d/%d Zoom:%d%% %dx%dpx %dbpp"), m_pImgMergeWindow->GetCurrentPage(pane) + 1, m_pImgMergeWindow->GetPageCount(pane), static_cast(m_pImgMergeWindow->GetZoom() * 100), @@ -1325,7 +1325,7 @@ void CImgMergeFrame::OnUpdateStatusNum(CCmdUI* pCmdUI) else if (m_pImgMergeWindow->GetCurrentDiffIndex() < 0) { s = theApp.LoadString(nDiffs == 1 ? IDS_1_DIFF_FOUND : IDS_NO_DIFF_SEL_FMT); - string_replace(s, _T("%1"), _itot(nDiffs, sCnt, 10)); + strutils::replace(s, _T("%1"), _itot(nDiffs, sCnt, 10)); } // There are differences and diff selected @@ -1334,8 +1334,8 @@ void CImgMergeFrame::OnUpdateStatusNum(CCmdUI* pCmdUI) { s = theApp.LoadString(IDS_DIFF_NUMBER_STATUS_FMT); const int signInd = m_pImgMergeWindow->GetCurrentDiffIndex(); - string_replace(s, _T("%1"), _itot(signInd + 1, sIdx, 10)); - string_replace(s, _T("%2"), _itot(nDiffs, sCnt, 10)); + strutils::replace(s, _T("%1"), _itot(signInd + 1, sIdx, 10)); + strutils::replace(s, _T("%2"), _itot(nDiffs, sCnt, 10)); } pCmdUI->SetText(s.c_str()); } @@ -1891,15 +1891,15 @@ bool CImgMergeFrame::GenerateReport(const String& sFileName) const for (int i = 0; i < m_pImgMergeWindow->GetPaneCount(); ++i) { imgfilepath[i] = ucr::toTString(m_pImgMergeWindow->GetFileName(i)); - diffimg_filename[i] = string_format(_T("%s/%d.png"), imgdir.c_str(), i + 1); - m_pImgMergeWindow->SaveDiffImageAs(i, ucr::toUTF16(string_format(_T("%s\\%d.png"), imgdir_full.c_str(), i + 1)).c_str()); + diffimg_filename[i] = strutils::format(_T("%s/%d.png"), imgdir.c_str(), i + 1); + m_pImgMergeWindow->SaveDiffImageAs(i, ucr::toUTF16(strutils::format(_T("%s\\%d.png"), imgdir_full.c_str(), i + 1)).c_str()); } UniStdioFile file; if (!file.Open(sFileName, _T("wt"))) { String errMsg = GetSysError(GetLastError()); - String msg = string_format_string1( + String msg = strutils::format_string1( _("Error creating the report:\n%1"), errMsg); AfxMessageBox(msg.c_str(), MB_OK | MB_ICONSTOP); return false; @@ -1926,13 +1926,13 @@ bool CImgMergeFrame::GenerateReport(const String& sFileName) const _T("\n") _T("\n")); for (int i = 0; i < m_pImgMergeWindow->GetPaneCount(); ++i) - file.WriteString(string_format(_T("\n"), imgfilepath[i].c_str())); + file.WriteString(strutils::format(_T("\n"), imgfilepath[i].c_str())); file.WriteString( _T("\n") _T("\n")); for (int i = 0; i < m_pImgMergeWindow->GetPaneCount(); ++i) file.WriteString( - string_format(_T("\n"), + strutils::format(_T("\n"), diffimg_filename[i].c_str(), diffimg_filename[i].c_str())); file.WriteString( _T("\n") diff --git a/Src/LineFiltersList.cpp b/Src/LineFiltersList.cpp index 49f1dbd08..081fe3ec2 100644 --- a/Src/LineFiltersList.cpp +++ b/Src/LineFiltersList.cpp @@ -159,11 +159,11 @@ void LineFiltersList::Initialize(COptionsMgr *pOptionsMgr) for (unsigned i = 0; i < count; i++) { - String name = string_format(_T("%s/Filter%02u"), FiltersRegPath, i); + String name = strutils::format(_T("%s/Filter%02u"), FiltersRegPath, i); m_pOptionsMgr->InitOption(name, _T("")); String filter = m_pOptionsMgr->GetString(name); - name = string_format(_T("%s/Enabled%02u"), FiltersRegPath, i); + name = strutils::format(_T("%s/Enabled%02u"), FiltersRegPath, i); m_pOptionsMgr->InitOption(name, (int)true); int enabled = m_pOptionsMgr->GetInt(name); bool bEnabled = enabled ? true : false; @@ -188,29 +188,29 @@ void LineFiltersList::SaveFilters() { const LineFilterItemPtr& item = m_items[i]; - String name = string_format(_T("%s/Filter%02u"), FiltersRegPath, i); + String name = strutils::format(_T("%s/Filter%02u"), FiltersRegPath, i); m_pOptionsMgr->InitOption(name, _T("")); m_pOptionsMgr->SaveOption(name, item->filterStr); - name = string_format(_T("%s/Enabled%02u"), FiltersRegPath, i); + name = strutils::format(_T("%s/Enabled%02u"), FiltersRegPath, i); m_pOptionsMgr->InitOption(name, 0); m_pOptionsMgr->SaveOption(name, (int)item->enabled); } // Remove options we don't need anymore // We could have earlier 10 pcs but now we only need 5 - String filter = string_format(_T("%s/Filter%02u"), FiltersRegPath, count); + String filter = strutils::format(_T("%s/Filter%02u"), FiltersRegPath, count); int retval1 = m_pOptionsMgr->RemoveOption(filter); - filter = string_format(_T("%s/Enabled%02u"), FiltersRegPath, count); + filter = strutils::format(_T("%s/Enabled%02u"), FiltersRegPath, count); int retval2 = m_pOptionsMgr->RemoveOption(filter); while (retval1 == COption::OPT_OK || retval2 == COption::OPT_OK) { ++count; - filter = string_format(_T("%s/Filter%02u"), FiltersRegPath, count); + filter = strutils::format(_T("%s/Filter%02u"), FiltersRegPath, count); retval1 = m_pOptionsMgr->RemoveOption(filter); - filter = string_format(_T("%s/Enabled%02u"), FiltersRegPath, count); + filter = strutils::format(_T("%s/Enabled%02u"), FiltersRegPath, count); retval2 = m_pOptionsMgr->RemoveOption(filter); } } diff --git a/Src/LoadSaveCodepageDlg.cpp b/Src/LoadSaveCodepageDlg.cpp index cd3afd6e3..25117f712 100644 --- a/Src/LoadSaveCodepageDlg.cpp +++ b/Src/LoadSaveCodepageDlg.cpp @@ -88,7 +88,7 @@ BOOL CLoadSaveCodepageDlg::OnInitDialog() std::vector cpi = pexconv->enumCodePages(); for (size_t i = 0, j = 0; i < cpi.size(); i++) { - String desc = string_format(_T("%05d - %s"), cpi[i].codepage, cpi[i].desc.c_str()); + String desc = strutils::format(_T("%05d - %s"), cpi[i].codepage, cpi[i].desc.c_str()); combol.AddString(desc.c_str()); combos.AddString(desc.c_str()); if (cpi[i].codepage == m_nLoadCodepage) diff --git a/Src/LocationView.cpp b/Src/LocationView.cpp index 5ef315b52..b4fd090df 100644 --- a/Src/LocationView.cpp +++ b/Src/LocationView.cpp @@ -809,11 +809,11 @@ void CLocationView::OnContextMenu(CWnd* pWnd, CPoint point) if (bar == BAR_YAREA) bar = BAR_0; nLine = GetLineFromYPos(pt.y, bar); - strNum = string_to_str(nLine + 1); // Show linenumber not lineindex + strNum = strutils::to_str(nLine + 1); // Show linenumber not lineindex } else pPopup->EnableMenuItem(ID_LOCBAR_GOTODIFF, MF_GRAYED); - strItem = string_format_string1(_("G&oto Line %1"), strNum); + strItem = strutils::format_string1(_("G&oto Line %1"), strNum); pPopup->SetMenuText(ID_LOCBAR_GOTODIFF, strItem.c_str(), MF_BYCOMMAND); // invoke context menu diff --git a/Src/MainFrm.cpp b/Src/MainFrm.cpp index 709e28982..e926a4abd 100644 --- a/Src/MainFrm.cpp +++ b/Src/MainFrm.cpp @@ -1023,7 +1023,7 @@ BOOL CMainFrame::DoFileOpen(const PathContext * pFiles /*=NULL*/, if (!prediffer.empty()) { - String strBothFilenames = string_join(files.begin(), files.end(), _T("|")); + String strBothFilenames = strutils::join(files.begin(), files.end(), _T("|")); pDirDoc->GetPluginManager().SetPrediffer(strBothFilenames, prediffer); } @@ -1287,13 +1287,13 @@ void CMainFrame::addToMru(LPCTSTR szItem, LPCTSTR szRegSubKey, UINT nMaxItems) list.push_back(szItem); for (UINT i=0 ; iGetProfileString(szRegSubKey, string_format(_T("Item_%d"), i).c_str()); + s = AfxGetApp()->GetProfileString(szRegSubKey, strutils::format(_T("Item_%d"), i).c_str()); if (s != szItem) list.push_back(s); } cnt = list.size() > nMaxItems ? nMaxItems : static_cast(list.size()); for (UINT i=0 ; iWriteProfileString(szRegSubKey, string_format(_T("Item_%d"), i).c_str(), list[i]); + AfxGetApp()->WriteProfileString(szRegSubKey, strutils::format(_T("Item_%d"), i).c_str(), list[i]); // update count AfxGetApp()->WriteProfileInt(szRegSubKey, _T("Count"), cnt); } @@ -1538,7 +1538,7 @@ void CMainFrame::OnSaveConfigData() else { String sFileName = configLog.GetFileName(); - String msg = string_format_string2(_("Cannot open file\n%1\n\n%2"), sFileName, sError); + String msg = strutils::format_string2(_("Cannot open file\n%1\n\n%2"), sFileName, sError); AfxMessageBox(msg.c_str(), MB_OK | MB_ICONSTOP); } } @@ -2214,14 +2214,14 @@ void CMainFrame::OnHelpCheckForUpdates() file->Read(buf, sizeof(buf)); file->Close(); String current_version = ucr::toTString(buf); - string_replace(current_version, _T("\r\n"), _T("")); + strutils::replace(current_version, _T("\r\n"), _T("")); delete file; int exe_vers[4] = { 0 }, cur_vers[4] = { 0 }; _stscanf(version.GetProductVersion().c_str(), _T("%d.%d.%d.%d"), &exe_vers[0], &exe_vers[1], &exe_vers[2], &exe_vers[3]); _stscanf(current_version.c_str(), _T("%d.%d.%d.%d"), &cur_vers[0], &cur_vers[1], &cur_vers[2], &cur_vers[3]); - String exe_version_hex = string_format(_T("%08x%08x%08x%08x"), exe_vers[0], exe_vers[1], exe_vers[2], exe_vers[3]); - String cur_version_hex = string_format(_T("%08x%08x%08x%08x"), cur_vers[0], cur_vers[1], cur_vers[2], cur_vers[3]); + String exe_version_hex = strutils::format(_T("%08x%08x%08x%08x"), exe_vers[0], exe_vers[1], exe_vers[2], exe_vers[3]); + String cur_version_hex = strutils::format(_T("%08x%08x%08x%08x"), cur_vers[0], cur_vers[1], cur_vers[2], cur_vers[3]); switch (exe_version_hex.compare(cur_version_hex)) { @@ -2241,7 +2241,7 @@ void CMainFrame::OnHelpCheckForUpdates() } case -1: { - String msg = string_format_string2(_("A new version of WinMerge is available.\n%1 is now available (you have %2). Would you like to download it now?"), current_version, version.GetProductVersion()); + String msg = strutils::format_string2(_("A new version of WinMerge is available.\n%1 is now available (you have %2). Would you like to download it now?"), current_version, version.GetProductVersion()); if (AfxMessageBox(msg.c_str(), MB_ICONINFORMATION | MB_YESNO) == IDYES) ShellExecute(NULL, _T("open"), GetOptionsMgr()->GetString(OPT_DOWNLOAD_URL).c_str(), NULL, NULL, SW_SHOWNORMAL); break; @@ -2296,7 +2296,7 @@ BOOL CMainFrame::DoOpenConflict(const String& conflictFile, bool checked) bool confFile = IsConflictFile(conflictFile); if (!confFile) { - String message = string_format_string1(_("The file\n%1\nis not a conflict file."), conflictFile); + String message = strutils::format_string1(_("The file\n%1\nis not a conflict file."), conflictFile); AfxMessageBox(message.c_str(), MB_ICONSTOP); return FALSE; } @@ -2481,7 +2481,7 @@ void CMainFrame::OnUpdateNoMRUs(CCmdUI* pCmdUI) int ID = ID_MRU_FIRST; // first ID in menu for (i = 0 ; i < mrus.size() ; i++, ID++) ::AppendMenu(hMenu, MF_STRING, ID, - ((i < 9 ? string_format(_T("&%d "), i+1) : string_format(_T("&%c "), 'a' + i - 9)) + ((i < 9 ? strutils::format(_T("&%d "), i+1) : strutils::format(_T("&%c "), 'a' + i - 9)) + mrus[i].title).c_str()); } diff --git a/Src/Merge.cpp b/Src/Merge.cpp index a00f5253d..51f340df7 100644 --- a/Src/Merge.cpp +++ b/Src/Merge.cpp @@ -774,13 +774,13 @@ void CMergeApp::OpenFileToExternalEditor(const String& file, int nLineNumber/* = { String sCmd = GetOptionsMgr()->GetString(OPT_EXT_EDITOR_CMD); String sFile(file); - string_replace(sCmd, _T("$linenum"), string_to_str(nLineNumber)); + strutils::replace(sCmd, _T("$linenum"), strutils::to_str(nLineNumber)); size_t nIndex = sCmd.find(_T("$file")); if (nIndex != String::npos) { sFile.insert(0, _T("\"")); - string_replace(sCmd, _T("$file"), sFile); + strutils::replace(sCmd, _T("$file"), sFile); nIndex = sCmd.find(' ', nIndex + sFile.length()); if (nIndex != String::npos) sCmd.insert(nIndex, _T("\"")); @@ -805,7 +805,7 @@ void CMergeApp::OpenFileToExternalEditor(const String& file, int nLineNumber/* = if (!retVal) { // Error invoking external editor - String msg = string_format_string1(_("Failed to execute external editor: %1"), sCmd); + String msg = strutils::format_string1(_("Failed to execute external editor: %1"), sCmd); AfxMessageBox(msg.c_str(), MB_ICONSTOP); } else @@ -947,7 +947,7 @@ BOOL CMergeApp::CreateBackup(BOOL bFolder, const String& pszPath) if (!success) { - String msg = string_format_string1( + String msg = strutils::format_string1( _("Unable to backup original file:\n%1\n\nContinue anyway?"), pszPath); if (AfxMessageBox(msg.c_str(), MB_YESNO | MB_ICONWARNING | MB_DONT_ASK_AGAIN) != IDYES) @@ -1053,7 +1053,7 @@ int CMergeApp::HandleReadonlySave(String& strSavePath, BOOL bMultiFile, if (bMultiFile) { // Multiple files or folder - str = string_format_string1(_("%1\nis marked read-only. Would you like to override the read-only item?"), strSavePath); + str = strutils::format_string1(_("%1\nis marked read-only. Would you like to override the read-only item?"), strSavePath); userChoice = AfxMessageBox(str.c_str(), MB_YESNOCANCEL | MB_ICONWARNING | MB_DEFBUTTON3 | MB_DONT_ASK_AGAIN | MB_YES_TO_ALL, IDS_SAVEREADONLY_MULTI); @@ -1061,7 +1061,7 @@ int CMergeApp::HandleReadonlySave(String& strSavePath, BOOL bMultiFile, else { // Single file - str = string_format_string1(_("%1 is marked read-only. Would you like to override the read-only file ? (No to save as new filename.)"), strSavePath); + str = strutils::format_string1(_("%1 is marked read-only. Would you like to override the read-only file ? (No to save as new filename.)"), strSavePath); userChoice = AfxMessageBox(str.c_str(), MB_YESNOCANCEL | MB_ICONWARNING | MB_DEFBUTTON2 | MB_DONT_ASK_AGAIN, IDS_SAVEREADONLY_FMT); @@ -1145,7 +1145,7 @@ bool CMergeApp::IsProjectFile(const String& filepath) const { String ext; paths::SplitFilename(filepath, NULL, NULL, &ext); - if (string_compare_nocase(ext, ProjectFile::PROJECTFILE_EXT) == 0) + if (strutils::compare_nocase(ext, ProjectFile::PROJECTFILE_EXT) == 0) return true; else return false; @@ -1164,7 +1164,7 @@ bool CMergeApp::LoadProjectFile(const String& sProject, ProjectFile &project) { String sErr = _("Unknown error attempting to open project file"); sErr += ucr::toTString(e.displayText()); - String msg = string_format_string2(_("Cannot open file\n%1\n\n%2"), sProject, sErr); + String msg = strutils::format_string2(_("Cannot open file\n%1\n\n%2"), sProject, sErr); AfxMessageBox(msg.c_str(), MB_ICONSTOP); return false; } @@ -1182,7 +1182,7 @@ bool CMergeApp::SaveProjectFile(const String& sProject, const ProjectFile &proje { String sErr = _("Unknown error attempting to save project file"); sErr += ucr::toTString(e.displayText()); - String msg = string_format_string2(_("Cannot open file\n%1\n\n%2"), sProject, sErr); + String msg = strutils::format_string2(_("Cannot open file\n%1\n\n%2"), sProject, sErr); AfxMessageBox(msg.c_str(), MB_ICONSTOP); return false; } @@ -1213,7 +1213,7 @@ bool CMergeApp::LoadAndOpenProjectFile(const String& sProject, const String& sRe if (project.HasFilter()) { String filter = project.GetFilter(); - filter = string_trim_ws(filter); + filter = strutils::trim_ws(filter); m_pGlobalFileFilter->SetFilter(filter); } if (project.HasSubfolders()) diff --git a/Src/MergeApp.cpp b/Src/MergeApp.cpp index 2c7af3b2c..e60e4d3b9 100644 --- a/Src/MergeApp.cpp +++ b/Src/MergeApp.cpp @@ -141,10 +141,10 @@ int information(const String& msg, int type) AboutInfo::AboutInfo() { CVersionInfo verinfo; - version = string_format_string1(_("Version %1"), verinfo.GetProductVersion()); + version = strutils::format_string1(_("Version %1"), verinfo.GetProductVersion()); if (version.find(_T(" - ")) != String::npos) { - string_replace(version, _T(" - "), _T("\n")); + strutils::replace(version, _T(" - "), _T("\n")); version += _T(" "); } else @@ -173,11 +173,11 @@ AboutInfo::AboutInfo() private_build = verinfo.GetPrivateBuild(); if (!private_build.empty()) { - private_build = string_format_string1(_("Private Build: %1"), private_build); + private_build = strutils::format_string1(_("Private Build: %1"), private_build); } website = WinMergeURL; developers = _("Developers:\nDean Grimm, Christian List, Kimmo Varis, Jochen Tucht, Tim Gerundt, Takashi Sawanaki, Gal Hammer, Alexander Skinner"); - string_replace(developers, _T(", "), _T("\n")); + strutils::replace(developers, _T(", "), _T("\n")); } diff --git a/Src/MergeCmdLineInfo.cpp b/Src/MergeCmdLineInfo.cpp index d3d11094e..bb6601aa7 100644 --- a/Src/MergeCmdLineInfo.cpp +++ b/Src/MergeCmdLineInfo.cpp @@ -81,7 +81,7 @@ const TCHAR *MergeCmdLineInfo::EatParam(const TCHAR *p, String ¶m, bool *fla param.assign(p ? p : _T(""), q - p); if (q > p && flag) { - param = string_makelower(param); + param = strutils::makelower(param); } // Strip any leading or trailing whitespace or quotes param.erase(0, param.find_first_not_of(_T(" \t\r\n\""))); @@ -232,7 +232,7 @@ void MergeCmdLineInfo::AddPath(const String &path) { // Convert paths given in Linux-style ('/' as separator) given from // Cygwin to Windows style ('\' as separator) - string_replace(param, _T("/"), _T("\\")); + strutils::replace(param, _T("/"), _T("\\")); // If shortcut, expand it first if (paths::IsShortcut(param)) diff --git a/Src/MergeDoc.cpp b/Src/MergeDoc.cpp index 43bf3a53b..95c386362 100644 --- a/Src/MergeDoc.cpp +++ b/Src/MergeDoc.cpp @@ -389,7 +389,7 @@ int CMergeDoc::Rescan(bool &bBinary, IDENTLEVEL &identical, { if (FileChanged[nBuffer] == FileRemoved) { - String msg = string_format_string1(_("The file\n%1\nhas disappeared. Please save a copy of the file to continue."), m_filePaths[nBuffer]); + String msg = strutils::format_string1(_("The file\n%1\nhas disappeared. Please save a copy of the file to continue."), m_filePaths[nBuffer]); AfxMessageBox(msg.c_str(), MB_ICONWARNING); bool bSaveResult = false; bool ok = DoSaveAs(m_filePaths[nBuffer].c_str(), bSaveResult, nBuffer); @@ -607,7 +607,7 @@ void CMergeDoc::CheckFileChanged(void) { if (FileChange[nBuffer] == FileChanged) { - String msg = string_format_string1(_("Another application has updated file\n%1\nsince WinMerge scanned it last time.\n\nDo you want to reload the file?"), m_filePaths[nBuffer]); + String msg = strutils::format_string1(_("Another application has updated file\n%1\nsince WinMerge scanned it last time.\n\nDo you want to reload the file?"), m_filePaths[nBuffer]); if (AfxMessageBox(msg.c_str(), MB_YESNO | MB_ICONWARNING) == IDYES) { OnFileReload(); @@ -1019,10 +1019,10 @@ void CMergeDoc::DoAutoMerge(int dstPane) m_pView[dstPane]->SelectDiff(nDiff, true, false); AfxMessageBox( - string_format_string2( + strutils::format_string2( _T("The number of automatically merged changes: %1\nThe number of unresolved conflicts: %2"), - string_format(_T("%d"), autoMergedCount), - string_format(_T("%d"), unresolvedConflictCount)).c_str(), + strutils::format(_T("%d"), autoMergedCount), + strutils::format(_T("%d"), unresolvedConflictCount)).c_str(), MB_ICONINFORMATION); } @@ -1247,7 +1247,7 @@ bool CMergeDoc::TrySaveAs(String &strPath, int &nSaveResult, String & sError, { if (m_nBuffers == 3) { - str = string_format_string2( + str = strutils::format_string2( nBuffer == 0 ? _("Plugin '%2' cannot pack your changes to the left file back into '%1'.\n\nThe original file will not be changed.\n\nDo you want to save the unpacked version to another file?") : (nBuffer == 1 ? @@ -1257,7 +1257,7 @@ bool CMergeDoc::TrySaveAs(String &strPath, int &nSaveResult, String & sError, } else { - str = string_format_string2(nBuffer == 0 ? _("Plugin '%2' cannot pack your changes to the left file back into '%1'.\n\nThe original file will not be changed.\n\nDo you want to save the unpacked version to another file?") : + str = strutils::format_string2(nBuffer == 0 ? _("Plugin '%2' cannot pack your changes to the left file back into '%1'.\n\nThe original file will not be changed.\n\nDo you want to save the unpacked version to another file?") : _("Plugin '%2' cannot pack your changes to the right file back into '%1'.\n\nThe original file will not be changed.\n\nDo you want to save the unpacked version to another file?"), strPath, pInfoTempUnpacker->pluginName); } @@ -1266,7 +1266,7 @@ bool CMergeDoc::TrySaveAs(String &strPath, int &nSaveResult, String & sError, } else { - str = string_format_string2(_("Saving file failed.\n%1\n%2\nDo you want to:\n\t-use a different filename (Press Ok)\n\t-abort the current operation (Press Cancel)?"), strPath, sError); + str = strutils::format_string2(_("Saving file failed.\n%1\n%2\nDo you want to:\n\t-use a different filename (Press Ok)\n\t-abort the current operation (Press Cancel)?"), strPath, sError); } // SAVE_NO_FILENAME is temporarily used for scratchpad. @@ -1349,7 +1349,7 @@ bool CMergeDoc::DoSave(LPCTSTR szPath, bool &bSaveSuccess, int nBuffer) fileChanged = IsFileChangedOnDisk(szPath, fileInfo, true, nBuffer); if (fileChanged == FileChanged) { - String msg = string_format_string1(_("Another application has updated file\n%1\nsince WinMerge loaded it.\n\nOverwrite changed file?"), szPath); + String msg = strutils::format_string1(_("Another application has updated file\n%1\nsince WinMerge loaded it.\n\nOverwrite changed file?"), szPath); if (AfxMessageBox(msg.c_str(), MB_ICONWARNING | MB_YESNO) == IDNO) { bSaveSuccess = true; @@ -1823,7 +1823,7 @@ void CMergeDoc::OnUpdateStatusNum(CCmdUI* pCmdUI) else if (GetCurrentDiff() < 0) { s = nDiffs == 1 ? _("1 Difference Found") : _("%1 Differences Found"); - string_replace(s, _T("%1"), _itot(nDiffs, sCnt, 10)); + strutils::replace(s, _T("%1"), _itot(nDiffs, sCnt, 10)); } // There are differences and diff selected @@ -1832,8 +1832,8 @@ void CMergeDoc::OnUpdateStatusNum(CCmdUI* pCmdUI) { s = _("Difference %1 of %2"); const int signInd = m_diffList.GetSignificantIndex(GetCurrentDiff()); - string_replace(s, _T("%1"), _itot(signInd + 1, sIdx, 10)); - string_replace(s, _T("%2"), _itot(nDiffs, sCnt, 10)); + strutils::replace(s, _T("%1"), _itot(signInd + 1, sIdx, 10)); + strutils::replace(s, _T("%2"), _itot(nDiffs, sCnt, 10)); } pCmdUI->SetText(s.c_str()); } @@ -2400,14 +2400,14 @@ int CMergeDoc::LoadFile(CString sFileName, int nBuffer, bool & readOnly, const F { // Error from Unifile/system if (!sOpenError.IsEmpty()) - sError = string_format_string2(_("Cannot open file\n%1\n\n%2"), (LPCTSTR)sFileName, (LPCTSTR)sOpenError); + sError = strutils::format_string2(_("Cannot open file\n%1\n\n%2"), (LPCTSTR)sFileName, (LPCTSTR)sOpenError); else - sError = string_format_string1(_("File not found: %1"), (LPCTSTR)sFileName); + sError = strutils::format_string1(_("File not found: %1"), (LPCTSTR)sFileName); AfxMessageBox(sError.c_str(), MB_OK | MB_ICONSTOP | MB_MODELESS); } else if (FileLoadResult::IsErrorUnpack(retVal)) { - sError = string_format_string1(_("File not unpacked: %1"), (LPCTSTR)sFileName); + sError = strutils::format_string1(_("File not unpacked: %1"), (LPCTSTR)sFileName); AfxMessageBox(sError.c_str(), MB_OK | MB_ICONSTOP | MB_MODELESS); } return retVal; @@ -2904,9 +2904,9 @@ void CMergeDoc::SetTitle(LPCTSTR lpszTitle) for (int nBuffer = 0; nBuffer < m_nBuffers; nBuffer++) sFileName[nBuffer] = !m_strDesc[nBuffer].empty() ? m_strDesc[nBuffer] : paths::FindFileName(m_filePaths[nBuffer]); if (std::count(&sFileName[0], &sFileName[0] + m_nBuffers, sFileName[0]) == m_nBuffers) - sTitle = sFileName[0] + string_format(_T(" x %d"), m_nBuffers); + sTitle = sFileName[0] + strutils::format(_T(" x %d"), m_nBuffers); else - sTitle = string_join(&sFileName[0], &sFileName[0] + m_nBuffers, _T(" - ")); + sTitle = strutils::join(&sFileName[0], &sFileName[0] + m_nBuffers, _T(" - ")); } CDocument::SetTitle(sTitle.c_str()); } @@ -3167,7 +3167,7 @@ bool CMergeDoc::GenerateReport(const String& sFileName) const if (!file.Open(sFileName, _T("wt"))) { String errMsg = GetSysError(GetLastError()); - String msg = string_format_string1( + String msg = strutils::format_string1( _("Error creating the report:\n%1"), errMsg); AfxMessageBox(msg.c_str(), MB_OK | MB_ICONSTOP); return false; @@ -3176,7 +3176,7 @@ bool CMergeDoc::GenerateReport(const String& sFileName) const file.SetCodepage(ucr::CP_UTF_8); String header = - string_format( + strutils::format( _T("\n") _T("\n") @@ -3225,10 +3225,10 @@ bool CMergeDoc::GenerateReport(const String& sFileName) const for (nBuffer = 0; nBuffer < m_nBuffers; nBuffer++) { int nLineNumberColumnWidth = 1; - String data = string_format(_T(""), + String data = strutils::format(_T(""), nLineNumberColumnWidth); file.WriteString(data); - data = string_format(_T("
%s%s
\"%s\"
\"%s\"
"), + data = strutils::format(_T(""), (double)(100 - nLineNumberColumnWidth * m_nBuffers) / m_nBuffers); file.WriteString(data); file.WriteString(paths[nBuffer].c_str()); @@ -3267,10 +3267,10 @@ bool CMergeDoc::GenerateReport(const String& sFileName) const !(m_ptBuf[nBuffer]->GetLineFlags(idx[nBuffer] - 1) & (LF_DIFF | LF_GHOST)))) { ++nDiff; - tdtag += string_format(_T("."), nDiff, nDiff); + tdtag += strutils::format(_T("."), nDiff, nDiff); } if (!(dwFlags & LF_GHOST) && m_pView[nBuffer]->GetViewLineNumbers()) - tdtag += string_format(_T("%d"), m_ptBuf[nBuffer]->ComputeRealLine(idx[nBuffer]) + 1); + tdtag += strutils::format(_T("%d"), m_ptBuf[nBuffer]->ComputeRealLine(idx[nBuffer]) + 1); else tdtag += _T(""); file.WriteString(tdtag); diff --git a/Src/MergeEditView.cpp b/Src/MergeEditView.cpp index 47cf92208..a65f69952 100644 --- a/Src/MergeEditView.cpp +++ b/Src/MergeEditView.cpp @@ -2834,7 +2834,7 @@ void CMergeEditView::OnWMGoto() nLastLine = pDoc->m_ptBuf[m_nThisPane]->ComputeRealLine(nLineCount - 1); // Set active file and current line selected in dialog - dlg.m_strParam = string_to_str(nRealLine + 1); + dlg.m_strParam = strutils::to_str(nRealLine + 1); dlg.m_nFile = (pDoc->m_nBuffers < 3) ? (m_nThisPane == 1 ? 2 : 0) : m_nThisPane; dlg.m_nGotoWhat = 0; @@ -3232,7 +3232,7 @@ void CMergeEditView::OnEditCopyLineNumbers() // Get last selected line (having widest linenumber) int line = pDoc->m_ptBuf[m_nThisPane]->ComputeRealLine(ptEnd.y); - size_t nNumWidth = string_to_str(line + 1).length(); + size_t nNumWidth = strutils::to_str(line + 1).length(); for (int i = ptStart.y; i <= ptEnd.y; i++) { @@ -3244,7 +3244,7 @@ void CMergeEditView::OnEditCopyLineNumbers() // Insert spaces to align different width linenumbers (99, 100) strLine = GetLineText(i); - CString sSpaces(' ', static_cast(nNumWidth - string_to_str(line + 1).length())); + CString sSpaces(' ', static_cast(nNumWidth - strutils::to_str(line + 1).length())); strText += sSpaces; strNumLine.Format(_T("%d: %s"), line + 1, strLine); diff --git a/Src/OpenView.cpp b/Src/OpenView.cpp index d8dd1f63a..639eae8e4 100644 --- a/Src/OpenView.cpp +++ b/Src/OpenView.cpp @@ -452,7 +452,7 @@ void COpenView::OnOK() // If left path is a project-file, load it String ext; paths::SplitFilename(m_strPath[0], NULL, NULL, &ext); - if (m_strPath[1].empty() && string_compare_nocase(ext, ProjectFile::PROJECTFILE_EXT) == 0) + if (m_strPath[1].empty() && strutils::compare_nocase(ext, ProjectFile::PROJECTFILE_EXT) == 0) LoadProjectFile(m_strPath[0]); pathsType = paths::GetPairComparability(m_files, IsArchiveFile); @@ -467,7 +467,7 @@ void COpenView::OnOK() { // If user has edited path by hand, expand environment variables bool bExpand = false; - if (string_compare_nocase(m_strBrowsePath[index], m_files[index]) != 0) + if (strutils::compare_nocase(m_strBrowsePath[index], m_files[index]) != 0) bExpand = true; if (!paths::IsURLorCLSID(m_files[index])) @@ -484,7 +484,7 @@ void COpenView::OnOK() UpdateData(FALSE); KillTimer(IDT_CHECKFILES); - String filter(string_trim_ws(m_strExt)); + String filter(strutils::trim_ws(m_strExt)); // If prefix found from start.. if (filter.substr(0, filterPrefix.length()) == filterPrefix) @@ -614,7 +614,7 @@ static UINT UpdateButtonStatesThread(LPVOID lpParam) BOOL bProject = FALSE; String ext; paths::SplitFilename(paths[0], NULL, NULL, &ext); - if (paths[1].empty() && string_compare_nocase(ext, ProjectFile::PROJECTFILE_EXT) == 0) + if (paths[1].empty() && strutils::compare_nocase(ext, ProjectFile::PROJECTFILE_EXT) == 0) bProject = TRUE; if (!bProject) @@ -881,7 +881,7 @@ void COpenView::OnSelectFilter() const BOOL bUseMask = theApp.m_pGlobalFileFilter->IsUsingMask(); GetDlgItemText(IDC_EXT_COMBO, curFilter); - curFilter = string_trim_ws(curFilter); + curFilter = strutils::trim_ws(curFilter); GetMainFrame()->SelectFilter(); @@ -938,7 +938,7 @@ BOOL COpenView::LoadProjectFile(const String &path) } if (prj.HasFilter()) { - m_strExt = string_trim_ws(prj.GetFilter()); + m_strExt = strutils::trim_ws(prj.GetFilter()); if (m_strExt[0] != '*') m_strExt.insert(0, filterPrefix); } @@ -952,7 +952,7 @@ BOOL COpenView::LoadProjectFile(const String &path) void COpenView::TrimPaths() { for (int index = 0; index < countof(m_strPath); index++) - m_strPath[index] = string_trim_ws(m_strPath[index]); + m_strPath[index] = strutils::trim_ws(m_strPath[index]); } /** diff --git a/Src/OptionsCustomColors.cpp b/Src/OptionsCustomColors.cpp index bd363c699..d62f1e1b1 100644 --- a/Src/OptionsCustomColors.cpp +++ b/Src/OptionsCustomColors.cpp @@ -11,7 +11,7 @@ void Load(COptionsMgr *pOptionsMgr, COLORREF * colors) { for (int i = 0; i < 16; i++) { - String valuename = string_format(_T("%s/%d"), Section, i); + String valuename = strutils::format(_T("%s/%d"), Section, i); pOptionsMgr->InitOption(valuename, RGB(255, 255, 255), true); colors[i] = pOptionsMgr->GetInt(valuename); } @@ -21,7 +21,7 @@ void Save(COptionsMgr *pOptionsMgr, const COLORREF * colors) { for (int i = 0; i < 16; i++) { - String valuename = string_format(_T("%s/%d"), Section, i); + String valuename = strutils::format(_T("%s/%d"), Section, i); if (colors[i] == RGB(255, 255, 255)) pOptionsMgr->RemoveOption(valuename); else diff --git a/Src/OptionsSyntaxColors.cpp b/Src/OptionsSyntaxColors.cpp index b6550a924..e3526fc42 100644 --- a/Src/OptionsSyntaxColors.cpp +++ b/Src/OptionsSyntaxColors.cpp @@ -49,13 +49,13 @@ void Load(COptionsMgr *pOptionsMgr, ::SyntaxColors *pSyntaxColors) if (pOptionsMgr->GetBool(OPT_CLR_DEFAULT_TEXT_COLORING)) serializable = false; } - valuename = string_format(_T("%s/Color%02u"), DefColorsPath, i); + valuename = strutils::format(_T("%s/Color%02u"), DefColorsPath, i); pOptionsMgr->InitOption(valuename, color, serializable); color = pOptionsMgr->GetInt(valuename); ref = color; pSyntaxColors->SetColor(i, ref); - valuename = string_format(_T("%s/Bold%02u"), DefColorsPath, i); + valuename = strutils::format(_T("%s/Bold%02u"), DefColorsPath, i); bool bBold = pSyntaxColors->GetBold(i); pOptionsMgr->InitOption(valuename, bBold); int nBold = pOptionsMgr->GetBool(valuename); @@ -79,9 +79,9 @@ void Save(COptionsMgr *pOptionsMgr, const ::SyntaxColors *pSyntaxColors) for (unsigned i = COLORINDEX_NONE; i < COLORINDEX_LAST; i++) { int color = pSyntaxColors->GetColor(i); - pOptionsMgr->SaveOption(string_format(_T("%s/Color%02u"), DefColorsPath, i), color); + pOptionsMgr->SaveOption(strutils::format(_T("%s/Color%02u"), DefColorsPath, i), color); bool bold = pSyntaxColors->GetBold(i); - pOptionsMgr->SaveOption(string_format(_T("%s/Bold%02u"), DefColorsPath, i), bold); + pOptionsMgr->SaveOption(strutils::format(_T("%s/Bold%02u"), DefColorsPath, i), bold); } } diff --git a/Src/PatchDlg.cpp b/Src/PatchDlg.cpp index 81e4a10e9..6173386b2 100644 --- a/Src/PatchDlg.cpp +++ b/Src/PatchDlg.cpp @@ -140,7 +140,7 @@ void CPatchDlg::OnOK() } if (paths::IsPathAbsolute(m_fileResult) == FALSE) { - String msg = string_format_string1(_("The specified output path is not an absolute path: %1"), + String msg = strutils::format_string1(_("The specified output path is not an absolute path: %1"), m_fileResult); AfxMessageBox(msg.c_str(), MB_ICONSTOP); m_ctlResult.SetFocus(); @@ -226,7 +226,7 @@ BOOL CPatchDlg::OnInitDialog() } else if (count > 1) // Multiple files added, show number of files { - m_file1 = m_file2 = string_format_string1(_("[%1 files selected]"), string_to_str(count)).c_str(); + m_file1 = m_file2 = strutils::format_string1(_("[%1 files selected]"), strutils::to_str(count)).c_str(); } UpdateData(FALSE); @@ -484,7 +484,7 @@ void CPatchDlg::UpdateSettings() break; } - m_comboContext.SelectString(-1, string_to_str(m_contextLines).c_str()); + m_comboContext.SelectString(-1, strutils::to_str(m_contextLines).c_str()); if (m_outputStyle == OUTPUT_CONTEXT || m_outputStyle == OUTPUT_UNIFIED || m_outputStyle == OUTPUT_HTML) m_comboContext.EnableWindow(TRUE); diff --git a/Src/PatchTool.cpp b/Src/PatchTool.cpp index aa87e5717..070f09d57 100644 --- a/Src/PatchTool.cpp +++ b/Src/PatchTool.cpp @@ -151,7 +151,7 @@ int CPatchTool::CreatePatch() } else if (status.bPatchFileFailed) { - String errMsg = string_format_string1(_("Could not write to file %1."), dlgPatch.m_fileResult); + String errMsg = strutils::format_string1(_("Could not write to file %1."), dlgPatch.m_fileResult); AfxMessageBox(errMsg.c_str(), MB_ICONSTOP); bResult = false; break; diff --git a/Src/Plugins.cpp b/Src/Plugins.cpp index a29af9ac0..5c214d302 100644 --- a/Src/Plugins.cpp +++ b/Src/Plugins.cpp @@ -292,7 +292,7 @@ void PluginInfo::LoadFilterString() if (sPiece.empty()) break; - sPiece = string_makeupper(string_trim_ws_begin(sPiece)); + sPiece = strutils::makeupper(strutils::trim_ws_begin(sPiece)); int re_opts = 0; std::string regexString = ucr::toUTF8(sPiece); @@ -326,7 +326,7 @@ bool PluginInfo::TestAgainstRegList(const String& szTest) const sLine = sLine.substr(0, pos); if (sPiece.empty()) continue; - sPiece = string_makeupper(string_trim_ws_begin(sPiece)); + sPiece = strutils::makeupper(strutils::trim_ws_begin(sPiece)); if (::TestAgainstRegList(&m_filters, sPiece)) return true; @@ -538,7 +538,7 @@ int PluginInfo::LoadPlugin(const String & scriptletFilepath, const wchar_t *tran static void ReportPluginLoadFailure(const String & scriptletFilepath, const wchar_t *transformationEvent) { String sEvent = ucr::toTString(transformationEvent); - AppErrorMessageBox(string_format(_T("Exception loading plugin for event: %s\r\n%s"), sEvent.c_str(), scriptletFilepath.c_str())); + AppErrorMessageBox(strutils::format(_T("Exception loading plugin for event: %s\r\n%s"), sEvent.c_str(), scriptletFilepath.c_str())); } /** @@ -586,7 +586,7 @@ static vector& LoadTheScriptletList() for (i = 0 ; i < theScriptletList.size() ; i++) { String scriptlet = theScriptletList.at(i); - if (scriptlet.length() > 4 && string_compare_nocase(scriptlet.substr(scriptlet.length() - 4), _T(".sct")) != 0) + if (scriptlet.length() > 4 && strutils::compare_nocase(scriptlet.substr(scriptlet.length() - 4), _T(".sct")) != 0) { // don't need to lock this file theScriptletHandleList.push_back(NULL); @@ -779,7 +779,7 @@ void CScriptsOfThread::SaveSettings() list.push_back(String(plugin->m_name)); } } - GetOptionsMgr()->SaveOption(OPT_PLUGINS_DISABLED_LIST, string_join(list.begin(), list.end(), _T("|"))); + GetOptionsMgr()->SaveOption(OPT_PLUGINS_DISABLED_LIST, strutils::join(list.begin(), list.end(), _T("|"))); } void CScriptsOfThread::FreeAllScripts() @@ -950,7 +950,7 @@ static void ShowPluginErrorMessage(IDispatch *piScript, LPTSTR description) PluginInfo * pInfo = CAllThreadsScripts::GetActiveSet()->GetPluginInfo(piScript); assert(pInfo != NULL); assert(description != NULL); - AppErrorMessageBox(string_format(_T("%s: %s"), pInfo->m_name.c_str(), description)); + AppErrorMessageBox(strutils::format(_T("%s: %s"), pInfo->m_name.c_str(), description)); } /** diff --git a/Src/ProjectFilePathsDlg.cpp b/Src/ProjectFilePathsDlg.cpp index b2f09b61c..1c0bf55dc 100644 --- a/Src/ProjectFilePathsDlg.cpp +++ b/Src/ProjectFilePathsDlg.cpp @@ -98,7 +98,7 @@ void ProjectFilePathsDlg::OnBnClickedProjFilterSelect() const BOOL bUseMask = theApp.m_pGlobalFileFilter->IsUsingMask(); GetDlgItemText(IDC_PROJ_FILTER_EDIT, curFilter); - curFilter = string_trim_ws(curFilter); + curFilter = strutils::trim_ws(curFilter); GetMainFrame()->SelectFilter(); @@ -150,9 +150,9 @@ void ProjectFilePathsDlg::OnBnClickedProjSave() { UpdateData(TRUE); - m_sLeftFile = string_trim_ws(m_sLeftFile); - m_sRightFile = string_trim_ws(m_sRightFile); - m_sFilter = string_trim_ws(m_sFilter); + m_sLeftFile = strutils::trim_ws(m_sLeftFile); + m_sRightFile = strutils::trim_ws(m_sRightFile); + m_sFilter = strutils::trim_ws(m_sFilter); String fileName = AskProjectFileName(false); if (fileName.empty()) @@ -174,7 +174,7 @@ void ProjectFilePathsDlg::OnBnClickedProjSave() { m_sFilter.erase(0, prefix.length()); } - m_sFilter = string_trim_ws_begin(m_sFilter); + m_sFilter = strutils::trim_ws_begin(m_sFilter); project.SetFilter(m_sFilter); } project.SetSubfolders(m_bIncludeSubfolders); diff --git a/Src/PropBackups.cpp b/Src/PropBackups.cpp index 7885e93a3..644665ac6 100644 --- a/Src/PropBackups.cpp +++ b/Src/PropBackups.cpp @@ -65,7 +65,7 @@ void PropBackups::ReadOptions() */ void PropBackups::WriteOptions() { - string_trim_ws(m_sGlobalFolder); + strutils::trim_ws(m_sGlobalFolder); if (m_sGlobalFolder.length() > 3) m_sGlobalFolder = paths::AddTrailingSlash(m_sGlobalFolder); diff --git a/Src/PropCodepage.cpp b/Src/PropCodepage.cpp index a1f43a313..0b34b64de 100644 --- a/Src/PropCodepage.cpp +++ b/Src/PropCodepage.cpp @@ -79,7 +79,7 @@ void PropCodepage::ReadOptions() { m_nCodepageSystem = GetOptionsMgr()->GetInt(OPT_CP_DEFAULT_MODE); m_nCustomCodepageValue = GetOptionsMgr()->GetInt(OPT_CP_DEFAULT_CUSTOM); - m_cCustomCodepageValue = string_to_str(m_nCustomCodepageValue); + m_cCustomCodepageValue = strutils::to_str(m_nCustomCodepageValue); m_bDetectCodepage = GetOptionsMgr()->GetInt(OPT_CP_DETECT) & 1; m_bDetectCodepage2 = (GetOptionsMgr()->GetInt(OPT_CP_DETECT) & 2) != 0; m_nAutodetectType = ((unsigned)GetOptionsMgr()->GetInt(OPT_CP_DETECT) >> 16); @@ -107,7 +107,7 @@ BOOL PropCodepage::OnInitDialog() m_comboAutodetectType.EnableWindow( IsDlgButtonChecked(IDC_DETECT_CODEPAGE2) == 1); - m_comboCustomCodepageValue.SetWindowText(string_to_str(m_nCustomCodepageValue).c_str()); + m_comboCustomCodepageValue.SetWindowText(strutils::to_str(m_nCustomCodepageValue).c_str()); IExconverter *pexconv = Exconverter::getInstance(); if (pexconv != NULL) @@ -117,7 +117,7 @@ BOOL PropCodepage::OnInitDialog() { if (cpi[i].codepage == 1200 /* UNICODE */) continue; - String desc = string_format(_T("%05d - %s"), cpi[i].codepage, cpi[i].desc.c_str()); + String desc = strutils::format(_T("%05d - %s"), cpi[i].codepage, cpi[i].desc.c_str()); m_comboCustomCodepageValue.AddString(desc.c_str()); if (cpi[i].codepage == m_nCustomCodepageValue) m_comboCustomCodepageValue.SetCurSel(static_cast(j)); diff --git a/Src/PropEditor.cpp b/Src/PropEditor.cpp index 7577a5c0a..b98ed86bd 100644 --- a/Src/PropEditor.cpp +++ b/Src/PropEditor.cpp @@ -155,9 +155,9 @@ void PropEditor::OnEnKillfocusTabEdit() unsigned value = GetDlgItemInt(IDC_TAB_EDIT); if (value < 1 || value > MAX_TABSIZE) { - String msg = string_format_string1( + String msg = strutils::format_string1( _("Value in Tab size -field is not in range WinMerge accepts.\n\nPlease use values 1 - %1."), - string_to_str(MAX_TABSIZE)); + strutils::to_str(MAX_TABSIZE)); AfxMessageBox(msg.c_str(), MB_ICONWARNING); } } diff --git a/Src/PropRegistry.cpp b/Src/PropRegistry.cpp index 31960f0ff..3e3ef9df6 100644 --- a/Src/PropRegistry.cpp +++ b/Src/PropRegistry.cpp @@ -82,18 +82,18 @@ void PropRegistry::WriteOptions() { GetOptionsMgr()->SaveOption(OPT_USE_RECYCLE_BIN, m_bUseRecycleBin == TRUE); - String sExtEditor = string_trim_ws(m_strEditorPath); + String sExtEditor = strutils::trim_ws(m_strEditorPath); if (sExtEditor.empty()) sExtEditor = GetOptionsMgr()->GetDefault(OPT_EXT_EDITOR_CMD); GetOptionsMgr()->SaveOption(OPT_EXT_EDITOR_CMD, sExtEditor); - String sFilterPath = string_trim_ws(m_strUserFilterPath); + String sFilterPath = strutils::trim_ws(m_strUserFilterPath); GetOptionsMgr()->SaveOption(OPT_FILTER_USERPATH, sFilterPath); bool useSysTemp = m_tempFolderType == 0; GetOptionsMgr()->SaveOption(OPT_USE_SYSTEM_TEMP_PATH, useSysTemp); - String tempFolder = string_trim_ws(m_tempFolder); + String tempFolder = strutils::trim_ws(m_tempFolder); GetOptionsMgr()->SaveOption(OPT_CUSTOM_TEMP_PATH, tempFolder); } diff --git a/Src/PropShell.cpp b/Src/PropShell.cpp index 7628be36e..42018afc2 100644 --- a/Src/PropShell.cpp +++ b/Src/PropShell.cpp @@ -141,7 +141,7 @@ void PropShell::GetContextRegValues() retVal = reg.Open(HKEY_CURRENT_USER, RegDir); if (retVal != ERROR_SUCCESS) { - String msg = string_format(_T("Failed to open registry key HKCU/%s:\n\t%d : %s"), + String msg = strutils::format(_T("Failed to open registry key HKCU/%s:\n\t%d : %s"), RegDir, retVal, GetSysError(retVal).c_str()); LogErrorString(msg); return; @@ -175,7 +175,7 @@ void PropShell::SaveMergePath() retVal = reg.Open(HKEY_CURRENT_USER, RegDir); if (retVal != ERROR_SUCCESS) { - String msg = string_format(_T("Failed to open registry key HKCU/%s:\n\t%d : %s"), + String msg = strutils::format(_T("Failed to open registry key HKCU/%s:\n\t%d : %s"), RegDir, retVal, GetSysError(retVal).c_str()); LogErrorString(msg); return; @@ -185,7 +185,7 @@ void PropShell::SaveMergePath() retVal = reg.WriteString(f_RegValuePath, temp); if (retVal != ERROR_SUCCESS) { - String msg = string_format(_T("Failed to set registry value %s:\n\t%d : %s"), + String msg = strutils::format(_T("Failed to set registry value %s:\n\t%d : %s"), f_RegValuePath, retVal, GetSysError(retVal).c_str()); LogErrorString(msg); } @@ -205,7 +205,7 @@ void PropShell::SaveMergePath() retVal = reg.WriteDword(f_RegValueEnabled, dwContextEnabled); if (retVal != ERROR_SUCCESS) { - String msg = string_format(_T("Failed to set registry value %s to %d:\n\t%d : %s"), + String msg = strutils::format(_T("Failed to set registry value %s to %d:\n\t%d : %s"), f_RegValueEnabled, dwContextEnabled, retVal, GetSysError(retVal).c_str()); LogErrorString(msg); } diff --git a/Src/SourceControl.cpp b/Src/SourceControl.cpp index 6d66a8977..571adfa76 100644 --- a/Src/SourceControl.cpp +++ b/Src/SourceControl.cpp @@ -127,7 +127,7 @@ bool SourceControl::SaveToVersionControl(const String& strSavePath) { // Prompt for user choice CVssPromptDlg dlg; - dlg.m_strMessage = string_format_string1(_("Save changes to %1?"), strSavePath); + dlg.m_strMessage = strutils::format_string1(_("Save changes to %1?"), strSavePath); dlg.m_strProject = m_vssHelper.GetProjectBase(); dlg.m_strUser = m_strVssUser; // BSP - Add VSS user name to dialog box dlg.m_strPassword = m_strVssPassword; @@ -185,7 +185,7 @@ bool SourceControl::SaveToVersionControl(const String& strSavePath) CVssPromptDlg dlg; CRegKeyEx reg; - dlg.m_strMessage = string_format_string1(_("Save changes to %1?"), strSavePath); + dlg.m_strMessage = strutils::format_string1(_("Save changes to %1?"), strSavePath); dlg.m_strProject = m_vssHelper.GetProjectBase(); dlg.m_strUser = m_strVssUser; // BSP - Add VSS user name to dialog box dlg.m_strPassword = m_strVssPassword; @@ -281,7 +281,7 @@ bool SourceControl::SaveToVersionControl(const String& strSavePath) CMyComBSTR bstrLocalSpec; vssi->get_LocalSpec(&bstrLocalSpec); // BSP - ...and compare it to the directory WinMerge is using. - if (string_compare_nocase(ucr::toTString(bstrLocalSpec.m_str), strSavePath)) + if (strutils::compare_nocase(ucr::toTString(bstrLocalSpec.m_str), strSavePath)) { // BSP - if the directories are different, let the user confirm the CheckOut int iRes = AppMsgBox::warning(_("The VSS Working Folder and the location of the current file do not match. Continue?"), diff --git a/Src/TestFilterDlg.cpp b/Src/TestFilterDlg.cpp index 7000b0bfb..318f4351c 100644 --- a/Src/TestFilterDlg.cpp +++ b/Src/TestFilterDlg.cpp @@ -87,7 +87,7 @@ bool CTestFilterDlg::CheckText(String text) const if (isDir) { // Convert any forward slashes to canonical Windows-style backslashes - string_replace(text, _T("/"), _T("\\")); + strutils::replace(text, _T("/"), _T("\\")); return m_pFileFilterMgr->TestDirNameAgainstFilter(m_pFileFilter, text); } else diff --git a/Src/VSSHelper.cpp b/Src/VSSHelper.cpp index f18b56eb3..8ba3dc694 100644 --- a/Src/VSSHelper.cpp +++ b/Src/VSSHelper.cpp @@ -40,7 +40,7 @@ bool VSSHelper::SetProjectBase(const String& strPath) return false; m_strVssProjectBase = strPath; - string_replace(m_strVssProjectBase, _T("/"), _T("\\")); + strutils::replace(m_strVssProjectBase, _T("/"), _T("\\")); // Check if m_strVssProjectBase has leading $\\, if not put them in: if (m_strVssProjectBase[0] != '$' && m_strVssProjectBase[1] != '\\') @@ -64,7 +64,7 @@ bool VSSHelper::ReLinkVCProj(const String& strSavePath, String& sError) String ext; paths::SplitFilename(strSavePath, NULL, NULL, &ext); - String strExt = string_makelower(ext); + String strExt = strutils::makelower(ext); if (strExt == _T("vcproj") || strExt == _T("sln")) { bool bVCPROJ = false; @@ -93,11 +93,11 @@ bool VSSHelper::ReLinkVCProj(const String& strSavePath, String& sError) { if (hfile == INVALID_HANDLE_VALUE) { - sError = string_format(_T("CMainFrame::ReLinkVCProj() ") + sError = strutils::format(_T("CMainFrame::ReLinkVCProj() ") _T("- failed to open file: %s"), strSavePath.c_str()); LogErrorString(sError); String errMsg = GetSysError(GetLastError()); - sError = string_format_string2(_("Cannot open file\n%1\n\n%2"), errMsg, strSavePath); + sError = strutils::format_string2(_("Cannot open file\n%1\n\n%2"), errMsg, strSavePath); } else { @@ -105,11 +105,11 @@ bool VSSHelper::ReLinkVCProj(const String& strSavePath, String& sError) } if (tfile == INVALID_HANDLE_VALUE) { - sError = string_format(_T("CMainFrame::ReLinkVCProj() ") + sError = strutils::format(_T("CMainFrame::ReLinkVCProj() ") _T("- failed to open temporary file: %s"), tempFile.c_str()); LogErrorString(sError); String errMsg = GetSysError(GetLastError()); - sError = string_format_string2(_("Cannot open file\n%1\n\n%2"), errMsg, strSavePath); + sError = strutils::format_string2(_("Cannot open file\n%1\n\n%2"), errMsg, strSavePath); } else { @@ -167,7 +167,7 @@ bool VSSHelper::ReLinkVCProj(const String& strSavePath, String& sError) else { String errMsg = GetSysError(GetLastError()); - sError = string_format_string2(_("Cannot open file\n%1\n\n%2"), errMsg, strSavePath); + sError = strutils::format_string2(_("Cannot open file\n%1\n\n%2"), errMsg, strSavePath); return false; } } @@ -179,20 +179,20 @@ void VSSHelper::GetFullVSSPath(const String& strSavePath, bool & bVCProj) String ext; String path; paths::SplitFilename(strSavePath, &path, NULL, &ext); - String strExt = string_makelower(ext); + String strExt = strutils::makelower(ext); if (strExt == _T("vcproj")) bVCProj = true; String savepath(strSavePath); - string_replace(savepath, _T("/"), _T("\\")); - string_replace(m_strVssProjectBase, _T("/"), _T("\\")); + strutils::replace(savepath, _T("/"), _T("\\")); + strutils::replace(m_strVssProjectBase, _T("/"), _T("\\")); //check if m_strVssProjectBase has leading $\\, if not put them in: if (m_strVssProjectBase[0] != '$' && m_strVssProjectBase[1] != '\\') m_strVssProjectBase.insert(0, _T("$\\")); - savepath = string_makelower(savepath); - m_strVssProjectBase = string_makelower(m_strVssProjectBase); + savepath = strutils::makelower(savepath); + m_strVssProjectBase = strutils::makelower(m_strVssProjectBase); //take out last '\\' size_t nLen = m_strVssProjectBase.size(); @@ -216,7 +216,7 @@ void VSSHelper::GetFullVSSPath(const String& strSavePath, bool & bVCProj) //if sln file, we need to replace ' ' with _T("\\u0020") if (!bVCProj) - string_replace(m_strVssProjectFull, _T(" "), _T("\\u0020")); + strutils::replace(m_strVssProjectFull, _T(" "), _T("\\u0020")); } /** @@ -424,7 +424,7 @@ bool VSSHelper::GetSLNProjName(HANDLE hFile, HANDLE tFile, TCHAR * buf) const else capp += *pc; } - capp = string_makelower(capp); + capp = strutils::makelower(capp); //nab until the no space, and no = if (!GetWordFromFile(hFile, buffer, sizeof(buffer)/sizeof(buffer[0]), _T(" ="))) diff --git a/Src/codepage_detect.cpp b/Src/codepage_detect.cpp index 1dc7b607c..a47decf82 100644 --- a/Src/codepage_detect.cpp +++ b/Src/codepage_detect.cpp @@ -207,7 +207,7 @@ static unsigned GuessEncoding_from_bytes(const String& ext, const char *src, siz } if (guessEncodingType & 1) { - String lower_ext = string_makelower(ext); + String lower_ext = strutils::makelower(ext); if (lower_ext == _T(".rc")) { cp = demoGuessEncoding_rc(src, len, cp); diff --git a/Src/paths.cpp b/Src/paths.cpp index 30d7dc905..37f11c40c 100644 --- a/Src/paths.cpp +++ b/Src/paths.cpp @@ -762,7 +762,7 @@ bool IsURLorCLSID(const String& path) bool IsDecendant(const String& path, const String& ancestor) { return path.length() > ancestor.length() && - string_compare_nocase(String(path.c_str(), path.c_str() + ancestor.length()), ancestor) == 0; + strutils::compare_nocase(String(path.c_str(), path.c_str() + ancestor.length()), ancestor) == 0; } static void replace_char(TCHAR *s, int target, int repl) diff --git a/Testing/GoogleTest/UnicodeString/UnicodeString_test.cpp b/Testing/GoogleTest/UnicodeString/UnicodeString_test.cpp index dee8a37e5..851f69a04 100644 --- a/Testing/GoogleTest/UnicodeString/UnicodeString_test.cpp +++ b/Testing/GoogleTest/UnicodeString/UnicodeString_test.cpp @@ -52,7 +52,7 @@ namespace String orig(_T("OneTwoThree")); String find(_T("Blaa")); String rep(_T("Five")); - string_replace(orig, find, rep); + strutils::replace(orig, find, rep); EXPECT_EQ(_T("OneTwoThree"), orig); } @@ -61,7 +61,7 @@ namespace String orig(_T("OneTwoThree")); String find(_T("Two")); String rep(_T("Five")); - string_replace(orig, find, rep); + strutils::replace(orig, find, rep); EXPECT_EQ(_T("OneFiveThree"), orig); } @@ -70,7 +70,7 @@ namespace String orig(_T("OneTwoThree")); String find(_T("Two")); String rep(_T("")); - string_replace(orig, find, rep); + strutils::replace(orig, find, rep); EXPECT_EQ(_T("OneThree"), orig); } @@ -79,7 +79,7 @@ namespace String orig(_T("OneTwoThree")); String find(_T("One")); String rep(_T("five")); - string_replace(orig, find, rep); + strutils::replace(orig, find, rep); EXPECT_EQ(_T("fiveTwoThree"), orig); } @@ -88,7 +88,7 @@ namespace String orig(_T("OneTwoThree")); String find(_T("One")); String rep(_T("")); - string_replace(orig, find, rep); + strutils::replace(orig, find, rep); EXPECT_EQ(_T("TwoThree"), orig); } @@ -97,7 +97,7 @@ namespace String orig(_T("OneTwoThree")); String find(_T("Three")); String rep(_T("seven")); - string_replace(orig, find, rep); + strutils::replace(orig, find, rep); EXPECT_EQ(_T("OneTwoseven"), orig); } @@ -106,252 +106,252 @@ namespace String orig(_T("OneTwoThree")); String find(_T("Three")); String rep(_T("")); - string_replace(orig, find, rep); + strutils::replace(orig, find, rep); EXPECT_EQ(_T("OneTwo"), orig); } TEST_F(UnicodeStringTest, MakelowerEmpty) { String orig(_T("")); - String result = string_makelower(orig); + String result = strutils::makelower(orig); EXPECT_EQ(_T(""), result); } TEST_F(UnicodeStringTest, MakelowerWhitespace) { String orig(_T(" \t")); - String result = string_makelower(orig); + String result = strutils::makelower(orig); EXPECT_EQ(_T(" \t"), result); } TEST_F(UnicodeStringTest, Makelower1) { String orig(_T("onetwothree")); - String result = string_makelower(orig); + String result = strutils::makelower(orig); EXPECT_EQ(_T("onetwothree"), result); } TEST_F(UnicodeStringTest, Makelower2) { String orig(_T("OneTwoThree")); - String result = string_makelower(orig); + String result = strutils::makelower(orig); EXPECT_EQ(_T("onetwothree"), result); } TEST_F(UnicodeStringTest, TrimwsbeginEmpty) { String orig(_T("")); - String result = string_trim_ws_begin(orig); + String result = strutils::trim_ws_begin(orig); EXPECT_EQ(_T(""), result); } TEST_F(UnicodeStringTest, TrimwsbeginNoWs) { String orig(_T("abc")); - String result = string_trim_ws_begin(orig); + String result = strutils::trim_ws_begin(orig); EXPECT_EQ(_T("abc"), result); } TEST_F(UnicodeStringTest, TrimwsbeginWsEnd) { String orig(_T("abc\t")); - String result = string_trim_ws_begin(orig); + String result = strutils::trim_ws_begin(orig); EXPECT_EQ(_T("abc\t"), result); } TEST_F(UnicodeStringTest, TrimwsbeginWsOnly) { String orig(_T("\t")); - String result = string_trim_ws_begin(orig); + String result = strutils::trim_ws_begin(orig); EXPECT_EQ(_T(""), result); } TEST_F(UnicodeStringTest, TrimwsbeginWs1) { String orig(_T("\tabc")); - String result = string_trim_ws_begin(orig); + String result = strutils::trim_ws_begin(orig); EXPECT_EQ(_T("abc"), result); } TEST_F(UnicodeStringTest, TrimwsbeginWs2) { String orig(_T("\t\n abc")); - String result = string_trim_ws_begin(orig); + String result = strutils::trim_ws_begin(orig); EXPECT_EQ(_T("abc"), result); } TEST_F(UnicodeStringTest, TrimwsendEmpty) { String orig(_T("")); - String result = string_trim_ws_end(orig); + String result = strutils::trim_ws_end(orig); EXPECT_EQ(_T(""), result); } TEST_F(UnicodeStringTest, TrimwsendNoWs) { String orig(_T("abc")); - String result = string_trim_ws_end(orig); + String result = strutils::trim_ws_end(orig); EXPECT_EQ(_T("abc"), result); } TEST_F(UnicodeStringTest, TrimwsendWsBegin) { String orig(_T("\tabc")); - String result = string_trim_ws_end(orig); + String result = strutils::trim_ws_end(orig); EXPECT_EQ(_T("\tabc"), result); } TEST_F(UnicodeStringTest, TrimwsendWsOnly) { String orig(_T("\t")); - String result = string_trim_ws_end(orig); + String result = strutils::trim_ws_end(orig); EXPECT_EQ(_T(""), result); } TEST_F(UnicodeStringTest, TrimwsendWs1) { String orig(_T("abc\t")); - String result = string_trim_ws_end(orig); + String result = strutils::trim_ws_end(orig); EXPECT_EQ(_T("abc"), result); } TEST_F(UnicodeStringTest, TrimwsendWs2) { String orig(_T("abc\t\n ")); - String result = string_trim_ws_end(orig); + String result = strutils::trim_ws_end(orig); EXPECT_EQ(_T("abc"), result); } TEST_F(UnicodeStringTest, TrimwsEmpty) { String orig(_T("")); - String result = string_trim_ws(orig); + String result = strutils::trim_ws(orig); EXPECT_EQ(_T(""), result); } TEST_F(UnicodeStringTest, TrimwsNoWs) { String orig(_T("abc")); - String result = string_trim_ws(orig); + String result = strutils::trim_ws(orig); EXPECT_EQ(_T("abc"), result); } TEST_F(UnicodeStringTest, TrimwsWsOnly) { String orig(_T("\t")); - String result = string_trim_ws(orig); + String result = strutils::trim_ws(orig); EXPECT_EQ(_T(""), result); } TEST_F(UnicodeStringTest, TrimwsWsOnly2) { String orig(_T("\t \n")); - String result = string_trim_ws(orig); + String result = strutils::trim_ws(orig); EXPECT_EQ(_T(""), result); } TEST_F(UnicodeStringTest, TrimwsWsOnly3) { String orig(_T(" \t \t ")); - String result = string_trim_ws(orig); + String result = strutils::trim_ws(orig); EXPECT_EQ(_T(""), result); } TEST_F(UnicodeStringTest, TrimwsWsBegin) { String orig(_T("\tabc")); - String result = string_trim_ws(orig); + String result = strutils::trim_ws(orig); EXPECT_EQ(_T("abc"), result); } TEST_F(UnicodeStringTest, TrimwsWsBegin2) { String orig(_T("\t\n abc")); - String result = string_trim_ws(orig); + String result = strutils::trim_ws(orig); EXPECT_EQ(_T("abc"), result); } TEST_F(UnicodeStringTest, TrimwsWsEnd1) { String orig(_T("abc\t")); - String result = string_trim_ws(orig); + String result = strutils::trim_ws(orig); EXPECT_EQ(_T("abc"), result); } TEST_F(UnicodeStringTest, TrimwsWsEnd2) { String orig(_T("abc\t\n ")); - String result = string_trim_ws(orig); + String result = strutils::trim_ws(orig); EXPECT_EQ(_T("abc"), result); } TEST_F(UnicodeStringTest, TrimwsWsBoth1) { String orig(_T("\tabc\t")); - String result = string_trim_ws(orig); + String result = strutils::trim_ws(orig); EXPECT_EQ(_T("abc"), result); } TEST_F(UnicodeStringTest, TrimwsWsBoth2) { String orig(_T("\n \tabc \t\n")); - String result = string_trim_ws(orig); + String result = strutils::trim_ws(orig); EXPECT_EQ(_T("abc"), result); } TEST_F(UnicodeStringTest, ComparenocaseEmpty) { - EXPECT_EQ(0, string_compare_nocase(_T(""), _T(""))); + EXPECT_EQ(0, strutils::compare_nocase(_T(""), _T(""))); } TEST_F(UnicodeStringTest, ComparenocaseWhitespace1) { - EXPECT_EQ(0, string_compare_nocase(_T(" "), _T(" "))); + EXPECT_EQ(0, strutils::compare_nocase(_T(" "), _T(" "))); } TEST_F(UnicodeStringTest, ComparenocaseWhitespace) { - EXPECT_NE(0, string_compare_nocase(_T(" "), _T("\t"))); + EXPECT_NE(0, strutils::compare_nocase(_T(" "), _T("\t"))); } TEST_F(UnicodeStringTest, ComparenocaseLowercase) { - EXPECT_EQ(0, string_compare_nocase(_T("abc"), _T("abc"))); + EXPECT_EQ(0, strutils::compare_nocase(_T("abc"), _T("abc"))); } TEST_F(UnicodeStringTest, ComparenocaseUppercase) { - EXPECT_EQ(0, string_compare_nocase(_T("ABC"), _T("ABC"))); + EXPECT_EQ(0, strutils::compare_nocase(_T("ABC"), _T("ABC"))); } TEST_F(UnicodeStringTest, ComparenocaseMixedcase) { - EXPECT_EQ(0, string_compare_nocase(_T("AbC"), _T("AbC"))); + EXPECT_EQ(0, strutils::compare_nocase(_T("AbC"), _T("AbC"))); } TEST_F(UnicodeStringTest, ComparenocaseIdentical1) { - EXPECT_EQ(0, string_compare_nocase(_T("abc"), _T("aBc"))); + EXPECT_EQ(0, strutils::compare_nocase(_T("abc"), _T("aBc"))); } TEST_F(UnicodeStringTest, ComparenocaseIdentical2) { - EXPECT_EQ(0, string_compare_nocase(_T("ABc"), _T("abc"))); + EXPECT_EQ(0, strutils::compare_nocase(_T("ABc"), _T("abc"))); } TEST_F(UnicodeStringTest, ComparenocaseDifferent1) { - EXPECT_NE(0, string_compare_nocase(_T("abc"), _T("adc"))); + EXPECT_NE(0, strutils::compare_nocase(_T("abc"), _T("adc"))); } TEST_F(UnicodeStringTest, ComparenocaseDifferent2) { - EXPECT_NE(0, string_compare_nocase(_T("aBc"), _T("adc"))); + EXPECT_NE(0, strutils::compare_nocase(_T("aBc"), _T("adc"))); } TEST_F(UnicodeStringTest, ComparenocaseDifferent3) { - EXPECT_NE(0, string_compare_nocase(_T("abc"), _T("aDc"))); + EXPECT_NE(0, strutils::compare_nocase(_T("abc"), _T("aDc"))); } } // namespace -- 2.11.0