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

bool QString::endsWith ( const QString s,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
) const

Returns true if the string ends with s; otherwise returns false.

If cs is Qt::CaseSensitive (the default), the search is case sensitive; otherwise the search is case insensitive.

snippets/qstring/main.cpp Widget::endsWithFunction QString str str.endsWith("pple")

See also:
startsWith()

Definition at line 2862 of file qstring.cpp.

References d, and length().

Referenced by QDir::absoluteFilePath(), QDir::cleanPath(), QFSFileEngine::fileName(), Q3ListView::findItem(), Q3IconView::findItem(), Q3ListBox::findItem(), QDateTime::fromString(), QDirModel::index(), QLibrary::isLibrary(), QDBusUtil::isValidObjectPath(), QAbstractItemModel::match(), QSqlDriver::sqlStatement(), and QSqlError::text().

{
    if (d == &shared_null)
        return (s.d == &shared_null);
    if (d->size == 0)
        return s.d->size == 0;
    int pos = d->size - s.d->size;
    if (pos < 0)
        return false;
    if (cs == Qt::CaseSensitive) {
        return memcmp((char*)&d->data[pos], (char*)s.d->data, s.d->size*sizeof(QChar)) == 0;
    } else {
        for (int i = 0; i < s.length(); i++)
            if (QUnicodeTables::lower(d->data[pos+i]) != QUnicodeTables::lower(s.d->data[i]))
                return false;
    }
    return true;
}


Generated by  Doxygen 1.6.0   Back to index