3
* VBox frontends: Qt GUI ("VirtualBox"):
8
* Copyright (C) 2009 Oracle Corporation
10
* This file is part of VirtualBox Open Source Edition (OSE), as
11
* available from http://www.virtualbox.org. This file is free software;
12
* you can redistribute it and/or modify it under the terms of the GNU
13
* General Public License (GPL) as published by the Free Software
14
* Foundation, in version 2 as it comes in the "COPYING" file of the
15
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
19
#ifndef ___darwin_VBoxCocoaHelper_h
20
#define ___darwin_VBoxCocoaHelper_h
23
#include <VBox/VBoxCocoa.h>
28
#import <AppKit/NSImage.h>
29
#import <Foundation/NSAutoreleasePool.h>
30
#import <CoreFoundation/CFString.h>
34
#include <QVarLengthArray>
36
inline NSString *darwinQStringToNSString (const QString &aString)
38
return [reinterpret_cast<const NSString *>(CFStringCreateWithCharacters (0, reinterpret_cast<const UniChar *> (aString.unicode()),
39
aString.length())) autorelease];
42
inline QString darwinNSStringToQString (const NSString *aString)
44
CFStringRef str = reinterpret_cast<const CFStringRef> (aString);
47
CFIndex length = CFStringGetLength (str);
48
const UniChar *chars = CFStringGetCharactersPtr (str);
50
return QString (reinterpret_cast<const QChar *> (chars), length);
52
QVarLengthArray<UniChar> buffer (length);
53
CFStringGetCharacters (str, CFRangeMake (0, length), buffer.data());
54
return QString (reinterpret_cast<const QChar *> (buffer.constData()), length);
59
#endif /* ___darwin_VBoxCocoaHelper_h */