Blame qtools/qstrlist.h

Packit 1c1d7e
/****************************************************************************
Packit 1c1d7e
** 
Packit 1c1d7e
**
Packit 1c1d7e
** Definition of QStrList, QStrIList and QStrListIterator classes
Packit 1c1d7e
**
Packit 1c1d7e
** Created : 920730
Packit 1c1d7e
**
Packit 1c1d7e
** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
Packit 1c1d7e
**
Packit 1c1d7e
** This file is part of the tools module of the Qt GUI Toolkit.
Packit 1c1d7e
**
Packit 1c1d7e
** This file may be distributed under the terms of the Q Public License
Packit 1c1d7e
** as defined by Trolltech AS of Norway and appearing in the file
Packit 1c1d7e
** LICENSE.QPL included in the packaging of this file.
Packit 1c1d7e
**
Packit 1c1d7e
** This file may be distributed and/or modified under the terms of the
Packit 1c1d7e
** GNU General Public License version 2 as published by the Free Software
Packit 1c1d7e
** Foundation and appearing in the file LICENSE.GPL included in the
Packit 1c1d7e
** packaging of this file.
Packit 1c1d7e
**
Packit 1c1d7e
** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
Packit 1c1d7e
** licenses may use this file in accordance with the Qt Commercial License
Packit 1c1d7e
** Agreement provided with the Software.
Packit 1c1d7e
**
Packit 1c1d7e
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
Packit 1c1d7e
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
Packit 1c1d7e
**
Packit 1c1d7e
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
Packit 1c1d7e
**   information about Qt Commercial License Agreements.
Packit 1c1d7e
** See http://www.trolltech.com/qpl/ for QPL licensing information.
Packit 1c1d7e
** See http://www.trolltech.com/gpl/ for GPL licensing information.
Packit 1c1d7e
**
Packit 1c1d7e
** Contact info@trolltech.com if any conditions of this licensing are
Packit 1c1d7e
** not clear to you.
Packit 1c1d7e
**
Packit 1c1d7e
**********************************************************************/
Packit 1c1d7e
Packit 1c1d7e
#ifndef QSTRLIST_H
Packit 1c1d7e
#define QSTRLIST_H
Packit 1c1d7e
Packit 1c1d7e
#ifndef QT_H
Packit 1c1d7e
#include "qstring.h"
Packit 1c1d7e
#include "qinternallist.h"
Packit 1c1d7e
#include "qdatastream.h"
Packit 1c1d7e
#endif // QT_H
Packit 1c1d7e
Packit 1c1d7e
Packit 1c1d7e
#if defined(Q_TEMPLATEDLL)
Packit 1c1d7e
template class Q_EXPORT QInternalList<char>;
Packit 1c1d7e
template class Q_EXPORT QInternalListIterator<char>;
Packit 1c1d7e
#endif
Packit 1c1d7e
Packit 1c1d7e
typedef QInternalList<char>	QStrListBase;
Packit 1c1d7e
typedef QInternalListIterator<char>	QStrListIterator;
Packit 1c1d7e
Packit 1c1d7e
Packit 1c1d7e
class Q_EXPORT QStrList : public QStrListBase
Packit 1c1d7e
{
Packit 1c1d7e
public:
Packit 1c1d7e
    QStrList( bool deepCopies=TRUE ) { dc = deepCopies; del_item = deepCopies; }
Packit 1c1d7e
    QStrList( const QStrList & );
Packit 1c1d7e
   ~QStrList()			{ clear(); }
Packit 1c1d7e
    QStrList& operator=( const QStrList & );
Packit 1c1d7e
Packit 1c1d7e
private:
Packit 1c1d7e
    QCollection::Item newItem( QCollection::Item d ) { return dc ? qstrdup( (const char*)d ) : d; }
Packit 1c1d7e
    void deleteItem( QCollection::Item d ) { if ( del_item ) delete[] (char*)d; }
Packit 1c1d7e
    int compareItems( QCollection::Item s1, QCollection::Item s2 ) { return qstrcmp((const char*)s1,
Packit 1c1d7e
							 (const char*)s2); }
Packit 1c1d7e
#ifndef QT_NO_DATASTREAM
Packit 1c1d7e
    QDataStream &read( QDataStream &s, QCollection::Item &d )
Packit 1c1d7e
				{ s >> (char *&);; return s; }
Packit 1c1d7e
    QDataStream &write( QDataStream &s, QCollection::Item d ) const
Packit 1c1d7e
				{ return s << (const char *)d; }
Packit 1c1d7e
#endif
Packit 1c1d7e
    bool  dc;
Packit 1c1d7e
};
Packit 1c1d7e
Packit 1c1d7e
Packit 1c1d7e
class Q_EXPORT QStrIList : public QStrList	// case insensitive string list
Packit 1c1d7e
{
Packit 1c1d7e
public:
Packit 1c1d7e
    QStrIList( bool deepCopies=TRUE ) : QStrList( deepCopies ) {}
Packit 1c1d7e
   ~QStrIList()			{ clear(); }
Packit 1c1d7e
private:
Packit 1c1d7e
    int	  compareItems( QCollection::Item s1, QCollection::Item s2 )
Packit 1c1d7e
				{ return qstricmp((const char*)s1,
Packit 1c1d7e
						    (const char*)s2); }
Packit 1c1d7e
};
Packit 1c1d7e
Packit 1c1d7e
Packit 1c1d7e
inline QStrList & QStrList::operator=( const QStrList &strList )
Packit 1c1d7e
{
Packit 1c1d7e
    clear();
Packit 1c1d7e
    dc = strList.dc;
Packit 1c1d7e
    del_item = dc;
Packit 1c1d7e
    QStrListBase::operator=(strList);
Packit 1c1d7e
    return *this;
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
inline QStrList::QStrList( const QStrList &strList )
Packit 1c1d7e
    : QStrListBase( strList )
Packit 1c1d7e
{
Packit 1c1d7e
    dc = FALSE;
Packit 1c1d7e
    operator=(strList);
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
Packit 1c1d7e
#endif // QSTRLIST_H