aboutsummaryrefslogtreecommitdiff
path: root/include/cru/base/platform
diff options
context:
space:
mode:
authorYuqian Yang <crupest@crupest.life>2025-11-03 20:48:22 +0800
committerYuqian Yang <crupest@crupest.life>2025-11-03 20:48:22 +0800
commit40bbf3c14a782673bbd36c8a98adb0934b06add5 (patch)
tree4878604ccba77a957cbacd42dd1355fe33f5d0af /include/cru/base/platform
parenta04627baa74b2b6660addeb9853225852634cf34 (diff)
downloadcru-40bbf3c14a782673bbd36c8a98adb0934b06add5.tar.gz
cru-40bbf3c14a782673bbd36c8a98adb0934b06add5.tar.bz2
cru-40bbf3c14a782673bbd36c8a98adb0934b06add5.zip
Osx remove Resource.h.
Diffstat (limited to 'include/cru/base/platform')
-rw-r--r--include/cru/base/platform/osx/Base.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/include/cru/base/platform/osx/Base.h b/include/cru/base/platform/osx/Base.h
new file mode 100644
index 00000000..290d9b3d
--- /dev/null
+++ b/include/cru/base/platform/osx/Base.h
@@ -0,0 +1,38 @@
+#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 <CoreFoundation/CoreFoundation.h>
+#include <string>
+#include <string_view>
+
+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(std::string_view string);
+std::string FromCFStringRef(CFStringRef string);
+
+CFRange ToCFRange(const Range& range);
+Range FromCFRange(const CFRange& range);
+} // namespace cru