Audacity 3.2.0
CommandLineArgs.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 @file CommandLineArgs.cpp
6
7 Paul Licameli
8
9**********************************************************************/
10#include "CommandLineArgs.h"
11
13const char *const *CommandLineArgs::argv;
14
15#ifdef _WIN32
16#include <windows.h>
17
18#include <locale>
19#include <codecvt>
20
21namespace CommandLineArgs {
22MSWParser::MSWParser()
23{
24 wideArgv = ::CommandLineToArgvW(::GetCommandLineW(), &argc);
25 for (size_t ii = 0; ii < argc; ++ii)
26 {
27 auto begin = wideArgv[ii];
28 auto end = begin + wcslen(begin);
29
30 narrowArgv.emplace_back(
31 std::wstring_convert<std::codecvt_utf8<wchar_t>>().to_bytes(
32 begin, end));
33 }
34
35 for (const auto& arg : narrowArgv)
36 argv.push_back(arg.c_str());
37
38 argv.push_back(nullptr);
39}
40
41MSWParser::~MSWParser()
42{
43 if (wideArgv)
44 ::LocalFree(wideArgv);
45}
46} // namespace CommandLineArgs
47#endif
UTILITY_API const char *const * argv
A copy of argv; responsibility of application startup to assign it.
UTILITY_API int argc
A copy of argc; responsibility of application startup to assign it.
const char * end(const char *str) noexcept
Definition: StringUtils.h:106
const char * begin(const char *str) noexcept
Definition: StringUtils.h:101