UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
Command.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#if defined(UE_WITH_IAS_TOOL)
6
7#include <Containers/Array.h>
11
12#include <initializer_list>
13
14namespace UE::IoStore::Tool {
15
17struct FArgument
18{
19 static const uint32 ValueAlign = 16;
20 static const uint32 ValueSize = 16;
22 FStringView Desc;
24};
25
26using FArguments = TArray<FArgument>;
27
29struct FArgumentSet
30{
31 FArgumentSet(std::initializer_list<FArgument>);
32 operator FArgument () const;
33 FArguments Arguments;
34};
35
37template <typename Type> FArgument TArgument(FStringView Name, FStringView Desc);
38
39#define TARGUMENT_DECL(t) \
40 template <> FArgument TArgument<t>(FStringView Name, FStringView Desc);
41
48TARGUMENT_DECL(float) TARGUMENT_DECL(double)
49#undef TARGUMENT_DECL
50
52class FContext
53{
54public:
55 template <typename Type> Type Get(FStringView Name) const;
56 template <typename Type> Type Get(FStringView Name, Type Default) const;
57 [[noreturn]] void Abort(const TCHAR* Reason) const;
58
59private:
60 struct alignas(FArgument::ValueAlign) FValue
61 {
62 uint8 Buffer[FArgument::ValueSize] = {};
63 };
64
65 friend class FCommand;
66 FContext(const FArguments& InArguments, int32 ArgC, const TCHAR* const* ArgV);
67 void SetArguments(const FArguments& Input);
70 bool IsSet(uint32 Index) const { return !!((1ull << Index) & SetMask); }
71 FArguments Arguments;
72 TArray<FValue> Values;
73 uint64 SetMask = 0;
74};
75
77template <typename Type>
78Type FContext::Get(FStringView Name) const
79{
80 if (Name.GetData()[0] == '-')
81 {
82 return Get(Name, Type{});
83 }
84
86 if (IsSet(Index))
87 {
88 return *(Type*)(Values[Index].Buffer);
89 }
90
92}
93
95template <typename Type>
96Type FContext::Get(FStringView Name, Type Default) const
97{
99 return IsSet(Index) ? *(Type*)(Values[Index].Buffer) : Default;
100}
101
102
103
105class FCommand
106{
107public:
108 using EntryFunc = int32 (const FContext&);
109 FCommand(EntryFunc* InEntry, FStringView InName, FStringView InDesc, FArguments&& InArguments);
110 static int32 Main(int32 ArgC, const TCHAR* const* ArgV);
111
112private:
113 friend void CommandTest();
114 FCommand() = default;
116 FContext GetContext(int32 ArgC, const TCHAR* const* ArgV) const;
117 static FCommand*& Head();
118 static int32 MainInner(int32 ArgC, const TCHAR* const* ArgV);
119 void Usage() const;
120 int32 Call(int32 ArgC, const TCHAR* const* ArgV);
121 FCommand* Next = FCommand::Head();
123 FStringView Desc;
124 FArguments Arguments;
125 EntryFunc* Entry;
126};
127
128} // namespace UE::IoStore::Tool
129
130#endif // UE_WITH_IAS_TOOL
FPlatformTypes::int16 int16
A 16-bit signed integer.
Definition Platform.h:1123
FPlatformTypes::int8 int8
An 8-bit signed integer.
Definition Platform.h:1121
FPlatformTypes::PTRINT PTRINT
A signed integer the same size as a pointer.
Definition Platform.h:1148
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
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 Array.h:670
Type
Definition PawnAction_Move.h:11
FORCEINLINE T * Get(const FObjectPtr &ObjectPtr)
Definition ObjectPtr.h:426
FDocument::ValueType FValue
Definition RapidJsonUtils.h:61
VERSECOMPILER_API bool IsSet()
Definition CommandLine.cpp:63
U16 Index
Definition radfft.cpp:71