blob: 057302c2d4c1946d79c597869e009980991b7fe3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#pragma once
#ifndef __APPLE__
#error "This header can only be included on OSX platforms."
#endif
#include "String.h"
#include <CoreFoundation/CoreFoundation.h>
namespace cru {
template <typename CFClassRef>
class CFWrapper {
public:
CFClassRef ref;
explicit CFWrapper(CFClassRef ref) { this->ref = ref; }
~CFWrapper() {
if (this->ref) CFRelease(this->ref);
}
CFClassRef* release() {
auto ref = this->ref;
this->ref = nullptr;
return ref;
}
};
CFWrapper<CFStringRef> ToCFStringRef(StringView string);
String FromCFStringRef(CFStringRef string);
} // namespace cru
|