/* ibitstream.h
 *
 * CSI 2131
 * Lucia Moura
 *
 * This defines a class to pretend to read a file bit-by-bit.
 *
 */

#ifndef IBITSTREAM_H
#define IBITSTREAM_H

#include <iostream>
#include <fstream>
using namespace std;
 
class IBitStream {

 private:

  istream *pin;        // pointer to corresponding input file
  unsigned char buf;   // buffer to read byte-by-byte
  int bits_processed;  // counts how many bits were processed from buffer

 public:
 
  // two types of constructors
  IBitStream();
  IBitStream(istream & in);

  virtual ~IBitStream(); // destructor

  // input file accessors


  void setfile(istream & newin); // associates a file to this bit stream
  istream *getfile(); // returns a pointer to the file associated to this bit stream

  // reading one bit: this method returns the next bit from the input file
  short int get(); 

  // end-of-file indicator
  bool eof();
};

#endif


