00001 /* 00002 * @(#)QStringAdapter.h 0.2.0 / 2007-09-07 00003 * 00004 * Copyright (c) 2007, ETF and contributors. All rights reserved. 00005 * 00006 * This software is licensed under the LGPL, version 2.1, license. 00007 * A copy of the license is included in the file LICENSE-LGPL.txt. 00008 */ 00009 #ifndef QSTRINGADAPTER_H 00010 #define QSTRINGADAPTER_H 00011 00012 #include "JavaQxCommon.h" 00013 00014 /*^**************************************************************************^*/ 00015 /*- QStringAdapter Class. -*/ 00016 /*^**************************************************************************^*/ 00017 00024 class JAVAQX_EXPORT QStringAdapter : public QString 00025 { 00026 public: 00027 QStringAdapter(JNIEnv *env, jstring str); 00028 public: 00029 inline QStringAdapter(const QStringAdapter &qsa); 00030 inline QStringAdapter(const QString &qs); 00031 public: 00032 jstring toJString(JNIEnv *env); 00033 public: 00034 inline QStringAdapter &operator=(const QStringAdapter &qsa); 00035 inline QStringAdapter &operator=(const QString &qs); 00036 inline QStringAdapter &operator+=(const QStringAdapter &qsa); 00037 inline QStringAdapter &operator+=(const QString &qs); 00038 public: 00039 static jstring toJString(JNIEnv *env, const QString &str); 00040 private: 00041 static const QString EMPTY_STRING; 00042 }; 00043 00044 /*^**************************************************************************^*/ 00045 /*- QStringAdapter :: Public Inline Constructors. -*/ 00046 /*^**************************************************************************^*/ 00047 00054 inline QStringAdapter::QStringAdapter(const QStringAdapter &qsa) 00055 : QString(qsa) 00056 { 00057 // empty body 00058 } 00059 00066 inline QStringAdapter::QStringAdapter(const QString &qs) 00067 : QString(qs) 00068 { 00069 // empty body 00070 } 00071 00072 /*^**************************************************************************^*/ 00073 /*- QStringAdapter :: Public Inline Operators. -*/ 00074 /*^**************************************************************************^*/ 00075 00083 inline QStringAdapter &QStringAdapter::operator=(const QStringAdapter &qsa) 00084 { 00085 QString::operator=(qsa); 00086 return *this; 00087 } 00088 00096 inline QStringAdapter &QStringAdapter::operator=(const QString &qs) 00097 { 00098 QString::operator=(qs); 00099 return *this; 00100 } 00101 00109 inline QStringAdapter &QStringAdapter::operator+=(const QStringAdapter &qsa) 00110 { 00111 append(qsa); 00112 return *this; 00113 } 00114 00122 inline QStringAdapter &QStringAdapter::operator+=(const QString &qs) 00123 { 00124 append(qs); 00125 return *this; 00126 } 00127 00128 /*^**************************************************************************^*/ 00129 /*- QStringAdapter :: Related Non-Member. -*/ 00130 /*^**************************************************************************^*/ 00131 00140 inline const QStringAdapter operator+(const QStringAdapter &qsa1, 00141 const QStringAdapter &qsa2) 00142 { 00143 QStringAdapter tqsa(qsa1); 00144 tqsa.append(qsa2); 00145 return tqsa; 00146 } 00147 00148 #endif // QSTRINGADAPTER_H 00149 00150 /*^***************************************************************************** 00151 File History: 00152 00153 - 2007-05-20 18:12:03 Slobodan 00154 Initial version 00155 00156 *****************************************************************************^*/