Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

qstrlist.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 ** $Id: qstrlist.h,v 1.2 2003/07/10 02:40:11 llornkcor Exp $
00003 **
00004 ** Definition of QStrList, QStrIList and QStrListIterator classes
00005 **
00006 ** Created : 920730
00007 **
00008 ** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
00009 **
00010 ** This file is part of the tools module of the Qt GUI Toolkit.
00011 **
00012 ** This file may be distributed under the terms of the Q Public License
00013 ** as defined by Trolltech AS of Norway and appearing in the file
00014 ** LICENSE.QPL included in the packaging of this file.
00015 **
00016 ** This file may be distributed and/or modified under the terms of the
00017 ** GNU General Public License version 2 as published by the Free Software
00018 ** Foundation and appearing in the file LICENSE.GPL included in the
00019 ** packaging of this file.
00020 **
00021 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
00022 ** licenses may use this file in accordance with the Qt Commercial License
00023 ** Agreement provided with the Software.
00024 **
00025 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00026 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00027 **
00028 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
00029 **   information about Qt Commercial License Agreements.
00030 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
00031 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00032 **
00033 ** Contact info@trolltech.com if any conditions of this licensing are
00034 ** not clear to you.
00035 **
00036 **********************************************************************/
00037 
00038 #ifndef QSTRLIST_H
00039 #define QSTRLIST_H
00040 
00041 #ifndef QT_H
00042 #include "qstring.h"
00043 #include "qptrlist.h"
00044 #include "qdatastream.h"
00045 #endif // QT_H
00046 
00047 
00048 #ifndef QT_QWINEXPORT
00049 #if defined(Q_TEMPLATEDLL)
00050 Q_TEMPLATE_EXTERN template class Q_EXPORT QPtrList<char>;
00051 Q_TEMPLATE_EXTERN template class Q_EXPORT QPtrListIterator<char>;
00052 #endif
00053 #endif /* QT_QWINEXPORT */
00054 
00055 #if defined(Q_QDOC)
00056 class QStrListIterator : public QPtrListIterator<char>
00057 {
00058 };
00059 #else
00060 typedef QPtrListIterator<char> QStrListIterator;
00061 #endif
00062 
00063 class Q_EXPORT QStrList : public QPtrList<char>
00064 {
00065 public:
00066     QStrList( bool deepCopies=TRUE ) { dc = deepCopies; del_item = deepCopies; }
00067     QStrList( const QStrList & );
00068     ~QStrList()                 { clear(); }
00069     QStrList& operator=( const QStrList & );
00070 
00071 private:
00072     QPtrCollection::Item newItem( QPtrCollection::Item d ) { return dc ? qstrdup( (const char*)d ) : d; }
00073     void deleteItem( QPtrCollection::Item d ) { if ( del_item ) delete[] (char*)d; }
00074     int compareItems( QPtrCollection::Item s1, QPtrCollection::Item s2 ) { return qstrcmp((const char*)s1,
00075                                                          (const char*)s2); }
00076 #ifndef QT_NO_DATASTREAM
00077     QDataStream &read( QDataStream &s, QPtrCollection::Item &d )
00078                                 { s >> (char *&)d; return s; }
00079     QDataStream &write( QDataStream &s, QPtrCollection::Item d ) const
00080                                 { return s << (const char *)d; }
00081 #endif
00082     bool  dc;
00083 };
00084 
00085 
00086 class Q_EXPORT QStrIList : public QStrList      // case insensitive string list
00087 {
00088 public:
00089     QStrIList( bool deepCopies=TRUE ) : QStrList( deepCopies ) {}
00090     ~QStrIList()                        { clear(); }
00091 private:
00092     int   compareItems( QPtrCollection::Item s1, QPtrCollection::Item s2 )
00093                                 { return qstricmp((const char*)s1,
00094                                                     (const char*)s2); }
00095 };
00096 
00097 
00098 inline QStrList & QStrList::operator=( const QStrList &strList )
00099 {
00100     clear();
00101     dc = strList.dc;
00102     del_item = dc;
00103     QPtrList<char>::operator=( strList );
00104     return *this;
00105 }
00106 
00107 inline QStrList::QStrList( const QStrList &strList )
00108     : QPtrList<char>( strList )
00109 {
00110     dc = FALSE;
00111     operator=( strList );
00112 }
00113 
00114 #endif // QSTRLIST_H

Generated on Sat Nov 5 16:18:26 2005 for OPIE by  doxygen 1.4.2