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

opair.h

Go to the documentation of this file.
00001 // QPair minus QT_INLINE_TEMPLATE (instead directly using 'inline' directive)
00002 //FIXME: remove and use qpair.h as soon as we're on Qt3
00003 // name file qpair -zecke
00004 
00005 /****************************************************************************
00006 **
00007 ** Definition of QPair class
00008 **
00009 **
00010 ** Copyright (C) 1992-2001 Trolltech AS.  All rights reserved.
00011 **
00012 ** This file is part of the tools module of the Qt GUI Toolkit.
00013 **
00014 ** This file may be distributed under the terms of the Q Public License
00015 ** as defined by Trolltech AS of Norway and appearing in the file
00016 ** LICENSE.QPL included in the packaging of this file.
00017 **
00018 ** This file may be distributed and/or modified under the terms of the
00019 ** GNU General Public License version 2 as published by the Free Software
00020 ** Foundation and appearing in the file LICENSE.GPL included in the
00021 ** packaging of this file.
00022 **
00023 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
00024 ** licenses may use this file in accordance with the Qt Commercial License
00025 ** Agreement provided with the Software.
00026 **
00027 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00028 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00029 **
00030 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
00031 **   information about Qt Commercial License Agreements.
00032 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
00033 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00034 **
00035 ** Contact info@trolltech.com if any conditions of this licensing are
00036 ** not clear to you.
00037 **
00038 **********************************************************************/
00039 
00040 #ifndef QPAIR_H
00041 #define QPAIR_H
00042 
00043 #ifndef QT_H
00044 #include "qglobal.h"
00045 #include "qdatastream.h"
00046 #endif // QT_H
00047 
00048 template <class T1, class T2>
00049 struct QPair
00050 {
00051     typedef T1 first_type;
00052     typedef T2 second_type;
00053 
00054     QPair()
00055         : first( T1() ), second( T2() )
00056     {}
00057     QPair( const T1& t1, const T2& t2 )
00058         : first( t1 ), second( t2 )
00059     {}
00060 
00061     T1 first;
00062     T2 second;
00063 };
00064 
00065 template <class T1, class T2>
00066 inline bool operator==( const QPair<T1, T2>& x, const QPair<T1, T2>& y )
00067 {
00068     return x.first == y.first && x.second == y.second;
00069 }
00070 
00071 template <class T1, class T2>
00072 inline bool operator<( const QPair<T1, T2>& x, const QPair<T1, T2>& y )
00073 {
00074     return x.first < y.first ||
00075            ( !( y.first < x.first ) && x.second < y.second );
00076 }
00077 
00078 template <class T1, class T2>
00079 inline QPair<T1, T2> qMakePair( const T1& x, const T2& y )
00080 {
00081     return QPair<T1, T2>( x, y );
00082 }
00083 
00084 #ifndef QT_NO_DATASTREAM
00085 template <class T1, class T2>
00086 inline QDataStream& operator>>( QDataStream& s, QPair<T1, T2>& p )
00087 {
00088     s >> p.first >> p.second;
00089     return s;
00090 }
00091 
00092 template <class T1, class T2>
00093 inline QDataStream& operator<<( QDataStream& s, const QPair<T1, T2>& p )
00094 {
00095     s << p.first << p.second;
00096     return s;
00097 }
00098 #endif
00099 
00100 #endif

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