Implement read support for file types.
More...
#include <io.hpp>
|
int | getc () |
| Read a single character from the file. More...
|
|
template<typename T > |
std::size_t | read (T &dst) |
| Read the given object from the file. More...
|
|
template<typename T , std::size_t Count> |
std::size_t | read (T(&dst)[Count], std::size_t const count) |
| Read the requested number of objects from the file. More...
|
|
template<auto CountFmt, typename ... RefTs> |
int | scanf (char const (&fmt)[CountFmt], RefTs &... refs) |
| Read formatted input. More...
|
|
template<auto Count> |
bool | gets (char(&dst)[Count]) |
| Read a line from the file. More...
|
|
| operator bool () const |
| Cast to boolean. More...
|
|
bool | eof () const |
| Return whether the file instance is in EOF state. More...
|
|
bool | error () const |
| Return whether the file instance is in an error state. More...
|
|
template<class FileT, feature ... Tail>
class sys::io::file_feature< FileT, read, Tail ... >
Implement read support for file types.
- Template Parameters
-
FileT | The file access type inheriting the feature |
Tail | The remaining features |
◆ getc()
template<class FileT , feature ... Tail>
Read a single character from the file.
- See also
- fgetc()
- Returns
- The character or EOF
◆ gets()
template<class FileT , feature ... Tail>
template<auto Count>
Read a line from the file.
Reads the file up to and including the first newline or terminating zero, as long as it fits into the destination buffer. Always zero terminated.
- See also
- fgets()
- Template Parameters
-
Count | The maximum number of characters to read |
- Parameters
-
dst | A reference to the destination buffer |
- Return values
-
true | Characters have been read |
false | Characters could not be read |
◆ read() [1/2]
template<class FileT , feature ... Tail>
template<typename T >
Read the given object from the file.
- See also
- fread()
- Template Parameters
-
T | The object type, should be a POD type |
- Parameters
-
dst | A reference to the object to overwrite |
- Returns
- The number of characters read
◆ read() [2/2]
template<class FileT , feature ... Tail>
template<typename T , std::size_t Count>
std::size_t sys::io::file_feature< FileT, read, Tail ... >::read |
( |
T(&) |
dst[Count], |
|
|
std::size_t const |
count |
|
) |
| |
|
inline |
Read the requested number of objects from the file.
- See also
- fread()
- Template Parameters
-
T | The object type, should be a POD type |
Count | The number of objects in the destination buffer |
- Parameters
-
dst | A reference to an array of objects |
count | The number of objects to read |
- Returns
- The number of characters read
◆ scanf()
template<class FileT , feature ... Tail>
template<auto CountFmt, typename ... RefTs>
Read formatted input.
- See also
- fscanf()
- Template Parameters
-
CountFmt | The number of characters in the format string |
RefTs | The argument types to read |
- Parameters
-
fmt | The input format |
refs | A set of references to write to |
- Returns
- The number of inputs successfully parsed
- Return values
-
EOF | No inputs could be parsed due to end of file |
The documentation for this class was generated from the following file: