FieldFormat

FieldFormat holds all the formatting info needed to format data values in a specific column. e.g. Field 1 may be text, field 2 may be a float, etc. This is calculated during the caching phase. Each FieldFormat instance is part of a vector representing the full row, so each includes the start position on the line and similar data.

APIs used during the caching phase to gather field value samples - this - Initial construction. Takes the field index. - setHeader - Used to set the header text. - updateForFieldValue - Used to add the next field value sample. - finalizeFormatting - Used at the end of caching to finalize the format choices.

APIs used after caching is finished (after finalizeFormatting): - startPosition - Returns the expected start position for the field. - endPosition - Returns the expected end position for the field. - writeHeader - Outputs the header, properly aligned. - writeFieldValue - Outputs the current field value, properly aligned.

Constructors

this
this(size_t fieldIndex)

Initial construction. Takes a field index.

Members

Functions

endPosition
size_t endPosition()

Returns the expected end position for the field.

fieldType
FieldType fieldType()

Returns the type of field.

finalizeFormatting
size_t finalizeFormatting(size_t startPosition, TsvPrettyOptions options)

Updates field formatting info based on the current state. It is expected to be called after adding field entries via updateForFieldValue(). It returns its new end position.

setHeader
void setHeader(char[] header)

Sets the header text.

startPosition
size_t startPosition()

Returns the expected start position for the field.

updateForFieldValue
void updateForFieldValue(char[] fieldValue, TsvPrettyOptions options)

Updates type and format given a new field value.

writeFieldValue
size_t writeFieldValue(OutputRange!char outputStream, size_t currPosition, char[] fieldValue, TsvPrettyOptions options)

Writes the field value for the current column.

writeHeader
size_t writeHeader(OutputRange!char outputStream, TsvPrettyOptions options)

Writes the field header or underline characters to the output stream.

Meta