summaryrefslogtreecommitdiffabout
path: root/qtcompat/qpair.h
Unidiff
Diffstat (limited to 'qtcompat/qpair.h') (more/less context) (ignore whitespace changes)
-rw-r--r--qtcompat/qpair.h96
1 files changed, 96 insertions, 0 deletions
diff --git a/qtcompat/qpair.h b/qtcompat/qpair.h
new file mode 100644
index 0000000..9518179
--- a/dev/null
+++ b/qtcompat/qpair.h
@@ -0,0 +1,96 @@
1/****************************************************************************
2**
3** Definition of QPair class
4**
5**
6** Copyright (C) 1992-2001 Trolltech AS. All rights reserved.
7**
8** This file is part of the tools module of the Qt GUI Toolkit.
9**
10** This file may be distributed under the terms of the Q Public License
11** as defined by Trolltech AS of Norway and appearing in the file
12** LICENSE.QPL included in the packaging of this file.
13**
14** This file may be distributed and/or modified under the terms of the
15** GNU General Public License version 2 as published by the Free Software
16** Foundation and appearing in the file LICENSE.GPL included in the
17** packaging of this file.
18**
19** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
20** licenses may use this file in accordance with the Qt Commercial License
21** Agreement provided with the Software.
22**
23** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
24** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
25**
26** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
27** information about Qt Commercial License Agreements.
28** See http://www.trolltech.com/qpl/ for QPL licensing information.
29** See http://www.trolltech.com/gpl/ for GPL licensing information.
30**
31** Contact info@trolltech.com if any conditions of this licensing are
32** not clear to you.
33**
34**********************************************************************/
35
36#ifndef QPAIR_H
37#define QPAIR_H
38
39#ifndef QT_H
40#include "qglobal.h"
41#include "qdatastream.h"
42#endif // QT_H
43
44template <class T1, class T2>
45struct QPair
46{
47 typedef T1 first_type;
48 typedef T2 second_type;
49
50 QPair()
51 : first( T1() ), second( T2() )
52 {}
53 QPair( const T1& t1, const T2& t2 )
54 : first( t1 ), second( t2 )
55 {}
56
57 T1 first;
58 T2 second;
59};
60
61template <class T1, class T2>
62inline bool operator==( const QPair<T1, T2>& x, const QPair<T1, T2>& y )
63{
64 return x.first == y.first && x.second == y.second;
65}
66
67template <class T1, class T2>
68inline bool operator<( const QPair<T1, T2>& x, const QPair<T1, T2>& y )
69{
70 return x.first < y.first ||
71 ( !( y.first < x.first ) && x.second < y.second );
72}
73
74template <class T1, class T2>
75inline QPair<T1, T2> qMakePair( const T1& x, const T2& y )
76{
77 return QPair<T1, T2>( x, y );
78}
79
80#ifndef QT_NO_DATASTREAM
81template <class T1, class T2>
82inline QDataStream& operator>>( QDataStream& s, QPair<T1, T2>& p )
83{
84 s >> p.first >> p.second;
85 return s;
86}
87
88template <class T1, class T2>
89inline QDataStream& operator<<( QDataStream& s, const QPair<T1, T2>& p )
90{
91 s << p.first << p.second;
92 return s;
93}
94#endif
95
96#endif