std.format.read
This is a submodule of std.format.
It provides two functions for reading formatted input: unformatValue and formattedRead. The former reads a single value. The latter reads several values at once and matches the characters found between format specifiers.
Parameters are ignored, except for the ones consisting of a single
'*'. See formattedRead for more information.A space outside of a format specifier has a special meaning: it matches any sequence of whitespace characters, not just a single space.
The following combinations of format characters and types are available:
Below are highlighted examples on how these combinations are used with unformatValue, however, they apply for formattedRead also
Copyright
Functions 3
uint formattedRead(Range, Char, Args...)(auto ref Range r, const(Char)[] fmt, auto ref Args args)Reads an input range according to a format string and stores the read values into its arguments.uint formattedRead(alias fmt, Range, Args...)(auto ref Range r, auto ref Args args) if (!isType!fmt && isSomeString!(typeof(fmt)))dittoT unformatValue(T, Range, Char)(ref Range input, scope const ref FormatSpec!Char spec)Reads a value from the given input range and converts it according to a format specifier.Templates 2
if (Args.length && allSatisfy!(isType, Args))Reads an input range according to a format string and returns a tuple of Args with the read values.
Format specifiers with format character 'd', 'u' and 'c' can take a '*' parameter for skipping values.
The second version of formattedRead takes the format string as template argument. In this case, it is checked for consistency at compile-time.
Parameters
Args | a variadic list of types of the arguments |
Parameters
r | an input range, where the formatted input is read from |
fmt | a format string |
Range | the type of the input range r |
Char | the character type used for fmt |
Returns
Throws
if reading did not succeed.