Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ROOT::option::PrintUsageImplementation::LineWrapper Class Reference

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.
 

#include </home/sftnight/build/workspace/root-makedoc-v626/rootspi/rdoc/src/v6-26-00-patches/core/dictgen/res/OptionParser.h>

Constructor & Destructor Documentation

◆ LineWrapper()

ROOT::option::PrintUsageImplementation::LineWrapper::LineWrapper ( int  x1,
int  x2 
)
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 2421 of file OptionParser.h.

Member Function Documentation

◆ buf_empty()

bool ROOT::option::PrintUsageImplementation::LineWrapper::buf_empty ( )
inlineprivate

Definition at line 2246 of file OptionParser.h.

◆ buf_full()

bool ROOT::option::PrintUsageImplementation::LineWrapper::buf_full ( )
inlineprivate

Definition at line 2251 of file OptionParser.h.

◆ buf_next()

void ROOT::option::PrintUsageImplementation::LineWrapper::buf_next ( )
inlineprivate

Call BEFORE reading ...buf[tail].

Definition at line 2264 of file OptionParser.h.

◆ buf_store()

void ROOT::option::PrintUsageImplementation::LineWrapper::buf_store ( const char *  data,
int  len 
)
inlineprivate

Definition at line 2256 of file OptionParser.h.

◆ flush()

void ROOT::option::PrintUsageImplementation::LineWrapper::flush ( IStringWriter write)
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.

◆ output()

void ROOT::option::PrintUsageImplementation::LineWrapper::output ( IStringWriter write,
const char *  data,
int  len 
)
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.

◆ process()

void ROOT::option::PrintUsageImplementation::LineWrapper::process ( IStringWriter write,
const char *  data,
int  len 
)
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.

Parameters
writewhere to write the data.
datathe new chunk of data to write.
lenthe length of the chunk of data to write.

Definition at line 2338 of file OptionParser.h.

◆ write_one_line()

void ROOT::option::PrintUsageImplementation::LineWrapper::write_one_line ( IStringWriter write)
inlineprivate

Writes a single line of output from the buffer to write.

Definition at line 2284 of file OptionParser.h.

Member Data Documentation

◆ bufmask

const int ROOT::option::PrintUsageImplementation::LineWrapper::bufmask = 15
staticprivate

Must be a power of 2 minus 1.

Definition at line 2214 of file OptionParser.h.

◆ datbuf

const char* ROOT::option::PrintUsageImplementation::LineWrapper::datbuf[bufmask+1]
private

Ring buffer for data component of pair (data, length).

Definition at line 2222 of file OptionParser.h.

◆ head

int ROOT::option::PrintUsageImplementation::LineWrapper::head
private

index for next write

Definition at line 2234 of file OptionParser.h.

◆ lenbuf

int ROOT::option::PrintUsageImplementation::LineWrapper::lenbuf[bufmask+1]
private

Ring buffer for length component of pair (data, length).

Definition at line 2218 of file OptionParser.h.

◆ tail

int ROOT::option::PrintUsageImplementation::LineWrapper::tail
private

index for next read - 1 (i.e.

increment tail BEFORE read)

Definition at line 2235 of file OptionParser.h.

◆ width

int ROOT::option::PrintUsageImplementation::LineWrapper::width
private

The width of the column to line wrap.

Definition at line 2233 of file OptionParser.h.

◆ wrote_something

bool ROOT::option::PrintUsageImplementation::LineWrapper::wrote_something
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.

◆ x

int ROOT::option::PrintUsageImplementation::LineWrapper::x
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.

  • core/dictgen/res/OptionParser.h