blob: fbdffc5471ef5ed848d555af11934e24551e25c2 (
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
32
33
34
35
36
37
 | #pragma once
// TODO: Move This file to platform dir.
#ifndef __APPLE__
#error "This header can only be included on OSX platforms."
#endif
#include "Range.h"
#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> ToCFString(StringView string);
String FromCFStringRef(CFStringRef string);
CFRange ToCFRange(const Range& range);
Range FromCFRange(const CFRange& range);
}  // namespace cru
 |