ICF 3.1.1.10
Technical documentation of ICF Libraries
CBitManip.h
Go to the documentation of this file.
1/********************************************************************************
2** This file is part of the ICF Framework. Copyright (C) Witold Gantzke & Kirill Lepskiy
3** ICF Framework may be used under the terms of the LGPL License v. 2.1 by the Free Software Foundation.
4********************************************************************************/
5
6#pragma once
7
8
9// Qt includes
10#include <QtCore/QtGlobal>
11
12
13namespace istd
14{
15
16
21{
22public:
24
28 int GetFirstBitIndex(quint32 bits) const;
29
31
32private:
33 qint8 m_firstBitInByte[256];
34};
35
36
37// inline methods
38
39inline int CBitManip::GetFirstBitIndex(quint32 bits) const
40{
41 quint16* words = (quint16*)&bits;
42 quint8* bytes = (quint8*)&bits;
43 if (words[0] != 0){
44 if (bytes[0] != 0){
45 return int(m_firstBitInByte[bytes[0]]);
46 }
47
48 return int(m_firstBitInByte[bytes[1]]);
49 }
50 else if (words[1] != 0){
51 if (bytes[2] != 0){
52 return int(m_firstBitInByte[bytes[2]]);
53 }
54
55 return int(m_firstBitInByte[bytes[3]]);
56 }
57
58 return -1;
59}
60
61
62} // namespace istd
63
64
Helper class for bits manipulations.
Definition CBitManip.h:21
int GetFirstBitIndex(quint32 bits) const
Return index of first bit in byte.
Definition CBitManip.h:39
static CBitManip instance
Definition CBitManip.h:30
Standard library.
Definition IComponent.h:17

© Witold Gantzke and Kirill Lepskiy