/ OSX / libsecurity_transform / lib / c++utils.h
c++utils.h
 1  #ifndef __CPLUSPLUS_UTILS__
 2  #define __CPLUSPLUS_UTILS__
 3  
 4  #include <string>
 5  #include <CoreFoundation/CoreFoundation.h>
 6  
 7  std::string StringFromCFString(CFStringRef theString);
 8  CFStringRef CFStringFromString(std::string theString) CF_RETURNS_RETAINED;
 9  
10  // class to automatically manage the lifetime of a CFObject
11  
12  class CFTypeRefHolder
13  {
14  private:
15  	CFTypeRef mTypeRef;
16  
17  public:
18  	CFTypeRefHolder(CFTypeRef typeRef) : mTypeRef(typeRef) {}
19  	virtual ~CFTypeRefHolder();
20  	
21  	void Set(CFTypeRef typeRef); // replace the value in the holder with another -- releases the current value
22  	CFTypeRef Get() {return mTypeRef;}
23  };
24  
25  
26  
27  #endif