Rudiments
|
#include <bytebuffer.h>
Inherits output.
Inherited by stringbuffer, ucs2stringbuffer, and wstringbuffer.
The bytebuffer class can be used to store binary data of arbitrary length.
It is generally more efficient to reuse the same bytebuffer over and over than to allocate a new one for each operation.
bytebuffer::bytebuffer | ( | ) |
Creates an instance of the bytebuffer class with default initial size and increment parameters.
bytebuffer::bytebuffer | ( | size_t | initialsize | ) |
Creates an instance of the bytebuffer class with the specified "initialsize".
bytebuffer::bytebuffer | ( | byte_t * | initialcontents, |
size_t | initialsize ) |
Creates an instance of the bytebuffer class. The buffer "initialcontents" will be attached to the instance and used as the initial contents. This buffer should not be freed by the calling program.
bytebuffer::bytebuffer | ( | bytebuffer & | v | ) |
Creates an instance of the bytebuffer class that is a copy of "v".
|
virtual |
Deletes this instance of the bytebuffer class.
bytebuffer * bytebuffer::append | ( | byte_t | character | ) |
Appends "character" to the bytebuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: vb->append("numbers: ")->append(5)->append(5.5);
bytebuffer * bytebuffer::append | ( | char | character | ) |
Appends "character" to the bytebuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: vb->append("numbers: ")->append(5)->append(5.5);
bytebuffer * bytebuffer::append | ( | const byte_t * | data, |
size_t | size ) |
Appends the first "size" bytes of "data" to the bytebuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: vb->append("numbers: ")->append(5)->append(5.5);
bytebuffer * bytebuffer::append | ( | const char * | string | ) |
Appends "string" to the bytebuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: vb->append("numbers: ")->append(5)->append(5.5);
bytebuffer * bytebuffer::append | ( | const char * | string, |
size_t | length ) |
Appends the first "length" characters of "string" to the bytebuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: vb->append("numbers: ")->append(5)->append(5.5);
bytebuffer * bytebuffer::append | ( | const wchar_t * | string | ) |
Appends "string" to the bytebuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: vb->append("numbers: ")->append(5)->append(5.5);
bytebuffer * bytebuffer::append | ( | const wchar_t * | string, |
size_t | length ) |
Appends the first "length" characters of "string" to the bytebuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: vb->append("numbers: ")->append(5)->append(5.5);
bytebuffer * bytebuffer::append | ( | double | number | ) |
Appends "number" to the bytebuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: vb->append("numbers: ")->append(5)->append(5.5);
bytebuffer * bytebuffer::append | ( | float | number | ) |
Appends "number" to the bytebuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: vb->append("numbers: ")->append(5)->append(5.5);
bytebuffer * bytebuffer::append | ( | int16_t | number | ) |
Appends "number" to the bytebuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: vb->append("numbers: ")->append(5)->append(5.5);
bytebuffer * bytebuffer::append | ( | int32_t | number | ) |
Appends "number" to the bytebuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: vb->append("numbers: ")->append(5)->append(5.5);
bytebuffer * bytebuffer::append | ( | int64_t | number | ) |
Appends "number" to the bytebuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: vb->append("numbers: ")->append(5)->append(5.5);
bytebuffer * bytebuffer::append | ( | uint16_t | number | ) |
Appends "number" to the bytebuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: vb->append("numbers: ")->append(5)->append(5.5);
bytebuffer * bytebuffer::append | ( | uint32_t | number | ) |
Appends "number" to the bytebuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: vb->append("numbers: ")->append(5)->append(5.5);
bytebuffer * bytebuffer::append | ( | uint64_t | number | ) |
Appends "number" to the bytebuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: vb->append("numbers: ")->append(5)->append(5.5);
bytebuffer * bytebuffer::append | ( | wchar_t | character | ) |
Appends "character" to the bytebuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: vb->append("numbers: ")->append(5)->append(5.5);
bytebuffer * bytebuffer::appendUcs2 | ( | const ucs2_t * | string | ) |
Appends "string" to the bytebuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: vb->append("numbers: ")->append(5)->append(5.5);
bytebuffer * bytebuffer::appendUcs2 | ( | const ucs2_t * | string, |
size_t | length ) |
Appends the first "length" characters of "string" to the bytebuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: vb->append("numbers: ")->append(5)->append(5.5);
bytebuffer * bytebuffer::appendUcs2 | ( | ucs2_t | character | ) |
Appends "character" to the bytebuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: vb->append("numbers: ")->append(5)->append(5.5);
bool bytebuffer::clear | ( | ) |
Empties the bytebuffer.
Always returns true.
Empties the bytebuffer and attaches the buffer "initialcontents" to the instance as the initial contents. This buffer should not be freed by the calling program. Also resets the specified "initialsize".
Always returns true.
Empties the bytebuffer and resets the specified "initialsize" parameter.
Always returns true.
byte_t * bytebuffer::detachBuffer | ( | ) |
Returns a pointer to the buffer currently stored in the bytebuffer, then resets the bytebuffer such that it will no longer use that buffer.
The calling program must deallocate the buffer returned from this method.
size_t bytebuffer::getActualSize | ( | ) |
Returns the actual number of bytes of internal storage used by the bytebuffer, which may be larger than the value returned by getSize() since the buffer grows in extents.
const byte_t * bytebuffer::getBuffer | ( | ) |
Returns the current data stored in the bytebuffer.
size_t bytebuffer::getInitialSize | ( | ) |
Returns the number of bytes in the original initial exent.
|
virtual |
Returns the position in the buffer at which the next write will occur.
Reimplemented from output.
Reimplemented in stringbuffer, ucs2stringbuffer, and wstringbuffer.
size_t bytebuffer::getSize | ( | ) |
Returns the number of bytes currently stored in the bytebuffer.
bytebuffer & bytebuffer::operator= | ( | bytebuffer & | v | ) |
Makes this instance of the bytebuffer class identical to "v".
ssize_t bytebuffer::read | ( | byte_t * | data, |
size_t | size ) |
Reads "size" bytes from the bytebuffer at the current position into "data". Also increments the current position by "size" bytes. Returns the number of bytes read.
|
virtual |
Sets the position (relative to the beginning of the buffer) at which the next read or write will occur to "offset". If the position is set beyond the end of the buffer, the buffer will grow but the data between the current end of the buffer and the new position will be undefined.
Reimplemented from output.
Reimplemented in stringbuffer, ucs2stringbuffer, and wstringbuffer.
|
virtual |
Advances the position at which the next read or write will occur by "offset" bytes. If the position is set beyond the end of the buffer, the buffer will grow but the data between the current end of the buffer and the new position will be undefined.
Reimplemented from output.
Reimplemented in stringbuffer, ucs2stringbuffer, and wstringbuffer.
|
virtual |
Sets the position at which the next read or write will occur to the end of the buffer plus "offset" bytes. Generally, offset will be negative. If it is positive then the buffer will grow, but the data between the current buffer will grow but the data between the current end of the buffer and the new position will be undefined.
Reimplemented from output.
Reimplemented in stringbuffer, ucs2stringbuffer, and wstringbuffer.
Truncates the bytebuffer at the current position.
Reimplemented in stringbuffer, ucs2stringbuffer, and wstringbuffer.
Truncates the bytebuffer at position "pos".
Reimplemented in stringbuffer, ucs2stringbuffer, and wstringbuffer.
|
virtual |
Writes "character" to the bytebuffer at the current position and increments the current position to the next byte after the data that was written. If necessary, the internal buffer will grow to accommodate the new data.
Returns the number of bytes written.
Implements output.
Reimplemented in stringbuffer, and ucs2stringbuffer.
|
virtual |
Writes "character" to the bytebuffer at the current position and increments the current position to the next byte after the data that was written. If necessary, the internal buffer will grow to accommodate the new data.
Returns the number of bytes written.
Implements output.
Reimplemented in stringbuffer.
Writes the first "size" bytes of "data" to the bytebuffer at the current position and increments the current position to the next byte after the data that was written. If necessary, the internal buffer will grow to accommodate the new data.
Returns the number of bytes written.
Implements output.
Reimplemented in stringbuffer, and ucs2stringbuffer.
Writes "string" to the bytebuffer at the current position and increments the current position to the next byte after the data that was written. If necessary, the internal buffer will grow to accommodate the new data.
Returns the number of bytes written.
Implements output.
Reimplemented in stringbuffer.
Writes the first "length" characters of "string" to the bytebuffer at the current position and increments the current position to the next byte after the data that was written. If necessary, the internal buffer will grow to accommodate the new data.
Returns the number of bytes written.
Implements output.
Reimplemented in stringbuffer.
Writes "string" to the bytebuffer at the current position and increments the current position to the next byte after the data that was written. If necessary, the internal buffer will grow to accommodate the new data.
Returns the number of bytes written.
Implements output.
Reimplemented in wstringbuffer.
Writes the first "length" characters of "string" to the bytebuffer at the current position and increments the current position to the next byte after the data that was written. If necessary, the internal buffer will grow to accommodate the new data.
Returns the number of bytes written.
Implements output.
Reimplemented in wstringbuffer.
|
virtual |
Writes "number" to the bytebuffer at the current position and increments the current position to the next byte after the data that was written. If necessary, the internal buffer will grow to accommodate the new data.
Returns the number of bytes written.
Implements output.
Reimplemented in stringbuffer, ucs2stringbuffer, and wstringbuffer.
|
virtual |
Writes "number" to the bytebuffer at the current position and increments the current position to the next byte after the data that was written. If necessary, the internal buffer will grow to accommodate the new data.
Returns the number of bytes written.
Implements output.
Reimplemented in stringbuffer, ucs2stringbuffer, and wstringbuffer.
|
virtual |
Writes "number" to the bytebuffer at the current position and increments the current position to the next byte after the data that was written. If necessary, the internal buffer will grow to accommodate the new data.
Returns the number of bytes written.
Implements output.
Reimplemented in stringbuffer, ucs2stringbuffer, and wstringbuffer.
|
virtual |
Writes "number" to the bytebuffer at the current position and increments the current position to the next byte after the data that was written. If necessary, the internal buffer will grow to accommodate the new data.
Returns the number of bytes written.
Implements output.
Reimplemented in stringbuffer, ucs2stringbuffer, and wstringbuffer.
|
virtual |
Writes "number" to the bytebuffer at the current position and increments the current position to the next byte after the data that was written. If necessary, the internal buffer will grow to accommodate the new data.
Returns the number of bytes written.
Implements output.
Reimplemented in stringbuffer, ucs2stringbuffer, and wstringbuffer.
|
virtual |
Writes "number" to the bytebuffer at the current position and increments the current position to the next byte after the data that was written. If necessary, the internal buffer will grow to accommodate the new data.
Returns the number of bytes written.
Implements output.
Reimplemented in stringbuffer, ucs2stringbuffer, and wstringbuffer.
|
virtual |
Writes "number" to the bytebuffer at the current position and increments the current position to the next byte after the data that was written. If necessary, the internal buffer will grow to accommodate the new data.
Returns the number of bytes written.
Implements output.
Reimplemented in stringbuffer, ucs2stringbuffer, and wstringbuffer.
|
virtual |
Writes "number" to the bytebuffer at the current position and increments the current position to the next byte after the data that was written. If necessary, the internal buffer will grow to accommodate the new data.
Returns the number of bytes written.
Implements output.
Reimplemented in stringbuffer, ucs2stringbuffer, and wstringbuffer.
|
virtual |
Writes "character" to the bytebuffer at the current position and increments the current position to the next byte after the data that was written. If necessary, the internal buffer will grow to accommodate the new data.
Returns the number of bytes written.
Implements output.
Reimplemented in wstringbuffer.
|
virtual |
Writes "string" to the bytebuffer at the current position and increments the current position to the next byte after the data that was written. If necessary, the internal buffer will grow to accommodate the new data.
Returns the number of bytes written.
Implements output.
Reimplemented in ucs2stringbuffer.
Writes the first "length" characters of "string" to the bytebuffer at the current position and increments the current position to the next byte after the data that was written. If necessary, the internal buffer will grow to accommodate the new data.
Returns the number of bytes written.
Implements output.
Reimplemented in ucs2stringbuffer.
|
virtual |
Writes "character" to the bytebuffer at the current position and increments the current position to the next byte after the data that was written. If necessary, the internal buffer will grow to accommodate the new data.
Returns the number of bytes written.
Implements output.
Reimplemented in ucs2stringbuffer.