UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
Parse.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
7#include "CoreTypes.h"
8#include "HAL/PlatformCrt.h"
9#include "Misc/Build.h"
10#include "Misc/EnumClassFlags.h"
11#include "Templates/Function.h"
12
13class FExec;
14class FName;
15class FOutputDevice;
16class FText;
17
18/*-----------------------------------------------------------------------------
19 Parsing functions.
20-----------------------------------------------------------------------------*/
21struct FParse
22{
28 static CORE_API bool Command( const TCHAR** Stream, const TCHAR* Match, bool bParseMightTriggerExecution = true );
30 static CORE_API bool Value( const TCHAR* Stream, const TCHAR* Match, FName& Name );
32 static CORE_API bool Value( const TCHAR* Stream, const TCHAR* Match, uint32& Value );
34 static CORE_API bool Value( const TCHAR* Stream, const TCHAR* Match, struct FGuid& Guid );
46 static CORE_API bool Value( const TCHAR* Stream, const TCHAR* Match, TCHAR* Value, int32 MaxLen, bool bShouldStopOnSeparator=true, const TCHAR** OptStreamGotTo = nullptr);
48 static CORE_API bool Value( const TCHAR* Stream, const TCHAR* Match, uint8& Value );
50 static CORE_API bool Value( const TCHAR* Stream, const TCHAR* Match, int8& Value );
52 static CORE_API bool Value( const TCHAR* Stream, const TCHAR* Match, uint16& Value );
54 static CORE_API bool Value( const TCHAR* Stream, const TCHAR* Match, int16& Value );
56 static CORE_API bool Value( const TCHAR* Stream, const TCHAR* Match, float& Value );
58 static CORE_API bool Value(const TCHAR* Stream, const TCHAR* Match, double& Value);
60 static CORE_API bool Value( const TCHAR* Stream, const TCHAR* Match, int32& Value );
71 static CORE_API bool Value( const TCHAR* Stream, const TCHAR* Match, FString& Value, bool bShouldStopOnSeparator =true, const TCHAR** OptStreamGotTo = nullptr);
73 static CORE_API bool Value( const TCHAR* Stream, const TCHAR* Match, FText& Value, const TCHAR* Namespace = NULL );
75 static CORE_API bool Value( const TCHAR* Stream, const TCHAR* Match, uint64& Value );
77 static CORE_API bool Value( const TCHAR* Stream, const TCHAR* Match, int64& Value );
79 static CORE_API bool Bool( const TCHAR* Stream, const TCHAR* Match, bool& OnOff );
81 static CORE_API bool Line( const TCHAR** Stream, TCHAR* Result, int32 MaxLen, bool Exact= false );
83 static CORE_API bool Line( const TCHAR** Stream, FString& Result, bool Exact = false );
85 static CORE_API bool Line( const TCHAR** Stream, FStringView& Result, bool Exact = false );
90 {
91 None = 0,
95 BreakOnPipe = 8,
96 AllowBracketedMultiline = 16, // if a EOL happens between {} curly brackets, insert a space, and continue parsing the next line
97 AllowEscapedEOLMultiline = 32, // if a EOL happens right after a \ backslash, insert a space, and continue parsing the next line
98
99 // Standard maps to an "expected" set of flags (<eol> is replaced with space, no comments, don't swallow extra EOLs, no { } processing)
101
102 // OldDefaultMode maps to what the previous 'bExact' mapped to when false
104 // OldExactMode maps to what the previous 'bExact' mapped to when true
106 };
107
110 UE_DEPRECATED(5.6, "Use the version that takes ELineExtendedFlags")
115 UE_DEPRECATED(5.6, "Use the version that takes ELineExtendedFlags")
121 static CORE_API bool Token( const TCHAR*& Str, TCHAR* Result, int32 MaxLen, bool bUseEscape, const TCHAR SingleCharacterDelimiter = TEXT('\0'));
123 static CORE_API bool Token( const TCHAR*& Str, FString& Arg, bool bUseEscape, const TCHAR SingleCharacterDelimiter = TEXT('\0'));
125 static CORE_API bool AlnumToken(const TCHAR*& Str, FString& Arg);
127 static CORE_API FString Token( const TCHAR*& Str, bool UseEscape );
129 static CORE_API void Next( const TCHAR** Stream );
131 static CORE_API bool Param( const TCHAR* Stream, const TCHAR* Param );
133 static CORE_API bool Text( const TCHAR* Stream, FText& Value, const TCHAR* Namespace = nullptr );
135 static CORE_API bool QuotedString( const TCHAR* Stream, FString& Value, int32* OutNumCharsRead = nullptr );
147 static CORE_API bool Expression(const TCHAR*& Str, FString& OutExpression, bool bUseEscape, const TCHAR SingleCharacterDelimiter = TEXT('\0'));
148
149 //
150 // Parse a hex digit.
151 //
152 static inline int32 HexDigit(TCHAR c)
153 {
154 int32 Result = 0;
155
156 if (c >= '0' && c <= '9')
157 {
158 Result = c - '0';
159 }
160 else if (c >= 'a' && c <= 'f')
161 {
162 Result = c + 10 - 'a';
163 }
164 else if (c >= 'A' && c <= 'F')
165 {
166 Result = c + 10 - 'A';
167 }
168 else
169 {
170 Result = 0;
171 }
172
173 return Result;
174 }
175
179
181 static CORE_API bool SchemeNameFromURI(const TCHAR* InURI, FString& OutSchemeName);
182
183
184 //
185 // CLI string parsing using grammar based parser.
186 //
187
189 {
190 None = 0u,
191 AllowQuotedCommands = 1 << 0u,
192 };
193
201
207
228};
229
232
233#if !UE_BUILD_SHIPPING
234
235UE_DEPRECATED("5.6", "Use the overload that takes the entire command instead of a pattern.")
237
240
243#endif // !UE_BUILD_SHIPPING
#define NULL
Definition oodle2base.h:134
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
FPlatformTypes::int16 int16
A 16-bit signed integer.
Definition Platform.h:1123
FPlatformTypes::int8 int8
An 8-bit signed integer.
Definition Platform.h:1121
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
FPlatformTypes::int64 int64
A 64-bit signed integer.
Definition Platform.h:1127
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
FPlatformTypes::uint64 uint64
A 64-bit unsigned integer.
Definition Platform.h:1117
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
CORE_API bool ConsoleCommandLibrary_DumpLibraryHTML(class UWorld *InWorld, FExec &SubSystem, const FString &OutPath)
Definition Parse.cpp:118
CORE_API bool ConsoleCommandLibrary_DumpLibrary(class UWorld *InWorld, FExec &SubSystem, const FString &Cmd, FOutputDevice &Ar)
Definition Parse.cpp:65
uint8_t uint8
Definition binka_ue_file_header.h:8
uint16_t uint16
Definition binka_ue_file_header.h:7
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Exec.h:29
Definition NameTypes.h:617
Definition OutputDevice.h:133
Definition Text.h:385
Definition AssetRegistryState.h:50
Definition World.h:918
Definition Guid.h:109
Definition Parse.h:203
EGrammarBasedParseErrorCode ErrorCode
Definition Parse.h:205
const TCHAR * At
Definition Parse.h:204
Definition Parse.h:22
static CORE_API bool LineExtended(const TCHAR **Stream, FString &Result, int32 &LinesConsumed, ELineExtendedFlags Flags=ELineExtendedFlags::Standard)
Definition Parse.cpp:1332
static CORE_API bool Command(const TCHAR **Stream, const TCHAR *Match, bool bParseMightTriggerExecution=true)
Definition Parse.cpp:767
static CORE_API bool AlnumToken(const TCHAR *&Str, FString &Arg)
Definition Parse.cpp:1032
static CORE_API uint32 HexNumber(FStringView HexString)
Definition Parse.cpp:1342
static CORE_API bool QuotedString(const TCHAR *Stream, FString &Value, int32 *OutNumCharsRead=nullptr)
Definition Parse.cpp:513
static CORE_API bool Token(const TCHAR *&Str, TCHAR *Result, int32 MaxLen, bool bUseEscape, const TCHAR SingleCharacterDelimiter=TEXT('\0'))
Definition Parse.cpp:846
static CORE_API uint64 HexNumber64(FStringView HexString)
Definition Parse.cpp:1355
static int32 HexDigit(TCHAR c)
Definition Parse.h:152
static CORE_API FGrammarBasedParseResult GrammarBasedCLIParse(const TCHAR *Stream, TFunctionRef< void(FStringView, FStringView)> OnCommandCallback, EGrammarBasedParseFlags Flags=EGrammarBasedParseFlags::AllowQuotedCommands)
Definition Parse.cpp:1866
static CORE_API bool Param(const TCHAR *Stream, const TCHAR *Param)
Definition Parse.cpp:325
static CORE_API bool SchemeNameFromURI(const TCHAR *InURI, FString &OutSchemeName)
Definition Parse.cpp:1368
ELineExtendedFlags
Definition Parse.h:90
EGrammarBasedParseFlags
Definition Parse.h:189
static CORE_API bool Expression(const TCHAR *&Str, FString &OutExpression, bool bUseEscape, const TCHAR SingleCharacterDelimiter=TEXT('\0'))
Definition Parse.cpp:1395
EGrammarBasedParseErrorCode
Definition Parse.h:195