diff --git a/include/MacStd/CoreFoundation.hpp b/include/MacStd/CoreFoundation.hpp index ffb830d..c51737e 100644 --- a/include/MacStd/CoreFoundation.hpp +++ b/include/MacStd/CoreFoundation.hpp @@ -92,6 +92,27 @@ namespace macstd { cfstring(const std::basic_string &s) : cfstring(s.c_str()) {} }; + /// + /// Core Foundation number + /// + class cfnumber : public cfobject + { + public: + cfnumber(CFNumberRef h) : cfobject(h) {} + + cfnumber(float n) : cfobject(CFNumberCreate(kCFAllocatorDefault, kCFNumberFloatType, &n)) + { + if (!valid()) [[unlikely]] + throw std::bad_alloc(); + } + + cfnumber(double n) : cfobject(CFNumberCreate(kCFAllocatorDefault, kCFNumberDoubleType, &n)) + { + if (!valid()) [[unlikely]] + throw std::bad_alloc(); + } + }; + /// /// Core Foundation runtime error ///