Qt logo

qstrlist.h


This is the verbatim text of the qstrlist.h include file. It is is provided only for illustration; the copyright remains with Troll Tech.
/****************************************************************************
** $Id: qstrlist.h,v 2.12.2.3 1998/08/25 09:20:55 hanord Exp $
**
** Definition of QStrList, QStrIList and QStrListIterator classes
**
** Created : 920730
**
** Copyright (C) 1992-1998 Troll Tech AS.  All rights reserved.
**
** This file is part of Troll Tech's internal development tree for Qt.
**
** This header text will be replaced by an appropriate text by the
** mkdist script which generates external distributions.
**
** If you are using the Qt Professional Edition or the Qt Free Edition,
** please notify Troll Tech at <info@troll.no> if you see this text.
**
** To Troll Tech developers: This header was generated by the script
** fixcopyright-int. It has the same number of text lines as the free
** and professional editions to avoid line number inconsistency.
**
*****************************************************************************/

#ifndef QSTRLIST_H
#define QSTRLIST_H

#ifndef QT_H
#include "qstring.h"
#include "qlist.h"
#include "qdatastream.h"
#endif // QT_H


#if defined(DEFAULT_TEMPLATECLASS)
#if defined(Q_TEMPLATEDLL)
template class Q_EXPORT QList<char>;
template class Q_EXPORT QListIterator<char>;
#endif
typedef QList<char>                     QStrListBase;
typedef QListIterator<char>             QStrListIterator;
#else
typedef Q_DECLARE(QListM,char)          QStrListBase;
typedef Q_DECLARE(QListIteratorM,char)  QStrListIterator;
#endif


class Q_EXPORT QStrList : public QStrListBase
{
public:
    QStrList( bool deepCopies=TRUE ) { dc = deepCopies; }
    QStrList( const QStrList & );
   ~QStrList()                  { clear(); }
    QStrList& operator=( const QStrList & );

private:
    GCI   newItem( GCI d )      { return dc ? qstrdup( (const char*)d ) : d; }
    void  deleteItem( GCI d )   { if ( dc ) delete[] (char*)d; }
    int   compareItems( GCI s1, GCI s2 )
                                { return strcmp((const char*)s1,
                                                (const char*)s2); }
    QDataStream &read( QDataStream &s, GCI &d )
                                { s >> (char *&)d; return s; }
    QDataStream &write( QDataStream &s, GCI d ) const
                                { return s << (const char *)d; }
    bool  dc;
};


class Q_EXPORT QStrIList : public QStrList      // case insensitive string list
{
public:
    QStrIList( bool deepCopies=TRUE ) : QStrList( deepCopies ) {}
   ~QStrIList()                 { clear(); }
private:
    int   compareItems( GCI s1, GCI s2 )
                                { return stricmp((const char*)s1,
                                                 (const char*)s2); }
};


inline QStrList & QStrList::operator=( const QStrList &strList )
{
    clear();
    dc = strList.dc;
    QStrListBase::operator=(strList);
    return *this;
}

inline QStrList::QStrList( const QStrList &strList )
    : QStrListBase( strList )
{
    dc = FALSE;
    operator=(strList);
}


#endif // QSTRLIST_H


Copyright © 1998 Troll TechTrademarks
Qt version 1.41