cawlign 0.0.1
Codon-aware pairwise sequence alignment
Loading...
Searching...
No Matches
StringBuffer Class Reference

A simple string buffer class that allows for dynamic resizing. More...

#include <stringBuffer.h>

Public Member Functions

 StringBuffer (void)
 Construct a new String Buffer object.
 ~StringBuffer (void)
 Destroy the String Buffer object.
char * getString (void) const
 Get the underlying C string.
void appendChar (const char)
 Append a character to the string buffer.
void appendBuffer (const char *, const long=-1)
 Append a C string to the string buffer.
void resetString (void)
 Reset the string buffer to an empty state.
void swap (StringBuffer &)
 Swap the contents of this string buffer with another.
unsigned long length (void) const
 Get the length of the string buffer.
void reset_length (unsigned long newL)
 Reset the length of the string buffer.
char setChar (const long i, const char c)
 Set a character at a specific index.
char getChar (const long i) const
 Get a character at a specific index.
void flip (void)
 Flip the string buffer in place.
void detach (void)
 Detach the underlying C string from the string buffer.

Static Public Attributes

static long sbDefaultLength = 16
static long sbDefaultBoost = 16

Detailed Description

A simple string buffer class that allows for dynamic resizing.

Constructor & Destructor Documentation

◆ StringBuffer()

StringBuffer::StringBuffer ( void )

Construct a new String Buffer object.

Initializes an empty StringBuffer with a default initial capacity. This buffer dynamically grows as new characters are appended.

◆ ~StringBuffer()

StringBuffer::~StringBuffer ( void )

Destroy the String Buffer object.

Frees the memory allocated for the string buffer.

Member Function Documentation

◆ appendBuffer()

void StringBuffer::appendBuffer ( const char * buffer,
const long length = -1 )

Append a C string to the string buffer.

Parameters
bufferThe C string to append.
lengthThe length of the C string to append. If -1, the entire string is appended.

Appends a string or a buffer of specified length to the StringBuffer.

Parameters
bufferThe string or character buffer to append.
lengthThe length of the buffer, if known. If not, the length is inferred using strlen.

◆ appendChar()

void StringBuffer::appendChar ( const char c)

Append a character to the string buffer.

Parameters
cThe character to append.

Appends a single character to the end of the buffer, growing the buffer if needed.

Parameters
cThe character to append.

◆ flip()

void StringBuffer::flip ( void )

Flip the string buffer in place.

Reverses the content of the StringBuffer.

◆ getChar()

char StringBuffer::getChar ( const long i) const
inline

Get a character at a specific index.

Parameters
iThe index to get the character from.
Returns
char The character at the index.

◆ getString()

char * StringBuffer::getString ( void ) const
inline

Get the underlying C string.

Returns
char* A pointer to the underlying C string.

◆ length()

unsigned long StringBuffer::length ( void ) const
inline

Get the length of the string buffer.

Returns
unsigned long The length of the string buffer.

◆ reset_length()

void StringBuffer::reset_length ( unsigned long newL)
inline

Reset the length of the string buffer.

Parameters
newLThe new length of the string buffer.

◆ resetString()

void StringBuffer::resetString ( void )

Reset the string buffer to an empty state.

Resets the StringBuffer to an empty state.

Clears the buffer content by resetting its length, but keeps the allocated memory.

◆ setChar()

char StringBuffer::setChar ( const long i,
const char c )
inline

Set a character at a specific index.

Parameters
iThe index to set the character at.
cThe character to set.
Returns
char The character that was previously at the index.

◆ swap()

void StringBuffer::swap ( StringBuffer & src)

Swap the contents of this string buffer with another.

Parameters
otherThe other string buffer to swap with.

Swaps the contents of this StringBuffer with another StringBuffer.

This function exchanges the data, length, and capacity of two StringBuffer objects.

Parameters
srcThe StringBuffer object to swap with.

The documentation for this class was generated from the following files: