platform.cpp 565 B

12345678910111213141516171819202122
  1. #include "../platform.hpp"
  2. bool DeckLinkStringToStdString(decklink_string_t input, std::string& output)
  3. {
  4. const CFStringRef string = static_cast<CFStringRef>(input);
  5. const CFIndex length = CFStringGetLength(string);
  6. const CFIndex maxLength = CFStringGetMaximumSizeForEncoding(length,
  7. kCFStringEncodingASCII) + 1;
  8. char * const buffer = new char[maxLength];
  9. const bool result = CFStringGetCString(string, buffer, maxLength,
  10. kCFStringEncodingASCII);
  11. if (result)
  12. output = std::string(buffer);
  13. delete[] buffer;
  14. CFRelease(string);
  15. return result;
  16. }