A simple string buffer class that allows for dynamic resizing.
More...
#include <stringBuffer.h>
|
| | 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 long | sbDefaultLength = 16 |
|
static long | sbDefaultBoost = 16 |
A simple string buffer class that allows for dynamic resizing.
◆ 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.
◆ appendBuffer()
| void StringBuffer::appendBuffer |
( |
const char * | buffer, |
|
|
const long | length = -1 ) |
Append a C string to the string buffer.
- Parameters
-
| buffer | The C string to append. |
| length | The 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
-
| buffer | The string or character buffer to append. |
| length | The 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
-
| c | The character to append. |
Appends a single character to the end of the buffer, growing the buffer if needed.
- Parameters
-
| c | The 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
-
| i | The 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
-
| newL | The 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
-
| i | The index to set the character at. |
| c | The character to set. |
- Returns
- char The character that was previously at the index.
◆ swap()
Swap the contents of this string buffer with another.
- Parameters
-
| other | The 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
-
The documentation for this class was generated from the following files: