77 inline quint8
getBit(
int index)
const {
78 return (content[index/8] >> (7-index%8)) & 0x01;
89 inline void setBit(
int index, quint8 bit) {
90 quint32 byteIndex = index/8;
92 content[byteIndex] = content[byteIndex] | (0b00000001 << (7-index%8));
94 content[byteIndex] = content[byteIndex] & ~(0b00000001 << (7-index%8));
170 if (_size+32 > content.size()*8)
171 content.resize(2*content.size()+1000);
173 quint32 value = mbv.
value;
174 for(
int i=0; i<mbv.
numBits; i++) {
175 bool bit = value & 0x01;
193 operator QByteArray();
199 operator QString()
const;
212 static inline quint8
getBit(
const quint8 *ptr,
int index) {
213 return (ptr[index/8] >> (7-index%8)) & 0x01;
227 static inline void setBit(quint8 *ptr,
int index, quint8 bit) {
228 quint32 byteIndex = index/8;
230 ptr[byteIndex] = ptr[byteIndex] | (0b00000001 << (7-index%8));
232 ptr[byteIndex] = ptr[byteIndex] & ~(0b00000001 << (7-index%8));
251 static inline void fill(quint8 *ptr,
int startIndex,
int numBits, quint8 bit) {
252 quint32 endIndex = startIndex+numBits;
253 quint32 index=startIndex;
254 while(index < endIndex) {
257 uintptr_t currentBytePtr = (uintptr_t)(ptr+index/8);
259 if ((currentBytePtr%8 == 0) && (index+64<endIndex)) {
260 *((quint64 *)currentBytePtr) = (bit == 0) ? 0x0000000000000000 : 0xFFFFFFFFFFFFFFFF;
265 if ((currentBytePtr%4 == 0) && (index+32<endIndex)) {
266 *((quint32 *)currentBytePtr) = (bit == 0) ? 0x00000000 : 0xFFFFFFFF;
271 if ((currentBytePtr%2 == 0) && (index+16<endIndex)) {
273 *((quint16 *)currentBytePtr) = (bit == 0) ? 0x0000 : 0xFFFF;
278 if (index+8<endIndex) {
279 ptr[index/8] = (bit == 0) ? 0x00 : 0xFF;
304 static inline int findEndOfRun(
const quint8 *ptr,
int startIndex,
int endIndex, quint8 runValue) {
305 int index=startIndex;
307 while(index < endIndex) {
310 uintptr_t currentBytePtr = (uintptr_t)(ptr+index/8);
313 if ((currentBytePtr%8 == 0) && (endIndex-index >= 64)) {
315 if ( *((quint64 *)currentBytePtr) == 0) {
320 if ( *((quint64 *)currentBytePtr) == 0xFFFFFFFFFFFFFFFF) {
328 if ((currentBytePtr%4 == 0) && (endIndex-index >= 32)) {
330 if ( *((quint32 *)currentBytePtr) == 0) {
335 if ( *((quint32 *)currentBytePtr) == 0xFFFFFFFF) {
343 if ((currentBytePtr%2 == 0) && (endIndex-index >= 16)) {
345 if ( *((quint16 *)currentBytePtr) == 0) {
350 if ( *((quint16 *)currentBytePtr) == 0xFFFF) {
358 if (endIndex-index >= 8) {
360 if (ptr[index/8] == 0) {
365 if (ptr[index/8] == 0xFF) {