- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- Class List
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Friends

# QBitArray Class Reference

Search for all occurrences

## Detailed Description

Definition at line 54 of file qbitarray.h.

`#include <qbitarray.h>`

List of all members.

## Public Types
typedef QByteArray::DataPtr | DataPtr
## Public Member Functions
| QBitArray ()
| QBitArray (int size, bool val=false)
| QBitArray (const QBitArray &other)
QBitArray & | operator= (const 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
QBitArray & | operator&= (const QBitArray &)
QBitArray & | operator|= (const QBitArray &)
QBitArray & | operator^= (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)
DataPtr & | data_ptr ()
## Friends
Q_CORE_EXPORT QDataStream & | operator<< (QDataStream &, const QBitArray &)
Q_CORE_EXPORT QDataStream & | operator>> (QDataStream &, QBitArray &)
Q_CORE_EXPORT uint | qHash (const QBitArray &key)

## Member Typedef Documentation

typedef QByteArray::DataPtr DataPtr

Search for all occurrences

Definition at line 107 of file qbitarray.h.

## Constructor & Destructor Documentation

QBitArray | ( |  | ) | `[inline]`

Definition at line 62 of file qbitarray.h.

    {}

QBitArray | ( | int | size,
|  | bool | val = `false`
| ) |  | `[explicit]`

QBitArray | ( | const QBitArray & | other | ) | `[inline]`

Definition at line 64 of file qbitarray.h.

    : d(other.d) {}

## Member Function Documentation

QBitArray& operator= | ( | const QBitArray & | other | ) | `[inline]`

Definition at line 65 of file qbitarray.h.

    { d = other.d; return *this; }

int size | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 67 of file qbitarray.h.

    { return (d.size() << 3) - *d.constData(); }

int count | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 68 of file qbitarray.h.

    { return (d.size() << 3) - *d.constData(); }

int count | ( | bool | on | ) | const

Search for all occurrences

bool isEmpty | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 72 of file qbitarray.h.

    { return d.isEmpty(); }

bool isNull | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 73 of file qbitarray.h.

    { return d.isNull(); }

void resize | ( | int | size | ) |

Search for all occurrences

void detach | ( |  | ) | `[inline]`

Search for all occurrences

Definition at line 77 of file qbitarray.h.

    { d.detach(); }

bool isDetached | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 78 of file qbitarray.h.

    { return d.isDetached(); }

void clear | ( |  | ) | `[inline]`

Search for all occurrences

Definition at line 79 of file qbitarray.h.

    { d.clear(); }

bool testBit | ( | int | i | ) | const `[inline]`

Search for all occurrences

Definition at line 118 of file qbitarray.h.

    { Q_ASSERT(i >= 0 && i < size());
     return (*(reinterpret_cast<const uchar*>(d.constData())+1+(i>>3)) & (1 << (i & 7))) != 0; }

void setBit | ( | int | i | ) | `[inline]`

Search for all occurrences

Definition at line 122 of file qbitarray.h.

    { Q_ASSERT(i >= 0 && i < size());
     *(reinterpret_cast<uchar*>(d.data())+1+(i>>3)) |= uchar(1 << (i & 7)); }

void setBit | ( | int | i,
|  | bool | val
| ) |  | `[inline]`

Search for all occurrences

Definition at line 130 of file qbitarray.h.

    { if (val) setBit(i); else clearBit(i); }

void clearBit | ( | int | i | ) | `[inline]`

Search for all occurrences

Definition at line 126 of file qbitarray.h.

    { Q_ASSERT(i >= 0 && i < size());
     *(reinterpret_cast<uchar*>(d.data())+1+(i>>3)) &= ~uchar(1 << (i & 7)); }

bool toggleBit | ( | int | i | ) | `[inline]`

Search for all occurrences

Definition at line 133 of file qbitarray.h.

    { Q_ASSERT(i >= 0 &&  i < size());
     uchar b = uchar(1<<(i&7)); uchar* p = reinterpret_cast<uchar*>(d.data())+1+(i>>3);
     uchar c = uchar(*p&b); *p^=b; return c!=0; }

bool at | ( | int | i | ) | const `[inline]`

Search for all occurrences

Definition at line 140 of file qbitarray.h.

    { return testBit(i); }

QBitRef operator[] | ( | int | i | ) | `[inline]`

Definition at line 156 of file qbitarray.h.

    { Q_ASSERT(i >= 0); return QBitRef(*this, i); }

bool operator[] | ( | int | i | ) | const `[inline]`

Definition at line 138 of file qbitarray.h.

    { return testBit(i); }

QBitRef operator[] | ( | uint | i | ) | `[inline]`

Definition at line 158 of file qbitarray.h.

    { return QBitRef(*this, i); }

bool operator[] | ( | uint | i | ) | const `[inline]`

Definition at line 139 of file qbitarray.h.

    { return testBit(i); }

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 98 of file qbitarray.h.

    { return d == a.d; }

bool operator!= | ( | const QBitArray & | a | ) | const `[inline]`

Definition at line 99 of file qbitarray.h.

    { return d != a.d; }

bool fill | ( | bool | val,
|  | int | size = `-1`
| ) |  | `[inline]`

Search for all occurrences

Definition at line 111 of file qbitarray.h.

    { *this = QBitArray((asize < 0 ? this->size() : asize), aval); return true; }

void fill | ( | bool | val,
|  | int | first,
|  | int | last
| ) |  |

Search for all occurrences

void truncate | ( | int | pos | ) | `[inline]`

Search for all occurrences

Definition at line 104 of file qbitarray.h.

    { if (pos < size()) resize(pos); }

DataPtr& data_ptr | ( |  | ) | `[inline]`

Search for all occurrences

Definition at line 108 of file qbitarray.h.

    { return d.data_ptr(); }

## 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]`

Search for all occurrences

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

- QtCore/qbitarray.h

QBitArray QBitArray QBitArray QBitArray QBitArray QBitArray QBitArray QBitArray QBitArray QBitArray
QBitArray QBitArray QBitArray QBitArray QBitArray QBitArray QBitArray QBitArray QBitArray QBitArray