-
Notifications
You must be signed in to change notification settings - Fork 1
/
bitsource.h
38 lines (25 loc) · 903 Bytes
/
bitsource.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef _bitsource
#define _bitsource
const int NUMUNIQUEBITS=8192*8;
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13...
// Bit numbering as above
void InitBits();
int GetBit(unsigned char byte, int num);
int GetBit(unsigned char *bytearray, int num);
void SetBit(unsigned char &byte, int num, int val);
void SetBit(unsigned char *bytearray, int num, int val);
void ZeroBits(unsigned char *bitsout, int num, int offsetout);
void CopyBits(unsigned char *bitsin, int num, int offsetin, int offsetout, unsigned char *bitsout);
void GetNextBits(unsigned char *bits, int num, int offsetout);
void PrintBits(ostream &os,unsigned char *bits, int num, int offsetin);
struct hexme_t {
unsigned int x;
hexme_t(unsigned int x) : x(x) {}
};
inline ostream &operator<<(ostream &s, const hexme_t &hexme) {
return s <<hex <<hexme.x <<dec;
}
inline hexme_t hexme(unsigned int x) {
return hexme_t(x);
}
#endif