ObjQt  OFString+QString.mm at [ed8ed56b3a]

File common/OFString+QString.mm artifact 30948bf7cc part of check-in ed8ed56b3a


#import "OFString+QString.h"

@implementation OFString (QString)
+ stringWithQString: (const QString&)qString
{
	return [[[self alloc] initWithQString: qString] autorelease];
}

- initWithQString: (const QString&)qString
{
	static_assert(sizeof(QChar) == sizeof(of_char16_t),
	    "QChar and of_char16_t have a different size!");

	return [self initWithUTF16String: (of_char16_t*)qString.data()
				  length: qString.length()];
}

- (QString)qString
{
	static_assert(sizeof(of_char16_t) == sizeof(QChar),
	    "of_char16_t and QChar have a different size!");

	void *pool = objc_autoreleasePoolPush();
	QString ret = QString((QChar*)[self UTF16String]);

	objc_autoreleasePoolPop(pool);

	return ret;
}
@end