BinaryFileReader: interface for reading binary files, bit by bit or byte by byte.
More...
#include "binary_file_reader.h"
BinaryFileReader: interface for reading binary files, bit by bit or byte by byte.
Wraps an ifstream in binary mode.
- Author
- Chase Geigle
- Date
- Summer 2012
◆ BinaryFileReader()
BinaryFileReader::BinaryFileReader |
( |
const std::string & |
fileName | ) |
|
Constructs a new BinaryFileReader by opening the given file.
- Parameters
-
fileName | File to be opened. |
◆ ~BinaryFileReader()
BinaryFileReader::~BinaryFileReader |
( |
| ) |
|
Destroys a BinaryFileReader, ensuring the file is correctly closed.
If the file is already closed, does nothing.
◆ getNextBit()
bool BinaryFileReader::getNextBit |
( |
| ) |
|
Reads the next bit of the file.
Should only be called when hasBits() is true.
- Returns
- The next bit of the file.
◆ getNextByte()
char BinaryFileReader::getNextByte |
( |
| ) |
|
Reads the next byte of the file.
Should only be called when hasBytes() is true.
- Returns
- The next byte of the file, as a char.
◆ reset()
void BinaryFileReader::reset |
( |
| ) |
|
Resets the file pointer to the beginning of the file.
◆ close()
void BinaryFileReader::close |
( |
| ) |
|
◆ hasBits()
bool BinaryFileReader::hasBits |
( |
| ) |
const |
Determines if there are more bits to be read in the file.
- Returns
- Whether or not there exists at least one more unread bit in the file.
◆ hasBytes()
bool BinaryFileReader::hasBytes |
( |
| ) |
const |
Determines if there are more bytes to be read in the file.
- Returns
- Whether or not there exists at least one more unread byte in the file.
◆ needsNextByte()
bool BinaryFileReader::needsNextByte |
( |
| ) |
const |
|
private |
Determines whether or not another byte needs read from the file.
- Returns
- Whether or not another byte must be read.
◆ readNextByte()
void BinaryFileReader::readNextByte |
( |
| ) |
|
|
private |
Reads in a single byte from the file.
◆ file
◆ currentByte
char BinaryFileReader::currentByte |
|
private |
The current byte to read bits from.
◆ currentBit
int BinaryFileReader::currentBit |
|
private |
The current bit within the currentByte that is being read.
◆ maxBytes
int BinaryFileReader::maxBytes |
|
private |
The total number of bytes in the file.
◆ numRead
int BinaryFileReader::numRead |
|
private |
The number of bytes read from the file.
◆ paddingBits
int BinaryFileReader::paddingBits |
|
private |
The number of padding bits there are in the final byte.
The documentation for this class was generated from the following files: