Ticket #5311: mstring.diff

File mstring.diff, 46.9 KB (added by jpbrock@…, 15 years ago)

MString, a thread-safe replacement for QString

  • mythtv/libs/libmyth/libmyth.pro

     
    2727HEADERS += volumebase.h virtualkeyboard.h visual.h xmlparse.h
    2828HEADERS += mythhdd.h mythcdrom.h storagegroup.h dbutil.h
    2929HEADERS += mythcommandlineparser.h mythterminal.h
    30 HEADERS += mythhttppool.h mythhttphandler.h
     30HEADERS += mythhttppool.h mythhttphandler.h mstring.h
    3131
    3232SOURCES += audiooutput.cpp audiooutputbase.cpp audiooutputnull.cpp
    3333SOURCES += audiooutputdigitalencoder.cpp audiosettings.cpp
     
    4444SOURCES += volumebase.cpp virtualkeyboard.cpp xmlparse.cpp
    4545SOURCES += mythhdd.cpp mythcdrom.cpp storagegroup.cpp dbutil.cpp
    4646SOURCES += mythcommandlineparser.cpp mythterminal.cpp
    47 SOURCES += mythhttppool.cpp mythhttphandler.cpp
     47SOURCES += mythhttppool.cpp mythhttphandler.cpp mstring.cpp
    4848
    4949
    5050INCLUDEPATH += ../libmythsamplerate ../libmythsoundtouch ../libmythfreesurround
  • mythtv/libs/libmyth/mstring.h

     
     1/*
     2 *  Class MString: a thread-safe version of QString
     3 *
     4 *  Copyright (C) 2008 Jerome Brock <jpbrock@users.sourceforge.net>
     5 *
     6 *   This program is free software; you can redistribute it and/or modify
     7 *   it under the terms of the GNU General Public License as published by
     8 *   the Free Software Foundation; either version 2 of the License, or
     9 *   (at your option) any later version.
     10 *
     11 *   This program is distributed in the hope that it will be useful,
     12 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     13 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14 *   GNU General Public License for more details.
     15 *
     16 *   You should have received a copy of the GNU General Public License
     17 *   along with this program; if not, write to the Free Software
     18 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     19 */
     20
     21#ifndef MSTRING_H
     22#define MSTRING_H
     23
     24#include <QtCore/QString>
     25#include <QtCore/QReadWriteLock>
     26
     27#include "mythexp.h"
     28
     29class MPUBLIC MString
     30{
     31private:
     32    mutable QReadWriteLock m_lock;
     33    QString m_string;
     34
     35public:
     36    MString() {};
     37    MString(const QChar * unicode, int size) {m_string = QString(unicode, size);};
     38    MString(int size, QChar ch) {m_string = QString(size, ch);};
     39    MString(const MString & other) {m_string = other.toQString();};
     40    MString(const QString & other) {m_string = QString(other);};
     41    MString(const char * str) {m_string = QString(str);};
     42    MString(const QByteArray & ba) {m_string = QString(ba);};
     43    ~MString() {};
     44
     45
     46    static const MString null;
     47    enum NormalizationForm {
     48            NormalizationForm_D,
     49            NormalizationForm_C,
     50            NormalizationForm_KD,
     51            NormalizationForm_KC
     52    };
     53    enum SectionFlag {
     54            SectionDefault             = 0x00,
     55            SectionSkipEmpty           = 0x01,
     56            SectionIncludeLeadingSep   = 0x02,
     57            SectionIncludeTrailingSep  = 0x04,
     58            SectionCaseInsensitiveSeps = 0x08,
     59    };
     60    Q_DECLARE_FLAGS(SectionFlags, SectionFlag)
     61   
     62    enum SplitBehavior {KeepEmptyParts, SkipEmptyParts};
     63
     64
     65    MString & append(const MString & str);
     66    MString & append(const QLatin1String & str);
     67    MString & append(const QByteArray & ba);
     68    MString & append(const char * str);
     69    MString & append(QChar ch);
     70    MString arg(const MString & a, int fieldWidth = 0,
     71                    const QChar & fillChar = QLatin1Char(' ')) const;
     72    MString arg(const MString & a1, const MString & a2) const;
     73    MString arg(const MString & a1, const MString & a2, const MString & a3) const;
     74    MString arg(const MString & a1, const MString & a2, const MString & a3,
     75                    const MString & a4) const;
     76    MString arg(const MString & a1, const MString & a2, const MString & a3,
     77                    const MString & a4, const MString & a5) const;
     78    MString arg(const MString & a1, const MString & a2, const MString & a3,
     79                    const MString & a4, const MString & a5,
     80                    const MString & a6) const;
     81    MString arg(const MString & a1, const MString & a2, const MString & a3,
     82                    const MString & a4, const MString & a5,
     83                    const MString & a6, const MString & a7) const;
     84    MString arg(const MString & a1, const MString & a2, const MString & a3,
     85                    const MString & a4, const MString & a5,
     86                    const MString & a6, const MString & a7,
     87                    const MString & a8) const;
     88    MString arg(const MString & a1, const MString & a2, const MString & a3,
     89                    const MString & a4, const MString & a5,
     90                    const MString & a6, const MString & a7,
     91                    const MString & a8, const MString & a9) const;
     92    const QChar at(int position) const;
     93    int capacity() const;
     94    void chop(int n);
     95    void clear();
     96    int compare(const MString & other) const;
     97    int compare(const MString & other, Qt::CaseSensitivity cs) const;
     98    int compare(const QLatin1String & other,
     99                    Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
     100    const QChar * constData() const;
     101    bool contains(const MString & str,
     102                    Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
     103    bool contains(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
     104    bool contains(const QRegExp & rx) const;
     105    int count(const MString & str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
     106    int count(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
     107    int count(const QRegExp & rx) const;
     108    int count() const;
     109    //QChar * data ();
     110    //const QChar * data () const;
     111    bool endsWith(const MString & s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
     112    bool endsWith(const QLatin1String & s,
     113                    Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
     114    bool endsWith(const QChar & c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
     115    MString & fill(QChar ch, int size = -1);
     116    int indexOf(const MString & str, int from = 0,
     117                    Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
     118    int indexOf(QChar ch, int from = 0,
     119                    Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
     120    int indexOf(const QRegExp & rx, int from = 0) const;
     121    MString & insert(int position, const MString & str);
     122    MString & insert(int position, const QLatin1String & str);
     123    MString & insert(int position, const QChar * unicode, int size);
     124    MString & insert(int position, QChar ch);
     125    bool isEmpty() const;
     126    bool isNull() const;
     127    int lastIndexOf(const MString & str, int from = -1,
     128                        Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
     129    int lastIndexOf(QChar ch, int from = -1,
     130                        Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
     131    int lastIndexOf(const QRegExp & rx, int from = -1) const;
     132    MString left(int n) const;
     133    MString leftJustified(int width, QChar fill = QLatin1Char(' '),
     134                            bool truncate = false) const;
     135    int length() const;
     136    int localeAwareCompare(const MString & other) const;
     137    MString mid(int position, int n = -1) const;
     138    MString normalized(QString::NormalizationForm mode) const;
     139    MString normalized(QString::NormalizationForm mode,
     140                            QChar::UnicodeVersion version) const;
     141    MString & prepend(const MString & str);
     142    MString & prepend(const QLatin1String & str);
     143    MString & prepend(const QByteArray & ba);
     144    MString & prepend(const char * str);
     145    MString & prepend(QChar ch);
     146    void push_back(const MString & other) {append(other);};
     147    void push_back(QChar ch) {append(ch);};
     148    void push_front(const MString & other) {prepend(other);};
     149    void push_front(QChar ch) {prepend(ch);};
     150    MString & remove(int position, int n);
     151    MString & remove(const MString & str,
     152                        Qt::CaseSensitivity cs = Qt::CaseSensitive);
     153    MString & remove(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive);
     154    MString & remove(const QRegExp & rx);
     155    MString & replace(int position, int n, const MString & after);
     156    MString & replace(int position, int n, const QChar * unicode, int size);
     157    MString & replace(int position, int n, QChar after);
     158    MString & replace(const MString & before, const MString & after,
     159                        Qt::CaseSensitivity cs = Qt::CaseSensitive);
     160    MString & replace(QChar ch, const MString & after,
     161                        Qt::CaseSensitivity cs = Qt::CaseSensitive);
     162    MString & replace(QChar before, QChar after,
     163                        Qt::CaseSensitivity cs = Qt::CaseSensitive);
     164    MString & replace(const QRegExp & rx, const MString & after);
     165    void reserve(int size);
     166    void resize(int size);
     167    MString right(int n) const;
     168    MString rightJustified(int width, QChar fill = QLatin1Char(' '),
     169                                bool truncate = false) const;
     170    MString section(QChar sep, int start, int end = -1,
     171                        SectionFlags flags = SectionDefault) const;
     172    MString section(const MString & sep, int start, int end = -1,
     173                        SectionFlags flags = SectionDefault) const;
     174    MString section(const QRegExp & reg, int start, int end = -1,
     175                        SectionFlags flags = SectionDefault) const;
     176    MString & setNum(uint n, int base = 10);
     177    MString & setNum(long n, int base = 10);
     178    MString & setNum(ulong n, int base = 10);
     179    MString & setNum(qlonglong n, int base = 10);
     180    MString & setNum(qulonglong n, int base = 10);
     181    MString & setNum(short n, int base = 10);
     182    MString & setNum(ushort n, int base = 10);
     183    MString & setNum(double n, char format = 'g', int precision = 6);
     184    MString & setNum(float n, char format = 'g', int precision = 6);
     185    MString & setUnicode(const QChar * unicode, int size);
     186    MString & setUtf16(const ushort * unicode, int size);
     187    MString simplified() const;
     188    int size() const;
     189    QStringList split(const MString & sep,
     190                        SplitBehavior behavior = KeepEmptyParts,
     191                        Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
     192    QStringList split(const QChar & sep,
     193                        SplitBehavior behavior = KeepEmptyParts,
     194                        Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
     195    QStringList split(const QRegExp & rx,
     196                        SplitBehavior behavior = KeepEmptyParts) const;
     197    //MString & sprintf ( const char * cformat, ... );
     198    void squeeze();
     199    bool startsWith(const MString & s,
     200                        Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
     201    bool startsWith(const QLatin1String & s,
     202                        Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
     203    bool startsWith(const QChar & c,
     204                        Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
     205    QByteArray toAscii() const;
     206    MString toCaseFolded() const;
     207    double toDouble(bool * ok = 0) const;
     208    float toFloat(bool * ok = 0) const;
     209    int toInt(bool * ok = 0, int base = 10) const;
     210    QByteArray toLatin1() const;
     211    QByteArray toLocal8Bit() const;
     212    long toLong(bool * ok = 0, int base = 10) const;
     213    qlonglong toLongLong(bool * ok = 0, int base = 10) const;
     214    MString toLower() const;
     215    QString toQString() const;
     216    short toShort(bool * ok = 0, int base = 10) const;
     217    std::string toStdString() const;
     218    std::wstring toStdWString() const;
     219    uint toUInt(bool * ok = 0, int base = 10) const;
     220    ulong toULong(bool * ok = 0, int base = 10) const;
     221    qulonglong toULongLong(bool * ok = 0, int base = 10) const;
     222    ushort toUShort(bool * ok = 0, int base = 10) const;
     223    QVector<uint> toUcs4() const;
     224    MString toUpper() const;
     225    QByteArray toUtf8() const;
     226    int toWCharArray(wchar_t * array) const;
     227    MString trimmed() const;
     228    void truncate(int position);
     229    const QChar * unicode() const;
     230    MString & vsprintf(const char * cformat, va_list ap);
     231
     232    bool operator== (const MString & other) const;
     233    bool operator== (const QLatin1String & other) const;
     234    bool operator== (const QByteArray & other) const;
     235    bool operator== (const char * other) const;
     236
     237    bool operator!= (const MString & other) const {return !(*this == other);};
     238    bool operator!= (const QLatin1String & other) const {return !(*this == other);};
     239    bool operator!= (const QByteArray & other) const {return !(*this == other);};
     240    bool operator!= (const char * other) const {return !(*this == other);};
     241
     242    bool operator< (const MString & other) const;
     243    bool operator< (const QLatin1String & other) const;
     244    bool operator< (const QByteArray & other) const;
     245    bool operator< (const char * other) const;
     246
     247    bool operator<= (const MString & other) const;
     248    bool operator<= (const QLatin1String & other) const;
     249    bool operator<= (const QByteArray & other) const;
     250    bool operator<= (const char * other) const;
     251
     252    bool operator> (const MString & other) const {return !(*this <= other);};
     253    bool operator> (const QLatin1String & other) const {return !(*this <= other);};
     254    bool operator> (const QByteArray & other) const {return !(*this <= other);};
     255    bool operator> (const char * other) const {return !(*this <= other);};
     256
     257    bool operator>= (const MString & other) const {return !(*this < other);};
     258    bool operator>= (const QLatin1String & other) const {return !(*this < other);};
     259    bool operator>= (const QByteArray & other) const {return !(*this < other);};
     260    bool operator>= (const char * other) const {return !(*this < other);};
     261
     262    MString & operator= (const MString & other);
     263    MString & operator= (const QLatin1String & str);
     264    MString & operator= (const QByteArray & ba);
     265    MString & operator= (const char * str);
     266    MString & operator= (char ch);
     267    MString & operator= (QChar ch);
     268
     269    MString & operator+= (const MString & other) {return append(other);};
     270    MString & operator+= (const QLatin1String & str) {return append(str);};
     271    MString & operator+= (const QByteArray & ba) {return append(ba);};
     272    MString & operator+= (const char * str) {return append(str);};
     273    MString & operator+= (char ch) {return append(ch);};
     274    MString & operator+= (QChar ch) {return append(ch);};
     275
     276    //QCharRef operator[] ( int position );
     277    const QChar operator[](int position) const;
     278    //QCharRef operator[] ( uint position );
     279    const QChar operator[](uint position) const;
     280
     281    static int compare(const MString & s1, const MString & s2,
     282                            Qt::CaseSensitivity cs) {return s1.compare(s2, cs);};
     283    static int compare(const MString & s1, const MString & s2)
     284                        {return s1.compare(s2);};
     285    static int compare(const MString & s1, const QLatin1String & s2,
     286                            Qt::CaseSensitivity cs = Qt::CaseSensitive)
     287                            {return s1.compare(s2, cs);};
     288    static int compare(const QLatin1String & s1, const QString & s2,
     289                            Qt::CaseSensitivity cs = Qt::CaseSensitive)
     290                            {return -s2.compare(s1, cs);};
     291
     292    static MString fromAscii(const char * str, int size = -1)
     293                                {return MString(QString::fromAscii(str, size));};
     294    static MString fromLatin1(const char * str, int size = -1)
     295                                {return MString(QString::fromLatin1(str, size));};
     296    static MString fromLocal8Bit(const char * str, int size = -1)
     297                                {return MString(QString::fromLocal8Bit(str, size));};
     298    static MString fromRawData(const QChar * unicode, int size)
     299                                {return MString(QString::fromRawData(unicode, size));};
     300    static MString fromStdString(const std::string & str)
     301                                {return MString(QString::fromStdString(str));};
     302    static MString fromStdWString(const std::wstring & str)
     303                                {return MString(QString::fromStdWString(str));};
     304    static MString fromUcs4(const uint * unicode, int size = -1)
     305                                {return MString(QString::fromUcs4(unicode, size));};
     306    static MString fromUtf8(const char * str, int size = -1)
     307                                {return MString(QString::fromUtf8(str, size));};
     308    static MString fromUtf16(const ushort * unicode, int size = -1)
     309                                {return MString(QString::fromUtf16(unicode, size));};
     310    static MString fromWCharArray(const wchar_t * string, int size = -1)
     311                                {return MString(QString::fromWCharArray(string, size));};
     312    static int localeAwareCompare(const MString & s1, const MString & s2)
     313                                {return QString::localeAwareCompare(s1.toQString(),
     314                                s2.toQString());};
     315
     316    static MString number(long n, int base = 10)
     317                                {return MString(QString::number(n, base));};
     318    static MString number(ulong n, int base = 10)
     319                                {return MString(QString::number(n, base));};
     320    static MString number(int n, int base = 10)
     321                                {return MString(QString::number(n, base));};
     322    static MString number(uint n, int base = 10)
     323                                {return MString(QString::number(n, base));};
     324    static MString number(qlonglong n, int base = 10)
     325                                {return MString(QString::number(n, base));};
     326    static MString number(qulonglong n, int base = 10)
     327                                {return MString(QString::number(n, base));};
     328    static MString number(double n, char format = 'g', int precision = 6)
     329                                {return MString(QString::number(n, format, precision));};
     330
     331    friend QDataStream & operator<< (QDataStream & stream, const MString & string);
     332    friend QDataStream & operator>> (QDataStream & stream, MString & string);
     333
     334};
     335
     336inline const MString operator+ (const MString & s1, const MString & s2)
     337                                    {return MString(s1.toQString() + s2.toQString());};
     338inline const MString operator+ (const MString & s1, const char * s2)
     339                                    {return MString(s1.toQString() + s2);};
     340inline const MString operator+ (const char * s1, const MString & s2)
     341                                    {return MString(s1 + s2.toQString());};
     342inline const MString operator+ (const MString & s, char ch)
     343                                    {return MString(s.toQString() + ch);};
     344inline const MString operator+ (char ch, const MString & s)
     345                                    {return MString(ch + s.toQString());};
     346inline bool operator== (const char * s1, const MString & s2)
     347                                    {return (s1 == s2.toQString());};
     348inline bool operator!= (const char * s1, const MString & s2)
     349                                    {return !(s1 != s2);};
     350inline bool operator< (const char * s1, const MString & s2)
     351                                    {return (s1 < s2.toQString());};
     352inline bool operator<= (const char * s1, const MString & s2)
     353                                    {return (s1 <= s2.toQString());};
     354inline bool operator> (const char * s1, const MString & s2)
     355                                    {return !(s1 <= s2);};
     356inline bool operator>= (const char * s1, const MString & s2)
     357                                    {return !(s1 < s2);};
     358
     359Q_DECLARE_OPERATORS_FOR_FLAGS(MString::SectionFlags)
     360#endif
     361
     362/* vim: set expandtab tabstop=4 shiftwidth=4: */
  • mythtv/libs/libmyth/mstring.cpp

     
     1/*
     2 *  Class MString: a thread-safe version of QString
     3 *
     4 *  Copyright (C) 2008 Jerome Brock <jpbrock@users.sourceforge.net>
     5 *
     6 *   This program is free software; you can redistribute it and/or modify
     7 *   it under the terms of the GNU General Public License as published by
     8 *   the Free Software Foundation; either version 2 of the License, or
     9 *   (at your option) any later version.
     10 *
     11 *   This program is distributed in the hope that it will be useful,
     12 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     13 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14 *   GNU General Public License for more details.
     15 *
     16 *   You should have received a copy of the GNU General Public License
     17 *   along with this program; if not, write to the Free Software
     18 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     19 */
     20
     21
     22// Avoid deadlock: do not read/write from another MString from within
     23// this class while holding your own lock!
     24//
     25// Don't bypass the thread safety of this class, i.e. don't bypass the lock by
     26// reading another MString's private QString directly // Use the 'toString()'
     27// method to retrieve the string in a thread-safe manner
     28//
     29// According to the documentation
     30// (see 4.3/threads.html#threads-and-implicit-sharing) sharing QStrings
     31// between threads is safe in QT4 as related to QString's implicit sharing. 
     32// In MString we are covering the thread safety for the QString objects,
     33// themselves.
     34
     35#include "mstring.h"
     36#include <QtCore/QStringList>
     37#include <QtCore/QVector>
     38
     39
     40MString & MString::append(const MString & str)
     41{
     42    const QString other_qstring = str.toQString();
     43
     44    QWriteLocker locker(&m_lock);
     45
     46    m_string.append(other_qstring);
     47    return *this;
     48};
     49
     50MString & MString::append(const QLatin1String & str)
     51{
     52    QWriteLocker locker(&m_lock);
     53
     54    m_string.append(str);
     55    return *this;
     56};
     57
     58MString & MString::append(const QByteArray & ba)
     59{
     60    QWriteLocker locker(&m_lock);
     61
     62    m_string.append(ba);
     63    return *this;
     64}
     65
     66MString & MString::append(const char * str)
     67{
     68    QWriteLocker locker(&m_lock);
     69
     70    m_string.append(str);
     71    return *this;
     72}
     73
     74MString & MString::append(QChar ch)
     75{
     76    QWriteLocker locker(&m_lock);
     77
     78    m_string.append(ch);
     79    return *this;
     80}
     81
     82MString MString::arg(const MString & a, int fieldWidth, const QChar & fillChar) const
     83{
     84    QString a_string = a.toQString();
     85
     86    QReadLocker locker(&m_lock);
     87
     88    return MString(m_string.arg(a_string, fieldWidth, fillChar));
     89}
     90
     91MString MString::arg(const MString & a1, const MString & a2) const
     92{
     93    QString a1_string = a1.toQString();
     94    QString a2_string = a2.toQString();
     95
     96    QReadLocker locker(&m_lock);
     97
     98    return MString(m_string.arg(a1_string, a2_string));
     99}
     100
     101MString MString::arg(const MString & a1, const MString & a2,
     102                        const MString & a3) const
     103{
     104    QString a1_string = a1.toQString();
     105    QString a2_string = a2.toQString();
     106    QString a3_string = a3.toQString();
     107
     108    QReadLocker locker(&m_lock);
     109
     110    return MString(m_string.arg(a1_string, a2_string, a3_string));
     111}
     112
     113MString MString::arg(const MString & a1, const MString & a2,
     114                        const MString & a3, const MString & a4) const
     115{
     116    QString a1_string = a1.toQString();
     117    QString a2_string = a2.toQString();
     118    QString a3_string = a3.toQString();
     119    QString a4_string = a4.toQString();
     120
     121    QReadLocker locker(&m_lock);
     122
     123    return MString(m_string.arg(a1_string, a2_string, a3_string, a4_string));
     124}
     125
     126MString MString::arg(const MString & a1, const MString & a2,
     127                        const MString & a3, const MString & a4,
     128                        const MString & a5) const
     129{
     130    QString a1_string = a1.toQString();
     131    QString a2_string = a2.toQString();
     132    QString a3_string = a3.toQString();
     133    QString a4_string = a4.toQString();
     134    QString a5_string = a5.toQString();
     135
     136    QReadLocker locker(&m_lock);
     137
     138    return MString(m_string.arg(a1_string, a2_string, a3_string, a4_string,
     139                    a5_string));
     140}
     141
     142MString MString::arg(const MString & a1, const MString & a2,
     143                        const MString & a3, const MString & a4,
     144                        const MString & a5, const MString & a6) const
     145{
     146    QString a1_string = a1.toQString();
     147    QString a2_string = a2.toQString();
     148    QString a3_string = a3.toQString();
     149    QString a4_string = a4.toQString();
     150    QString a5_string = a5.toQString();
     151    QString a6_string = a6.toQString();
     152
     153    QReadLocker locker(&m_lock);
     154
     155    return MString(m_string.arg(a1_string, a2_string, a3_string, a4_string,
     156                    a5_string, a6_string));
     157}
     158
     159MString MString::arg(const MString & a1, const MString & a2,
     160                        const MString & a3, const MString & a4,
     161                        const MString & a5, const MString & a6,
     162                        const MString & a7) const
     163{
     164    QString a1_string = a1.toQString();
     165    QString a2_string = a2.toQString();
     166    QString a3_string = a3.toQString();
     167    QString a4_string = a4.toQString();
     168    QString a5_string = a5.toQString();
     169    QString a6_string = a6.toQString();
     170    QString a7_string = a7.toQString();
     171
     172    QReadLocker locker(&m_lock);
     173
     174    return MString(m_string.arg(a1_string, a2_string, a3_string, a4_string,
     175                    a5_string, a6_string, a7_string));
     176}
     177
     178MString MString::arg(const MString & a1, const MString & a2,
     179                        const MString & a3, const MString & a4,
     180                        const MString & a5, const MString & a6,
     181                        const MString & a7, const MString & a8) const
     182{
     183    QString a1_string = a1.toQString();
     184    QString a2_string = a2.toQString();
     185    QString a3_string = a3.toQString();
     186    QString a4_string = a4.toQString();
     187    QString a5_string = a5.toQString();
     188    QString a6_string = a6.toQString();
     189    QString a7_string = a7.toQString();
     190    QString a8_string = a8.toQString();
     191
     192    QReadLocker locker(&m_lock);
     193
     194    return MString(m_string.arg(a1_string, a2_string, a3_string, a4_string,
     195                    a5_string, a6_string, a7_string, a8_string));
     196}
     197
     198MString MString::arg(const MString & a1, const MString & a2,
     199                        const MString & a3, const MString & a4,
     200                        const MString & a5, const MString & a6,
     201                        const MString & a7, const MString & a8,
     202                        const MString & a9) const
     203{
     204    QString a1_string = a1.toQString();
     205    QString a2_string = a2.toQString();
     206    QString a3_string = a3.toQString();
     207    QString a4_string = a4.toQString();
     208    QString a5_string = a5.toQString();
     209    QString a6_string = a6.toQString();
     210    QString a7_string = a7.toQString();
     211    QString a8_string = a8.toQString();
     212    QString a9_string = a9.toQString();
     213
     214    QReadLocker locker(&m_lock);
     215   
     216    return MString(m_string.arg(a1_string, a2_string, a3_string, a4_string,
     217                    a5_string, a6_string, a7_string, a8_string, a9_string));
     218}
     219
     220const QChar MString::at(int position) const
     221{
     222    QReadLocker locker(&m_lock);
     223
     224    return m_string.at(position);
     225}
     226
     227int MString::capacity() const
     228{
     229    QReadLocker locker(&m_lock);
     230
     231    return m_string.capacity();
     232}
     233
     234void MString::chop(int n)
     235{
     236    QWriteLocker locker(&m_lock);
     237
     238    m_string.chop(n);
     239}
     240
     241void MString::clear()
     242{
     243    QWriteLocker locker(&m_lock);
     244
     245    m_string.clear();
     246}
     247
     248int MString::compare(const MString & other) const
     249{
     250    const QString other_qstring = other.toQString();
     251
     252    QReadLocker locker(&m_lock);
     253
     254    return m_string.compare(other_qstring);
     255}
     256
     257int MString::compare(const MString & other, Qt::CaseSensitivity cs) const
     258{
     259    const QString other_qstring = other.toQString();
     260
     261    QReadLocker locker(&m_lock);
     262
     263    return m_string.compare(other_qstring, cs);
     264}
     265
     266int MString::compare(const QLatin1String & other, Qt::CaseSensitivity cs) const
     267{
     268    QReadLocker locker(&m_lock);
     269
     270    return m_string.compare(other, cs);
     271}
     272
     273const QChar * MString::constData() const
     274{
     275    QReadLocker locker(&m_lock);
     276
     277    return m_string.constData();
     278}
     279
     280bool MString::contains(const MString & str, Qt::CaseSensitivity cs) const
     281{
     282    const QString other_qstring = str.toQString();
     283
     284    QReadLocker locker(&m_lock);
     285
     286    return m_string.contains(other_qstring, cs);
     287}
     288
     289bool MString::contains(QChar ch, Qt::CaseSensitivity cs) const
     290{
     291    QReadLocker locker(&m_lock);
     292
     293    return m_string.contains(ch, cs);
     294}
     295
     296bool MString::contains(const QRegExp & rx) const
     297{
     298    QReadLocker locker(&m_lock);
     299
     300    return m_string.contains(rx);
     301}
     302
     303int MString::count(const MString & str, Qt::CaseSensitivity cs) const
     304{
     305    const QString other_qstring = str.toQString();
     306
     307    QReadLocker locker(&m_lock);
     308
     309    return m_string.count(other_qstring, cs);
     310}
     311
     312int MString::count(QChar ch, Qt::CaseSensitivity cs) const
     313{
     314    QReadLocker locker(&m_lock);
     315
     316    return m_string.count(ch, cs);
     317}
     318
     319int MString::count(const QRegExp & rx) const
     320{
     321    QReadLocker locker(&m_lock);
     322
     323    return m_string.count(rx);
     324}
     325
     326int MString::count() const
     327{
     328    QReadLocker locker(&m_lock);
     329
     330    return m_string.count();
     331}
     332
     333bool MString::endsWith(const MString & s, Qt::CaseSensitivity cs) const
     334{
     335    const QString other_qstring = s.toQString();
     336
     337    QReadLocker locker(&m_lock);
     338
     339    return m_string.endsWith(other_qstring, cs);
     340}
     341
     342bool MString::endsWith(const QLatin1String & s, Qt::CaseSensitivity cs) const
     343{
     344    QReadLocker locker(&m_lock);
     345
     346    return m_string.endsWith(s, cs);
     347}
     348
     349bool MString::endsWith(const QChar & c, Qt::CaseSensitivity cs) const
     350{
     351    QReadLocker locker(&m_lock);
     352
     353    return m_string.endsWith(c, cs);
     354}
     355
     356MString & MString::fill(QChar ch, int size)
     357{
     358    QWriteLocker locker(&m_lock);
     359
     360    m_string.fill(ch, size);
     361    return *this;
     362}
     363
     364int MString::indexOf(const MString & str, int from, Qt::CaseSensitivity cs) const
     365{
     366    const QString other_qstring = str.toQString();
     367
     368    QReadLocker locker(&m_lock);
     369
     370    return m_string.indexOf(other_qstring, from, cs);
     371}
     372
     373int MString::indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
     374{
     375    QReadLocker locker(&m_lock);
     376
     377    return m_string.indexOf(ch, from, cs);
     378}
     379
     380int MString::indexOf(const QRegExp & rx, int from) const
     381{
     382    QReadLocker locker(&m_lock);
     383
     384    return m_string.indexOf(rx, from);
     385}
     386
     387MString & MString::insert(int position, const MString & str)
     388{
     389    const QString other_qstring = str.toQString();
     390
     391    QWriteLocker locker(&m_lock);
     392
     393    m_string.insert(position, other_qstring);
     394    return *this;
     395}
     396
     397MString & MString::insert(int position, const QLatin1String & str)
     398{
     399    QWriteLocker locker(&m_lock);
     400
     401    m_string.insert(position, str);
     402    return *this;
     403}
     404
     405MString & MString::insert(int position, const QChar * unicode, int size)
     406{
     407    QWriteLocker locker(&m_lock);
     408
     409    m_string.insert(position, unicode, size);
     410    return *this;
     411}
     412
     413MString & MString::insert(int position, QChar ch)
     414{
     415    QWriteLocker locker(&m_lock);
     416
     417    m_string.insert(position, ch);
     418    return *this;
     419}
     420
     421bool MString::isEmpty() const
     422{
     423    QReadLocker locker(&m_lock);
     424
     425    return m_string.isEmpty();
     426}
     427
     428bool MString::isNull() const
     429{
     430    QReadLocker locker(&m_lock);
     431
     432    return m_string.isNull();
     433}
     434
     435int MString::lastIndexOf(const MString & str, int from, Qt::CaseSensitivity cs) const
     436{
     437    const QString other_qstring = str.toQString();
     438
     439    QReadLocker locker(&m_lock);
     440
     441    return m_string.lastIndexOf(other_qstring, from, cs);
     442}
     443
     444int MString::lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
     445{
     446    QReadLocker locker(&m_lock);
     447
     448    return m_string.lastIndexOf(ch, from, cs);
     449}
     450
     451int MString::lastIndexOf(const QRegExp & rx, int from) const
     452{
     453    QReadLocker locker(&m_lock);
     454
     455    return m_string.lastIndexOf(rx, from);
     456}
     457
     458MString MString::left(int n) const
     459{
     460    QReadLocker locker(&m_lock);
     461
     462    return MString(m_string.left(n));
     463}
     464
     465MString MString::leftJustified(int width, QChar fill, bool truncate) const
     466{
     467    QReadLocker locker(&m_lock);
     468
     469    return MString(m_string.leftJustified(width, fill, truncate));
     470}
     471
     472int MString::length() const
     473{
     474    QReadLocker locker(&m_lock);
     475
     476    return m_string.length();
     477}
     478
     479int MString::localeAwareCompare(const MString & other) const
     480{
     481    const QString other_qstring = other.toQString();
     482
     483    QReadLocker locker(&m_lock);
     484
     485    return m_string.localeAwareCompare(other_qstring);
     486}
     487
     488MString MString::mid(int position, int n) const
     489{
     490    QReadLocker locker(&m_lock);
     491
     492    return MString(m_string.mid(position, n));
     493}
     494
     495MString MString::normalized(QString::NormalizationForm mode) const
     496{
     497    QReadLocker locker(&m_lock);
     498
     499    return MString(m_string.normalized(mode));
     500}
     501
     502MString MString::normalized(QString::NormalizationForm mode,
     503                                QChar::UnicodeVersion version) const
     504{
     505    QReadLocker locker(&m_lock);
     506
     507    return MString(m_string.normalized(mode, version));
     508}
     509
     510MString & MString::prepend(const MString & str)
     511{
     512    const QString other_qstring = str.toQString();
     513
     514    QWriteLocker locker(&m_lock);
     515
     516    m_string.prepend(other_qstring);
     517    return *this;
     518}
     519
     520MString & MString::prepend(const QLatin1String & str)
     521{
     522    QWriteLocker locker(&m_lock);
     523
     524    m_string.prepend(str);
     525    return *this;
     526}
     527
     528MString & MString::prepend(const QByteArray & ba)
     529{
     530    QWriteLocker locker(&m_lock);
     531
     532    m_string.prepend(ba);
     533    return *this;
     534}
     535
     536MString & MString::prepend(const char * str)
     537{
     538    QWriteLocker locker(&m_lock);
     539
     540    m_string.prepend(str);
     541    return *this;
     542}
     543
     544MString & MString::prepend(QChar ch)
     545{
     546    QWriteLocker locker(&m_lock);
     547
     548    m_string.prepend(ch);
     549    return *this;
     550}
     551
     552MString & MString::remove(int position, int n)
     553{
     554    QWriteLocker locker(&m_lock);
     555
     556    m_string.remove(position, n);
     557    return *this;
     558}
     559
     560MString & MString::remove(const MString & str, Qt::CaseSensitivity cs)
     561{
     562    const QString other_qstring = str.toQString();
     563
     564    QWriteLocker locker(&m_lock);
     565    m_string.remove(other_qstring, cs);
     566    return *this;
     567}
     568
     569MString & MString::remove(QChar ch, Qt::CaseSensitivity cs)
     570{
     571    QWriteLocker locker(&m_lock);
     572
     573    m_string.remove(ch, cs);
     574    return *this;
     575}
     576
     577MString & MString::remove(const QRegExp & rx)
     578{
     579    QWriteLocker locker(&m_lock);
     580
     581    m_string.remove(rx);
     582    return *this;
     583}
     584
     585MString & MString::replace(int position, int n, const MString & after)
     586{
     587    const QString other_qstring = after.toQString();
     588
     589    QWriteLocker locker(&m_lock);
     590    m_string.replace(position, n, other_qstring);
     591    return *this;
     592}
     593
     594MString & MString::replace(int position, int n, const QChar * unicode, int size)
     595{
     596    QWriteLocker locker(&m_lock);
     597
     598    m_string.replace(position, n, unicode, size);
     599    return *this;
     600}
     601
     602MString & MString::replace(int position, int n, QChar after)
     603{
     604    QWriteLocker locker(&m_lock);
     605
     606    m_string.replace(position, n, after);
     607    return *this;
     608}
     609
     610MString & MString::replace(const MString & before, const MString & after,
     611                            Qt::CaseSensitivity cs)
     612{
     613    const QString before_qstring = before.toQString();
     614    const QString after_qstring = after.toQString();
     615
     616    QWriteLocker locker(&m_lock);
     617
     618    m_string.replace(before_qstring, after_qstring, cs);
     619    return *this;
     620}
     621
     622MString & MString::replace(QChar ch, const MString & after, Qt::CaseSensitivity cs)
     623{
     624    const QString after_qstring = after.toQString();
     625
     626    QWriteLocker locker(&m_lock);
     627
     628    m_string.replace(ch, after_qstring, cs);
     629    return *this;
     630}
     631
     632MString & MString::replace(QChar before, QChar after, Qt::CaseSensitivity cs)
     633{
     634    QWriteLocker locker(&m_lock);
     635
     636    m_string.replace(before, after, cs);
     637    return *this;
     638}
     639
     640MString & MString::replace(const QRegExp & rx, const MString & after)
     641{
     642    const QString after_qstring = after.toQString();
     643
     644    QWriteLocker locker(&m_lock);
     645
     646    m_string.replace(rx, after_qstring);
     647    return *this;
     648}
     649
     650void MString::reserve(int size)
     651{
     652    QWriteLocker locker(&m_lock);
     653
     654    m_string.reserve(size);
     655}
     656
     657void MString::resize(int size)
     658{
     659    QWriteLocker locker(&m_lock);
     660
     661    m_string.resize(size);
     662}
     663
     664MString MString::right(int n) const
     665{
     666    QReadLocker locker(&m_lock);
     667
     668    return MString(m_string.right(n));
     669}
     670
     671MString MString::rightJustified(int width, QChar fill, bool truncate) const
     672{
     673    QReadLocker locker(&m_lock);
     674
     675    return MString(m_string.rightJustified(width, fill, truncate));
     676}
     677
     678MString MString::section(QChar sep, int start, int end, SectionFlags flags) const
     679{
     680    int qflag_int = flags;
     681    QString::SectionFlags qflags(qflag_int);
     682    QReadLocker locker(&m_lock);
     683
     684    return MString(m_string.section(sep, start, end, qflags));
     685}
     686
     687MString MString::section(const MString & sep, int start, int end,
     688                            SectionFlags flags) const
     689{
     690    const QString sep_qstring = sep.toQString();
     691    int qflag_int = flags;
     692    QString::SectionFlags qflags(qflag_int);
     693
     694    QReadLocker locker(&m_lock);
     695    return MString(m_string.section(sep_qstring, start, end, qflags));
     696}
     697
     698MString MString::section(const QRegExp & reg, int start, int end,
     699                            SectionFlags flags) const
     700{
     701    int qflag_int = flags;
     702    QString::SectionFlags qflags(qflag_int);
     703    QReadLocker locker(&m_lock);
     704
     705    return MString(m_string.section(reg, start, end, qflags));
     706}
     707
     708MString & MString::setNum(uint n, int base)
     709{
     710    QWriteLocker locker(&m_lock);
     711
     712    m_string.setNum(n, base);
     713    return *this;
     714}
     715
     716MString & MString::setNum(long n, int base)
     717{
     718    QWriteLocker locker(&m_lock);
     719
     720    m_string.setNum(n, base);
     721    return *this;
     722}
     723
     724MString & MString::setNum(ulong n, int base)
     725{
     726    QWriteLocker locker(&m_lock);
     727
     728    m_string.setNum(n, base);
     729    return *this;
     730}
     731
     732MString & MString::setNum(qlonglong n, int base)
     733{
     734    QWriteLocker locker(&m_lock);
     735
     736    m_string.setNum(n, base);
     737    return *this;
     738}
     739
     740MString & MString::setNum(qulonglong n, int base)
     741{
     742    QWriteLocker locker(&m_lock);
     743
     744    m_string.setNum(n, base);
     745    return *this;
     746}
     747
     748MString & MString::setNum(short n, int base)
     749{
     750    QWriteLocker locker(&m_lock);
     751
     752    m_string.setNum(n, base);
     753    return *this;
     754}
     755
     756MString & MString::setNum(ushort n, int base)
     757{
     758    QWriteLocker locker(&m_lock);
     759
     760    m_string.setNum(n, base);
     761    return *this;
     762}
     763
     764MString & MString::setNum(double n, char format, int precision)
     765{
     766    QWriteLocker locker(&m_lock);
     767
     768    m_string.setNum(n, format, precision);
     769    return *this;
     770}
     771
     772MString & MString::setNum(float n, char format, int precision)
     773{
     774    QWriteLocker locker(&m_lock);
     775
     776    m_string.setNum(n, format, precision);
     777    return *this;
     778}
     779
     780MString & MString::setUnicode(const QChar * unicode, int size)
     781{
     782    QWriteLocker locker(&m_lock);
     783
     784    m_string.setUnicode(unicode, size);
     785    return *this;
     786}
     787
     788MString & MString::setUtf16(const ushort * unicode, int size)
     789{
     790    QWriteLocker locker(&m_lock);
     791
     792    m_string.setUtf16(unicode, size);
     793    return *this;
     794}
     795
     796MString MString::simplified() const
     797{
     798    QReadLocker locker(&m_lock);
     799
     800    return MString(m_string.simplified());
     801}
     802
     803int MString::size() const
     804{
     805    QReadLocker locker(&m_lock);
     806
     807    return m_string.size();
     808}
     809
     810QStringList MString::split(const MString & sep, SplitBehavior behavior,
     811                            Qt::CaseSensitivity cs) const
     812{
     813    const QString sep_qstring = sep.toQString();
     814
     815    QReadLocker locker(&m_lock);
     816    return m_string.split(sep_qstring, (QString::SplitBehavior)behavior, cs);
     817}
     818
     819QStringList MString::split(const QChar & sep, SplitBehavior behavior,
     820                            Qt::CaseSensitivity cs) const
     821{
     822    QReadLocker locker(&m_lock);
     823
     824    return m_string.split(sep, (QString::SplitBehavior)behavior, cs);
     825}
     826
     827QStringList MString::split(const QRegExp & rx, SplitBehavior behavior) const
     828{
     829    QReadLocker locker(&m_lock);
     830
     831    return m_string.split(rx, (QString::SplitBehavior)behavior);
     832}
     833
     834void MString::squeeze()
     835{
     836    QWriteLocker locker(&m_lock);
     837
     838    m_string.squeeze();
     839}
     840
     841bool MString::startsWith(const MString & s, Qt::CaseSensitivity cs) const
     842{
     843    const QString other_qstring = s.toQString();
     844
     845    QReadLocker locker(&m_lock);
     846
     847    return m_string.startsWith(other_qstring, cs);
     848}
     849
     850bool MString::startsWith(const QLatin1String & s, Qt::CaseSensitivity cs) const
     851{
     852    QReadLocker locker(&m_lock);
     853
     854    return m_string.startsWith(s, cs);
     855}
     856
     857bool MString::startsWith(const QChar & c, Qt::CaseSensitivity cs) const
     858{
     859    QReadLocker locker(&m_lock);
     860
     861    return m_string.startsWith(c, cs);
     862}
     863
     864QByteArray MString::toAscii() const
     865{
     866    QReadLocker locker(&m_lock);
     867
     868    return m_string.toAscii();
     869}
     870
     871MString MString::toCaseFolded() const
     872{
     873    QReadLocker locker(&m_lock);
     874
     875    return m_string.toCaseFolded();
     876}
     877
     878double MString::toDouble(bool * ok) const
     879{
     880    QReadLocker locker(&m_lock);
     881
     882    return m_string.toDouble(ok);
     883}
     884
     885float MString::toFloat(bool * ok) const
     886{
     887    QReadLocker locker(&m_lock);
     888
     889    return m_string.toFloat(ok);
     890}
     891
     892int MString::toInt(bool * ok, int base) const
     893{
     894    QReadLocker locker(&m_lock);
     895
     896    return m_string.toInt(ok, base);
     897}
     898
     899QByteArray MString::toLatin1() const
     900{
     901    QReadLocker locker(&m_lock);
     902
     903    return m_string.toLatin1();
     904}
     905
     906QByteArray MString::toLocal8Bit() const
     907{
     908    QReadLocker locker(&m_lock);
     909
     910    return m_string.toLocal8Bit();
     911}
     912
     913long MString::toLong(bool * ok, int base) const
     914{
     915    QReadLocker locker(&m_lock);
     916
     917    return m_string.toLong(ok, base);
     918}
     919
     920qlonglong MString::toLongLong(bool * ok, int base) const
     921{
     922    QReadLocker locker(&m_lock);
     923
     924    return m_string.toLongLong(ok, base);
     925}
     926
     927MString MString::toLower() const
     928{
     929    QReadLocker locker(&m_lock);
     930
     931    return m_string.toLower();
     932}
     933
     934QString MString::toQString() const
     935{
     936    QReadLocker locker(&m_lock);
     937
     938    return QString(m_string);
     939}
     940
     941short MString::toShort(bool * ok, int base) const
     942{
     943    QReadLocker locker(&m_lock);
     944
     945    return m_string.toShort(ok, base);
     946}
     947
     948std::string MString::toStdString() const
     949{
     950    QReadLocker locker(&m_lock);
     951
     952    return m_string.toStdString();
     953}
     954
     955std::wstring MString::toStdWString() const
     956{
     957    QReadLocker locker(&m_lock);
     958
     959    return m_string.toStdWString();
     960}
     961
     962uint MString::toUInt(bool * ok, int base) const
     963{
     964    QReadLocker locker(&m_lock);
     965
     966    return m_string.toUInt(ok, base);
     967}
     968
     969ulong MString::toULong(bool * ok, int base) const
     970{
     971    QReadLocker locker(&m_lock);
     972
     973    return m_string.toULong(ok, base);
     974}
     975
     976qulonglong MString::toULongLong(bool * ok, int base) const
     977{
     978    QReadLocker locker(&m_lock);
     979
     980    return m_string.toULongLong(ok, base);
     981}
     982
     983ushort MString::toUShort(bool * ok, int base) const
     984{
     985    QReadLocker locker(&m_lock);
     986
     987    return m_string.toUShort(ok, base);
     988}
     989
     990QVector<uint> MString::toUcs4() const
     991{
     992    QReadLocker locker(&m_lock);
     993
     994    return m_string.toUcs4();
     995}
     996
     997MString MString::toUpper() const
     998{
     999    QReadLocker locker(&m_lock);
     1000
     1001    return m_string.toUpper();
     1002}
     1003
     1004QByteArray MString::toUtf8() const
     1005{
     1006    QReadLocker locker(&m_lock);
     1007
     1008    return m_string.toUtf8();
     1009}
     1010
     1011int MString::toWCharArray(wchar_t * array) const
     1012{
     1013    QReadLocker locker(&m_lock);
     1014
     1015    return m_string.toWCharArray(array);
     1016}
     1017
     1018MString MString::trimmed() const
     1019{
     1020    QReadLocker locker(&m_lock);
     1021
     1022    return MString(m_string.trimmed());
     1023}
     1024
     1025void MString::truncate(int position)
     1026{
     1027    QWriteLocker locker(&m_lock);
     1028
     1029    m_string.truncate(position);
     1030}
     1031
     1032const QChar * MString::unicode() const
     1033{
     1034    QReadLocker locker(&m_lock);
     1035
     1036    return m_string.unicode();
     1037}
     1038
     1039MString & MString::vsprintf(const char * cformat, va_list ap)
     1040{
     1041    QWriteLocker locker(&m_lock);
     1042
     1043    m_string.vsprintf(cformat, ap);
     1044    return *this;
     1045}
     1046
     1047bool MString::operator< (const MString & other) const
     1048{
     1049    const QString other_qstring = other.toQString();
     1050
     1051    QReadLocker locker(&m_lock);
     1052
     1053    return (m_string < other_qstring);
     1054}
     1055
     1056bool MString::operator< (const QLatin1String & other) const
     1057{
     1058    QReadLocker locker(&m_lock);
     1059
     1060    return (m_string < other);
     1061}
     1062
     1063bool MString::operator< (const QByteArray & other) const
     1064{
     1065    QReadLocker locker(&m_lock);
     1066
     1067    return (m_string < other);
     1068}
     1069
     1070bool MString::operator< (const char * other) const
     1071{
     1072    QReadLocker locker(&m_lock);
     1073
     1074    return (m_string < other);
     1075}
     1076
     1077bool MString::operator<= (const MString & other) const
     1078{
     1079    const QString other_qstring = other.toQString();
     1080
     1081    QReadLocker locker(&m_lock);
     1082
     1083    return (m_string <= other_qstring);
     1084}
     1085
     1086bool MString::operator<= (const QLatin1String & other) const
     1087{
     1088    QReadLocker locker(&m_lock);
     1089
     1090    return (m_string <= other);
     1091}
     1092
     1093bool MString::operator<= (const QByteArray & other) const
     1094{
     1095    QReadLocker locker(&m_lock);
     1096
     1097    return (m_string <= other);
     1098}
     1099
     1100bool MString::operator<= (const char * other) const
     1101{
     1102    QReadLocker locker(&m_lock);
     1103
     1104    return (m_string <= other);
     1105}
     1106
     1107MString & MString::operator= (const MString & other)
     1108{
     1109    if (this == &other)
     1110    {
     1111        return *this; //skip self-assignment
     1112    }
     1113    const QString other_qstring = other.toQString();
     1114
     1115    QWriteLocker locker(&m_lock);
     1116
     1117    m_string = other_qstring;
     1118    return *this;
     1119}
     1120
     1121MString & MString::operator= (const QLatin1String & str)
     1122{
     1123    QWriteLocker locker(&m_lock);
     1124
     1125    m_string = str;
     1126    return *this;
     1127}
     1128
     1129MString & MString::operator= (const QByteArray & ba)
     1130{
     1131    QWriteLocker locker(&m_lock);
     1132
     1133    m_string = ba;
     1134    return *this;
     1135}
     1136
     1137MString & MString::operator= (const char * str)
     1138{
     1139    QWriteLocker locker(&m_lock);
     1140
     1141    m_string = str;
     1142    return *this;
     1143}
     1144
     1145MString & MString::operator= (char ch)
     1146{
     1147    QWriteLocker locker(&m_lock);
     1148
     1149    m_string = ch;
     1150    return *this;
     1151}
     1152
     1153MString & MString::operator= (QChar ch)
     1154{
     1155    QWriteLocker locker(&m_lock);
     1156
     1157    m_string = ch;
     1158    return *this;
     1159}
     1160
     1161bool MString::operator== (const MString & other) const
     1162{
     1163    const QString other_qstring = other.toQString();
     1164
     1165    QReadLocker locker(&m_lock);
     1166
     1167    return (m_string == other_qstring);
     1168}
     1169
     1170
     1171bool MString::operator== (const QLatin1String & other) const
     1172{
     1173    QReadLocker locker(&m_lock);
     1174
     1175    return (m_string == other);
     1176}
     1177
     1178
     1179bool MString::operator== (const QByteArray & other) const
     1180{
     1181    QReadLocker locker(&m_lock);
     1182
     1183    return (m_string == other);
     1184}
     1185
     1186bool MString::operator== (const char * other) const
     1187{
     1188    QReadLocker locker(&m_lock);
     1189
     1190    return (m_string == other);
     1191}
     1192
     1193const QChar MString::operator[](int position) const
     1194{
     1195    QReadLocker locker(&m_lock);
     1196
     1197    return m_string[position];
     1198}
     1199
     1200const QChar MString::operator[](uint position) const
     1201{
     1202    QReadLocker locker(&m_lock);
     1203
     1204    return m_string[position];
     1205}
     1206
     1207QDataStream & operator<< (QDataStream & stream, const MString & string)
     1208{
     1209    QReadLocker locker(&(string.m_lock));
     1210
     1211    stream << string.m_string;
     1212    return stream;
     1213}
     1214
     1215QDataStream & operator>> (QDataStream & stream, MString & string)
     1216{
     1217    QWriteLocker locker(&(string.m_lock));
     1218
     1219    stream >> string.m_string;
     1220    return stream;
     1221}
     1222
     1223/* vim: set expandtab tabstop=4 shiftwidth=4: */