Remove ambiguous symbols

The "ambiguous" symbols (TCHAR & generic_string) are used when Notepad++ suppoted both ANSI & Unicode formats.
Since ANSI format of Notepad++ has been dropped (since long time ago), TCHAR & generic_string will be replaced by wchar_t & wstring respectively.

Close #15371
pull/15376/head
Don Ho 2024-06-28 16:30:41 +02:00
parent 982f52224c
commit 94af271be9
2 changed files with 158 additions and 156 deletions

View File

@ -29,20 +29,22 @@
#include <Parameters.h> #include <Parameters.h>
#include "Buffer.h" #include "Buffer.h"
using namespace std;
void printInt(int int2print) void printInt(int int2print)
{ {
TCHAR str[32]; wchar_t str[32];
wsprintf(str, TEXT("%d"), int2print); wsprintf(str, TEXT("%d"), int2print);
::MessageBox(NULL, str, TEXT(""), MB_OK); ::MessageBox(NULL, str, TEXT(""), MB_OK);
} }
void printStr(const TCHAR *str2print) void printStr(const wchar_t *str2print)
{ {
::MessageBox(NULL, str2print, TEXT(""), MB_OK); ::MessageBox(NULL, str2print, TEXT(""), MB_OK);
} }
generic_string commafyInt(size_t n) wstring commafyInt(size_t n)
{ {
generic_stringstream ss; generic_stringstream ss;
ss.imbue(std::locale("")); ss.imbue(std::locale(""));
@ -50,7 +52,7 @@ generic_string commafyInt(size_t n)
return ss.str(); return ss.str();
} }
std::string getFileContent(const TCHAR *file2read) std::string getFileContent(const wchar_t *file2read)
{ {
if (!::PathFileExists(file2read)) if (!::PathFileExists(file2read))
return ""; return "";
@ -78,7 +80,7 @@ std::string getFileContent(const TCHAR *file2read)
char getDriveLetter() char getDriveLetter()
{ {
char drive = '\0'; char drive = '\0';
TCHAR current[MAX_PATH]; wchar_t current[MAX_PATH];
::GetCurrentDirectory(MAX_PATH, current); ::GetCurrentDirectory(MAX_PATH, current);
int driveNbr = ::PathGetDriveNumber(current); int driveNbr = ::PathGetDriveNumber(current);
@ -89,10 +91,10 @@ char getDriveLetter()
} }
generic_string relativeFilePathToFullFilePath(const TCHAR *relativeFilePath) wstring relativeFilePathToFullFilePath(const wchar_t *relativeFilePath)
{ {
generic_string fullFilePathName; wstring fullFilePathName;
TCHAR fullFileName[MAX_PATH]; wchar_t fullFileName[MAX_PATH];
BOOL isRelative = ::PathIsRelative(relativeFilePath); BOOL isRelative = ::PathIsRelative(relativeFilePath);
if (isRelative) if (isRelative)
@ -115,7 +117,7 @@ generic_string relativeFilePathToFullFilePath(const TCHAR *relativeFilePath)
} }
void writeFileContent(const TCHAR *file2write, const char *content2write) void writeFileContent(const wchar_t *file2write, const char *content2write)
{ {
Win32_IO_File file(file2write); Win32_IO_File file(file2write);
@ -124,7 +126,7 @@ void writeFileContent(const TCHAR *file2write, const char *content2write)
} }
void writeLog(const TCHAR *logFileName, const char *log2write) void writeLog(const wchar_t *logFileName, const char *log2write)
{ {
const DWORD accessParam{ GENERIC_READ | GENERIC_WRITE }; const DWORD accessParam{ GENERIC_READ | GENERIC_WRITE };
const DWORD shareParam{ FILE_SHARE_READ | FILE_SHARE_WRITE }; const DWORD shareParam{ FILE_SHARE_READ | FILE_SHARE_WRITE };
@ -140,7 +142,7 @@ void writeLog(const TCHAR *logFileName, const char *log2write)
SYSTEMTIME currentTime = {}; SYSTEMTIME currentTime = {};
::GetLocalTime(&currentTime); ::GetLocalTime(&currentTime);
generic_string dateTimeStrW = getDateTimeStrFrom(TEXT("yyyy-MM-dd HH:mm:ss"), currentTime); wstring dateTimeStrW = getDateTimeStrFrom(TEXT("yyyy-MM-dd HH:mm:ss"), currentTime);
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter; std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
std::string log2writeStr = converter.to_bytes(dateTimeStrW); std::string log2writeStr = converter.to_bytes(dateTimeStrW);
log2writeStr += " "; log2writeStr += " ";
@ -156,14 +158,14 @@ void writeLog(const TCHAR *logFileName, const char *log2write)
} }
generic_string folderBrowser(HWND parent, const generic_string & title, int outputCtrlID, const TCHAR *defaultStr) wstring folderBrowser(HWND parent, const wstring & title, int outputCtrlID, const wchar_t *defaultStr)
{ {
generic_string folderName; wstring folderName;
CustomFileDialog dlg(parent); CustomFileDialog dlg(parent);
dlg.setTitle(title.c_str()); dlg.setTitle(title.c_str());
// Get an initial directory from the edit control or from argument provided // Get an initial directory from the edit control or from argument provided
TCHAR directory[MAX_PATH] = {}; wchar_t directory[MAX_PATH] = {};
if (outputCtrlID != 0) if (outputCtrlID != 0)
::GetDlgItemText(parent, outputCtrlID, directory, _countof(directory)); ::GetDlgItemText(parent, outputCtrlID, directory, _countof(directory));
directory[_countof(directory) - 1] = '\0'; directory[_countof(directory) - 1] = '\0';
@ -183,7 +185,7 @@ generic_string folderBrowser(HWND parent, const generic_string & title, int outp
} }
generic_string getFolderName(HWND parent, const TCHAR *defaultDir) wstring getFolderName(HWND parent, const wchar_t *defaultDir)
{ {
return folderBrowser(parent, TEXT("Select a folder"), 0, defaultDir); return folderBrowser(parent, TEXT("Select a folder"), 0, defaultDir);
} }
@ -207,15 +209,15 @@ void ClientRectToScreenRect(HWND hWnd, RECT* rect)
} }
std::vector<generic_string> tokenizeString(const generic_string & tokenString, const char delim) std::vector<wstring> tokenizeString(const wstring & tokenString, const char delim)
{ {
//Vector is created on stack and copied on return //Vector is created on stack and copied on return
std::vector<generic_string> tokens; std::vector<wstring> tokens;
// Skip delimiters at beginning. // Skip delimiters at beginning.
generic_string::size_type lastPos = tokenString.find_first_not_of(delim, 0); wstring::size_type lastPos = tokenString.find_first_not_of(delim, 0);
// Find first "non-delimiter". // Find first "non-delimiter".
generic_string::size_type pos = tokenString.find_first_of(delim, lastPos); wstring::size_type pos = tokenString.find_first_of(delim, lastPos);
while (pos != std::string::npos || lastPos != std::string::npos) while (pos != std::string::npos || lastPos != std::string::npos)
{ {
@ -256,7 +258,7 @@ int filter(unsigned int code, struct _EXCEPTION_POINTERS *)
} }
bool isInList(const TCHAR *token, const TCHAR *list) bool isInList(const wchar_t *token, const wchar_t *list)
{ {
if ((!token) || (!list)) if ((!token) || (!list))
return false; return false;
@ -264,7 +266,7 @@ bool isInList(const TCHAR *token, const TCHAR *list)
const size_t wordLen = 64; const size_t wordLen = 64;
size_t listLen = lstrlen(list); size_t listLen = lstrlen(list);
TCHAR word[wordLen] = { '\0' }; wchar_t word[wordLen] = { '\0' };
size_t i = 0; size_t i = 0;
size_t j = 0; size_t j = 0;
@ -294,10 +296,10 @@ bool isInList(const TCHAR *token, const TCHAR *list)
} }
generic_string purgeMenuItemString(const TCHAR * menuItemStr, bool keepAmpersand) wstring purgeMenuItemString(const wchar_t * menuItemStr, bool keepAmpersand)
{ {
const size_t cleanedNameLen = 64; const size_t cleanedNameLen = 64;
TCHAR cleanedName[cleanedNameLen] = TEXT(""); wchar_t cleanedName[cleanedNameLen] = TEXT("");
size_t j = 0; size_t j = 0;
size_t menuNameLen = lstrlen(menuItemStr); size_t menuNameLen = lstrlen(menuItemStr);
if (menuNameLen >= cleanedNameLen) if (menuNameLen >= cleanedNameLen)
@ -511,9 +513,9 @@ std::string wstring2string(const std::wstring & rwString, UINT codepage)
// Escapes ampersands in file name to use it in menu // Escapes ampersands in file name to use it in menu
template <typename T> template <typename T>
generic_string convertFileName(T beg, T end) wstring convertFileName(T beg, T end)
{ {
generic_string strTmp; wstring strTmp;
for (T it = beg; it != end; ++it) for (T it = beg; it != end; ++it)
{ {
@ -525,53 +527,53 @@ generic_string convertFileName(T beg, T end)
} }
generic_string intToString(int val) wstring intToString(int val)
{ {
std::vector<TCHAR> vt; std::vector<wchar_t> vt;
bool isNegative = val < 0; bool isNegative = val < 0;
// can't use abs here because std::numeric_limits<int>::min() has no positive representation // can't use abs here because std::numeric_limits<int>::min() has no positive representation
//val = std::abs(val); //val = std::abs(val);
vt.push_back('0' + static_cast<TCHAR>(std::abs(val % 10))); vt.push_back('0' + static_cast<wchar_t>(std::abs(val % 10)));
val /= 10; val /= 10;
while (val != 0) while (val != 0)
{ {
vt.push_back('0' + static_cast<TCHAR>(std::abs(val % 10))); vt.push_back('0' + static_cast<wchar_t>(std::abs(val % 10)));
val /= 10; val /= 10;
} }
if (isNegative) if (isNegative)
vt.push_back('-'); vt.push_back('-');
return generic_string(vt.rbegin(), vt.rend()); return wstring(vt.rbegin(), vt.rend());
} }
generic_string uintToString(unsigned int val) wstring uintToString(unsigned int val)
{ {
std::vector<TCHAR> vt; std::vector<wchar_t> vt;
vt.push_back('0' + static_cast<TCHAR>(val % 10)); vt.push_back('0' + static_cast<wchar_t>(val % 10));
val /= 10; val /= 10;
while (val != 0) while (val != 0)
{ {
vt.push_back('0' + static_cast<TCHAR>(val % 10)); vt.push_back('0' + static_cast<wchar_t>(val % 10));
val /= 10; val /= 10;
} }
return generic_string(vt.rbegin(), vt.rend()); return wstring(vt.rbegin(), vt.rend());
} }
// Build Recent File menu entries from given // Build Recent File menu entries from given
generic_string BuildMenuFileName(int filenameLen, unsigned int pos, const generic_string &filename, bool ordinalNumber) wstring BuildMenuFileName(int filenameLen, unsigned int pos, const wstring &filename, bool ordinalNumber)
{ {
generic_string strTemp; wstring strTemp;
if (ordinalNumber) if (ordinalNumber)
{ {
if (pos < 9) if (pos < 9)
{ {
strTemp.push_back('&'); strTemp.push_back('&');
strTemp.push_back('1' + static_cast<TCHAR>(pos)); strTemp.push_back('1' + static_cast<wchar_t>(pos));
} }
else if (pos == 9) else if (pos == 9)
{ {
@ -593,7 +595,7 @@ generic_string BuildMenuFileName(int filenameLen, unsigned int pos, const generi
if (filenameLen > 0) if (filenameLen > 0)
{ {
std::vector<TCHAR> vt(filenameLen + 1); std::vector<wchar_t> vt(filenameLen + 1);
// W removed from PathCompactPathExW due to compiler errors for ANSI version. // W removed from PathCompactPathExW due to compiler errors for ANSI version.
PathCompactPathEx(&vt[0], filename.c_str(), filenameLen + 1, 0); PathCompactPathEx(&vt[0], filename.c_str(), filenameLen + 1, 0);
strTemp.append(convertFileName(vt.begin(), vt.begin() + lstrlen(&vt[0]))); strTemp.append(convertFileName(vt.begin(), vt.begin() + lstrlen(&vt[0])));
@ -601,7 +603,7 @@ generic_string BuildMenuFileName(int filenameLen, unsigned int pos, const generi
else else
{ {
// (filenameLen < 0) // (filenameLen < 0)
generic_string::const_iterator it = filename.begin(); wstring::const_iterator it = filename.begin();
if (filenameLen == 0) if (filenameLen == 0)
it += PathFindFileName(filename.c_str()) - filename.c_str(); it += PathFindFileName(filename.c_str()) - filename.c_str();
@ -623,10 +625,10 @@ generic_string BuildMenuFileName(int filenameLen, unsigned int pos, const generi
} }
generic_string PathRemoveFileSpec(generic_string& path) wstring PathRemoveFileSpec(wstring& path)
{ {
generic_string::size_type lastBackslash = path.find_last_of(TEXT('\\')); wstring::size_type lastBackslash = path.find_last_of(TEXT('\\'));
if (lastBackslash == generic_string::npos) if (lastBackslash == wstring::npos)
{ {
if (path.size() >= 2 && path[1] == TEXT(':')) // "C:foo.bar" becomes "C:" if (path.size() >= 2 && path[1] == TEXT(':')) // "C:foo.bar" becomes "C:"
path.erase(2); path.erase(2);
@ -646,7 +648,7 @@ generic_string PathRemoveFileSpec(generic_string& path)
} }
generic_string pathAppend(generic_string& strDest, const generic_string& str2append) wstring pathAppend(wstring& strDest, const wstring& str2append)
{ {
if (strDest.empty() && str2append.empty()) // "" + "" if (strDest.empty() && str2append.empty()) // "" + ""
{ {
@ -721,7 +723,7 @@ COLORREF getCtrlBgColor(HWND hWnd)
} }
generic_string stringToUpper(generic_string strToConvert) wstring stringToUpper(wstring strToConvert)
{ {
std::transform(strToConvert.begin(), strToConvert.end(), strToConvert.begin(), std::transform(strToConvert.begin(), strToConvert.end(), strToConvert.begin(),
[](wchar_t ch){ return static_cast<wchar_t>(towupper(ch)); } [](wchar_t ch){ return static_cast<wchar_t>(towupper(ch)); }
@ -729,14 +731,14 @@ generic_string stringToUpper(generic_string strToConvert)
return strToConvert; return strToConvert;
} }
generic_string stringToLower(generic_string strToConvert) wstring stringToLower(wstring strToConvert)
{ {
std::transform(strToConvert.begin(), strToConvert.end(), strToConvert.begin(), ::towlower); std::transform(strToConvert.begin(), strToConvert.end(), strToConvert.begin(), ::towlower);
return strToConvert; return strToConvert;
} }
generic_string stringReplace(generic_string subject, const generic_string& search, const generic_string& replace) wstring stringReplace(wstring subject, const wstring& search, const wstring& replace)
{ {
size_t pos = 0; size_t pos = 0;
while ((pos = subject.find(search, pos)) != std::string::npos) while ((pos = subject.find(search, pos)) != std::string::npos)
@ -748,7 +750,7 @@ generic_string stringReplace(generic_string subject, const generic_string& searc
} }
void stringSplit(const generic_string& input, const generic_string& delimiter, std::vector<generic_string>& output) void stringSplit(const wstring& input, const wstring& delimiter, std::vector<wstring>& output)
{ {
size_t start = 0U; size_t start = 0U;
size_t end = input.find(delimiter); size_t end = input.find(delimiter);
@ -763,7 +765,7 @@ void stringSplit(const generic_string& input, const generic_string& delimiter, s
} }
bool str2numberVector(generic_string str2convert, std::vector<size_t>& numVect) bool str2numberVector(wstring str2convert, std::vector<size_t>& numVect)
{ {
numVect.clear(); numVect.clear();
@ -784,7 +786,7 @@ bool str2numberVector(generic_string str2convert, std::vector<size_t>& numVect)
} }
} }
std::vector<generic_string> v; std::vector<wstring> v;
stringSplit(str2convert, TEXT(" "), v); stringSplit(str2convert, TEXT(" "), v);
for (const auto& i : v) for (const auto& i : v)
{ {
@ -797,7 +799,7 @@ bool str2numberVector(generic_string str2convert, std::vector<size_t>& numVect)
return true; return true;
} }
void stringJoin(const std::vector<generic_string>& strings, const generic_string& separator, generic_string& joinedString) void stringJoin(const std::vector<wstring>& strings, const wstring& separator, wstring& joinedString)
{ {
size_t length = strings.size(); size_t length = strings.size();
for (size_t i = 0; i < length; ++i) for (size_t i = 0; i < length; ++i)
@ -811,7 +813,7 @@ void stringJoin(const std::vector<generic_string>& strings, const generic_string
} }
generic_string stringTakeWhileAdmissable(const generic_string& input, const generic_string& admissable) wstring stringTakeWhileAdmissable(const wstring& input, const wstring& admissable)
{ {
// Find first non-admissable character in "input", and remove everything after it. // Find first non-admissable character in "input", and remove everything after it.
size_t idx = input.find_first_not_of(admissable); size_t idx = input.find_first_not_of(admissable);
@ -826,7 +828,7 @@ generic_string stringTakeWhileAdmissable(const generic_string& input, const gene
} }
double stodLocale(const generic_string& str, [[maybe_unused]] _locale_t loc, size_t* idx) double stodLocale(const wstring& str, [[maybe_unused]] _locale_t loc, size_t* idx)
{ {
// Copied from the std::stod implementation but uses _wcstod_l instead of wcstod. // Copied from the std::stod implementation but uses _wcstod_l instead of wcstod.
const wchar_t* ptr = str.c_str(); const wchar_t* ptr = str.c_str();
@ -847,9 +849,9 @@ double stodLocale(const generic_string& str, [[maybe_unused]] _locale_t loc, siz
} }
bool str2Clipboard(const generic_string &str2cpy, HWND hwnd) bool str2Clipboard(const wstring &str2cpy, HWND hwnd)
{ {
size_t len2Allocate = (str2cpy.size() + 1) * sizeof(TCHAR); size_t len2Allocate = (str2cpy.size() + 1) * sizeof(wchar_t);
HGLOBAL hglbCopy = ::GlobalAlloc(GMEM_MOVEABLE, len2Allocate); HGLOBAL hglbCopy = ::GlobalAlloc(GMEM_MOVEABLE, len2Allocate);
if (hglbCopy == NULL) if (hglbCopy == NULL)
{ {
@ -867,14 +869,14 @@ bool str2Clipboard(const generic_string &str2cpy, HWND hwnd)
return false; return false;
} }
// Lock the handle and copy the text to the buffer. // Lock the handle and copy the text to the buffer.
TCHAR *pStr = (TCHAR *)::GlobalLock(hglbCopy); wchar_t *pStr = (wchar_t *)::GlobalLock(hglbCopy);
if (!pStr) if (!pStr)
{ {
::GlobalFree(hglbCopy); ::GlobalFree(hglbCopy);
::CloseClipboard(); ::CloseClipboard();
return false; return false;
} }
wcscpy_s(pStr, len2Allocate / sizeof(TCHAR), str2cpy.c_str()); wcscpy_s(pStr, len2Allocate / sizeof(wchar_t), str2cpy.c_str());
::GlobalUnlock(hglbCopy); ::GlobalUnlock(hglbCopy);
// Place the handle on the clipboard. // Place the handle on the clipboard.
unsigned int clipBoardFormat = CF_UNICODETEXT; unsigned int clipBoardFormat = CF_UNICODETEXT;
@ -893,13 +895,13 @@ bool str2Clipboard(const generic_string &str2cpy, HWND hwnd)
bool buf2Clipboard(const std::vector<Buffer*>& buffers, bool isFullPath, HWND hwnd) bool buf2Clipboard(const std::vector<Buffer*>& buffers, bool isFullPath, HWND hwnd)
{ {
const generic_string crlf = _T("\r\n"); const wstring crlf = _T("\r\n");
generic_string selection; wstring selection;
for (auto&& buf : buffers) for (auto&& buf : buffers)
{ {
if (buf) if (buf)
{ {
const TCHAR* fileName = isFullPath ? buf->getFullPathName() : buf->getFileName(); const wchar_t* fileName = isFullPath ? buf->getFullPathName() : buf->getFileName();
if (fileName) if (fileName)
selection += fileName; selection += fileName;
} }
@ -911,7 +913,7 @@ bool buf2Clipboard(const std::vector<Buffer*>& buffers, bool isFullPath, HWND hw
return false; return false;
} }
bool matchInList(const TCHAR *fileName, const std::vector<generic_string> & patterns) bool matchInList(const wchar_t *fileName, const std::vector<wstring> & patterns)
{ {
bool is_matched = false; bool is_matched = false;
for (size_t i = 0, len = patterns.size(); i < len; ++i) for (size_t i = 0, len = patterns.size(); i < len; ++i)
@ -930,7 +932,7 @@ bool matchInList(const TCHAR *fileName, const std::vector<generic_string> & patt
return is_matched; return is_matched;
} }
bool matchInExcludeDirList(const TCHAR* dirName, const std::vector<generic_string>& patterns, size_t level) bool matchInExcludeDirList(const wchar_t* dirName, const std::vector<wstring>& patterns, size_t level)
{ {
for (size_t i = 0, len = patterns.size(); i < len; ++i) for (size_t i = 0, len = patterns.size(); i < len; ++i)
{ {
@ -951,7 +953,7 @@ bool matchInExcludeDirList(const TCHAR* dirName, const std::vector<generic_strin
return false; return false;
} }
bool allPatternsAreExclusion(const std::vector<generic_string> patterns) bool allPatternsAreExclusion(const std::vector<wstring> patterns)
{ {
bool oneInclusionPatternFound = false; bool oneInclusionPatternFound = false;
for (size_t i = 0, len = patterns.size(); i < len; ++i) for (size_t i = 0, len = patterns.size(); i < len; ++i)
@ -965,9 +967,9 @@ bool allPatternsAreExclusion(const std::vector<generic_string> patterns)
return !oneInclusionPatternFound; return !oneInclusionPatternFound;
} }
generic_string GetLastErrorAsString(DWORD errorCode) wstring GetLastErrorAsString(DWORD errorCode)
{ {
generic_string errorMsg(_T("")); wstring errorMsg(_T(""));
// Get the error message, if any. // Get the error message, if any.
// If both error codes (passed error n GetLastError) are 0, then return empty // If both error codes (passed error n GetLastError) are 0, then return empty
if (errorCode == 0) if (errorCode == 0)
@ -1079,7 +1081,7 @@ HWND CreateToolTipRect(int toolID, HWND hWnd, HINSTANCE hInst, const PTSTR pszTe
return hwndTip; return hwndTip;
} }
bool isCertificateValidated(const generic_string & fullFilePath, const generic_string & subjectName2check) bool isCertificateValidated(const wstring & fullFilePath, const wstring & subjectName2check)
{ {
bool isOK = false; bool isOK = false;
HCERTSTORE hStore = NULL; HCERTSTORE hStore = NULL;
@ -1094,7 +1096,7 @@ bool isCertificateValidated(const generic_string & fullFilePath, const generic_s
CERT_INFO CertInfo{}; CERT_INFO CertInfo{};
LPTSTR szName = NULL; LPTSTR szName = NULL;
generic_string subjectName; wstring subjectName;
try { try {
// Get message handle and store handle from the signed file. // Get message handle and store handle from the signed file.
@ -1112,7 +1114,7 @@ bool isCertificateValidated(const generic_string & fullFilePath, const generic_s
if (!result) if (!result)
{ {
generic_string errorMessage = TEXT("Check certificate of ") + fullFilePath + TEXT(" : "); wstring errorMessage = TEXT("Check certificate of ") + fullFilePath + TEXT(" : ");
errorMessage += GetLastErrorAsString(GetLastError()); errorMessage += GetLastErrorAsString(GetLastError());
throw errorMessage; throw errorMessage;
} }
@ -1121,7 +1123,7 @@ bool isCertificateValidated(const generic_string & fullFilePath, const generic_s
result = CryptMsgGetParam(hMsg, CMSG_SIGNER_INFO_PARAM, 0, NULL, &dwSignerInfo); result = CryptMsgGetParam(hMsg, CMSG_SIGNER_INFO_PARAM, 0, NULL, &dwSignerInfo);
if (!result) if (!result)
{ {
generic_string errorMessage = TEXT("CryptMsgGetParam first call: "); wstring errorMessage = TEXT("CryptMsgGetParam first call: ");
errorMessage += GetLastErrorAsString(GetLastError()); errorMessage += GetLastErrorAsString(GetLastError());
throw errorMessage; throw errorMessage;
} }
@ -1130,7 +1132,7 @@ bool isCertificateValidated(const generic_string & fullFilePath, const generic_s
pSignerInfo = (PCMSG_SIGNER_INFO)LocalAlloc(LPTR, dwSignerInfo); pSignerInfo = (PCMSG_SIGNER_INFO)LocalAlloc(LPTR, dwSignerInfo);
if (!pSignerInfo) if (!pSignerInfo)
{ {
generic_string errorMessage = TEXT("CryptMsgGetParam memory allocation problem: "); wstring errorMessage = TEXT("CryptMsgGetParam memory allocation problem: ");
errorMessage += GetLastErrorAsString(GetLastError()); errorMessage += GetLastErrorAsString(GetLastError());
throw errorMessage; throw errorMessage;
} }
@ -1139,7 +1141,7 @@ bool isCertificateValidated(const generic_string & fullFilePath, const generic_s
result = CryptMsgGetParam(hMsg, CMSG_SIGNER_INFO_PARAM, 0, (PVOID)pSignerInfo, &dwSignerInfo); result = CryptMsgGetParam(hMsg, CMSG_SIGNER_INFO_PARAM, 0, (PVOID)pSignerInfo, &dwSignerInfo);
if (!result) if (!result)
{ {
generic_string errorMessage = TEXT("CryptMsgGetParam: "); wstring errorMessage = TEXT("CryptMsgGetParam: ");
errorMessage += GetLastErrorAsString(GetLastError()); errorMessage += GetLastErrorAsString(GetLastError());
throw errorMessage; throw errorMessage;
} }
@ -1152,7 +1154,7 @@ bool isCertificateValidated(const generic_string & fullFilePath, const generic_s
pCertContext = CertFindCertificateInStore(hStore, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, 0, CERT_FIND_SUBJECT_CERT, (PVOID)&CertInfo, NULL); pCertContext = CertFindCertificateInStore(hStore, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, 0, CERT_FIND_SUBJECT_CERT, (PVOID)&CertInfo, NULL);
if (!pCertContext) if (!pCertContext)
{ {
generic_string errorMessage = TEXT("Certificate context: "); wstring errorMessage = TEXT("Certificate context: ");
errorMessage += GetLastErrorAsString(GetLastError()); errorMessage += GetLastErrorAsString(GetLastError());
throw errorMessage; throw errorMessage;
} }
@ -1163,32 +1165,32 @@ bool isCertificateValidated(const generic_string & fullFilePath, const generic_s
dwData = CertGetNameString(pCertContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, NULL, NULL, 0); dwData = CertGetNameString(pCertContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, NULL, NULL, 0);
if (dwData <= 1) if (dwData <= 1)
{ {
throw generic_string(TEXT("Certificate checking error: getting data size problem.")); throw wstring(TEXT("Certificate checking error: getting data size problem."));
} }
// Allocate memory for subject name. // Allocate memory for subject name.
szName = (LPTSTR)LocalAlloc(LPTR, dwData * sizeof(TCHAR)); szName = (LPTSTR)LocalAlloc(LPTR, dwData * sizeof(wchar_t));
if (!szName) if (!szName)
{ {
throw generic_string(TEXT("Certificate checking error: memory allocation problem.")); throw wstring(TEXT("Certificate checking error: memory allocation problem."));
} }
// Get subject name. // Get subject name.
if (CertGetNameString(pCertContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, NULL, szName, dwData) <= 1) if (CertGetNameString(pCertContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, NULL, szName, dwData) <= 1)
{ {
throw generic_string(TEXT("Cannot get certificate info.")); throw wstring(TEXT("Cannot get certificate info."));
} }
// check Subject name. // check Subject name.
subjectName = szName; subjectName = szName;
if (subjectName != subjectName2check) if (subjectName != subjectName2check)
{ {
throw generic_string(TEXT("Certificate checking error: the certificate is not matched.")); throw wstring(TEXT("Certificate checking error: the certificate is not matched."));
} }
isOK = true; isOK = true;
} }
catch (const generic_string& s) catch (const wstring& s)
{ {
// display error message // display error message
MessageBox(NULL, s.c_str(), TEXT("Certificate checking"), MB_OK); MessageBox(NULL, s.c_str(), TEXT("Certificate checking"), MB_OK);
@ -1196,7 +1198,7 @@ bool isCertificateValidated(const generic_string & fullFilePath, const generic_s
catch (...) catch (...)
{ {
// Unknown error // Unknown error
generic_string errorMessage = TEXT("Unknown exception occured. "); wstring errorMessage = TEXT("Unknown exception occured. ");
errorMessage += GetLastErrorAsString(GetLastError()); errorMessage += GetLastErrorAsString(GetLastError());
MessageBox(NULL, errorMessage.c_str(), TEXT("Certificate checking"), MB_OK); MessageBox(NULL, errorMessage.c_str(), TEXT("Certificate checking"), MB_OK);
} }
@ -1251,10 +1253,10 @@ std::string ws2s(const std::wstring& wstr)
return converterX.to_bytes(wstr); return converterX.to_bytes(wstr);
} }
bool deleteFileOrFolder(const generic_string& f2delete) bool deleteFileOrFolder(const wstring& f2delete)
{ {
auto len = f2delete.length(); auto len = f2delete.length();
TCHAR* actionFolder = new TCHAR[len + 2]; wchar_t* actionFolder = new wchar_t[len + 2];
wcscpy_s(actionFolder, len + 2, f2delete.c_str()); wcscpy_s(actionFolder, len + 2, f2delete.c_str());
actionFolder[len] = 0; actionFolder[len] = 0;
actionFolder[len + 1] = 0; actionFolder[len + 1] = 0;
@ -1276,9 +1278,9 @@ bool deleteFileOrFolder(const generic_string& f2delete)
} }
// Get a vector of full file paths in a given folder. File extension type filter should be *.*, *.xml, *.dll... according the type of file you want to get. // Get a vector of full file paths in a given folder. File extension type filter should be *.*, *.xml, *.dll... according the type of file you want to get.
void getFilesInFolder(std::vector<generic_string>& files, const generic_string& extTypeFilter, const generic_string& inFolder) void getFilesInFolder(std::vector<wstring>& files, const wstring& extTypeFilter, const wstring& inFolder)
{ {
generic_string filter = inFolder; wstring filter = inFolder;
pathAppend(filter, extTypeFilter); pathAppend(filter, extTypeFilter);
WIN32_FIND_DATA foundData; WIN32_FIND_DATA foundData;
@ -1289,7 +1291,7 @@ void getFilesInFolder(std::vector<generic_string>& files, const generic_string&
{ {
if (!(foundData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) if (!(foundData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{ {
generic_string foundFullPath = inFolder; wstring foundFullPath = inFolder;
pathAppend(foundFullPath, foundData.cFileName); pathAppend(foundFullPath, foundData.cFileName);
files.push_back(foundFullPath); files.push_back(foundFullPath);
} }
@ -1337,14 +1339,14 @@ int nbDigitsFromNbLines(size_t nbLines)
namespace namespace
{ {
constexpr TCHAR timeFmtEscapeChar = 0x1; constexpr wchar_t timeFmtEscapeChar = 0x1;
constexpr TCHAR middayFormat[] = _T("tt"); constexpr wchar_t middayFormat[] = _T("tt");
// Returns AM/PM string defined by the system locale for the specified time. // Returns AM/PM string defined by the system locale for the specified time.
// This string may be empty or customized. // This string may be empty or customized.
generic_string getMiddayString(const TCHAR* localeName, const SYSTEMTIME& st) wstring getMiddayString(const wchar_t* localeName, const SYSTEMTIME& st)
{ {
generic_string midday; wstring midday;
midday.resize(MAX_PATH); midday.resize(MAX_PATH);
int ret = GetTimeFormatEx(localeName, 0, &st, middayFormat, &midday[0], static_cast<int>(midday.size())); int ret = GetTimeFormatEx(localeName, 0, &st, middayFormat, &midday[0], static_cast<int>(midday.size()));
if (ret > 0) if (ret > 0)
@ -1355,7 +1357,7 @@ namespace
} }
// Replaces conflicting time format specifiers by a special character. // Replaces conflicting time format specifiers by a special character.
bool escapeTimeFormat(generic_string& format) bool escapeTimeFormat(wstring& format)
{ {
bool modified = false; bool modified = false;
for (auto& ch : format) for (auto& ch : format)
@ -1370,7 +1372,7 @@ namespace
} }
// Replaces special time format characters by actual AM/PM string. // Replaces special time format characters by actual AM/PM string.
void unescapeTimeFormat(generic_string& format, const generic_string& midday) void unescapeTimeFormat(wstring& format, const wstring& midday)
{ {
if (midday.empty()) if (midday.empty())
{ {
@ -1381,7 +1383,7 @@ namespace
else else
{ {
size_t i = 0; size_t i = 0;
while ((i = format.find(timeFmtEscapeChar, i)) != generic_string::npos) while ((i = format.find(timeFmtEscapeChar, i)) != wstring::npos)
{ {
if (i + 1 < format.size() && format[i + 1] == timeFmtEscapeChar) if (i + 1 < format.size() && format[i + 1] == timeFmtEscapeChar)
{ {
@ -1399,19 +1401,19 @@ namespace
} }
} }
generic_string getDateTimeStrFrom(const generic_string& dateTimeFormat, const SYSTEMTIME& st) wstring getDateTimeStrFrom(const wstring& dateTimeFormat, const SYSTEMTIME& st)
{ {
const TCHAR* localeName = LOCALE_NAME_USER_DEFAULT; const wchar_t* localeName = LOCALE_NAME_USER_DEFAULT;
const DWORD flags = 0; const DWORD flags = 0;
constexpr int bufferSize = MAX_PATH; constexpr int bufferSize = MAX_PATH;
TCHAR buffer[bufferSize] = {}; wchar_t buffer[bufferSize] = {};
int ret = 0; int ret = 0;
// 1. Escape 'tt' that means AM/PM or 't' that means A/P. // 1. Escape 'tt' that means AM/PM or 't' that means A/P.
// This is needed to avoid conflict with 'M' date format that stands for month. // This is needed to avoid conflict with 'M' date format that stands for month.
generic_string newFormat = dateTimeFormat; wstring newFormat = dateTimeFormat;
const bool hasMiddayFormat = escapeTimeFormat(newFormat); const bool hasMiddayFormat = escapeTimeFormat(newFormat);
// 2. Format the time (h/m/s/t/H). // 2. Format the time (h/m/s/t/H).
@ -1428,8 +1430,8 @@ generic_string getDateTimeStrFrom(const generic_string& dateTimeFormat, const SY
if (hasMiddayFormat) if (hasMiddayFormat)
{ {
// 4. Now format only the AM/PM string. // 4. Now format only the AM/PM string.
const generic_string midday = getMiddayString(localeName, st); const wstring midday = getMiddayString(localeName, st);
generic_string result = buffer; wstring result = buffer;
unescapeTimeFormat(result, midday); unescapeTimeFormat(result, midday);
return result; return result;
} }
@ -1440,7 +1442,7 @@ generic_string getDateTimeStrFrom(const generic_string& dateTimeFormat, const SY
} }
// Don't forget to use DeleteObject(createdFont) before leaving the program // Don't forget to use DeleteObject(createdFont) before leaving the program
HFONT createFont(const TCHAR* fontName, int fontSize, bool isBold, HWND hDestParent) HFONT createFont(const wchar_t* fontName, int fontSize, bool isBold, HWND hDestParent)
{ {
HDC hdc = GetDC(hDestParent); HDC hdc = GetDC(hDestParent);
@ -1471,7 +1473,7 @@ bool removeReadOnlyFlagFromFileAttributes(const wchar_t* fileFullPath)
// "For file I/O, the "\\?\" prefix to a path string tells the Windows APIs to disable all string parsing // "For file I/O, the "\\?\" prefix to a path string tells the Windows APIs to disable all string parsing
// and to send the string that follows it straight to the file system..." // and to send the string that follows it straight to the file system..."
// Ref: https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#win32-file-namespaces // Ref: https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#win32-file-namespaces
bool isWin32NamespacePrefixedFileName(const generic_string& fileName) bool isWin32NamespacePrefixedFileName(const wstring& fileName)
{ {
// TODO: // TODO:
// ?! how to handle similar NT Object Manager path style prefix case \??\... // ?! how to handle similar NT Object Manager path style prefix case \??\...
@ -1482,13 +1484,13 @@ bool isWin32NamespacePrefixedFileName(const generic_string& fileName)
return (fileName.starts_with(TEXT("\\\\?\\")) || fileName.starts_with(TEXT("//?/"))); return (fileName.starts_with(TEXT("\\\\?\\")) || fileName.starts_with(TEXT("//?/")));
} }
bool isWin32NamespacePrefixedFileName(const TCHAR* szFileName) bool isWin32NamespacePrefixedFileName(const wchar_t* szFileName)
{ {
const generic_string fileName = szFileName; const wstring fileName = szFileName;
return isWin32NamespacePrefixedFileName(fileName); return isWin32NamespacePrefixedFileName(fileName);
} }
bool isUnsupportedFileName(const generic_string& fileName) bool isUnsupportedFileName(const wstring& fileName)
{ {
bool isUnsupported = true; bool isUnsupported = true;
@ -1509,7 +1511,7 @@ bool isUnsupportedFileName(const generic_string& fileName)
for (size_t pos = 0; pos < fileName.size(); ++pos) for (size_t pos = 0; pos < fileName.size(); ++pos)
{ {
TCHAR c = fileName.at(pos); wchar_t c = fileName.at(pos);
if (c <= 31) if (c <= 31)
{ {
invalidASCIIChar = true; invalidASCIIChar = true;
@ -1536,7 +1538,7 @@ bool isUnsupportedFileName(const generic_string& fileName)
if (!invalidASCIIChar) if (!invalidASCIIChar)
{ {
// strip input string to a filename without a possible path and extension(s) // strip input string to a filename without a possible path and extension(s)
generic_string fileNameOnly; wstring fileNameOnly;
size_t pos = fileName.find_first_of(TEXT(".")); size_t pos = fileName.find_first_of(TEXT("."));
if (pos != std::string::npos) if (pos != std::string::npos)
fileNameOnly = fileName.substr(0, pos); fileNameOnly = fileName.substr(0, pos);
@ -1552,7 +1554,7 @@ bool isUnsupportedFileName(const generic_string& fileName)
// upperize because the std::find is case sensitive unlike the Windows OS filesystem // upperize because the std::find is case sensitive unlike the Windows OS filesystem
std::transform(fileNameOnly.begin(), fileNameOnly.end(), fileNameOnly.begin(), ::towupper); std::transform(fileNameOnly.begin(), fileNameOnly.end(), fileNameOnly.begin(), ::towupper);
const std::vector<generic_string> reservedWin32NamespaceDeviceList{ const std::vector<wstring> reservedWin32NamespaceDeviceList {
TEXT("CON"), TEXT("PRN"), TEXT("AUX"), TEXT("NUL"), TEXT("CON"), TEXT("PRN"), TEXT("AUX"), TEXT("NUL"),
TEXT("COM1"), TEXT("COM2"), TEXT("COM3"), TEXT("COM4"), TEXT("COM5"), TEXT("COM6"), TEXT("COM7"), TEXT("COM8"), TEXT("COM9"), TEXT("COM1"), TEXT("COM2"), TEXT("COM3"), TEXT("COM4"), TEXT("COM5"), TEXT("COM6"), TEXT("COM7"), TEXT("COM8"), TEXT("COM9"),
TEXT("LPT1"), TEXT("LPT2"), TEXT("LPT3"), TEXT("LPT4"), TEXT("LPT5"), TEXT("LPT6"), TEXT("LPT7"), TEXT("LPT8"), TEXT("LPT9") TEXT("LPT1"), TEXT("LPT2"), TEXT("LPT3"), TEXT("LPT4"), TEXT("LPT5"), TEXT("LPT6"), TEXT("LPT7"), TEXT("LPT8"), TEXT("LPT9")
@ -1571,14 +1573,14 @@ bool isUnsupportedFileName(const generic_string& fileName)
return isUnsupported; return isUnsupported;
} }
bool isUnsupportedFileName(const TCHAR* szFileName) bool isUnsupportedFileName(const wchar_t* szFileName)
{ {
const generic_string fileName = szFileName; const wstring fileName = szFileName;
return isUnsupportedFileName(fileName); return isUnsupportedFileName(fileName);
} }
Version::Version(const generic_string& versionStr) Version::Version(const wstring& versionStr)
{ {
try { try {
auto ss = tokenizeString(versionStr, '.'); auto ss = tokenizeString(versionStr, '.');
@ -1627,13 +1629,13 @@ Version::Version(const generic_string& versionStr)
_patch = 0; _patch = 0;
_build = 0; _build = 0;
#ifdef DEBUG #ifdef DEBUG
throw std::wstring(TEXT("Unknown exception from \"Version::Version(const generic_string& versionStr)\"")); throw std::wstring(TEXT("Unknown exception from \"Version::Version(const wstring& versionStr)\""));
#endif #endif
} }
} }
void Version::setVersionFrom(const generic_string& filePath) void Version::setVersionFrom(const wstring& filePath)
{ {
if (!filePath.empty() && ::PathFileExists(filePath.c_str())) if (!filePath.empty() && ::PathFileExists(filePath.c_str()))
{ {
@ -1660,7 +1662,7 @@ void Version::setVersionFrom(const generic_string& filePath)
} }
} }
generic_string Version::toString() wstring Version::toString()
{ {
if (_build == 0 && _patch == 0 && _minor == 0 && _major == 0) // "" if (_build == 0 && _patch == 0 && _minor == 0 && _major == 0) // ""
{ {

View File

@ -46,35 +46,35 @@ const bool dirDown = false;
#define NPP_INTERNAL_FUCTION_STR L"Notepad++::InternalFunction" #define NPP_INTERNAL_FUCTION_STR L"Notepad++::InternalFunction"
typedef std::basic_string<TCHAR> generic_string; typedef std::basic_string<wchar_t> generic_string;
typedef std::basic_stringstream<TCHAR> generic_stringstream; typedef std::basic_stringstream<wchar_t> generic_stringstream;
generic_string folderBrowser(HWND parent, const generic_string & title = TEXT(""), int outputCtrlID = 0, const TCHAR *defaultStr = NULL); std::wstring folderBrowser(HWND parent, const std::wstring & title = TEXT(""), int outputCtrlID = 0, const wchar_t *defaultStr = NULL);
generic_string getFolderName(HWND parent, const TCHAR *defaultDir = NULL); std::wstring getFolderName(HWND parent, const wchar_t *defaultDir = NULL);
void printInt(int int2print); void printInt(int int2print);
void printStr(const TCHAR *str2print); void printStr(const wchar_t *str2print);
generic_string commafyInt(size_t n); std::wstring commafyInt(size_t n);
void writeLog(const TCHAR *logFileName, const char *log2write); void writeLog(const wchar_t *logFileName, const char *log2write);
int filter(unsigned int code, struct _EXCEPTION_POINTERS *ep); int filter(unsigned int code, struct _EXCEPTION_POINTERS *ep);
generic_string purgeMenuItemString(const TCHAR * menuItemStr, bool keepAmpersand = false); std::wstring purgeMenuItemString(const wchar_t * menuItemStr, bool keepAmpersand = false);
std::vector<generic_string> tokenizeString(const generic_string & tokenString, const char delim); std::vector<std::wstring> tokenizeString(const std::wstring & tokenString, const char delim);
void ClientRectToScreenRect(HWND hWnd, RECT* rect); void ClientRectToScreenRect(HWND hWnd, RECT* rect);
void ScreenRectToClientRect(HWND hWnd, RECT* rect); void ScreenRectToClientRect(HWND hWnd, RECT* rect);
std::wstring string2wstring(const std::string & rString, UINT codepage); std::wstring string2wstring(const std::string & rString, UINT codepage);
std::string wstring2string(const std::wstring & rwString, UINT codepage); std::string wstring2string(const std::wstring & rwString, UINT codepage);
bool isInList(const TCHAR *token, const TCHAR *list); bool isInList(const wchar_t *token, const wchar_t *list);
generic_string BuildMenuFileName(int filenameLen, unsigned int pos, const generic_string &filename, bool ordinalNumber = true); std::wstring BuildMenuFileName(int filenameLen, unsigned int pos, const std::wstring &filename, bool ordinalNumber = true);
std::string getFileContent(const TCHAR *file2read); std::string getFileContent(const wchar_t *file2read);
generic_string relativeFilePathToFullFilePath(const TCHAR *relativeFilePath); std::wstring relativeFilePathToFullFilePath(const wchar_t *relativeFilePath);
void writeFileContent(const TCHAR *file2write, const char *content2write); void writeFileContent(const wchar_t *file2write, const char *content2write);
bool matchInList(const TCHAR *fileName, const std::vector<generic_string> & patterns); bool matchInList(const wchar_t *fileName, const std::vector<std::wstring> & patterns);
bool matchInExcludeDirList(const TCHAR* dirName, const std::vector<generic_string>& patterns, size_t level); bool matchInExcludeDirList(const wchar_t* dirName, const std::vector<std::wstring>& patterns, size_t level);
bool allPatternsAreExclusion(const std::vector<generic_string> patterns); bool allPatternsAreExclusion(const std::vector<std::wstring> patterns);
class WcharMbcsConvertor final class WcharMbcsConvertor final
{ {
@ -151,39 +151,39 @@ protected:
#define REBARBAND_SIZE sizeof(REBARBANDINFO) #define REBARBAND_SIZE sizeof(REBARBANDINFO)
generic_string PathRemoveFileSpec(generic_string & path); std::wstring PathRemoveFileSpec(std::wstring & path);
generic_string pathAppend(generic_string &strDest, const generic_string & str2append); std::wstring pathAppend(std::wstring &strDest, const std::wstring & str2append);
COLORREF getCtrlBgColor(HWND hWnd); COLORREF getCtrlBgColor(HWND hWnd);
generic_string stringToUpper(generic_string strToConvert); std::wstring stringToUpper(std::wstring strToConvert);
generic_string stringToLower(generic_string strToConvert); std::wstring stringToLower(std::wstring strToConvert);
generic_string stringReplace(generic_string subject, const generic_string& search, const generic_string& replace); std::wstring stringReplace(std::wstring subject, const std::wstring& search, const std::wstring& replace);
void stringSplit(const generic_string& input, const generic_string& delimiter, std::vector<generic_string>& output); void stringSplit(const std::wstring& input, const std::wstring& delimiter, std::vector<std::wstring>& output);
bool str2numberVector(generic_string str2convert, std::vector<size_t>& numVect); bool str2numberVector(std::wstring str2convert, std::vector<size_t>& numVect);
void stringJoin(const std::vector<generic_string>& strings, const generic_string& separator, generic_string& joinedString); void stringJoin(const std::vector<std::wstring>& strings, const std::wstring& separator, std::wstring& joinedString);
generic_string stringTakeWhileAdmissable(const generic_string& input, const generic_string& admissable); std::wstring stringTakeWhileAdmissable(const std::wstring& input, const std::wstring& admissable);
double stodLocale(const generic_string& str, _locale_t loc, size_t* idx = NULL); double stodLocale(const std::wstring& str, _locale_t loc, size_t* idx = NULL);
bool str2Clipboard(const generic_string &str2cpy, HWND hwnd); bool str2Clipboard(const std::wstring &str2cpy, HWND hwnd);
class Buffer; class Buffer;
bool buf2Clipboard(const std::vector<Buffer*>& buffers, bool isFullPath, HWND hwnd); bool buf2Clipboard(const std::vector<Buffer*>& buffers, bool isFullPath, HWND hwnd);
generic_string GetLastErrorAsString(DWORD errorCode = 0); std::wstring GetLastErrorAsString(DWORD errorCode = 0);
generic_string intToString(int val); std::wstring intToString(int val);
generic_string uintToString(unsigned int val); std::wstring uintToString(unsigned int val);
HWND CreateToolTip(int toolID, HWND hDlg, HINSTANCE hInst, const PTSTR pszText, bool isRTL); HWND CreateToolTip(int toolID, HWND hDlg, HINSTANCE hInst, const PTSTR pszText, bool isRTL);
HWND CreateToolTipRect(int toolID, HWND hWnd, HINSTANCE hInst, const PTSTR pszText, const RECT rc); HWND CreateToolTipRect(int toolID, HWND hWnd, HINSTANCE hInst, const PTSTR pszText, const RECT rc);
bool isCertificateValidated(const generic_string & fullFilePath, const generic_string & subjectName2check); bool isCertificateValidated(const std::wstring & fullFilePath, const std::wstring & subjectName2check);
bool isAssoCommandExisting(LPCTSTR FullPathName); bool isAssoCommandExisting(LPCTSTR FullPathName);
std::wstring s2ws(const std::string& str); std::wstring s2ws(const std::string& str);
std::string ws2s(const std::wstring& wstr); std::string ws2s(const std::wstring& wstr);
bool deleteFileOrFolder(const generic_string& f2delete); bool deleteFileOrFolder(const std::wstring& f2delete);
void getFilesInFolder(std::vector<generic_string>& files, const generic_string& extTypeFilter, const generic_string& inFolder); void getFilesInFolder(std::vector<std::wstring>& files, const std::wstring& extTypeFilter, const std::wstring& inFolder);
template<typename T> size_t vecRemoveDuplicates(std::vector<T>& vec, bool isSorted = false, bool canSort = false) template<typename T> size_t vecRemoveDuplicates(std::vector<T>& vec, bool isSorted = false, bool canSort = false)
{ {
@ -215,27 +215,27 @@ void trim(std::wstring& str);
int nbDigitsFromNbLines(size_t nbLines); int nbDigitsFromNbLines(size_t nbLines);
generic_string getDateTimeStrFrom(const generic_string& dateTimeFormat, const SYSTEMTIME& st); std::wstring getDateTimeStrFrom(const std::wstring& dateTimeFormat, const SYSTEMTIME& st);
HFONT createFont(const TCHAR* fontName, int fontSize, bool isBold, HWND hDestParent); HFONT createFont(const wchar_t* fontName, int fontSize, bool isBold, HWND hDestParent);
bool removeReadOnlyFlagFromFileAttributes(const wchar_t* fileFullPath); bool removeReadOnlyFlagFromFileAttributes(const wchar_t* fileFullPath);
bool isWin32NamespacePrefixedFileName(const generic_string& fileName); bool isWin32NamespacePrefixedFileName(const std::wstring& fileName);
bool isWin32NamespacePrefixedFileName(const TCHAR* szFileName); bool isWin32NamespacePrefixedFileName(const wchar_t* szFileName);
bool isUnsupportedFileName(const generic_string& fileName); bool isUnsupportedFileName(const std::wstring& fileName);
bool isUnsupportedFileName(const TCHAR* szFileName); bool isUnsupportedFileName(const wchar_t* szFileName);
class Version final class Version final
{ {
public: public:
Version() = default; Version() = default;
Version(const generic_string& versionStr); Version(const std::wstring& versionStr);
void setVersionFrom(const generic_string& filePath); void setVersionFrom(const std::wstring& filePath);
generic_string toString(); std::wstring toString();
bool isNumber(const generic_string& s) const { bool isNumber(const std::wstring& s) const {
return !s.empty() && return !s.empty() &&
find_if(s.begin(), s.end(), [](TCHAR c) { return !_istdigit(c); }) == s.end(); find_if(s.begin(), s.end(), [](wchar_t c) { return !_istdigit(c); }) == s.end();
}; };
int compareTo(const Version& v2c) const; int compareTo(const Version& v2c) const;