1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QCORECMDLINEARGS_P_H
5#define QCORECMDLINEARGS_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/private/qglobal_p.h>
19#include "QtCore/qstring.h"
20#include "QtCore/qstringlist.h"
21
22#if defined(Q_OS_WIN)
23# ifdef Q_OS_WIN32
24# include <qt_windows.h> // first to suppress min, max macros.
25# include <shlobj.h>
26# else
27# include <qt_windows.h>
28# endif
29
30QT_BEGIN_NAMESPACE
31
32#if defined(Q_OS_WIN32)
33
34static inline QStringList qWinCmdArgs(const QString &cmdLine)
35{
36 QStringList result;
37 int size;
38 if (wchar_t **argv = CommandLineToArgvW((const wchar_t *)cmdLine.utf16(), &size)) {
39 result.reserve(size);
40 wchar_t **argvEnd = argv + size;
41 for (wchar_t **a = argv; a < argvEnd; ++a)
42 result.append(QString::fromWCharArray(*a));
43 LocalFree(argv);
44 }
45 return result;
46}
47
48#endif // Q_OS_WIN32
49
50QT_END_NAMESPACE
51
52#endif // Q_OS_WIN
53
54#endif // QCORECMDLINEARGS_WIN_P_H
55

source code of qtbase/src/corelib/kernel/qcorecmdlineargs_p.h