UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
CoreMisc.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Containers/Array.h"
7#include "Containers/Map.h"
9#include "CoreGlobals.h"
10#include "CoreTypes.h"
12#include "HAL/ThreadSingleton.h"
14#include "Math/IntPoint.h"
15#include "Misc/Build.h"
16#include "Misc/Exec.h"
17#include "Templates/Function.h"
18#include "UObject/NameTypes.h"
19
20class FOutputDevice;
21class UWorld;
22
28{
29public:
34
36 static CORE_API bool StaticExec( UWorld* Inworld, const TCHAR* Cmd, FOutputDevice& Ar );
37};
38
41{
42public:
43
46
47 //~ Begin Exec Interface
48#if UE_ALLOW_EXEC_COMMANDS
49 CORE_API virtual bool Exec( UWorld* InWorld, const TCHAR* Cmd, FOutputDevice& Ar ) override;
50#endif
51 //~ End Exec Interface
52
53private:
54
55 bool (*StaticExecFunc)(UWorld* Inworld, const TCHAR* Cmd,FOutputDevice& Ar);
56};
57
60{
61public:
62
65
66 //~ Begin Exec Interface
67 CORE_API virtual bool Exec_Dev(UWorld* InWorld, const TCHAR* Cmd, FOutputDevice& Ar) override;
68 //~ End Exec Interface
69
70private:
71
72 bool (*StaticExecFunc)(UWorld* Inworld, const TCHAR* Cmd,FOutputDevice& Ar);
73};
74
77{
78public:
79
82
83 //~ Begin Exec Interface
84 CORE_API virtual bool Exec_Editor(UWorld* InWorld, const TCHAR* Cmd, FOutputDevice& Ar) override;
85 //~ End Exec Interface
86
87private:
88
89 bool (*StaticExecFunc)(UWorld* Inworld, const TCHAR* Cmd, FOutputDevice& Ar);
90};
91
92// Interface for returning a context string.
94{
95public:
96 virtual ~FContextSupplier() {}
97 virtual FString GetContext()=0;
98};
99
100
102{
104 static CORE_API void DeleteOldLogs();
105};
106
107/*-----------------------------------------------------------------------------
108 Module singletons.
109-----------------------------------------------------------------------------*/
110
113
116
119
127
130
136
137/*-----------------------------------------------------------------------------
138 Runtime.
139-----------------------------------------------------------------------------*/
140
141#if UE_EDITOR
142CORE_API int32 StaticDedicatedServerCheck(); // Internal, use IsRunningDedicatedServer()
143CORE_API int32 StaticGameCheck(); // Internal, use IsRunningGame()
144CORE_API int32 StaticClientOnlyCheck(); // Internal, use IsRunningClientOnly()
145#endif
146
153{
154 if (FPlatformProperties::IsServerOnly())
155 {
156 return true;
157 }
158
159 if (FPlatformProperties::IsGameOnly())
160 {
161 return false;
162 }
163
164#if UE_EDITOR
165 return (StaticDedicatedServerCheck() == 1);
166#else
167 return false;
168#endif
169}
170
177inline bool IsRunningGame()
178{
179 if (FPlatformProperties::IsGameOnly())
180 {
181 return true;
182 }
183
184 if (FPlatformProperties::IsServerOnly())
185 {
186 return false;
187 }
188
189#if UE_EDITOR
190 return (StaticGameCheck() == 1);
191#else
192 return false;
193#endif
194}
195
203{
204 if (FPlatformProperties::IsClientOnly())
205 {
206 return true;
207 }
208
209#if UE_EDITOR
210 return (StaticClientOnlyCheck() == 1);
211#else
212 return false;
213#endif
214}
215
220{
222 FString DefaultName;
223 FString DefaultHost;
227
231 CORE_API void Init();
232
236 CORE_API void Reset();
237};
238
239bool CORE_API StringHasBadDashes(const TCHAR* Str);
240
243{
244private:
245 bool bValue;
246public:
247 CORE_API FBoolConfigValueHelper(const TCHAR* Section, const TCHAR* Key, const FString& Filename = GEditorIni);
248
249 operator bool() const
250 {
251 return bValue;
252 }
253};
254
258typedef TFunction<void(ELogVerbosity::Type /*Verbosity*/, const TCHAR* /*ExceptionMessage*/, const TCHAR* /*StackMessage*/)> FScriptExceptionHandlerFunc;
259
261
262
266{
267public:
271 static CORE_API FScriptExceptionHandler& Get();
272
276 CORE_API void PushExceptionHandler(const FScriptExceptionHandlerFunc& InFunc);
277
281 CORE_API void PopExceptionHandler();
282
286 CORE_API void HandleException(ELogVerbosity::Type Verbosity, const TCHAR* ExceptionMessage, const TCHAR* StackMessage);
287
291 static CORE_API void AssertionExceptionHandler(ELogVerbosity::Type Verbosity, const TCHAR* ExceptionMessage, const TCHAR* StackMessage);
292
296 static CORE_API void LoggingExceptionHandler(ELogVerbosity::Type Verbosity, const TCHAR* ExceptionMessage, const TCHAR* StackMessage);
297
298private:
302 static FScriptExceptionHandlerFunc DefaultExceptionHandler;
303
309};
310
319
326{
327public:
328 CORE_API void Update(bool bIsProfiling);
329
330private:
331 bool bSetNamedEventsEnabled = false;
332};
333
338#ifndef DO_BLUEPRINT_GUARD
339 #if (!(UE_BUILD_SHIPPING || UE_BUILD_TEST) || WITH_EDITOR)
340 #define DO_BLUEPRINT_GUARD 1
341 #else
342 #define DO_BLUEPRINT_GUARD 0
343 #endif
344#endif
345
347#ifndef SCRIPT_AUDIT_ROUTINES
348 #if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
349 #define SCRIPT_AUDIT_ROUTINES 1
350 #else
351 #define SCRIPT_AUDIT_ROUTINES 0
352 #endif
353#endif
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
FString GEditorIni
Definition CoreGlobals.cpp:240
CORE_API class FDerivedDataCacheInterface & GetDerivedDataCacheRef()
Definition CoreMisc.cpp:144
CORE_API class ITargetPlatformManagerModule * GetTargetPlatformManager(bool bFailOnInitErrors=true)
Definition CoreMisc.cpp:167
bool CORE_API StringHasBadDashes(const TCHAR *Str)
Definition CoreMisc.cpp:339
bool IsRunningGame()
Definition CoreMisc.h:177
bool IsRunningClientOnly()
Definition CoreMisc.h:202
CORE_API class FDerivedDataCacheInterface * TryGetDerivedDataCache()
Definition CoreMisc.cpp:155
TFunction< void(ELogVerbosity::Type, const TCHAR *, const TCHAR *)> FScriptExceptionHandlerFunc
Definition CoreMisc.h:258
CORE_API class ITargetPlatformManagerModule & GetTargetPlatformManagerRef()
Definition CoreMisc.cpp:189
bool IsRunningDedicatedServer()
Definition CoreMisc.h:152
CORE_API bool WillNeedAudioVisualData()
Definition CoreMisc.cpp:200
CORE_API class FDerivedDataCacheInterface * GetDerivedDataCache()
Definition CoreMisc.cpp:125
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
const bool
Definition NetworkReplayStreaming.h:178
#define UE_DECLARE_THREAD_SINGLETON_TLS(Type, Api)
Definition ThreadSingleton.h:35
Definition CoreMisc.h:326
Definition CoreMisc.h:94
virtual FString GetContext()=0
virtual ~FContextSupplier()
Definition CoreMisc.h:96
Definition Exec.h:29
virtual CORE_API bool Exec(UWorld *InWorld, const TCHAR *Cmd, FOutputDevice &Ar)
Definition Exec.cpp:30
Definition OutputDevice.h:133
Definition CoreMisc.h:266
Definition CoreMisc.h:28
virtual CORE_API ~FSelfRegisteringExec()
Definition CoreMisc.cpp:69
CORE_API FSelfRegisteringExec()
Definition CoreMisc.cpp:62
static CORE_API bool StaticExec(UWorld *Inworld, const TCHAR *Cmd, FOutputDevice &Ar)
Definition CoreMisc.cpp:75
Definition CoreMisc.h:60
virtual CORE_API bool Exec_Dev(UWorld *InWorld, const TCHAR *Cmd, FOutputDevice &Ar) override
Definition CoreMisc.cpp:104
Definition CoreMisc.h:77
virtual CORE_API bool Exec_Editor(UWorld *InWorld, const TCHAR *Cmd, FOutputDevice &Ar) override
Definition CoreMisc.cpp:113
Definition CoreMisc.h:41
Definition Array.h:670
Definition AndroidPlatformMisc.h:14
Definition ThreadSingleton.h:44
Definition World.h:918
Type
Definition LogVerbosity.h:17
Definition CoreMisc.h:243
Definition CoreMisc.h:102
static CORE_API void DeleteOldLogs()
Definition FileHelper.cpp:1211
Definition CoreMisc.h:315
CORE_API ~FScopedScriptExceptionHandler()
Definition CoreMisc.cpp:429
Definition CoreMisc.h:220
FString DefaultPortal
Definition CoreMisc.h:224
int32 DefaultPort
Definition CoreMisc.h:226
FString DefaultHost
Definition CoreMisc.h:223
CORE_API void Reset()
Definition CoreMisc.cpp:330
FString DefaultSaveExt
Definition CoreMisc.h:225
CORE_API void Init()
Definition CoreMisc.cpp:312
FString DefaultProtocol
Definition CoreMisc.h:221
FString DefaultName
Definition CoreMisc.h:222