FReadFmt
Description
Read formatted data from a file stream. Delegates to the in-tree file formatted-read backend.
Parameters
| Name | Direction | Description |
|---|---|---|
stream |
in | Pointer to the File to read from. |
fmtstr |
in | Format string to be used for reading. This must exactly describe the expected input format in the stream. argument should be a modifiable l-value wrapped with &variable. |
Success
Attempts to match fmtstr with the stream of characters in stream and reads values into the provided arguments.
Failure
Failure occurs within the file formatted-read backend (logs error message and returns, may roll back read data, or abort in unexpected situations).
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Io.h:732:
do { \
File UNPL(in) = FileStdin(); \
FReadFmt(&UNPL(in), __VA_ARGS__); \
} while (0)- In
Write.c:4195:
i32 v = 0;
FReadFmt(&f, "{}", v);
ok = ok && (v == 42);
// Seekable branch advances to exactly the consumed bytes ("42").
- In
Write.c:4220:
i32 v = -1;
FReadFmt(&f, "{}", v);
ok = ok && (v == 7);- In
Write.c:4245:
i32 v = 0;
FReadFmt(&f, "{}", v);
ok = ok && (v == 53);
ok = ok && (FileTell(&f) == 2);- In
Read.c:1657:
i32 v = -1;
FReadFmt(&f, "{}", v);
ok = ok && (v == 91);- In
Read.c:1678:
i32 v = 1234;
FReadFmt(&f, "{}", v);
ok = ok && (v == 1234); // untouched
ok = ok && (FileTell(&f) == 0); // no advance
- In
Read.c:2689:
FileSeek(&f, 0, FILE_SEEK_SET);
i32 v = 0;
FReadFmt(&f, "{}", v);
ok = (v == 42);
FileClose(&f);- In
Read.c:2711:
FileSeek(&f, 0, FILE_SEEK_SET);
i32 v = 123;
FReadFmt(&f, "{}", v); // fails -> rollback
// position must still be 0: read the first raw byte.
char c = 0;
Last updated on