1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/include/qbitarray.h:1 -->
|
---|
3 | <html>
|
---|
4 | <head>
|
---|
5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
6 | <title>qbitarray.h Include File</title>
|
---|
7 | <style type="text/css"><!--
|
---|
8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
9 | a:link { color: #004faf; text-decoration: none }
|
---|
10 | a:visited { color: #672967; text-decoration: none }
|
---|
11 | body { background: #ffffff; color: black; }
|
---|
12 | --></style>
|
---|
13 | </head>
|
---|
14 | <body>
|
---|
15 |
|
---|
16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
17 | <tr bgcolor="#E5E5E5">
|
---|
18 | <td valign=center>
|
---|
19 | <a href="index.html">
|
---|
20 | <font color="#004faf">Home</font></a>
|
---|
21 | | <a href="classes.html">
|
---|
22 | <font color="#004faf">All Classes</font></a>
|
---|
23 | | <a href="mainclasses.html">
|
---|
24 | <font color="#004faf">Main Classes</font></a>
|
---|
25 | | <a href="annotated.html">
|
---|
26 | <font color="#004faf">Annotated</font></a>
|
---|
27 | | <a href="groups.html">
|
---|
28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
29 | | <a href="functions.html">
|
---|
30 | <font color="#004faf">Functions</font></a>
|
---|
31 | </td>
|
---|
32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>qbitarray.h</h1>
|
---|
33 |
|
---|
34 | <p>This is the verbatim text of the qbitarray.h include file. It is provided only for illustration; the copyright remains with Trolltech.
|
---|
35 | <hr>
|
---|
36 | <pre>
|
---|
37 | /****************************************************************************
|
---|
38 | ** $Id: qbitarray-h.html 2051 2007-02-21 10:04:20Z chehrlic $
|
---|
39 | **
|
---|
40 | ** Definition of QBitArray class
|
---|
41 | **
|
---|
42 | ** Created : 940118
|
---|
43 | **
|
---|
44 | ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
|
---|
45 | **
|
---|
46 | ** This file is part of the tools module of the Qt GUI Toolkit.
|
---|
47 | **
|
---|
48 | ** This file may be distributed under the terms of the Q Public License
|
---|
49 | ** as defined by Trolltech ASA of Norway and appearing in the file
|
---|
50 | ** LICENSE.QPL included in the packaging of this file.
|
---|
51 | **
|
---|
52 | ** This file may be distributed and/or modified under the terms of the
|
---|
53 | ** GNU General Public License version 2 as published by the Free Software
|
---|
54 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
55 | ** packaging of this file.
|
---|
56 | **
|
---|
57 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
|
---|
58 | ** licenses may use this file in accordance with the Qt Commercial License
|
---|
59 | ** Agreement provided with the Software.
|
---|
60 | **
|
---|
61 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
---|
62 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
---|
63 | **
|
---|
64 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
---|
65 | ** information about Qt Commercial License Agreements.
|
---|
66 | ** See http://www.trolltech.com/qpl/ for QPL licensing information.
|
---|
67 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
---|
68 | **
|
---|
69 | ** Contact info@trolltech.com if any conditions of this licensing are
|
---|
70 | ** not clear to you.
|
---|
71 | **
|
---|
72 | **********************************************************************/
|
---|
73 |
|
---|
74 | #ifndef QBITARRAY_H
|
---|
75 | #define QBITARRAY_H
|
---|
76 |
|
---|
77 | #ifndef QT_H
|
---|
78 | #include "qstring.h"
|
---|
79 | #endif // QT_H
|
---|
80 |
|
---|
81 |
|
---|
82 | /*****************************************************************************
|
---|
83 | QBitVal class; a context class for QBitArray::operator[]
|
---|
84 | *****************************************************************************/
|
---|
85 |
|
---|
86 | class QBitArray;
|
---|
87 |
|
---|
88 | class Q_EXPORT QBitVal
|
---|
89 | {
|
---|
90 | private:
|
---|
91 | QBitArray *array;
|
---|
92 | uint index;
|
---|
93 | public:
|
---|
94 | QBitVal( QBitArray *a, uint i ) : array(a), index(i) {}
|
---|
95 | operator int();
|
---|
96 | QBitVal &operator=( const QBitVal &v );
|
---|
97 | QBitVal &operator=( bool v );
|
---|
98 | };
|
---|
99 |
|
---|
100 |
|
---|
101 | /*****************************************************************************
|
---|
102 | QBitArray class
|
---|
103 | *****************************************************************************/
|
---|
104 |
|
---|
105 | class Q_EXPORT QBitArray : public QByteArray
|
---|
106 | {
|
---|
107 | public:
|
---|
108 | QBitArray();
|
---|
109 | QBitArray( uint size );
|
---|
110 | QBitArray( const QBitArray &a ) : QByteArray( a ) {}
|
---|
111 |
|
---|
112 | QBitArray &operator=( const QBitArray & );
|
---|
113 |
|
---|
114 | uint size() const;
|
---|
115 | bool resize( uint size );
|
---|
116 |
|
---|
117 | bool fill( bool v, int size = -1 );
|
---|
118 |
|
---|
119 | void detach();
|
---|
120 | QBitArray copy() const;
|
---|
121 |
|
---|
122 | bool testBit( uint index ) const;
|
---|
123 | void setBit( uint index );
|
---|
124 | void setBit( uint index, bool value );
|
---|
125 | void clearBit( uint index );
|
---|
126 | bool toggleBit( uint index );
|
---|
127 |
|
---|
128 | bool at( uint index ) const;
|
---|
129 | QBitVal operator[]( int index );
|
---|
130 | bool operator[]( int index ) const;
|
---|
131 |
|
---|
132 | QBitArray &operator&=( const QBitArray & );
|
---|
133 | QBitArray &operator|=( const QBitArray & );
|
---|
134 | QBitArray &operator^=( const QBitArray & );
|
---|
135 | QBitArray operator~() const;
|
---|
136 |
|
---|
137 | protected:
|
---|
138 | struct bitarr_data : public QGArray::array_data {
|
---|
139 | uint nbits;
|
---|
140 | };
|
---|
141 | array_data *newData() { return new bitarr_data; }
|
---|
142 | void deleteData( array_data *d ) { delete (bitarr_data*)d; }
|
---|
143 | private:
|
---|
144 | void pad0();
|
---|
145 | };
|
---|
146 |
|
---|
147 |
|
---|
148 | inline QBitArray &QBitArray::operator=( const QBitArray &a )
|
---|
149 | { return (QBitArray&)assign( a ); }
|
---|
150 |
|
---|
151 | inline uint QBitArray::size() const
|
---|
152 | { return ((bitarr_data*)sharedBlock())->nbits; }
|
---|
153 |
|
---|
154 | inline void QBitArray::setBit( uint index, bool value )
|
---|
155 | { if ( value ) setBit(index); else clearBit(index); }
|
---|
156 |
|
---|
157 | inline bool QBitArray::at( uint index ) const
|
---|
158 | { return testBit(index); }
|
---|
159 |
|
---|
160 | inline QBitVal QBitArray::operator[]( int index )
|
---|
161 | { return QBitVal( (QBitArray*)this, index ); }
|
---|
162 |
|
---|
163 | inline bool QBitArray::operator[]( int index ) const
|
---|
164 | { return testBit( index ); }
|
---|
165 |
|
---|
166 |
|
---|
167 | /*****************************************************************************
|
---|
168 | Misc. QBitArray operator functions
|
---|
169 | *****************************************************************************/
|
---|
170 |
|
---|
171 | Q_EXPORT QBitArray operator&( const QBitArray &, const QBitArray & );
|
---|
172 | Q_EXPORT QBitArray operator|( const QBitArray &, const QBitArray & );
|
---|
173 | Q_EXPORT QBitArray operator^( const QBitArray &, const QBitArray & );
|
---|
174 |
|
---|
175 |
|
---|
176 | inline QBitVal::operator int()
|
---|
177 | {
|
---|
178 | return array->testBit( index );
|
---|
179 | }
|
---|
180 |
|
---|
181 | inline QBitVal &QBitVal::operator=( const QBitVal &v )
|
---|
182 | {
|
---|
183 | array->setBit( index, v.array->testBit(v.index) );
|
---|
184 | return *this;
|
---|
185 | }
|
---|
186 |
|
---|
187 | inline QBitVal &QBitVal::operator=( bool v )
|
---|
188 | {
|
---|
189 | array->setBit( index, v );
|
---|
190 | return *this;
|
---|
191 | }
|
---|
192 |
|
---|
193 |
|
---|
194 | /*****************************************************************************
|
---|
195 | QBitArray stream functions
|
---|
196 | *****************************************************************************/
|
---|
197 | #ifndef QT_NO_DATASTREAM
|
---|
198 | Q_EXPORT QDataStream &operator<<( QDataStream &, const QBitArray & );
|
---|
199 | Q_EXPORT QDataStream &operator>>( QDataStream &, QBitArray & );
|
---|
200 | #endif
|
---|
201 |
|
---|
202 | #endif // QBITARRAY_H
|
---|
203 | </pre>
|
---|
204 | <!-- eof -->
|
---|
205 | <p><address><hr><div align=center>
|
---|
206 | <table width=100% cellspacing=0 border=0><tr>
|
---|
207 | <td>Copyright © 2007
|
---|
208 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
209 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
210 | </table></div></address></body>
|
---|
211 | </html>
|
---|