std.format.spec

This is a submodule of std.format.

It centers around a struct called FormatSpec, which takes a

format string and provides tools for

parsing this string. Additionally this module contains a function

singleSpec which helps treating a single format specifier.

Types 1

structFormatSpec(Char) if (is(Unqual!Char == Char))

A general handler for format strings.

This handler centers around the function writeUpToNextSpec, which parses the format string until the next format specifier is found. After the call, it provides information about this format specifier in its numerous variables.

Parameters

Charthe character type of the format string
Fields
int widthMinimum width.
int precisionPrecision. Its semantic depends on the format character.
int separatorsNumber of elements between separators.
bool dynamicSeparatorCharThe separator charactar is supplied at runtime.
dchar separatorCharCharacter to use as separator.
int DYNAMICSpecial value for `width`, `precision` and `separators`.
int UNSPECIFIEDSpecial value for `precision` and `separators`.
char specThe format character.
ushort indexStartIndex of the argument for positional parameters.
ushort indexEndIndex of the last argument for positional parameter ranges.
const(Char)[] nestedThe inner format string of a nested format specifier.
const(Char)[] sepThe separator of a nested format specifier.
const(Char)[] trailingContains the part of the format string, that has not yet been parsed.
immutable(Char)[] seqBeforeSequence `"["` inserted before each range or range like structure.
immutable(Char)[] seqAfterSequence `"]"` inserted after each range or range like structure.
immutable(Char)[] keySeparatorSequence `":"` inserted between element key and element value of an associative array.
immutable(Char)[] seqSeparatorSequence `", "` inserted between elements of a range, a range like structure or the elements of an associative array.
Methods
int separatorCharPos()Set to `DYNAMIC` when the separator character is supplied at runtime.
void separatorCharPos(int value)ditto
bool writeUpToNextSpec(OutputRange)(ref OutputRange writer) scopeWrites the format string to an output range until the next format specifier is found and parse that format specifier.
private void fillUp() scope
bool readUpToNextSpec(R)(ref R r) scope
string getCurFmtStr() const
string toString() const @safe pureProvides a string representation.
void toString(OutputRange)(ref OutputRange writer) if (isOutputRange!(OutputRange, char)) constWrites a string representation to an output range.
Constructors
this(in Char[] fmt)Creates a new `FormatSpec`.

Functions 2

fnFormatSpec!Char singleSpec(Char)(Char[] fmt)Helper function that returns a `FormatSpec` for a single format specifier.
fnvoid enforceValidFormatSpec(T, Char)(scope const ref FormatSpec!Char f)
deprecated enforceValidFormatSpec was accidentally made public and will be removed in 2.107.0

Templates 1

tmplFormatSpec(Char) if (!is(Unqual!Char == Char))