A StringFormatter which stores the output text in a specified buffer. More...
#include <stringf.h>

Public Member Functions | |
| StringBufferFormatter (char *buffer, size_t size) | |
| virtual void | Out (const char *text, size_t textSize) |
| virtual void | Out (char character, size_t repeatCount) |
| char * | End () |
Protected Attributes | |
| char * | BufferStart |
| Start of buffer used to store text. | |
| char * | BufferEnd |
| End of buffer used to store text. (The address immediately after the last byte.). | |
| char * | BufferPtr |
| Address to store the next byte of text to be 'output'. | |
A StringFormatter which stores the output text in a specified buffer.
Example useage:
char buffer[100]; StringBufferFormatter formatter(buffer,sizeof(buffer)); formatter.Format("Part %d,",1); formatter.Format("and append a %s part","second"); char* end = formatter.End(); // appends NUL (if room) and resets formatter for new string size_t stringLength = end-buffer;
Important note: the produced string will only have a terminating null character if the produced text has a size less than the size of the buffer.
Definition at line 366 of file stringf.h.
| StringBufferFormatter::StringBufferFormatter | ( | char * | buffer, | |
| size_t | size | |||
| ) |
| buffer | Address of the buffer to store the generated text in. | |
| size | Size of buffer. |
Definition at line 633 of file stringf.cpp.
| void StringBufferFormatter::Out | ( | const char * | text, | |
| size_t | textSize | |||
| ) | [virtual] |
Called to 'output' generated text.
| text | Pointer to text. | |
| textSize | Size of text. |
Implements StringFormatter.
Definition at line 644 of file stringf.cpp.
| void StringBufferFormatter::Out | ( | char | character, | |
| size_t | repeatCount | |||
| ) | [virtual] |
Called to 'output' a repeated single character.
| character | The character to output. | |
| repeatCount | Number of times character should be output. |
Implements StringFormatter.
Definition at line 656 of file stringf.cpp.
| char * StringBufferFormatter::End | ( | ) |
Terminate text generation.
This appends a null character after the end of the generated text (if there is space in the buffer) and sets the buffer state to be empty.
Definition at line 668 of file stringf.cpp.
1.6.1