Rudiments
Public Member Functions | List of all members
stringbuffer Class Reference

Inherits bytebuffer.

Public Member Functions

 stringbuffer ()
 
 stringbuffer (size_t initialsize)
 
 stringbuffer (char *initialcontents, size_t initialsize)
 
 stringbuffer (const stringbuffer &s)
 
stringbufferoperator= (const stringbuffer &s)
 
 ~stringbuffer ()
 
void setPosition (size_t pos)
 
size_t getPosition ()
 
ssize_t write (const unsigned char *string)
 
ssize_t write (const unsigned char *string, size_t size)
 
ssize_t write (const char *string)
 
ssize_t write (const char *string, size_t size)
 
ssize_t write (char character)
 
ssize_t write (int16_t number)
 
ssize_t write (int32_t number)
 
ssize_t write (int64_t number)
 
ssize_t write (unsigned char character)
 
ssize_t write (uint16_t number)
 
ssize_t write (uint32_t number)
 
ssize_t write (uint64_t number)
 
ssize_t write (float number)
 
ssize_t write (float number, uint16_t scale)
 
ssize_t write (float number, uint16_t precision, uint16_t scale)
 
ssize_t write (double number)
 
ssize_t write (double number, uint16_t scale)
 
ssize_t write (double number, uint16_t precision, uint16_t scale)
 
stringbufferappend (const unsigned char *string)
 
stringbufferappend (const unsigned char *string, size_t size)
 
stringbufferappend (const char *string)
 
stringbufferappend (const char *string, size_t size)
 
stringbufferappend (char character)
 
stringbufferappend (int16_t number)
 
stringbufferappend (int32_t number)
 
stringbufferappend (int64_t number)
 
stringbufferappend (unsigned char character)
 
stringbufferappend (uint16_t number)
 
stringbufferappend (uint32_t number)
 
stringbufferappend (uint64_t number)
 
stringbufferappend (int16_t number, uint16_t zeropadding)
 
stringbufferappend (int32_t number, uint16_t zeropadding)
 
stringbufferappend (int64_t number, uint16_t zeropadding)
 
stringbufferappend (uint16_t number, uint16_t zeropadding)
 
stringbufferappend (uint32_t number, uint16_t zeropadding)
 
stringbufferappend (uint64_t number, uint16_t zeropadding)
 
stringbufferappend (float number)
 
stringbufferappend (float number, uint16_t scale)
 
stringbufferappend (float number, uint16_t precision, uint16_t scale)
 
stringbufferappend (double number)
 
stringbufferappend (double number, uint16_t scale)
 
stringbufferappend (double number, uint16_t precision, uint16_t scale)
 
void truncate (size_t pos)
 
void truncate ()
 
void clear ()
 
void clear (size_t initialsize)
 
void clear (char *initialcontents, size_t initialsize)
 
const char * getString ()
 
char * detachString ()
 
size_t getStringLength ()
 
- Public Member Functions inherited from bytebuffer
 bytebuffer ()
 
 bytebuffer (size_t initialsize)
 
 bytebuffer (unsigned char *initialcontents, size_t initialsize)
 
 bytebuffer (const bytebuffer &v)
 
bytebufferoperator= (const bytebuffer &v)
 
virtual ~bytebuffer ()
 
void setPosition (size_t pos)
 
size_t getPosition ()
 
ssize_t writeFormatted (const char *format,...)
 
ssize_t writeFormatted (const char *format, va_list *argp)
 
bytebufferappend (const unsigned char *data, size_t size)
 
bytebufferappend (const char *string, size_t size)
 
bytebufferappend (const char *string)
 
bytebufferappend (char character)
 
bytebufferappend (int16_t number)
 
bytebufferappend (int32_t number)
 
bytebufferappend (int64_t number)
 
bytebufferappend (unsigned char character)
 
bytebufferappend (uint16_t number)
 
bytebufferappend (uint32_t number)
 
bytebufferappend (uint64_t number)
 
bytebufferappend (float number)
 
bytebufferappend (double number)
 
bytebufferappendFormatted (const char *format,...)
 
bytebufferappendFormatted (const char *format, va_list *argp)
 
ssize_t read (unsigned char *data, size_t size)
 
void clear ()
 
void clear (size_t initialsize)
 
void clear (unsigned char *initialcontents, size_t initialsize)
 
const unsigned char * getBuffer ()
 
size_t getSize ()
 
size_t getActualSize ()
 
size_t getInitialSize ()
 
unsigned char * detachBuffer ()
 
- Public Member Functions inherited from output
virtual ssize_t write (const unsigned char *string, size_t size, int32_t sec, int32_t usec)
 
virtual ssize_t write (const char *string, int32_t sec, int32_t usec)
 
virtual ssize_t write (const char *string, size_t size, int32_t sec, int32_t usec)
 
virtual ssize_t write (char character, int32_t sec, int32_t usec)
 
virtual ssize_t write (int16_t number, int32_t sec, int32_t usec)
 
virtual ssize_t write (int32_t number, int32_t sec, int32_t usec)
 
virtual ssize_t write (int64_t number, int32_t sec, int32_t usec)
 
virtual ssize_t write (unsigned char character, int32_t sec, int32_t usec)
 
virtual ssize_t write (uint16_t number, int32_t sec, int32_t usec)
 
virtual ssize_t write (uint32_t number, int32_t sec, int32_t usec)
 
virtual ssize_t write (uint64_t number, int32_t sec, int32_t usec)
 
virtual ssize_t write (float number, int32_t sec, int32_t usec)
 
virtual ssize_t write (double number, int32_t sec, int32_t usec)
 

Detailed Description

The stringbuffer class can be used to store strings of arbitrary length.

It is generally more efficient to reuse the same stringbuffer over and over than to allocate a new one for each operation.

Constructor & Destructor Documentation

◆ stringbuffer() [1/4]

stringbuffer::stringbuffer ( )
inline

Creates an instance of the stringbuffer class with default initial size.

◆ stringbuffer() [2/4]

stringbuffer::stringbuffer ( size_t  initialsize)
inline

Creates an instance of the stringbuffer class with the specified "initialsize".

◆ stringbuffer() [3/4]

stringbuffer::stringbuffer ( char *  initialcontents,
size_t  initialsize 
)
inline

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 may be specified by the "initialsize" parameter.

◆ stringbuffer() [4/4]

stringbuffer::stringbuffer ( const stringbuffer s)
inline

Creates an instance of the stringbuffer class that is a copy of "s".

◆ ~stringbuffer()

stringbuffer::~stringbuffer ( )
inline

Deletes this instance of the stringbuffer class.

Member Function Documentation

◆ append() [1/24]

stringbuffer * stringbuffer::append ( const unsigned char *  string)
inline

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);

◆ append() [2/24]

stringbuffer * stringbuffer::append ( const unsigned char *  string,
size_t  size 
)
inline

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);

◆ append() [3/24]

stringbuffer * stringbuffer::append ( const char *  string)
inline

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);

◆ append() [4/24]

stringbuffer * stringbuffer::append ( const char *  string,
size_t  size 
)
inline

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);

◆ append() [5/24]

stringbuffer * stringbuffer::append ( char  character)
inline

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);

◆ append() [6/24]

stringbuffer * stringbuffer::append ( int16_t  number)
inline

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);

◆ append() [7/24]

stringbuffer * stringbuffer::append ( int32_t  number)
inline

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);

◆ append() [8/24]

stringbuffer * stringbuffer::append ( int64_t  number)
inline

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);

◆ append() [9/24]

stringbuffer * stringbuffer::append ( unsigned char  character)
inline

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);

◆ append() [10/24]

stringbuffer * stringbuffer::append ( uint16_t  number)
inline

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);

◆ append() [11/24]

stringbuffer * stringbuffer::append ( uint32_t  number)
inline

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);

◆ append() [12/24]

stringbuffer * stringbuffer::append ( uint64_t  number)
inline

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);

◆ append() [13/24]

stringbuffer * stringbuffer::append ( int16_t  number,
uint16_t  zeropadding 
)
inline

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);

◆ append() [14/24]

stringbuffer * stringbuffer::append ( int32_t  number,
uint16_t  zeropadding 
)
inline

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);

◆ append() [15/24]

stringbuffer * stringbuffer::append ( int64_t  number,
uint16_t  zeropadding 
)
inline

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);

◆ append() [16/24]

stringbuffer * stringbuffer::append ( uint16_t  number,
uint16_t  zeropadding 
)
inline

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);

◆ append() [17/24]

stringbuffer * stringbuffer::append ( uint32_t  number,
uint16_t  zeropadding 
)
inline

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);

◆ append() [18/24]

stringbuffer * stringbuffer::append ( uint64_t  number,
uint16_t  zeropadding 
)
inline

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);

◆ append() [19/24]

stringbuffer * stringbuffer::append ( float  number)
inline

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);

◆ append() [20/24]

stringbuffer * stringbuffer::append ( float  number,
uint16_t  scale 
)
inline

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);

◆ append() [21/24]

stringbuffer * stringbuffer::append ( float  number,
uint16_t  precision,
uint16_t  scale 
)
inline

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);

◆ append() [22/24]

stringbuffer * stringbuffer::append ( double  number)
inline

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);

◆ append() [23/24]

stringbuffer * stringbuffer::append ( double  number,
uint16_t  scale 
)
inline

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);

◆ append() [24/24]

stringbuffer * stringbuffer::append ( double  number,
uint16_t  precision,
uint16_t  scale 
)
inline

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);

◆ clear() [1/3]

void stringbuffer::clear ( )
inline

Empties the stringbuffer.

◆ clear() [2/3]

void stringbuffer::clear ( size_t  initialsize)
inline

Empties the bytebuffer and resets the specified "initialsize" parameter.

◆ clear() [3/3]

void stringbuffer::clear ( char *  initialcontents,
size_t  initialsize 
)
inline

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" parameter.

◆ detachString()

char * stringbuffer::detachString ( )
inline

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.

◆ getPosition()

size_t stringbuffer::getPosition ( )
inline

Returns the position in the internal buffer at which the next write will occur.

◆ getString()

const char * stringbuffer::getString ( )
inline

Returns the string currently stored in the stringbuffer.

◆ getStringLength()

size_t stringbuffer::getStringLength ( )
inline

Returns the length of the string currently stored in the stringbuffer.

◆ operator=()

stringbuffer & stringbuffer::operator= ( const stringbuffer s)
inline

Makes this instance of the stringbuffer class identical to "s".

◆ setPosition()

void stringbuffer::setPosition ( size_t  pos)
inline

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.

◆ truncate() [1/2]

void stringbuffer::truncate ( size_t  pos)
inlinevirtual

Trucnates the stringbuffer at position "pos".

Reimplemented from bytebuffer.

◆ truncate() [2/2]

void stringbuffer::truncate ( )
inlinevirtual

Trucnates the stringbuffer at the current position.

Reimplemented from bytebuffer.

◆ write() [1/18]

ssize_t stringbuffer::write ( const unsigned char *  string)
inline

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);

◆ write() [2/18]

ssize_t stringbuffer::write ( const unsigned char *  string,
size_t  size 
)
inlinevirtual

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);

Reimplemented from bytebuffer.

◆ write() [3/18]

ssize_t stringbuffer::write ( const char *  string)
inlinevirtual

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);

Reimplemented from bytebuffer.

◆ write() [4/18]

ssize_t stringbuffer::write ( const char *  string,
size_t  size 
)
inlinevirtual

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);

Reimplemented from bytebuffer.

◆ write() [5/18]

ssize_t stringbuffer::write ( char  character)
inlinevirtual

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);

Reimplemented from bytebuffer.

◆ write() [6/18]

ssize_t stringbuffer::write ( int16_t  number)
inlinevirtual

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);

Reimplemented from bytebuffer.

◆ write() [7/18]

ssize_t stringbuffer::write ( int32_t  number)
inlinevirtual

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);

Reimplemented from bytebuffer.

◆ write() [8/18]

ssize_t stringbuffer::write ( int64_t  number)
inlinevirtual

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);

Reimplemented from bytebuffer.

◆ write() [9/18]

ssize_t stringbuffer::write ( unsigned char  character)
inlinevirtual

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);

Reimplemented from bytebuffer.

◆ write() [10/18]

ssize_t stringbuffer::write ( uint16_t  number)
inlinevirtual

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);

Reimplemented from bytebuffer.

◆ write() [11/18]

ssize_t stringbuffer::write ( uint32_t  number)
inlinevirtual

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);

Reimplemented from bytebuffer.

◆ write() [12/18]

ssize_t stringbuffer::write ( uint64_t  number)
inlinevirtual

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);

Reimplemented from bytebuffer.

◆ write() [13/18]

ssize_t stringbuffer::write ( float  number)
inlinevirtual

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);

Reimplemented from bytebuffer.

◆ write() [14/18]

ssize_t stringbuffer::write ( float  number,
uint16_t  scale 
)
inline

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);

◆ write() [15/18]

ssize_t stringbuffer::write ( float  number,
uint16_t  precision,
uint16_t  scale 
)
inline

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);

◆ write() [16/18]

ssize_t stringbuffer::write ( double  number)
inlinevirtual

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);

Reimplemented from bytebuffer.

◆ write() [17/18]

ssize_t stringbuffer::write ( double  number,
uint16_t  scale 
)
inline

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);

◆ write() [18/18]

ssize_t stringbuffer::write ( double  number,
uint16_t  precision,
uint16_t  scale 
)
inline

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);