Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
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"
7#include "Containers/UnrealString.h"
8
9/*-----------------------------------------------------------------------------
10 Command line.
11-----------------------------------------------------------------------------*/
12
13#ifndef UE_COMMAND_LINE_USES_ALLOW_LIST
14 #ifdef WANTS_COMMANDLINE_WHITELIST
15 #pragma message("Use UE_COMMAND_LINE_USES_ALLOW_LIST instead of WANTS_COMMANDLINE_WHITELIST")
16 #define UE_COMMAND_LINE_USES_ALLOW_LIST WANTS_COMMANDLINE_WHITELIST
17 #else
18 #define UE_COMMAND_LINE_USES_ALLOW_LIST 0
19 #endif
20#endif
21
22
24{
25 /** maximum size of the command line */
26 static constexpr uint32 MaxCommandLineSize = 16384;
27
28 /**
29 * Resets FCommandLine to an uninitialised state as if Set() has never been called
30 */
31 static void Reset();
32
33 /**
34 * Returns an edited version of the executable's command line with the game name and certain other parameters removed.
35 */
36 static const TCHAR* Get();
37
38 /**
39 * Returns an edited version of the executable's command line.
40 */
41 static const TCHAR* GetForLogging();
42
43 /**
44 * Returns the command line originally passed to the executable.
45 */
46 static const TCHAR* GetOriginal();
47
48 /**
49 * Returns an edited version of the command line originally passed to the executable.
50 */
51 static const TCHAR* GetOriginalForLogging();
52
53 /**
54 * Checks if the command line has been initialized.
55 */
56 static bool IsInitialized();
57
58 /**
59 * Sets CmdLine to the string given
60 */
61 static bool Set(const TCHAR* NewCommandLine);
62
63 /**
64 * Appends the passed string to the command line as it is (no space is added).
65 * @param AppendString String that should be appended to the commandline.
66 */
67 static void Append(const TCHAR* AppendString);
68
69 /**
70 * Adds a new parameter to subprocess command line. If Param
71 * does not start with a space, one is added.
72 *
73 * @param Param Command line param string.
74 */
75 static void AddToSubprocessCommandline( const TCHAR* Param );
76
77 /**
78 * Returns the subprocess command line string
79 */
81
82 /**
83 * Removes the executable name from the passed CmdLine, denoted by parentheses.
84 * Returns the CmdLine string without the executable name.
85 */
86 static const TCHAR* RemoveExeName(const TCHAR* CmdLine);
87
88 /**
89 * Parses a string into tokens, separating switches (beginning with -) from
90 * other parameters
91 *
92 * @param CmdLine the string to parse
93 * @param Tokens [out] filled with all parameters found in the string
94 * @param Switches [out] filled with all switches found in the string
95 */
96 static void Parse(const TCHAR* CmdLine, TArray<FString>& Tokens, TArray<FString>& Switches);
97
98 /**
99 * Checks if command line logging filtering is enabled
100 *
101 * Returns true if logging filter is enabled
102 */
104
105 /**
106 * Builds a command line string from the ArgC/ArgV main() arguments, together with
107 * an optional prefix or suffix, for adding additional command list arguments programmatically.
108 */
109 static FString BuildFromArgV(const TCHAR* Prefix, int32 ArgC, TCHAR* ArgV[], const TCHAR* Suffix);
110
111private:
113 /** Filters both the original and current command line list for approved only args */
114 static void ApplyCommandLineAllowList();
115 /** Filters any command line args that aren't on the approved list */
117 /** Filters any command line args that are on the to-strip list */
119 /** Rebuilds the command line using the filtered args */
123#else
124 #define ApplyCommandLineAllowList()
125#endif
126
127 /** Flag to check if the commandline has been initialized or not. */
128 static bool bIsInitialized;
129 /** character buffer containing the command line */
131 /** character buffer containing the original command line */
133 /** character buffer containing the command line filtered for logging purposes */
135 /** character buffer containing the original command line filtered for logging purposes */
137 /** subprocess command line */
139};
#define UE_COMMAND_LINE_USES_ALLOW_LIST
Definition CommandLine.h:18
static void Parse(const TCHAR *CmdLine, TArray< FString > &Tokens, TArray< FString > &Switches)
static const TCHAR * GetOriginal()
static bool bIsInitialized
static void AddToSubprocessCommandline(const TCHAR *Param)
static TCHAR OriginalCmdLine[MaxCommandLineSize]
static TCHAR CmdLine[MaxCommandLineSize]
static bool IsInitialized()
static TCHAR LoggingCmdLine[MaxCommandLineSize]
static const TCHAR * Get()
static void Reset()
static const TCHAR * GetOriginalForLogging()
static FString BuildFromArgV(const TCHAR *Prefix, int32 ArgC, TCHAR *ArgV[], const TCHAR *Suffix)
static void Append(const TCHAR *AppendString)
static const TCHAR * RemoveExeName(const TCHAR *CmdLine)
static TCHAR LoggingOriginalCmdLine[MaxCommandLineSize]
static constexpr uint32 MaxCommandLineSize
Definition CommandLine.h:26
static const TCHAR * GetForLogging()
static bool Set(const TCHAR *NewCommandLine)
static const FString & GetSubprocessCommandline()
static FString & GetSubprocessCommandLine_Internal()
static bool IsCommandLineLoggingFiltered()