Logo Search packages:      
Sourcecode: qt4-x11 version File versions

q3cstring.h

/****************************************************************************
**
** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
**
** This file is part of the Qt3Support module of the Qt Toolkit.
**
** This file may be used under the terms of the GNU General Public
** License version 2.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of
** this file.  Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
** http://www.trolltech.com/products/qt/opensource.html
**
** If you are unsure which license is appropriate for your use, please
** review the following information:
** http://www.trolltech.com/products/qt/licensing.html or contact the
** sales department at sales@trolltech.com.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/

#ifndef Q3CSTRING_H
#define Q3CSTRING_H

#include <QtCore/qbytearray.h>

QT_BEGIN_HEADER

QT_MODULE(Qt3SupportLight)

/*****************************************************************************
  QCString class
 *****************************************************************************/

class QRegExp;

00039 class Q_COMPAT_EXPORT Q3CString : public QByteArray
{
public:
00042     Q3CString() {}
00043     Q3CString(int size) : QByteArray(size, '\0') {}
00044     Q3CString(const Q3CString &s) : QByteArray(s) {}
00045     Q3CString(const QByteArray &ba) : QByteArray(ba) {}
00046     Q3CString(const char *str) : QByteArray(str) {}
00047     Q3CString(const char *str, uint maxlen) : QByteArray(str, qMin(qstrlen(str), maxlen - 1)) {}

00049     Q3CString    &operator=(const Q3CString &s) {
        QByteArray::operator=(s); return *this;
    }
00052     Q3CString    &operator=(const char *str) {
        QByteArray::operator=(str); return *this;
    }
00055     Q3CString    &operator=(const QByteArray &ba) {
        QByteArray::operator=(ba); return *this;
    }

00059     Q3CString        copy()        const { return *this; }
    Q3CString    &sprintf(const char *format, ...);

00062     Q3CString        left(uint len)  const { return QByteArray::left(len); }
00063     Q3CString        right(uint len) const { return QByteArray::right(len); }
00064     Q3CString        mid(uint index, uint len=0xffffffff) const { return QByteArray::mid(index, len); }

    Q3CString        leftJustify(uint width, char fill=' ', bool trunc=false)const;
    Q3CString        rightJustify(uint width, char fill=' ',bool trunc=false)const;

00069     Q3CString        lower() const { return QByteArray::toLower(); }
00070     Q3CString        upper() const { return QByteArray::toUpper(); }

00072     Q3CString        stripWhiteSpace()        const { return QByteArray::trimmed(); }
00073     Q3CString        simplifyWhiteSpace()        const { return QByteArray::simplified(); }

00075     Q3CString    &insert(uint index, const char *c) { QByteArray::insert(index, c); return *this; }
00076     Q3CString    &insert(uint index, char c) { QByteArray::insert(index, c); return *this; }
00077     Q3CString    &append(const char *c) { QByteArray::append(c); return *this; }
00078     Q3CString    &prepend(const char *c) { QByteArray::prepend(c); return *this; }
00079     Q3CString    &remove(uint index, uint len) { QByteArray::remove(index, len); return *this; }
00080     Q3CString    &replace(uint index, uint len, const char *c)
    { QByteArray::replace(index, len, c); return *this; }
00082     Q3CString    &replace(char c, const Q3CString &after) { return replace(c, after.constData()); }
00083     Q3CString    &replace(char c, const char *after) { QByteArray::replace(c, after); return *this; }
00084     Q3CString    &replace(const Q3CString &b, const Q3CString &a)
    { return replace(b.constData(), a.constData()); }
00086     Q3CString    &replace(const char *b, const char *a) { QByteArray::replace(b, a); return *this; }
00087     Q3CString    &replace(char b, char a) { QByteArray::replace(b, a); return *this; }

    short        toShort(bool *ok=0)        const;
    ushort        toUShort(bool *ok=0)        const;
    int                toInt(bool *ok=0)        const;
    uint        toUInt(bool *ok=0)        const;
    long        toLong(bool *ok=0)        const;
    ulong        toULong(bool *ok=0)        const;
    float        toFloat(bool *ok=0)        const;
    double        toDouble(bool *ok=0)        const;

00098     Q3CString    &setStr(const char *s) { *this = s; return *this; }
    Q3CString    &setNum(short);
    Q3CString    &setNum(ushort);
    Q3CString    &setNum(int);
    Q3CString    &setNum(uint);
    Q3CString    &setNum(long);
    Q3CString    &setNum(ulong);
    Q3CString    &setNum(float, char f='g', int prec=6);
    Q3CString    &setNum(double, char f='g', int prec=6);

    bool        setExpand(uint index, char c);

};


/*****************************************************************************
  Q3CString stream functions
 *****************************************************************************/
#ifndef QT_NO_DATASTREAM
00117 inline Q_COMPAT_EXPORT QDataStream &operator<<(QDataStream &d, const Q3CString &s) {
    return operator<<(d, static_cast<const QByteArray &>(s));
}
00120 inline Q_COMPAT_EXPORT QDataStream &operator>>(QDataStream &d, Q3CString &s) {
    return operator>>(d, static_cast<QByteArray &>(s));
}
#endif

