UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
CommandLine.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreTypes.h"
6#include "Containers/Array.h"
9
10/*-----------------------------------------------------------------------------
11 Command line.
12-----------------------------------------------------------------------------*/
13
14#ifndef UE_COMMAND_LINE_USES_ALLOW_LIST
15 #ifdef WANTS_COMMANDLINE_WHITELIST
16 #pragma message("Use UE_COMMAND_LINE_USES_ALLOW_LIST instead of WANTS_COMMANDLINE_WHITELIST")
17 #define UE_COMMAND_LINE_USES_ALLOW_LIST WANTS_COMMANDLINE_WHITELIST
18 #else
19 #define UE_COMMAND_LINE_USES_ALLOW_LIST 0
20 #endif
21#endif
22
23
25{
26 None = 0x0000,
27
28 //~ Application context for a commandline argument
29 EditorContext = 0x0001,
30 ClientContext = 0x0002,
31 ServerContext = 0x0004,
32 CommandletContext = 0x0008,
33 ProgramContext = 0x0010,
34
35 GameContexts = 0x0006,
36 AllContexts = 0x001F,
37
38 // Indicates this argument should be automatically inherited by subprocesses.
39 // To be combined with one or more application context to inherit to.
40 Inherit = 0x0020,
41};
42
44
46{
48 static constexpr inline uint32 MaxCommandLineSize = 16384;
49
53 CORE_API static void Reset();
54
58 CORE_API static const TCHAR* Get();
59
63 CORE_API static const TCHAR* GetForLogging();
64
68 CORE_API static const TCHAR* GetOriginal();
69
73 CORE_API static const TCHAR* GetOriginalForLogging();
74
78 CORE_API static bool IsInitialized();
79
83 CORE_API static uint32 GetCommandLineVersion();
84
88 CORE_API static bool Set(const TCHAR* NewCommandLine);
89
94 CORE_API static void Append(const TCHAR* AppendString);
95
102 CORE_API static void RegisterArgument(FStringView Name, ECommandLineArgumentFlags Flags, FStringView Description = FStringView());
103
110 UE_DEPRECATED(5.6, "Use AddToSubprocessCommandLine version with capital L and flags argument.")
111 CORE_API static void AddToSubprocessCommandline( const TCHAR* Param );
112
120 CORE_API static void AddToSubprocessCommandLine( const TCHAR* Param, ECommandLineArgumentFlags ApplicationContextFlags );
121
125 UE_DEPRECATED(5.6, "Use BuildSubprocessCommandLine instead.")
126 CORE_API static const FString& GetSubprocessCommandline();
127
136
141 CORE_API static const TCHAR* RemoveExeName(const TCHAR* CmdLine);
142
151 CORE_API static void Parse(const TCHAR* CmdLine, TArray<FString>& Tokens, TArray<FString>& Switches);
152
158 CORE_API static bool IsCommandLineLoggingFiltered();
159
164 CORE_API static FString BuildFromArgV(const WIDECHAR* Prefix, int32 ArgC, WIDECHAR* ArgV[], const WIDECHAR* Suffix);
165 CORE_API static FString BuildFromArgV(const ANSICHAR* Prefix, int32 ArgC, ANSICHAR* ArgV[], const ANSICHAR* Suffix);
166
180 static bool FilterCLIUsingGrammarBasedParser(TCHAR* OutLine, int32 MaxLen, const TCHAR* InLine, const TArrayView<FString>& AllowedList);
181private:
182#if UE_COMMAND_LINE_USES_ALLOW_LIST
184 static void ApplyCommandLineAllowList();
193#else
194 #define ApplyCommandLineAllowList()
195#endif
196
198 static bool bIsInitialized;
200 static TCHAR CmdLine[MaxCommandLineSize];
202 static TCHAR OriginalCmdLine[MaxCommandLineSize];
204 static TCHAR LoggingCmdLine[MaxCommandLineSize];
206 static TCHAR LoggingOriginalCmdLine[MaxCommandLineSize];
208 static FString& GetSubprocessCommandLine_Internal(ECommandLineArgumentFlags ContextFlags);
210 static void AddToSubprocessCommandLine_Internal(const TCHAR* Param, ECommandLineArgumentFlags ApplicationContextFlags);
212 static uint32 CmdLineVersion;
213
214 struct FRegisteredArgData
215 {
217 FString Description;
218 };
219 static TMap<FString, FRegisteredArgData> RegisteredArgs;
220};
221
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
FPlatformTypes::WIDECHAR WIDECHAR
A wide character. Normally a signed type.
Definition Platform.h:1133
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
FPlatformTypes::ANSICHAR ANSICHAR
An ANSI character. Normally a signed type.
Definition Platform.h:1131
ECommandLineArgumentFlags
Definition CommandLine.h:25
#define ApplyCommandLineAllowList()
Definition CommandLine.h:194
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define ENUM_CLASS_FLAGS(Enum)
Definition EnumClassFlags.h:6
TStringView< TCHAR > FStringView
Definition StringFwd.h:45
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition UnrealType.h:3087
Definition ArrayView.h:139
Definition Array.h:670
Definition UnrealString.h.inl:34
Definition CommandLine.h:46