/
apple.hh
58 lines (42 loc) · 1.44 KB
/
apple.hh
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright 2015 Alexander Bohn <fish2000@gmail.com>
// License: MIT (see COPYING.MIT file)
#ifndef LPC_APPLE_HH_INCLUDE_GUARD_
#define LPC_APPLE_HH_INCLUDE_GUARD_
#ifdef __OBJC__
#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>
#import <CoreFoundation/CoreFoundation.h>
#endif
#include <memory>
#include <cstdio>
#include <cstring>
#include <libimread/libimread.hpp>
#include <libimread/base.hh>
namespace im {
#ifdef __OBJC__
namespace cf {
/// NOTE TO SELF:
/// replace this with CF++ and the like
template <typename C = CFTypeRef>
struct unref {
constexpr unref() noexcept = default;
template <typename U> unref(const unref<U>&) noexcept {};
void operator()(C ref) { if (ref) CFRelease(ref); }
};
template <typename Ref>
using REF = std::unique_ptr<typename std::decay<Ref>::type, unref<Ref>>;
}
#endif
class NSImageFormat : public ImageFormat {
public:
typedef std::true_type can_read;
virtual std::unique_ptr<Image> read(byte_source *src,
ImageFactory *factory,
const options_map &opts) override;
};
namespace format {
using NS = NSImageFormat;
using Apple = NSImageFormat;
}
}
#endif // LPC_APPLE_HH_INCLUDE_GUARD_