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