Qt 4.8
Public Functions | Properties | List of all members
QBitField Class Reference

#include <qbitfield_p.h>

Public Functions

QBitFieldoperator= (const QBitField &)
 
 QBitField ()
 
 QBitField (const quint32 *, int bits)
 
 QBitField (const QBitField &)
 
quint32 size () const
 
bool testBit (int) const
 
QBitField united (const QBitField &)
 
 ~QBitField ()
 

Properties

quint32 bits:31
 
const quint32data
 
quint32ownData
 

Detailed Description

Definition at line 60 of file qbitfield_p.h.

Constructors and Destructors

◆ QBitField() [1/3]

QBitField::QBitField ( )
inline

Definition at line 80 of file qbitfield_p.h.

81 : bits(0), ownData(0), data(0)
82 {
83 }
quint32 bits
Definition: qbitfield_p.h:75
const quint32 * data
Definition: qbitfield_p.h:77
quint32 * ownData
Definition: qbitfield_p.h:76

◆ QBitField() [2/3]

QBitField::QBitField ( const quint32 bitData,
int  bits 
)
inline

Definition at line 85 of file qbitfield_p.h.

86 : bits((quint32)bitCount), ownData(0), data(bitData)
87 {
88 }
quint32 bits
Definition: qbitfield_p.h:75
const quint32 * data
Definition: qbitfield_p.h:77
unsigned int quint32
Definition: qglobal.h:938
quint32 * ownData
Definition: qbitfield_p.h:76

◆ QBitField() [3/3]

QBitField::QBitField ( const QBitField other)
inline

Definition at line 90 of file qbitfield_p.h.

91 : bits(other.bits), ownData(other.ownData), data(other.data)
92 {
93  if (ownData)
94  ++(*ownData);
95 }
quint32 bits
Definition: qbitfield_p.h:75
const quint32 * data
Definition: qbitfield_p.h:77
quint32 * ownData
Definition: qbitfield_p.h:76

◆ ~QBitField()

QBitField::~QBitField ( )
inline

Definition at line 97 of file qbitfield_p.h.

98 {
99  if (ownData)
100  if(0 == --(*ownData)) delete [] ownData;
101 }
quint32 * ownData
Definition: qbitfield_p.h:76

Functions

◆ operator=()

QBitField & QBitField::operator= ( const QBitField other)
inline

Definition at line 103 of file qbitfield_p.h.

104 {
105  if (other.data == data)
106  return *this;
107 
108  if (ownData)
109  if(0 == --(*ownData)) delete [] ownData;
110 
111  bits = other.bits;
112  ownData = other.ownData;
113  data = other.data;
114 
115  if (ownData)
116  ++(*ownData);
117 
118  return *this;
119 }
quint32 bits
Definition: qbitfield_p.h:75
const quint32 * data
Definition: qbitfield_p.h:77
quint32 * ownData
Definition: qbitfield_p.h:76

◆ size()

quint32 QBitField::size ( ) const
inline

Definition at line 121 of file qbitfield_p.h.

122 {
123  return bits;
124 }
quint32 bits
Definition: qbitfield_p.h:75

◆ testBit()

bool QBitField::testBit ( int  b) const
inline

Definition at line 153 of file qbitfield_p.h.

154 {
155  Q_ASSERT(b >= 0);
156  if ((quint32)b < bits) {
157  return data[b / 32] & (1 << (b % 32));
158  } else {
159  return false;
160  }
161 }
quint32 bits
Definition: qbitfield_p.h:75
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
const quint32 * data
Definition: qbitfield_p.h:77
unsigned int quint32
Definition: qglobal.h:938

◆ united()

QBitField QBitField::united ( const QBitField o)
inline

Definition at line 126 of file qbitfield_p.h.

Referenced by QDeclarativeVME::run().

127 {
128  if (o.bits == 0) {
129  return *this;
130  } else if (bits == 0) {
131  return o;
132  } else {
133  int max = (bits > o.bits)?bits:o.bits;
134  int length = (max + 31) / 32;
135  QBitField rv;
136  rv.bits = max;
137  rv.ownData = new quint32[length + 1];
138  *(rv.ownData) = 1;
139  rv.data = rv.ownData + 1;
140  if (bits > o.bits) {
141  ::memcpy((quint32 *)rv.data, data, length * sizeof(quint32));
142  for (quint32 ii = 0; ii < (o.bits + quint32(31)) / 32; ++ii)
143  ((quint32 *)rv.data)[ii] |= o.data[ii];
144  } else {
145  ::memcpy((quint32 *)rv.data, o.data, length * sizeof(quint32));
146  for (quint32 ii = 0; ii < (bits + quint32(31)) / 32; ++ii)
147  ((quint32 *)rv.data)[ii] |= data[ii];
148  }
149  return rv;
150  }
151 }
quint32 bits
Definition: qbitfield_p.h:75
const quint32 * data
Definition: qbitfield_p.h:77
unsigned int quint32
Definition: qglobal.h:938
quint32 * ownData
Definition: qbitfield_p.h:76

Properties

◆ bits

quint32 QBitField::bits
private

Definition at line 75 of file qbitfield_p.h.

Referenced by operator=(), size(), testBit(), and united().

◆ data

const quint32* QBitField::data
private

Definition at line 77 of file qbitfield_p.h.

Referenced by operator=(), testBit(), and united().

◆ ownData

quint32* QBitField::ownData
private

Definition at line 76 of file qbitfield_p.h.

Referenced by operator=(), QBitField(), united(), and ~QBitField().


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