#include "bitstream.h"

class ifbitstream : public ibitstream

This class reads bits of data from input files. This class inherits from the ibitstream class.

Available since: 2014/02/01 version of C++ library

Constructors
ifbitstream()  Constructs a new bit stream that is not attached to any file.
ifbitstream(filename)  Constructs a new bit stream that reads the specified file.
Methods
close()  Closes the currently-opened file, if the stream is open.
open(filename)  Opens the specified file for reading.
readBit()  Reads a single bit from the bit stream and returns 0 or 1 depending on the bit value.

Constructor detail


ifbitstream();
Constructs a new bit stream that is not attached to any file. You can open a file for reading using the open member function.

Usage:

ifbitstream stream;

ifbitstream(const char* filename);
ifbitstream(string filename);
Constructs a new bit stream that reads the specified file, if it exists. If not, the stream enters an error state.

Usage:

ifbitstream stream(filename);

Method detail


void close();
Closes the currently-opened file, if the stream is open. If the stream is not open, puts the stream into a fail state.

Usage:

stream.close();

void open(const char* filename);
void open(string filename);
Opens the specified file for reading. If an error occurs, the stream enters a failure state, which can be detected by calling the fail member function.

Usage:

stream.open(filename);

int readBit();
Reads a single bit from the ifbitstream and returns 0 or 1 depending on the bit value. If the stream is exhausted, -1 is returned. Raises an error if this bit stream has not been properly opened.

Usage:

int bit = stream.readBit();