Rudiments
|
Inherits bytebuffer.
Public Member Functions | |
stringbuffer () | |
stringbuffer (size_t initialsize, size_t increment) | |
stringbuffer (char *initialcontents, size_t initialsize, size_t increment) | |
stringbuffer (const stringbuffer &s) | |
stringbuffer & | operator= (const stringbuffer &s) |
~stringbuffer () | |
void | setPosition (size_t pos) |
size_t | getPosition () |
stringbuffer * | write (const unsigned char *string) |
stringbuffer * | write (const unsigned char *string, size_t size) |
stringbuffer * | write (const char *string) |
stringbuffer * | write (const char *string, size_t size) |
stringbuffer * | write (char character) |
stringbuffer * | write (int16_t number) |
stringbuffer * | write (int32_t number) |
stringbuffer * | write (int64_t number) |
stringbuffer * | write (unsigned char character) |
stringbuffer * | write (uint16_t number) |
stringbuffer * | write (uint32_t number) |
stringbuffer * | write (uint64_t number) |
stringbuffer * | write (float number) |
stringbuffer * | write (float number, uint16_t scale) |
stringbuffer * | write (float number, uint16_t precision, uint16_t scale) |
stringbuffer * | write (double number) |
stringbuffer * | write (double number, uint16_t scale) |
stringbuffer * | write (double number, uint16_t precision, uint16_t scale) |
stringbuffer * | append (const unsigned char *string) |
stringbuffer * | append (const unsigned char *string, size_t size) |
stringbuffer * | append (const char *string) |
stringbuffer * | append (const char *string, size_t size) |
stringbuffer * | append (char character) |
stringbuffer * | append (int16_t number) |
stringbuffer * | append (int32_t number) |
stringbuffer * | append (int64_t number) |
stringbuffer * | append (unsigned char character) |
stringbuffer * | append (uint16_t number) |
stringbuffer * | append (uint32_t number) |
stringbuffer * | append (uint64_t number) |
stringbuffer * | append (int16_t number, uint16_t zeropadding) |
stringbuffer * | append (int32_t number, uint16_t zeropadding) |
stringbuffer * | append (int64_t number, uint16_t zeropadding) |
stringbuffer * | append (uint16_t number, uint16_t zeropadding) |
stringbuffer * | append (uint32_t number, uint16_t zeropadding) |
stringbuffer * | append (uint64_t number, uint16_t zeropadding) |
stringbuffer * | append (float number) |
stringbuffer * | append (float number, uint16_t scale) |
stringbuffer * | append (float number, uint16_t precision, uint16_t scale) |
stringbuffer * | append (double number) |
stringbuffer * | append (double number, uint16_t scale) |
stringbuffer * | append (double number, uint16_t precision, uint16_t scale) |
void | truncate (size_t pos) |
void | truncate () |
void | clear () |
const char * | getString () |
char * | detachString () |
size_t | getStringLength () |
![]() | |
bytebuffer () | |
bytebuffer (size_t initialsize, size_t increment) | |
bytebuffer (unsigned char *initialcontents, size_t initialsize, size_t increment) | |
bytebuffer (const bytebuffer &v) | |
bytebuffer & | operator= (const bytebuffer &v) |
virtual | ~bytebuffer () |
void | setPosition (size_t pos) |
size_t | getPosition () |
bytebuffer * | write (const unsigned char *data, size_t size) |
bytebuffer * | write (const char *string) |
bytebuffer * | write (const char *string, size_t size) |
bytebuffer * | write (char character) |
bytebuffer * | write (int16_t number) |
bytebuffer * | write (int32_t number) |
bytebuffer * | write (int64_t number) |
bytebuffer * | write (unsigned char character) |
bytebuffer * | write (uint16_t number) |
bytebuffer * | write (uint32_t number) |
bytebuffer * | write (uint64_t number) |
bytebuffer * | write (float number) |
bytebuffer * | write (double number) |
bytebuffer * | writeFormatted (const char *format,...) |
bytebuffer * | writeFormatted (const char *format, va_list *argp) |
bytebuffer * | append (const unsigned char *data, size_t size) |
bytebuffer * | append (const char *string) |
bytebuffer * | append (const char *string, size_t size) |
bytebuffer * | append (char character) |
bytebuffer * | append (int16_t number) |
bytebuffer * | append (int32_t number) |
bytebuffer * | append (int64_t number) |
bytebuffer * | append (unsigned char character) |
bytebuffer * | append (uint16_t number) |
bytebuffer * | append (uint32_t number) |
bytebuffer * | append (uint64_t number) |
bytebuffer * | append (float number) |
bytebuffer * | append (double number) |
bytebuffer * | appendFormatted (const char *format,...) |
bytebuffer * | appendFormatted (const char *format, va_list *argp) |
ssize_t | read (unsigned char *data, size_t size) |
void | clear () |
const unsigned char * | getBuffer () |
size_t | getSize () |
size_t | getEnd () |
size_t | getActualSize () |
unsigned char * | detachBuffer () |
The stringbuffer class can be used to store strings of arbitrary length.
Internally, the class stores this data in a series of extents which are coalesced when getString() or detachString() are called. The size of the initial and incremental extents may be defined in the constructor, if desired.
When cleared, all extents are freed except for the initial extent.
It is generally more efficient to reuse the same stringbuffer over and over than to allocate a new one for each operation.
stringbuffer::stringbuffer | ( | ) |
Creates an instance of the stringbuffer class with default initial size and increment parameters.
stringbuffer::stringbuffer | ( | size_t | initialsize, |
size_t | increment | ||
) |
Creates an instance of the stringbuffer class with the specified "initialsize" and "increment" parameters.
stringbuffer::stringbuffer | ( | char * | initialcontents, |
size_t | initialsize, | ||
size_t | increment | ||
) |
Creates an instance of the stringbuffer 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. The initial size and increment may be specified respectively by the "initialsize" and "increment" parameters.
stringbuffer::stringbuffer | ( | const stringbuffer & | s | ) |
Creates an instance of the stringbuffer class that is a copy of "s".
stringbuffer::~stringbuffer | ( | ) |
Deletes this instance of the stringbuffer class.
stringbuffer* stringbuffer::append | ( | const unsigned char * | string | ) |
Appends "string" to the stringbuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: sb->append("numbers: ")->append(5)->append(5.5);
stringbuffer* stringbuffer::append | ( | const unsigned char * | string, |
size_t | size | ||
) |
Appends the first "size" bytes of "string" to the stringbuffer, growing the internall buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: sb->append("numbers: ")->append(5)->append(5.5);
stringbuffer* stringbuffer::append | ( | const char * | string | ) |
Appends "string" to the stringbuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: sb->append("numbers: ")->append(5)->append(5.5);
stringbuffer* stringbuffer::append | ( | const char * | string, |
size_t | size | ||
) |
Appends the first "size" bytes of "string" to the stringbuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: sb->append("numbers: ")->append(5)->append(5.5);
stringbuffer* stringbuffer::append | ( | char | character | ) |
Appends "character" to the stringbuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: sb->append("numbers: ")->append(5)->append(5.5);
stringbuffer* stringbuffer::append | ( | int16_t | number | ) |
Converts "number" to a string and appends it to the stringbuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: sb->append("numbers: ")->append(5)->append(5.5);
stringbuffer* stringbuffer::append | ( | int32_t | number | ) |
Converts "number" to a string and appends it to the stringbuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: sb->append("numbers: ")->append(5)->append(5.5);
stringbuffer* stringbuffer::append | ( | int64_t | number | ) |
Converts "number" to a string and appends it to the stringbuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: sb->append("numbers: ")->append(5)->append(5.5);
stringbuffer* stringbuffer::append | ( | unsigned char | character | ) |
Appends "character" to the stringbuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: sb->append("numbers: ")->append(5)->append(5.5);
stringbuffer* stringbuffer::append | ( | uint16_t | number | ) |
Converts "number" to a string and appends it to the stringbuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: sb->append("numbers: ")->append(5)->append(5.5);
stringbuffer* stringbuffer::append | ( | uint32_t | number | ) |
Converts "number" to a string and appends it to the stringbuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: sb->append("numbers: ")->append(5)->append(5.5);
stringbuffer* stringbuffer::append | ( | uint64_t | number | ) |
Converts "number" to a string and appends it to the stringbuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: sb->append("numbers: ")->append(5)->append(5.5);
stringbuffer* stringbuffer::append | ( | int16_t | number, |
uint16_t | zeropadding | ||
) |
Converts "number" to a string with the specified amount of zeropadding and appends it to the stringbuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: sb->append("numbers: ")->append(5)->append(5.5);
stringbuffer* stringbuffer::append | ( | int32_t | number, |
uint16_t | zeropadding | ||
) |
Converts "number" to a string with the specified amount of zeropadding and appends it to the stringbuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: sb->append("numbers: ")->append(5)->append(5.5);
stringbuffer* stringbuffer::append | ( | int64_t | number, |
uint16_t | zeropadding | ||
) |
Converts "number" to a string with the specified amount of zeropadding and appends it to the stringbuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: sb->append("numbers: ")->append(5)->append(5.5);
stringbuffer* stringbuffer::append | ( | uint16_t | number, |
uint16_t | zeropadding | ||
) |
Converts "number" to a string with the specified amount of zeropadding and appends it to the stringbuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: sb->append("numbers: ")->append(5)->append(5.5);
stringbuffer* stringbuffer::append | ( | uint32_t | number, |
uint16_t | zeropadding | ||
) |
Converts "number" to a string with the specified amount of zeropadding and appends it to the stringbuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: sb->append("numbers: ")->append(5)->append(5.5);
stringbuffer* stringbuffer::append | ( | uint64_t | number, |
uint16_t | zeropadding | ||
) |
Converts "number" to a string with the specified amount of zeropadding and appends it to the stringbuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: sb->append("numbers: ")->append(5)->append(5.5);
stringbuffer* stringbuffer::append | ( | float | number | ) |
Converts "number" to a string (using a default scale of 4) and appends it to the stringbuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: sb->append("numbers: ")->append(5)->append(5.5);
stringbuffer* stringbuffer::append | ( | float | number, |
uint16_t | scale | ||
) |
Converts "number" to a string using the specified "scale" and appends it to the stringbuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: sb->append("numbers: ")->append(5)->append(5.5);
stringbuffer* stringbuffer::append | ( | float | number, |
uint16_t | precision, | ||
uint16_t | scale | ||
) |
Converts "number" to a string using the specified "precision" and "scale" and appends it to the stringbuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: sb->append("numbers: ")->append(5)->append(5.5);
stringbuffer* stringbuffer::append | ( | double | number | ) |
Converts "number" to a string (using a default scale of 4) and appends it to the stringbuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: sb->append("numbers: ")->append(5)->append(5.5);
stringbuffer* stringbuffer::append | ( | double | number, |
uint16_t | scale | ||
) |
Converts "number" to a string using the specified "scale" and appends it to the stringbuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: sb->append("numbers: ")->append(5)->append(5.5);
stringbuffer* stringbuffer::append | ( | double | number, |
uint16_t | precision, | ||
uint16_t | scale | ||
) |
Converts "number" to a string using the specified "precision" and "scale" and appends it to the stringbuffer, growing the internal buffer as necessary to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: sb->append("numbers: ")->append(5)->append(5.5);
void stringbuffer::clear | ( | ) |
Empties the stringbuffer.
char* stringbuffer::detachString | ( | ) |
Returns a pointer to the string currently stored in the stringbuffer, then resets the stringbuffer such that it will no longer use that string.
The calling program must deallocate the string returned from this method.
size_t stringbuffer::getPosition | ( | ) |
Returns the position in the internal buffer at which the next write will occur.
const char* stringbuffer::getString | ( | ) |
Returns the string currently stored in the stringbuffer.
size_t stringbuffer::getStringLength | ( | ) |
Returns the length of the string currently stored in the stringbuffer.
stringbuffer& stringbuffer::operator= | ( | const stringbuffer & | s | ) |
Makes this instance of the stringbuffer class identical to "s".
void stringbuffer::setPosition | ( | size_t | pos | ) |
Sets the position in the internal buffer at which the next write will occur to "pos". 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.
|
virtual |
Trucnates the stringbuffer at position "pos".
Reimplemented from bytebuffer.
|
virtual |
Trucnates the stringbuffer at the current position.
Reimplemented from bytebuffer.
stringbuffer* stringbuffer::write | ( | const unsigned char * | string | ) |
Writes "string" to the stringbuffer 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 a pointer to "this" to enable chaining such as: sb->write("numbers: ")->write(5)->write(5.5);
stringbuffer* stringbuffer::write | ( | const unsigned char * | string, |
size_t | size | ||
) |
Writes the first "size" bytes of "string" to the stringbuffer 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 a pointer to "this" to enable chaining such as: sb->write("numbers: ")->write(5)->write(5.5);
stringbuffer* stringbuffer::write | ( | const char * | string | ) |
Writes "string" to the stringbuffer 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 a pointer to "this" to enable chaining such as: sb->write("numbers: ")->write(5)->write(5.5);
stringbuffer* stringbuffer::write | ( | const char * | string, |
size_t | size | ||
) |
Writes the first "size" bytes of "string" to the stringbuffer 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 a pointer to "this" to enable chaining such as: sb->write("numbers: ")->write(5)->write(5.5);
stringbuffer* stringbuffer::write | ( | char | character | ) |
Writes "character" to the stringbuffer 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 a pointer to "this" to enable chaining such as: sb->write("numbers: ")->write(5)->write(5.5);
stringbuffer* stringbuffer::write | ( | int16_t | number | ) |
Converts "number" to a string and writes it to the stringbuffer 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 a pointer to "this" to enable chaining such as: sb->write("numbers: ")->write(5)->write(5.5);
stringbuffer* stringbuffer::write | ( | int32_t | number | ) |
Converts "number" to a string and writes it to the stringbuffer 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 a pointer to "this" to enable chaining such as: sb->write("numbers: ")->write(5)->write(5.5);
stringbuffer* stringbuffer::write | ( | int64_t | number | ) |
Converts "number" to a string and writes it to the stringbuffer at the current position and increments the current position to the next byte after the data that was written. If necessary, the inernal buffer will grow to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: sb->write("numbers: ")->write(5)->write(5.5);
stringbuffer* stringbuffer::write | ( | unsigned char | character | ) |
Writes "character" to the stringbuffer 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 a pointer to "this" to enable chaining such as: sb->write("numbers: ")->write(5)->write(5.5);
stringbuffer* stringbuffer::write | ( | uint16_t | number | ) |
Converts "number" to a string and writes it to the stringbuffer 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 a pointer to "this" to enable chaining such as: sb->write("numbers: ")->write(5)->write(5.5);
stringbuffer* stringbuffer::write | ( | uint32_t | number | ) |
Converts "number" to a string and writes it to the stringbuffer 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 a pointer to "this" to enable chaining such as: sb->write("numbers: ")->write(5)->write(5.5);
stringbuffer* stringbuffer::write | ( | uint64_t | number | ) |
Converts "number" to a string and writes it to the stringbuffer 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 a pointer to "this" to enable chaining such as: sb->write("numbers: ")->write(5)->write(5.5);
stringbuffer* stringbuffer::write | ( | float | number | ) |
Converts "number" to a string (using a default scale of 4) and writes it to the stringbuffer at the current position and increments the current position to the next byte after the data that was written. If necessary, the interna buffer will grow to accommodate the new data.
Returns a pointer to "this" to enable chaining such as: sb->write("numbers: ")->write(5)->write(5.5);
stringbuffer* stringbuffer::write | ( | float | number, |
uint16_t | scale | ||
) |
Converts "number" to a string using the specified "scale" and writes it to the stringbuffer 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 a pointer to "this" to enable chaining such as: sb->write("numbers: ")->write(5)->write(5.5);
stringbuffer* stringbuffer::write | ( | float | number, |
uint16_t | precision, | ||
uint16_t | scale | ||
) |
Converts "number" to a string using the specified "precision" and "scale" and writes it to the stringbuffer 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 a pointer to "this" to enable chaining such as: sb->write("numbers: ")->write(5)->write(5.5);
stringbuffer* stringbuffer::write | ( | double | number | ) |
Converts "number" to a string (using a default scale of 4) and writes it to the stringbuffer 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 a pointer to "this" to enable chaining such as: sb->write("numbers: ")->write(5)->write(5.5);
stringbuffer* stringbuffer::write | ( | double | number, |
uint16_t | scale | ||
) |
Converts "number" to a string using the specified "scale" and writes it to the stringbuffer 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 a pointer to "this" to enable chaining such as: sb->write("numbers: ")->write(5)->write(5.5);
stringbuffer* stringbuffer::write | ( | double | number, |
uint16_t | precision, | ||
uint16_t | scale | ||
) |
Converts "number" to a string using the specified "precision" and "scale" and writes it to the stringbuffer 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 a pointer to "this" to enable chaining such as: sb->write("numbers: ")->write(5)->write(5.5);