UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
CFRef.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
6{
7 template <class CFRefType>
9
10#ifdef __OBJC__
11 template<> struct TTollFreeBridgeType<CFArrayRef> { using Type = NSArray*; };
12 template<> struct TTollFreeBridgeType<CFAttributedStringRef> { using Type = NSAttributedString*; };
13 template<> struct TTollFreeBridgeType<CFBooleanRef> { using Type = NSNumber*; };
14 template<> struct TTollFreeBridgeType<CFCalendarRef> { using Type = NSCalendar*; };
15 template<> struct TTollFreeBridgeType<CFCharacterSetRef> { using Type = NSCharacterSet*; };
16 template<> struct TTollFreeBridgeType<CFDataRef> { using Type = NSData*; };
17 template<> struct TTollFreeBridgeType<CFDateRef> { using Type = NSDate*; };
18 template<> struct TTollFreeBridgeType<CFDictionaryRef> { using Type = NSDictionary*; };
19 template<> struct TTollFreeBridgeType<CFErrorRef> { using Type = NSError*; };
20 template<> struct TTollFreeBridgeType<CFLocaleRef> { using Type = NSLocale*; };
21 template<> struct TTollFreeBridgeType<CFMutableArrayRef> { using Type = NSMutableArray*; };
22 template<> struct TTollFreeBridgeType<CFMutableAttributedStringRef> { using Type = NSMutableAttributedString*; };
23 template<> struct TTollFreeBridgeType<CFMutableCharacterSetRef> { using Type = NSMutableCharacterSet*; };
24 template<> struct TTollFreeBridgeType<CFMutableDataRef> { using Type = NSMutableData*; };
25 template<> struct TTollFreeBridgeType<CFMutableDictionaryRef> { using Type = NSMutableDictionary*; };
26 template<> struct TTollFreeBridgeType<CFMutableSetRef> { using Type = NSMutableSet*; };
27 template<> struct TTollFreeBridgeType<CFMutableStringRef> { using Type = NSMutableString*; };
28 template<> struct TTollFreeBridgeType<CFNullRef> { using Type = NSNull*; };
29 template<> struct TTollFreeBridgeType<CFNumberRef> { using Type = NSNumber*; };
30 template<> struct TTollFreeBridgeType<CFReadStreamRef> { using Type = NSInputStream*; };
31 template<> struct TTollFreeBridgeType<CFRunLoopTimerRef> { using Type = NSTimer*; };
32 template<> struct TTollFreeBridgeType<CFSetRef> { using Type = NSSet*; };
33 template<> struct TTollFreeBridgeType<CFStringRef> { using Type = NSString*; };
34 template<> struct TTollFreeBridgeType<CFTimeZoneRef> { using Type = NSTimeZone*; };
35 template<> struct TTollFreeBridgeType<CFURLRef> { using Type = NSURL*; };
36 template<> struct TTollFreeBridgeType<CFWriteStreamRef> { using Type = NSOutputStream*; };
37#endif // __OBJC__
38}
39
40template <class CFRefType>
41class TCFRef
42{
43public:
44
49 : Ref(nullptr)
50 {
51 }
52
59 : Ref(InRef)
60 {
61 }
62
69 {
70 CFRetain(Other.Ref);
71 Ref = Other.Ref;
72 }
73
80 {
81 Ref = Other.Ref;
82 Other.Ref = nullptr;
83 }
84
89 {
90 if (Ref)
91 {
92 CFRelease(Ref);
93 }
94 }
95
102 {
103 if (this != &Other)
104 {
105 if (Ref != nullptr)
106 {
107 CFRelease(Ref);
108 }
109 CFRetain(Other.Ref);
110 Ref = Other.Ref;
111 }
112 return *this;
113 }
114
121 {
122 if (this != &Other)
123 {
124 if (Ref)
125 {
126 CFRelease(Ref);
127 }
128 Ref = Other.Ref;
129 Other.Ref = nullptr;
130 }
131 return *this;
132 }
133
141 {
142 if (Ref != nullptr)
143 {
144 CFRelease(Ref);
145 Ref = nullptr;
146 }
147 return &Ref;
148 }
149
155 explicit operator bool() const
156 {
157 return Ref != nullptr;
158 }
159
165 operator CFRefType() const
166 {
167 return Ref;
168 }
169
175 template<typename T = CFRefType,
178 {
180 }
181
182private:
183 /* The Core Foundation Type. Can be nullptr. */
184 CFRefType Ref;
185};
186
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
const bool
Definition NetworkReplayStreaming.h:178
Definition CFRef.h:42
TCFRef(CFRefType InRef)
Definition CFRef.h:58
TCFRef & operator=(const TCFRef &Other)
Definition CFRef.h:101
TCFRef(TCFRef &&Other)
Definition CFRef.h:79
CFRefType * GetForAssignment()
Definition CFRef.h:140
~TCFRef()
Definition CFRef.h:88
TCFRef(const TCFRef &Other)
Definition CFRef.h:68
TCFRef()
Definition CFRef.h:48
TCFRef & operator=(TCFRef &&Other)
Definition CFRef.h:120
Type
Definition PawnAction_Move.h:11
Definition CFRef.h:6