Using Qt with turbo activate and turbo float

I have been using turbo activate and turbo float with the Qt framework on Windows and Mac OS X.I wrote a couple of simple classes to convert the QString (UNICODE) string into a form usable by turboactivate and turbofloat.

I am sharing these in case someone else finds them useful:

/** Utility class used to convert QString into STRCTYPE for use by * the TurboActivate API. */class QStringToSTRCTYPE{public: QStringToSTRCTYPE( const QString & str ): _value(0) {#ifdef Q_OS_WIN if( str.length() > sizeof(m_tempConstWChar ) ) { m_tempConstWChar[0] = 0; }else { int len = str.toWCharArray( m_tempConstWChar ); m_tempConstWChar[len] = 0; } _value = m_tempConstWChar;#else m_tempConstByteArray = str.toLocal8Bit(); _value = m_tempConstByteArray.data();#endif }

STRCTYPE Value() { return _value; }

#ifdef Q_OS_WIN wchar_t m_tempConstWChar[1024]; // Used by convertConstString()#else QByteArray m_tempConstByteArray; // Used by convertConstString()#endif STRCTYPE _value;};//////////////////////////////////////////////////////////////////////** Utility class used to process STRTYPE conversions */class STRTYPEbuffer{public: STRTYPEbuffer() { }

STRTYPE Pointer() {#ifdef Q_OS_WIN return m_tempBufWChar;#else return m_tempBufChar;#endif }

size_t Size() {#ifdef Q_OS_WIN return sizeof(m_tempBufWChar);#else return sizeof(m_tempBufChar);#endif }

void toString( QString & str, size_t len ) {#ifdef Q_OS_WIN str = QString::fromWCharArray( m_tempBufWChar );#else str = m_tempBufChar;#endif }

#ifdef Q_OS_WIN wchar_t m_tempBufWChar[1024]; // Used by tempBufPointer(), tempBufSize(), tempBufToString()#else char m_tempBufChar[1024]; // Used by tempBufPointer(), tempBufSize(), tempBufToString()#endif};