source: trunk/doc/html/qbitarray-h.html@ 190

Last change on this file since 190 was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 6.9 KB
Line 
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"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { 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&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;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&nbsp;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
86class QBitArray;
87
88class Q_EXPORT QBitVal
89{
90private:
91 QBitArray *array;
92 uint index;
93public:
94 QBitVal( QBitArray *a, uint i ) : array(a), index(i) {}
95 operator int();
96 QBitVal &amp;operator=( const QBitVal &amp;v );
97 QBitVal &amp;operator=( bool v );
98};
99
100
101/*****************************************************************************
102 QBitArray class
103 *****************************************************************************/
104
105class Q_EXPORT QBitArray : public QByteArray
106{
107public:
108 QBitArray();
109 QBitArray( uint size );
110 QBitArray( const QBitArray &amp;a ) : QByteArray( a ) {}
111
112 QBitArray &amp;operator=( const QBitArray &amp; );
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 &amp;operator&amp;=( const QBitArray &amp; );
133 QBitArray &amp;operator|=( const QBitArray &amp; );
134 QBitArray &amp;operator^=( const QBitArray &amp; );
135 QBitArray operator~() const;
136
137protected:
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; }
143private:
144 void pad0();
145};
146
147
148inline QBitArray &amp;QBitArray::operator=( const QBitArray &amp;a )
149{ return (QBitArray&amp;)assign( a ); }
150
151inline uint QBitArray::size() const
152{ return ((bitarr_data*)sharedBlock())-&gt;nbits; }
153
154inline void QBitArray::setBit( uint index, bool value )
155{ if ( value ) setBit(index); else clearBit(index); }
156
157inline bool QBitArray::at( uint index ) const
158{ return testBit(index); }
159
160inline QBitVal QBitArray::operator[]( int index )
161{ return QBitVal( (QBitArray*)this, index ); }
162
163inline bool QBitArray::operator[]( int index ) const
164{ return testBit( index ); }
165
166
167/*****************************************************************************
168 Misc. QBitArray operator functions
169 *****************************************************************************/
170
171Q_EXPORT QBitArray operator&amp;( const QBitArray &amp;, const QBitArray &amp; );
172Q_EXPORT QBitArray operator|( const QBitArray &amp;, const QBitArray &amp; );
173Q_EXPORT QBitArray operator^( const QBitArray &amp;, const QBitArray &amp; );
174
175
176inline QBitVal::operator int()
177{
178 return array-&gt;testBit( index );
179}
180
181inline QBitVal &amp;QBitVal::operator=( const QBitVal &amp;v )
182{
183 array-&gt;setBit( index, v.array-&gt;testBit(v.index) );
184 return *this;
185}
186
187inline QBitVal &amp;QBitVal::operator=( bool v )
188{
189 array-&gt;setBit( index, v );
190 return *this;
191}
192
193
194/*****************************************************************************
195 QBitArray stream functions
196 *****************************************************************************/
197#ifndef QT_NO_DATASTREAM
198Q_EXPORT QDataStream &amp;operator&lt;&lt;( QDataStream &amp;, const QBitArray &amp; );
199Q_EXPORT QDataStream &amp;operator&gt;&gt;( QDataStream &amp;, QBitArray &amp; );
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 &copy; 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>
Note: See TracBrowser for help on using the repository browser.