-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBitInputStream.h
More file actions
42 lines (34 loc) · 1.14 KB
/
Copy pathBitInputStream.h
File metadata and controls
42 lines (34 loc) · 1.14 KB
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
39
40
41
42
/*********************************************************************
*
* Kening Zhang, Gang Yang
* CSE 100, fall 17
* 11/9/2017
* cs100fje cs100fiy
*
* Assignment 3
* Filename: BitInputStream.h
* Description: set the private and public field in BitInputStream
********************************************************************/
#ifndef BITINPUTSTREAM_H
#define BITINPUTSTREAM_H
#include <iostream>
#define buf_count 8
typedef unsigned char byte;
using namespace std;
/** A function class for use as setting the private and public
* field of BitInputStream
*/
class BitInputStream{
private:
int counter; // how many bits have been read to buf
byte buffer; // one byte buffer of bits
std::istream & in; // reference to the input stream to use
public:
/* Initialize a BitInputStream that will use
* the given istream for input */
BitInputStream(std::istream & is): in(is){ buffer =0; counter = buf_count;}
void fill(); // call to fill the buffer
int readBit(); // call to read ifstream and return bit value
bool isEOF(); // check if ifstream is EOF
};
#endif //BITINPUTSTREAM_H