#include <DataBuffer.h>
Public Member Functions | |
DataBuffer () | |
Constructor. | |
DataBuffer (const DataBuffer &o) | |
Copy constructor. | |
DataBuffer (byte data[], unsigned int size) | |
DataBuffer (unsigned int maxsize) | |
byte * | data () |
unsigned int | size () |
unsigned int | maxsize () |
void | writeVariableLength (dword data) |
void | write (byte data) |
void | write (byte data[], unsigned int size) |
void | write (DataBuffer data) |
void | seek (int pos) |
void | remove (int numBytes) |
Class that represents a read/write buffer of bytes. Can be navigated using interfaces like a C++ STD stream.
Also contains functions that help to read data as if it were stored in a MIDI file. These include support for variable-length fields.
As of right now, buffers can be expanded only to a specified maximum length.
A buffer owns its data.
Definition at line 41 of file DataBuffer.h.
MIDI::DataBuffer::DataBuffer | ( | ) |
Constructor.
Creates an empty buffer, with 0 maximum length
Definition at line 31 of file DataBuffer.cpp.
MIDI::DataBuffer::DataBuffer | ( | const DataBuffer & | o | ) |
Copy constructor.
Definition at line 35 of file DataBuffer.cpp.
MIDI::DataBuffer::DataBuffer | ( | byte | data[], | |
unsigned int | size | |||
) |
Initializes the data by copying the first "size" number of bytes from the data array. The data is copied explicitely.
This buffer can store at most size bytes.
data | The data to copy | |
size | Number of bytes to copy from the data array |
Definition at line 46 of file DataBuffer.cpp.
MIDI::DataBuffer::DataBuffer | ( | unsigned int | maxsize | ) |
Initialize an empty data buffer that can store at most maxsize bytes.
maxsize | Maximum number of bytes that one can store in this buffer |
Definition at line 54 of file DataBuffer.cpp.
byte * MIDI::DataBuffer::data | ( | ) |
Definition at line 61 of file DataBuffer.cpp.
unsigned int MIDI::DataBuffer::maxsize | ( | ) |
Definition at line 71 of file DataBuffer.cpp.
void MIDI::DataBuffer::remove | ( | int | numBytes | ) |
Removes number of bytes at the current positions. All bytes after the removed ones are shifted down.
numBytes | Number of bytes to remove |
Definition at line 134 of file DataBuffer.cpp.
void MIDI::DataBuffer::seek | ( | int | pos | ) |
Moves the position counter somewhere else. The beginning of the buffer is pos=0
pos | Position to seek to |
Definition at line 129 of file DataBuffer.cpp.
unsigned int MIDI::DataBuffer::size | ( | ) |
Definition at line 66 of file DataBuffer.cpp.
void MIDI::DataBuffer::write | ( | DataBuffer | data | ) |
Write all data from another MIDI::DataBuffer to this buffer.
data | MIDI::DataBuffer to copy from |
Definition at line 123 of file DataBuffer.cpp.
void MIDI::DataBuffer::write | ( | byte | data[], | |
unsigned int | size | |||
) |
Write a whole set of bytes into the buffer. Increments position counter by size.
data | Array of data to write | |
size | Number of bytes from data[] to write |
void MIDI::DataBuffer::write | ( | byte | data | ) |
Write a byte into the buffer, and increment the position counter/
data | byte to write |
Definition at line 100 of file DataBuffer.cpp.
void MIDI::DataBuffer::writeVariableLength | ( | dword | data | ) |
Write a number of variable length into the buffer, at current pos.
data | The number to write. Can be at most 4 bytes. |
Definition at line 76 of file DataBuffer.cpp.