Definition at line 2212 of file OptionParser.h.
Public Member Functions | |
LineWrapper (int x1, int x2) | |
Constructs a LineWrapper that wraps its output to fit into screen columns x1 (incl.) to x2 (excl.). | |
void | flush (IStringWriter &write) |
Writes out all remaining data from the LineWrapper using write . | |
void | process (IStringWriter &write, const char *data, int len) |
Process, wrap and output the next piece of data. | |
Private Member Functions | |
bool | buf_empty () |
bool | buf_full () |
void | buf_next () |
Call BEFORE reading ...buf[tail]. | |
void | buf_store (const char *data, int len) |
void | output (IStringWriter &write, const char *data, int len) |
Writes (data,len) into the ring buffer. | |
void | write_one_line (IStringWriter &write) |
Writes a single line of output from the buffer to write . | |
Private Attributes | |
const char * | datbuf [bufmask+1] |
Ring buffer for data component of pair (data, length). | |
int | head |
index for next write | |
int | lenbuf [bufmask+1] |
Ring buffer for length component of pair (data, length). | |
int | tail |
index for next read - 1 (i.e. | |
int | width |
The width of the column to line wrap. | |
bool | wrote_something |
Multiple methods of LineWrapper may decide to flush part of the buffer to free up space. | |
int | x |
The indentation of the column to which the LineBuffer outputs. | |
Static Private Attributes | |
static const int | bufmask = 15 |
Must be a power of 2 minus 1. | |
Constructs a LineWrapper that wraps its output to fit into screen columns x1
(incl.) to x2
(excl.).
x1
gives the indentation LineWrapper uses if it needs to indent.
Definition at line 2421 of file OptionParser.h.
|
inlineprivate |
Definition at line 2246 of file OptionParser.h.
|
inlineprivate |
Definition at line 2251 of file OptionParser.h.
|
inlineprivate |
Call BEFORE reading ...buf[tail].
Definition at line 2264 of file OptionParser.h.
|
inlineprivate |
Definition at line 2256 of file OptionParser.h.
|
inline |
Writes out all remaining data from the LineWrapper using write
.
Unlike process() this method indents all lines including the first and will output a \n at the end (but only if something has been written).
Definition at line 2308 of file OptionParser.h.
|
inlineprivate |
Writes (data,len) into the ring buffer.
If the buffer is full, a single line is flushed out of the buffer into write
.
Definition at line 2273 of file OptionParser.h.
|
inline |
Process, wrap and output the next piece of data.
process() will output at least one line of output. This is not necessarily the data
passed in. It may be data queued from a prior call to process(). If the internal buffer is full, more than 1 line will be output.
process() assumes that the a proper amount of indentation has already been output. It won't write any further indentation before the 1st line. If more than 1 line is written due to buffer constraints, the lines following the first will be indented by this method, though.
No \n is written by this method after the last line that is written.
write | where to write the data. |
data | the new chunk of data to write. |
len | the length of the chunk of data to write. |
Definition at line 2338 of file OptionParser.h.
|
inlineprivate |
Writes a single line of output from the buffer to write
.
Definition at line 2284 of file OptionParser.h.
|
staticprivate |
Must be a power of 2 minus 1.
Definition at line 2214 of file OptionParser.h.
|
private |
Ring buffer for data component of pair (data, length).
Definition at line 2222 of file OptionParser.h.
|
private |
index for next write
Definition at line 2234 of file OptionParser.h.
Ring buffer for length component of pair (data, length).
Definition at line 2218 of file OptionParser.h.
|
private |
index for next read - 1 (i.e.
increment tail BEFORE read)
Definition at line 2235 of file OptionParser.h.
|
private |
The width of the column to line wrap.
Definition at line 2233 of file OptionParser.h.
|
private |
Multiple methods of LineWrapper may decide to flush part of the buffer to free up space.
The contract of process() says that only 1 line is output. So this variable is used to track whether something has output a line. It is reset at the beginning of process() and checked at the end to decide if output has already occurred or is still needed.
Definition at line 2244 of file OptionParser.h.
|
private |
The indentation of the column to which the LineBuffer outputs.
LineBuffer assumes that the indentation has already been written when process() is called, so this value is only used when a buffer flush requires writing additional lines of output.
Definition at line 2229 of file OptionParser.h.