#include <Iobuffer.h>
Description
Binary file reading utility.
InputBuffer, as the name implies, handles input data. Once instantiated with a target, the InputBuffer can then easily read and process binary data. InputBuffers are the most effective for unpacking data, especially data that is packed in accordance to OutputBuffer routines, as all OutputBuffer writing functions mirror the reading functions of InputBuffer. In the event that one wishes to processes text, the InputBuffer features a handy token grabber as well as the ability to process embedded C-Style strings, making them a viable alternative to other input streams.
Functions | |
void | OpenBuffer (const std::vector< uint8_t > &buffer) |
void | Open (const std::string &file) |
std::string | ReadString (unsigned int nBytes) |
std::vector< uint8_t > | ReadBytes (uint32_t numBytes) |
template<typename T > | |
T | Read () |
template<typename T > | |
void | Read (T &) |
void | GoToByte (int nBytes) |
int | Size () |
int | BytesLeft () |
bool | ReachedEnd () |
Member Function Documentation
void OpenBuffer | ( | const std::vector< uint8_t > & | buffer | ) |
Opens a raw buffer to read from.
void Open | ( | const std::string & | file | ) |
Opens a file to read from.
file should contain a path to a valid file.
std::string ReadString | ( | unsigned int | nBytes | ) |
Returns the next nBytes as a string.
std::vector<uint8_t> ReadBytes | ( | uint32_t | numBytes | ) |
Returns the next n bytes.
If there are less than numBytes remaining, the remaining bytes are returned.
T Read | ( | ) |
Reads the next sizeof<T> bytes adn returns a T object with its state set to the read contents.
Note: If used with user objects, be aware that this only performs a shallow copy If not enough bytes are left to acoomodate the data object, the contents are undefined.
void Read | ( | T & | o | ) |
Reads the next sizeof(T) bytes into the given reference.
While similar to the other Read functions, this will likely yeild the best performance.
void GoToByte | ( | int | nBytes | ) |
Set the buffer position byte.
If this operation operation were to go beyond the first index of data, it will move to the very first index. If a fastforward() operation were to go beyond the last valid index, it will move to the very last index.
int Size | ( | ) |
returns the size of the buffer in bytes.
int BytesLeft | ( | ) |
Returns the number of bytes left in the buffer.
bool ReachedEnd | ( | ) |
Returns whether or not all data has been read.
The documentation for this class was generated from the following file:
- /home/jc/git/Dynacoe/DynacoeSrc/includes/Dynacoe/Util/Iobuffer.h