QBitArray Class Reference

QBitArray Class Reference

#include <qbitarray.h>

Class Description

Definition at line 54 of file qbitarray.h.

Public Types

typedef QByteArray::DataPtr DataPtr
 

Public Member Functions

 QBitArray ()
 
 QBitArray (int size, bool val=false)
 
 QBitArray (const QBitArray &other)
 
QBitArrayoperator= (const QBitArray &other)
 
void swap (QBitArray &other)
 
int size () const
 
int count () const
 
int count (bool on) const
 
bool isEmpty () const
 
bool isNull () const
 
void resize (int size)
 
void detach ()
 
bool isDetached () const
 
void clear ()
 
bool testBit (int i) const
 
void setBit (int i)
 
void setBit (int i, bool val)
 
void clearBit (int i)
 
bool toggleBit (int i)
 
bool at (int i) const
 
QBitRef operator[] (int i)
 
bool operator[] (int i) const
 
QBitRef operator[] (uint i)
 
bool operator[] (uint i) const
 
QBitArrayoperator&= (const QBitArray &)
 
QBitArrayoperator|= (const QBitArray &)
 
QBitArrayoperator^= (const QBitArray &)
 
QBitArray operator~ () const
 
bool operator== (const QBitArray &a) const
 
bool operator!= (const QBitArray &a) const
 
bool fill (bool val, int size=-1)
 
void fill (bool val, int first, int last)
 
void truncate (int pos)
 
DataPtrdata_ptr ()
 

Friends

Q_CORE_EXPORT QDataStreamoperator<< (QDataStream &, const QBitArray &)
 
Q_CORE_EXPORT QDataStreamoperator>> (QDataStream &, QBitArray &)
 
Q_CORE_EXPORT uint qHash (const QBitArray &key)
 

Member Typedef Documentation

Definition at line 113 of file qbitarray.h.

Constructor & Destructor Documentation

QBitArray ( )
inline

Definition at line 62 of file qbitarray.h.

62 {}
QBitArray ( int  size,
bool  val = false 
)
explicit
QBitArray ( const QBitArray other)
inline

Definition at line 64 of file qbitarray.h.

64 : d(other.d) {}

Member Function Documentation

QBitArray& operator= ( const QBitArray other)
inline

Definition at line 65 of file qbitarray.h.

65 { d = other.d; return *this; }
void swap ( QBitArray other)
inline

Definition at line 71 of file qbitarray.h.

71 { qSwap(d, other.d); }
Q_INLINE_TEMPLATE void qSwap(QScopedPointer< T, Cleanup > &p1, QScopedPointer< T, Cleanup > &p2)
int size ( ) const
inline

Definition at line 73 of file qbitarray.h.

73 { return (d.size() << 3) - *d.constData(); }
const char * constData() const
Definition: qbytearray.h:433
int size() const
Definition: qbytearray.h:402
int count ( ) const
inline

Definition at line 74 of file qbitarray.h.

74 { return (d.size() << 3) - *d.constData(); }
const char * constData() const
Definition: qbytearray.h:433
int size() const
Definition: qbytearray.h:402
int count ( bool  on) const
bool isEmpty ( ) const
inline

Definition at line 78 of file qbitarray.h.

78 { return d.isEmpty(); }
bool isEmpty() const
Definition: qbytearray.h:421
bool isNull ( ) const
inline

Definition at line 79 of file qbitarray.h.

79 { return d.isNull(); }
bool isNull() const
void resize ( int  size)
void detach ( )
inline

Definition at line 83 of file qbitarray.h.

83 { d.detach(); }
void detach()
Definition: qbytearray.h:435
bool isDetached ( ) const
inline

Definition at line 84 of file qbitarray.h.

84 { return d.isDetached(); }
bool isDetached() const
Definition: qbytearray.h:437
void clear ( )
inline

Definition at line 85 of file qbitarray.h.

85 { d.clear(); }
void clear()
bool testBit ( int  i) const
inline

Definition at line 124 of file qbitarray.h.

125 { Q_ASSERT(uint(i) < uint(size()));
126  return (*(reinterpret_cast<const uchar*>(d.constData())+1+(i>>3)) & (1 << (i & 7))) != 0; }
const char * constData() const
Definition: qbytearray.h:433
int size() const
Definition: qbitarray.h:73
void setBit ( int  i)
inline

Definition at line 128 of file qbitarray.h.

129 { Q_ASSERT(uint(i) < uint(size()));
130  *(reinterpret_cast<uchar*>(d.data())+1+(i>>3)) |= uchar(1 << (i & 7)); }
char * data()
Definition: qbytearray.h:429
int size() const
Definition: qbitarray.h:73
void setBit ( int  i,
bool  val 
)
inline

Definition at line 136 of file qbitarray.h.

137 { if (val) setBit(i); else clearBit(i); }
void setBit(int i)
Definition: qbitarray.h:128
void clearBit(int i)
Definition: qbitarray.h:132
void clearBit ( int  i)
inline

Definition at line 132 of file qbitarray.h.

133 { Q_ASSERT(uint(i) < uint(size()));
134  *(reinterpret_cast<uchar*>(d.data())+1+(i>>3)) &= ~uchar(1 << (i & 7)); }
char * data()
Definition: qbytearray.h:429
int size() const
Definition: qbitarray.h:73
bool toggleBit ( int  i)
inline

Definition at line 139 of file qbitarray.h.

140 { Q_ASSERT(uint(i) < uint(size()));
141  uchar b = uchar(1<<(i&7)); uchar* p = reinterpret_cast<uchar*>(d.data())+1+(i>>3);
142  uchar c = uchar(*p&b); *p^=b; return c!=0; }
char * data()
Definition: qbytearray.h:429
int size() const
Definition: qbitarray.h:73
GLubyte GLubyte b
Definition: GLee.h:5404
GLfloat GLfloat p
Definition: GLee.h:5416
const GLubyte * c
Definition: GLee.h:5419
bool at ( int  i) const
inline

Definition at line 146 of file qbitarray.h.

146 { return testBit(i); }
bool testBit(int i) const
Definition: qbitarray.h:124
QBitRef operator[] ( int  i)
inline

Definition at line 162 of file qbitarray.h.

163 { Q_ASSERT(i >= 0); return QBitRef(*this, i); }
bool operator[] ( int  i) const
inline

Definition at line 144 of file qbitarray.h.

144 { return testBit(i); }
bool testBit(int i) const
Definition: qbitarray.h:124
QBitRef operator[] ( uint  i)
inline

Definition at line 164 of file qbitarray.h.

165 { return QBitRef(*this, i); }
bool operator[] ( uint  i) const
inline

Definition at line 145 of file qbitarray.h.

145 { return testBit(i); }
bool testBit(int i) const
Definition: qbitarray.h:124
QBitArray& operator&= ( const QBitArray )
QBitArray& operator|= ( const QBitArray )
QBitArray& operator^= ( const QBitArray )
QBitArray operator~ ( ) const
bool operator== ( const QBitArray a) const
inline

Definition at line 104 of file qbitarray.h.

104 { return d == a.d; }
bool operator!= ( const QBitArray a) const
inline

Definition at line 105 of file qbitarray.h.

105 { return d != a.d; }
bool fill ( bool  val,
int  size = -1 
)
inline

Definition at line 117 of file qbitarray.h.

118 { *this = QBitArray((asize < 0 ? this->size() : asize), aval); return true; }
int size() const
Definition: qbitarray.h:73
QBitArray()
Definition: qbitarray.h:62
void fill ( bool  val,
int  first,
int  last 
)
void truncate ( int  pos)
inline

Definition at line 110 of file qbitarray.h.

110 { if (pos < size()) resize(pos); }
int size() const
Definition: qbitarray.h:73
void resize(int size)
DataPtr& data_ptr ( )
inline

Definition at line 114 of file qbitarray.h.

114 { return d.data_ptr(); }
DataPtr & data_ptr()
Definition: qbytearray.h:397

Friends And Related Function Documentation

Q_CORE_EXPORT QDataStream& operator<< ( QDataStream ,
const QBitArray  
)
friend
Q_CORE_EXPORT QDataStream& operator>> ( QDataStream ,
QBitArray  
)
friend
Q_CORE_EXPORT uint qHash ( const QBitArray key)
friend

The documentation for this class was generated from the following file: