casa
5.7.0-16
|
#include <optionparser.h>
Public Member Functions | |
void | flush (IStringWriter &write) |
Writes out all remaining data from the LineWrapper using write . More... | |
void | process (IStringWriter &write, const char *data, int len) |
Process, wrap and output the next piece of data. More... | |
LineWrapper (int x1, int x2) | |
Constructs a LineWrapper that wraps its output to fit into screen columns x1 (incl.) to x2 (excl.). More... | |
Private Member Functions | |
bool | buf_empty () |
bool | buf_full () |
void | buf_store (const char *data, int len) |
void | buf_next () |
! More... | |
void | output (IStringWriter &write, const char *data, int len) |
Writes (data,len) into the ring buffer. More... | |
void | write_one_line (IStringWriter &write) |
Writes a single line of output from the buffer to write . More... | |
Private Attributes | |
int | lenbuf [bufmask+1] |
Ring buffer for length component of pair (data, length). More... | |
const char * | datbuf [bufmask+1] |
Ring buffer for data component of pair (data, length). More... | |
int | x |
The indentation of the column to which the LineBuffer outputs. More... | |
int | width |
The width of the column to line wrap. More... | |
int | head |
index for next write More... | |
int | tail |
index for next read - 1 (i.e. increment tail BEFORE read) More... | |
bool | wrote_something |
Multiple methods of LineWrapper may decide to flush part of the buffer to free up space. More... | |
Static Private Attributes | |
static const int | bufmask |
Must be a power of 2 minus 1. More... | |
Definition at line 2225 of file optionparser.h.
|
inline |
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 2434 of file optionparser.h.
References width.
|
inlineprivate |
Definition at line 2259 of file optionparser.h.
References bufmask, head, and tail.
Referenced by flush(), and write_one_line().
|
inlineprivate |
|
inlineprivate |
!
Call BEFORE reading...buf[tail].
Definition at line 2277 of file optionparser.h.
Referenced by write_one_line().
|
inlineprivate |
Definition at line 2269 of file optionparser.h.
References bufmask, casa::data, datbuf, head, and lenbuf.
Referenced by output().
|
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 2321 of file optionparser.h.
References buf_empty(), option::PrintUsageImplementation::indent(), write(), write_one_line(), wrote_something, and x.
Referenced by option::PrintUsageImplementation::printUsage().
|
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 2286 of file optionparser.h.
References buf_full(), buf_store(), and write_one_line().
Referenced by process().
|
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. |
int __builtin_clz (unsigned int x) Returns the number of leading 0-bits in x, starting at the most significant bit
ch is the decoded unicode code point
data[maxi-1] is the last byte of the UTF-8 sequence of the last character that fits onto the 1st line. If maxi == len, all characters fit on the line.
Definition at line 2351 of file optionparser.h.
References option::PrintUsageImplementation::isWideChar(), casacore::mask(), output(), width, write_one_line(), and wrote_something.
Referenced by option::PrintUsageImplementation::printUsage().
|
inlineprivate |
Writes a single line of output from the buffer to write
.
Definition at line 2297 of file optionparser.h.
References buf_empty(), buf_next(), datbuf, option::PrintUsageImplementation::indent(), lenbuf, tail, write(), wrote_something, and x.
|
staticprivate |
Must be a power of 2 minus 1.
Definition at line 2227 of file optionparser.h.
Referenced by buf_empty(), buf_next(), and buf_store().
|
private |
Ring buffer for data component of pair (data, length).
Definition at line 2235 of file optionparser.h.
Referenced by buf_store(), and write_one_line().
|
private |
index for next write
Definition at line 2247 of file optionparser.h.
Referenced by buf_empty(), buf_full(), and buf_store().
|
private |
Ring buffer for length component of pair (data, length).
Definition at line 2231 of file optionparser.h.
Referenced by buf_store(), and write_one_line().
|
private |
index for next read - 1 (i.e. increment tail BEFORE read)
Definition at line 2248 of file optionparser.h.
Referenced by buf_empty(), buf_full(), buf_next(), and write_one_line().
|
private |
The width of the column to line wrap.
Definition at line 2246 of file optionparser.h.
Referenced by LineWrapper(), and process().
|
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 2257 of file optionparser.h.
Referenced by flush(), process(), and write_one_line().
|
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 2242 of file optionparser.h.
Referenced by flush(), and write_one_line().