/*****************************************************************************
  Q3CString inline functions
 *****************************************************************************/

00129 inline Q3CString &Q3CString::setNum(short n)
{ return setNum(long(n)); }

00132 inline Q3CString &Q3CString::setNum(ushort n)
{ return setNum(ulong(n)); }

00135 inline Q3CString &Q3CString::setNum(int n)
{ return setNum(long(n)); }

00138 inline Q3CString &Q3CString::setNum(uint n)
{ return setNum(ulong(n)); }

00141 inline Q3CString &Q3CString::setNum(float n, char f, int prec)
{ return setNum(double(n),f,prec); }

/*****************************************************************************
  Q3CString non-member operators
 *****************************************************************************/

00148 Q_COMPAT_EXPORT inline bool operator==(const Q3CString &s1, const Q3CString &s2)
{ return qstrcmp(s1, s2) == 0; }

00151 Q_COMPAT_EXPORT inline bool operator==(const Q3CString &s1, const char *s2)
{ return qstrcmp(s1, s2) == 0; }

00154 Q_COMPAT_EXPORT inline bool operator==(const char *s1, const Q3CString &s2)
{ return qstrcmp(s1, s2) == 0; }

00157 Q_COMPAT_EXPORT inline bool operator!=(const Q3CString &s1, const Q3CString &s2)
{ return qstrcmp(s1, s2) != 0; }

00160 Q_COMPAT_EXPORT inline bool operator!=(const Q3CString &s1, const char *s2)
{ return qstrcmp(s1, s2) != 0; }

00163 Q_COMPAT_EXPORT inline bool operator!=(const char *s1, const Q3CString &s2)
{ return qstrcmp(s1, s2) != 0; }

Q_COMPAT_EXPORT inline bool operator<(const Q3CString &s1, const Q3CString& s2)
{ return qstrcmp(s1, s2) < 0; }

00169 Q_COMPAT_EXPORT inline bool operator<(const Q3CString &s1, const char *s2)
{ return qstrcmp(s1, s2) < 0; }

00172 Q_COMPAT_EXPORT inline bool operator<(const char *s1, const Q3CString &s2)
{ return qstrcmp(s1, s2) < 0; }

Q_COMPAT_EXPORT inline bool operator<=(const Q3CString &s1, const Q3CString &s2)
{ return qstrcmp(s1, s2) <= 0; }

00178 Q_COMPAT_EXPORT inline bool operator<=(const Q3CString &s1, const char *s2)
{ return qstrcmp(s1, s2) <= 0; }

00181 Q_COMPAT_EXPORT inline bool operator<=(const char *s1, const Q3CString &s2)
{ return qstrcmp(s1, s2) <= 0; }

Q_COMPAT_EXPORT inline bool operator>(const Q3CString &s1, const Q3CString &s2)
{ return qstrcmp(s1, s2) > 0; }

00187 Q_COMPAT_EXPORT inline bool operator>(const Q3CString &s1, const char *s2)
{ return qstrcmp(s1, s2) > 0; }

00190 Q_COMPAT_EXPORT inline bool operator>(const char *s1, const Q3CString &s2)
{ return qstrcmp(s1, s2) > 0; }

Q_COMPAT_EXPORT inline bool operator>=(const Q3CString &s1, const Q3CString& s2)
{ return qstrcmp(s1, s2) >= 0; }

00196 Q_COMPAT_EXPORT inline bool operator>=(const Q3CString &s1, const char *s2)
{ return qstrcmp(s1, s2) >= 0; }

00199 Q_COMPAT_EXPORT inline bool operator>=(const char *s1, const Q3CString &s2)
{ return qstrcmp(s1, s2) >= 0; }

00202 Q_COMPAT_EXPORT inline const Q3CString operator+(const Q3CString &s1,
                                          const Q3CString &s2)
{
    Q3CString tmp(s1);
    tmp += s2;
    return tmp;
}
Q_COMPAT_EXPORT inline const Q3CString operator+(const Q3CString &s1,
                                          const QByteArray &s2)
{
    QByteArray tmp(s1);
    tmp += s2;
    return tmp;
}
Q_COMPAT_EXPORT inline const Q3CString operator+(const QByteArray &s1,
                                          const Q3CString &s2)
{
    QByteArray tmp(s1);
    tmp += s2;
    return tmp;
}

00224 Q_COMPAT_EXPORT inline const Q3CString operator+(const Q3CString &s1, const char *s2)
{
    Q3CString tmp(s1);
    tmp += s2;
    return tmp;
}

00231 Q_COMPAT_EXPORT inline const Q3CString operator+(const char *s1, const Q3CString &s2)
{
    Q3CString tmp(s1);
    tmp += s2;
    return tmp;
}

00238 Q_COMPAT_EXPORT inline const Q3CString operator+(const Q3CString &s1, char c2)
{
    Q3CString tmp(s1);
    tmp += c2;
    return tmp;
}

00245 Q_COMPAT_EXPORT inline const Q3CString operator+(char c1, const Q3CString &s2)
{
    Q3CString tmp;
    tmp += c1;
    tmp += s2;
    return tmp;
}

QT_END_HEADER

#endif // Q3CSTRING_H

Generated by  Doxygen 1.6.0   Back to index