Skyler Lipthay 496031e8c8 decklink: Add Mac DeckLink project
The code specific to Mac OS X helps convert `CFString` instances to
`std::string`s.
2015-03-21 16:42:40 -07:00

23 lines
565 B
C++

#include "../platform.hpp"
bool DeckLinkStringToStdString(decklink_string_t input, std::string& output)
{
const CFStringRef string = static_cast<CFStringRef>(input);
const CFIndex length = CFStringGetLength(string);
const CFIndex maxLength = CFStringGetMaximumSizeForEncoding(length,
kCFStringEncodingASCII) + 1;
char * const buffer = new char[maxLength];
const bool result = CFStringGetCString(string, buffer, maxLength,
kCFStringEncodingASCII);
if (result)
output = std::string(buffer);
delete[] buffer;
CFRelease(string);
return result;
}