UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SourceLocation.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
7#include "HAL/Platform.h"
9
10#ifndef UE_INCLUDE_SOURCE_LOCATION
11#define UE_INCLUDE_SOURCE_LOCATION !UE_BUILD_SHIPPING
12#endif
13
14#if UE_INCLUDE_SOURCE_LOCATION && defined(__cpp_lib_source_location)
15#include <source_location>
16#endif
17
18namespace UE
19{
21 {
22#if UE_INCLUDE_SOURCE_LOCATION
23 #ifdef __cpp_lib_source_location
24 using FSourceLocationImpl = std::source_location;
25 #else // __cpp_lib_source_location
26 struct FSourceLocationImpl
27 {
28 static UE_CONSTEVAL FSourceLocationImpl current(
31 const char* const InFile = __builtin_FILE(),
32 const char* const InFunction = __builtin_FUNCTION()) noexcept
33 {
34 FSourceLocationImpl Location;
35 Location.Line = InLine;
36 Location.Column = InColumn;
37 Location.FileName = InFile;
38 Location.FunctionName = InFunction;
39 return Location;
40 };
41
42 constexpr FSourceLocationImpl() noexcept = default;
43
44 // source location field access
45 constexpr uint_least32_t line() const noexcept
46 {
47 return Line;
48 }
49 constexpr uint_least32_t column() const noexcept
50 {
51 return Column;
52 }
53 constexpr const char* file_name() const noexcept
54 {
55 return FileName;
56 }
57 constexpr const char* function_name() const noexcept
58 {
59 return FunctionName;
60 }
61
62 private:
63 uint_least32_t Line = 0;
64 uint_least32_t Column = 0;
65 const char* FileName = nullptr;
66 const char* FunctionName = nullptr;
67 };
68 #endif // __cpp_lib_source_location
69#else // UE_INCLUDE_SOURCE_LOCATION
70 struct FSourceLocationImpl{
71 static UE_CONSTEVAL FSourceLocationImpl current() noexcept
72 {
73 return {};
74 }
75 constexpr FSourceLocationImpl() noexcept = default;
76 constexpr uint_least32_t line() const noexcept
77 {
78 return 0;
79 }
80 constexpr uint_least32_t column() const noexcept
81 {
82 return 0;
83 }
84 constexpr const char* file_name() const noexcept
85 {
86 return "";
87 }
88 constexpr const char* function_name() const noexcept
89 {
90 return "";
91 }
92 };
93#endif // UE_INCLUDE_SOURCE_LOCATION
94
95 public:
107 static UE_CONSTEVAL FSourceLocation Current(FSourceLocationImpl Impl = FSourceLocationImpl::current()) noexcept
108 {
110 }
111
112 // source location field access
113 constexpr uint32 GetLine() const noexcept
114 {
115 return Impl.line();
116 }
117 constexpr uint32 GetColumn() const noexcept
118 {
119 return Impl.column();
120 }
121 constexpr const char* GetFileName() const noexcept
122 {
123 return Impl.file_name();
124 }
125 constexpr const char* GetFunctionName() const noexcept
126 {
127 return Impl.function_name();
128 }
129
130 private:
131 constexpr FSourceLocation(FSourceLocationImpl&& In) noexcept
132 : Impl(MoveTemp(In))
133 {
134 }
135
136 const FSourceLocationImpl Impl;
137 };
138
139}
OODEFFUNC typedef const char int line
Definition oodle2.h:678
#define UE_CONSTEVAL
Definition Platform.h:777
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition SourceLocation.h:21
constexpr const char * GetFileName() const noexcept
Definition SourceLocation.h:121
static UE_CONSTEVAL FSourceLocation Current(FSourceLocationImpl Impl=FSourceLocationImpl::current()) noexcept
Definition SourceLocation.h:107
constexpr uint32 GetLine() const noexcept
Definition SourceLocation.h:113
constexpr const char * GetFunctionName() const noexcept
Definition SourceLocation.h:125
constexpr uint32 GetColumn() const noexcept
Definition SourceLocation.h:117
Definition ExpressionParserTypes.h:21
Definition AdvancedWidgetsModule.cpp:13