Public Member Functions | |
Buffer (const char *filename) | |
Instantiate on filename. | |
Buffer (std::istream *is) | |
Instantiate on open input fstream. | |
Buffer (const char *buffer, unsigned long size) | |
Instantiate on existing buffer. | |
Buffer (const Buffer &buf, unsigned long start, unsigned long end) | |
Instantiate on subsection of existing buffer. | |
~Buffer () | |
Cleanup. | |
char | getnextchar () |
Get next character from buffer. | |
bool | unget () |
Back up in the buffer. | |
void | reset () |
Reset pointers to beginning of buffer. | |
bool | seek (unsigned long index) |
Seek to index in buffer. | |
unsigned long | offset () const |
Get current offset into buffer. | |
operator bool () const | |
True when not at end of buffer. | |
const char | operator[] (unsigned long index) |
Index access. | |
unsigned long | size () const |
Current size. | |
void | setname (const char *name) |
Set buffer name. | |
const char * | getname () |
Get buffer name. |
|
Instantiate on filename. Construct a read Buffer for the specified file.
|
|
Instantiate on open input fstream. Construct a read Buffer for an open fstream. The input stream will not be closed when Buffer is destructed.
|
|
Instantiate on existing buffer. Construct a read Buffer for an existing buffer.
|
|
Instantiate on subsection of existing buffer. Construct a read Buffer on a subspace of an existing Buffer.
|
|
Cleanup. Free buffer and fstream if necessary |
|
Get buffer name. Get the current buffer name.
|
|
Get next character from buffer. Get the next available character from the buffer. Use operator bool() to determine if more data is available. Reading past the end of the buffer results in undefined behavior.
|
|
Get current offset into buffer. Get the offset of the next character in the buffer to be read. Use operator bool() to determine if there is data in the buffer.
|
|
True when not at end of buffer. Perform a boolean check for availability of data in the buffer. Usage can look like:
TPT::Buffer readbuf("input.txt");
|
|
Index access. Read from a specific index in the buffer, without losing the current position information, reading the input file or stream if necessary.
|
|
Reset pointers to beginning of buffer. Reset the buffer index to the beginning of the input buffer.
|
|
Seek to index in buffer. Seek to a index point in the buffer. The seek will force reading of the file or stream if the index has not yet been buffered. If the index is past the end of the buffer, the attempt will fail and the internal index will not be reset.
|
|
Set buffer name. Set the buffer name. By default, file buffers will have a name of the filename if the buffer is a file buffer, or 'stream', 'memory', or 'buffer' depending on the constructor.
|
|
Current size. Get the size of the current buffer. If this is a file or stream buffer, the size may be smaller than the current file or stream if the buffer has not been fully filled.
|
|
Back up in the buffer. Unget a single character back into the buffer.
|