-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge changes from official SDK 2024-08-07
- Loading branch information
Showing
42 changed files
with
764 additions
and
246 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#pragma once | ||
|
||
#include <CoreFoundation/CoreFoundation.h> | ||
|
||
namespace pfc { | ||
template<typename type_t = CFTypeRef> | ||
class CFObject { | ||
public: | ||
typedef CFObject<type_t> self_t; | ||
type_t p = NULL; | ||
|
||
~CFObject() { | ||
if ( p ) CFRelease(p); | ||
} | ||
|
||
void Retain(type_t arg) { | ||
if ( p ) CFRelease(p); | ||
p = arg; | ||
if ( p ) CFRetain(p); | ||
} | ||
|
||
void Attach(type_t arg) { | ||
if ( p ) CFRelease(p); | ||
p = arg; | ||
} | ||
|
||
void operator=( self_t const & arg ) { | ||
if ( p ) CFRelease(p); | ||
p = arg.p; | ||
if ( p ) CFRetain(p); | ||
} | ||
CFObject() {} | ||
CFObject( self_t const & arg ) { | ||
p = arg.p; | ||
if ( p ) CFRetain(p); | ||
} | ||
|
||
CFObject(self_t && arg ) { | ||
p = arg.p; arg.p = NULL; | ||
} | ||
void operator=(self_t && arg) { | ||
if ( p ) CFRelease(p); | ||
p = arg.p; arg.p = NULL; | ||
} | ||
|
||
operator bool() const { return p != NULL; } | ||
operator type_t() const { return p;} | ||
|
||
|
||
void reset() { | ||
if ( p ) CFRelease(p); | ||
p = NULL; | ||
} | ||
|
||
void operator=(nullptr_t) { | ||
reset(); | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.