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