]> git.saurik.com Git - apple/security.git/blobdiff - Security/libsecurity_transform/lib/c++utils.h
Security-57031.1.35.tar.gz
[apple/security.git] / Security / libsecurity_transform / lib / c++utils.h
diff --git a/Security/libsecurity_transform/lib/c++utils.h b/Security/libsecurity_transform/lib/c++utils.h
new file mode 100644 (file)
index 0000000..b22810f
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef __CPLUSPLUS_UTILS__
+#define __CPLUSPLUS_UTILS__
+
+#include <string>
+#include <CoreFoundation/CoreFoundation.h>
+
+std::string StringFromCFString(CFStringRef theString);
+CFStringRef CFStringFromString(std::string theString);
+
+// class to automatically manage the lifetime of a CFObject
+
+class CFTypeRefHolder
+{
+private:
+       CFTypeRef mTypeRef;
+
+public:
+       CFTypeRefHolder(CFTypeRef typeRef) : mTypeRef(typeRef) {}
+       virtual ~CFTypeRefHolder();
+       
+       void Set(CFTypeRef typeRef); // replace the value in the holder with another -- releases the current value
+       CFTypeRef Get() {return mTypeRef;}
+};
+
+
+
+#endif