diff options
Diffstat (limited to 'include/cru/base/Osx.h')
-rw-r--r-- | include/cru/base/Osx.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/include/cru/base/Osx.h b/include/cru/base/Osx.h new file mode 100644 index 00000000..711da9a3 --- /dev/null +++ b/include/cru/base/Osx.h @@ -0,0 +1,26 @@ +#pragma once + +#ifndef CRU_PLATFORM_OSX +#error "This header can only be included on OSX." +#endif + +#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; + } +}; +} // namespace cru |