View source code
Display the source code in std/format.d from which this
page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a
Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Function std.format.formattedRead
Reads characters from input range
r
, converts them according to fmt
, and writes them to args
.
uint formattedRead(alias fmt, R, S...)
(
auto ref R r,
auto ref S args
)
if (isSomeString!(typeof(fmt)));
uint formattedRead(R, Char, S...)
(
auto ref R r,
const(Char)[] fmt,
auto ref S args
);
Parameters
Name | Description |
---|---|
r | The range to read from. |
fmt | The format of the data to read. |
args | The drain of the data read. |
Returns
On success, the function returns the number of variables filled. This count can match the expected number of readings or fewer, even zero, if a matching failure happens.
Throws
A FormatException
if S
and fmt
has format specifiers.
Example
The format string can be checked at compile-time (see format
for details):
string s = "hello!124:34.5";
string a;
int b;
double c;
s .formattedRead!"%s!%s:%s"(a, b, c);
assert(a == "hello" && b == 124 && c == 34.5);
Authors
Walter Bright, Andrei Alexandrescu, and Kenji Hara
License
Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.