- Timestamp:
- Mar 23, 2016 11:08:54 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/VBoxCocoaHelper.h
r55401 r60151 33 33 #include <QVarLengthArray> 34 34 35 inline NSString *darwinQStringToNSString 35 inline NSString *darwinQStringToNSString(const QString &aString) 36 36 { 37 return [reinterpret_cast<const NSString *>(CFStringCreateWithCharacters (0, reinterpret_cast<const UniChar *> (aString.unicode()), 38 aString.length())) autorelease]; 37 const UniChar *chars = reinterpret_cast<const UniChar *>(aString.unicode()); 38 CFStringRef str = CFStringCreateWithCharacters(0, chars, aString.length()); 39 return [(NSString*)CFStringCreateMutableCopy(0, 0, str) autorelease]; 39 40 } 40 41 41 inline QString darwinNSStringToQString 42 inline QString darwinNSStringToQString(const NSString *aString) 42 43 { 43 CFStringRef str = reinterpret_cast<const CFStringRef> 44 CFStringRef str = reinterpret_cast<const CFStringRef>(aString); 44 45 if(!str) 45 46 return QString(); 46 CFIndex length = CFStringGetLength 47 const UniChar *chars = CFStringGetCharactersPtr 47 CFIndex length = CFStringGetLength(str); 48 const UniChar *chars = CFStringGetCharactersPtr(str); 48 49 if (chars) 49 return QString (reinterpret_cast<const QChar *>(chars), length);50 return QString(reinterpret_cast<const QChar *>(chars), length); 50 51 51 QVarLengthArray<UniChar> buffer 52 CFStringGetCharacters (str, CFRangeMake(0, length), buffer.data());53 return QString (reinterpret_cast<const QChar *>(buffer.constData()), length);52 QVarLengthArray<UniChar> buffer(length); 53 CFStringGetCharacters(str, CFRangeMake(0, length), buffer.data()); 54 return QString(reinterpret_cast<const QChar *>(buffer.constData()), length); 54 55 } 55 56
Note:
See TracChangeset
for help on using the changeset viewer.