UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ULangUEUtils.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
4#include "CoreMinimal.h"
5#include "Containers/Set.h" // for BaseKeyFuncs
9#include "AutoRTFM.h"
10
14
16{
17public:
18
19 //=== String conversions from UE to uLang ===
20
21 static inline uLang::CUTF8String FStringToULangStr(const FString& String)
22 {
23 // Use the known byte length so that the scan for null terminator is not needed with each conversion
27 }
28
33
40
45
50
56
65
67 {
68 return uLang::CUTF8StringView((const uLang::UTF8Char*)StringView.GetData(), (const uLang::UTF8Char*)StringView.GetData() + StringView.Len());
69 }
70
72 {
73 return FUtf8StringViewToULangStringView(StringView);
74 }
75
76 //=== String conversions from uLang to UE ===
77
78 static inline FString ULangStrToFString(const uLang::CUTF8String& ULangString)
79 {
80 return UTF8_TO_TCHAR(ULangString.AsUTF8());
81 }
82
84 {
85 return FUtf8String::ConstructFromPtrSize(reinterpret_cast<const UTF8CHAR*>(ULangString.AsUTF8()), ULangString.ByteLen());
86 }
87
88 template <typename CharType>
90
91 template <>
93 {
95 }
96
97 template <>
99 {
101 }
102
104 {
105 FName Result;
106 UE_AUTORTFM_OPEN{ Result = FName(UTF8_TO_TCHAR(ULangString.AsUTF8())); };
107 return Result;
108 }
109
114
119
120 //=== Miscellaneous ===
121
123 static inline FString UeToULangFunctionName(const FString& UEFunctionName)
124 {
125 // Keeping UeToULangFunctionName(), UeToULangDataName() and UeToULangLocalVarName() distinct in case they ever differ.
126 return UEFunctionName;
127 }
128
130 static inline FString UeToULangDataName(const FString& UEDataName)
131 {
132 // Keeping UeToULangFunctionName(), UeToULangDataName() and UeToULangLocalVarName() distinct in case they ever differ.
133 return UEDataName;
134 }
136 static inline FString UeToULangLocalVarName(const FString& UELocalVarName)
137 {
138 // Keeping UeToULangFunctionName(), UeToULangDataName() and UeToULangLocalVarName() distinct in case they ever differ.
139 return UELocalVarName;
140 }
141};
142
143template<typename ValueType>
144struct TuLangSymbolKeyFuncs : BaseKeyFuncs<TPair<uLang::CSymbol, ValueType>, uLang::CSymbol>
145{
147
148 static inline const uLang::CSymbol& GetSetKey(typename Super::ElementInitType Element)
149 {
150 return Element.Key;
151 }
152 static inline bool Matches(const uLang::CSymbol& A, const uLang::CSymbol& B)
153 {
154 return (A == B);
155 }
156 static inline uint32 GetKeyHash(const uLang::CSymbol& Key)
157 {
158 return GetTypeHash(Key.GetId());
159 }
160};
161
162namespace uLang
163{
164
169{
170 return ::GetTypeHash(TextPosition._Row) ^ ::GetTypeHash(TextPosition._Column);
171}
172
173}
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
FPlatformTypes::UTF8CHAR UTF8CHAR
An 8-bit character containing a UTF8 (Unicode, 8-bit, variable-width) code unit.
Definition Platform.h:1137
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define UTF8_TO_TCHAR(str)
Definition StringConv.h:1022
TStringView< UTF8CHAR > FUtf8StringView
Definition StringFwd.h:48
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition NameTypes.h:617
Definition ULangUEUtils.h:16
static uLang::CSymbol FNameToULangSymbol(const FName &NameId, uLang::CSymbolTable &uLangSymTable)
Definition ULangUEUtils.h:46
static FString ULangStrToFString(const uLang::CUTF8String &ULangString)
Definition ULangUEUtils.h:78
static uLang::CUTF8String TCharToULangStr(const TCHAR *Text)
Definition ULangUEUtils.h:34
static uLang::CUTF8String FUtf8StringToULangStr(const FUtf8String &String)
Definition ULangUEUtils.h:29
static uLang::CUTF8String FUtf8StringViewToULangString(const FUtf8StringView &StringView)
Definition ULangUEUtils.h:71
static FString UeToULangLocalVarName(const FString &UELocalVarName)
Definition ULangUEUtils.h:136
static TString< CharType > ULangStrToTString(const uLang::CUTF8String &ULangString)
static uLang::CUTF8String FStringToULangStr(const FString &String)
Definition ULangUEUtils.h:21
static uLang::CUTF8StringView FUtf8StringViewToULangStringView(const FUtf8StringView &StringView)
Definition ULangUEUtils.h:66
static FString UeToULangFunctionName(const FString &UEFunctionName)
Definition ULangUEUtils.h:123
static FUtf8StringView ULangStrToFUtf8StringView(const uLang::CUTF8String &ULangString)
Definition ULangUEUtils.h:115
static FString UeToULangDataName(const FString &UEDataName)
Definition ULangUEUtils.h:130
static uLang::CSymbol TCharToULangSymbol(const TCHAR *Text, uLang::CSymbolTable &uLangSymTable)
Definition ULangUEUtils.h:51
static FName ULangStrToFName(const uLang::CUTF8String &ULangString)
Definition ULangUEUtils.h:103
static FUtf8StringView ULangStringViewToFUtf8StringView(const uLang::CUTF8StringView &ULangStringView)
Definition ULangUEUtils.h:110
static FUtf8String ULangStrToFUtf8String(const uLang::CUTF8String &ULangString)
Definition ULangUEUtils.h:83
static uLang::CUTF8String FNameToULangStr(const FName &NameId)
Definition ULangUEUtils.h:41
static uLang::CSymbol FStringToULangSymbol(const FString &String, uLang::CSymbolTable &uLangSymTable)
Definition ULangUEUtils.h:57
Definition StringConv.h:671
constexpr int32 Len() const
Definition StringView.h:174
constexpr const CharType * GetData() const
Definition StringView.h:160
Database keeping track of symbols and their text equivalent.
Definition Symbol.h:27
Symbol representing a text string with an associated id.
Definition Symbol.h:98
Definition UTF8StringView.h:15
Definition VVMEngineEnvironment.h:23
uLang::TUTF8String< CHeapRawAllocator > CUTF8String
A string allocated on the heap.
Definition UTF8String.h:269
uint8_t UTF8Char
UTF-8 octet.
Definition Unicode.h:20
ULANG_FORCEINLINE uint32_t GetTypeHash(const TArray< T > Array)
Definition Array.h:2132
Definition SetUtilities.h:23
TCallTraits< TPair< uLang::CSymbol, ValueType > >::ParamType ElementInitType
Definition SetUtilities.h:26
Definition ULangUEUtils.h:145
static uint32 GetKeyHash(const uLang::CSymbol &Key)
Definition ULangUEUtils.h:156
static const uLang::CSymbol & GetSetKey(typename Super::ElementInitType Element)
Definition ULangUEUtils.h:148
static bool Matches(const uLang::CSymbol &A, const uLang::CSymbol &B)
Definition ULangUEUtils.h:152
Definition TextRange.h:20