The class Stringbuffer composes single characters into a longer text that can be processed on block.
More...
#include <stringbuffer.h>
|
virtual | ~Stringbuffer () |
| Destructor (nothing to do here)
|
|
|
| Stringbuffer () |
| Constructor; Marks the buffer as empty.
|
|
void | put (char c) |
| Inserts a character into the buffer. More...
|
|
virtual void | flush ()=0 |
| Flush the buffer contents. More...
|
|
|
char | buffer [80+1] |
|
long unsigned | pos |
| current position in the buffer
|
|
The class Stringbuffer composes single characters into a longer text that can be processed on block.
To make Stringbuffer as versatile as possible, the class does make assumptions about neither the underlying hardware, nor the meaning of "processing". When flush() is called (i.e., either on explicit request or once the buffer is full). To be hardware independent, flush() is to be implemented by the derived classes.
- Hints for Implementation
- Use a buffer of fixed size for caching characters, which should be accessible by derived classes. Keep in mind that the derived implementation of flush() will need to know about numbers of characters in the buffer.
- Notes
- Reason for the existence of this class is that generating longer texts is often implemented by assembly of small fragments (such as single characters or numbers). However, writing such small fragments directly to (for example) screen is quite inefficient (e.g., due to the use of IO ports, syscalls, or locks) and can be improved drastically by delaying the output step until the assembly is finished (or the buffer runs full).
◆ flush()
virtual void Stringbuffer::flush |
( |
| ) |
|
|
protectedpure virtual |
◆ put()
void Stringbuffer::put |
( |
char |
c | ) |
|
|
protected |
Inserts a character into the buffer.
Once the buffer is full, a call to flush() will be issued and thereby clearing the buffer.
- Parameters
-
◆ buffer
char Stringbuffer::buffer[80+1] |
|
protected |
buffer containing characters that will be printed upon flush() put() keeps this buffer always '\0'-terminated
The documentation for this class was generated from the following files: