C++
#C++ GloballyGlobally, your c++ seems good enought
In argvw_of_cmdline
you don't have to wrap your second part in a else
since you returns in the if
.
You can remove a lot of things in current_exe_directory
:
std::wstring current_exe_directory(void) {
HMODULE h_module = GetModuleHandleW(nullptr);
WCHAR path[MAX_PATH];
memset(path, 0, sizeof(path));
GetModuleFileNameW(h_module, path, MAX_PATH);
std::wstring_view w_path(path);
return std::wstring{ws.begin(), ws.find_last_not_of(L'\\')};
}
(note: you can improve it, but it's already kinda simplified)
You can simplify your escape_string(...)
function:
std::wstring escape_string(std::wstring ws) {
const auto esc = std::wstring{L"\\\""};
for (size_t index = 0; (index = ws.find_first_of(esc, index)) != std::wstring::npos; index += 2) {
ws.insert(index, 1, L'\\');
}
return ws;
}
Note that I didn't tested theses codes, but it should work :)
#C++ Globally, your c++ seems good enought
In argvw_of_cmdline
you don't have to wrap your second part in a else
since you returns in the if
.
You can remove a lot of things in current_exe_directory
:
std::wstring current_exe_directory(void) {
HMODULE h_module = GetModuleHandleW(nullptr);
WCHAR path[MAX_PATH];
memset(path, 0, sizeof(path));
GetModuleFileNameW(h_module, path, MAX_PATH);
std::wstring_view w_path(path);
return std::wstring{ws.begin(), ws.find_last_not_of(L'\\')};
}
(note: you can improve it, but it's already kinda simplified)
You can simplify your escape_string(...)
function:
std::wstring escape_string(std::wstring ws) {
const auto esc = std::wstring{L"\\\""};
for (size_t index = 0; (index = ws.find_first_of(esc, index)) != std::wstring::npos; index += 2) {
ws.insert(index, 1, L'\\');
}
return ws;
}
Note that I didn't tested theses codes, but it should work :)
C++
Globally, your c++ seems good enought
In argvw_of_cmdline
you don't have to wrap your second part in a else
since you returns in the if
.
You can remove a lot of things in current_exe_directory
:
std::wstring current_exe_directory(void) {
HMODULE h_module = GetModuleHandleW(nullptr);
WCHAR path[MAX_PATH];
memset(path, 0, sizeof(path));
GetModuleFileNameW(h_module, path, MAX_PATH);
std::wstring_view w_path(path);
return std::wstring{ws.begin(), ws.find_last_not_of(L'\\')};
}
(note: you can improve it, but it's already kinda simplified)
You can simplify your escape_string(...)
function:
std::wstring escape_string(std::wstring ws) {
const auto esc = std::wstring{L"\\\""};
for (size_t index = 0; (index = ws.find_first_of(esc, index)) != std::wstring::npos; index += 2) {
ws.insert(index, 1, L'\\');
}
return ws;
}
Note that I didn't tested theses codes, but it should work :)
#C++ Globally, your c++ seems good enought
In argvw_of_cmdline
you don't have to wrap your second part in a else
since you returns in the if
.
You can remove a lot of things in current_exe_directory
:
std::wstring current_exe_directory(void) {
HMODULE h_module = GetModuleHandleW(nullptr);
WCHAR path[MAX_PATH];
memset(path, 0, sizeof(path));
GetModuleFileNameW(h_module, path, MAX_PATH);
std::wstring_view w_path(path);
return std::wstring{ws.begin(), ws.find_last_not_of(L'\\')};
}
(note: you can improve it, but it's already kinda simplified)
You can simplify your escape_string(...)
function:
std::wstring escape_string(std::wstring ws) {
const auto esc = std::wstring{L"\\\""};
for (size_t index = 0; (index = ws.find_first_of(esc, index)) != std::wstring::npos; index += 2) {
ws.insert(index, 1, L'\\');
}
return ws;
}
Note that I didn't tested theses codes, but it should work :)