powerd++  0.4.4
Public Member Functions | List of all members
sys::io::file_feature< FileT, read, Tail ... > Class Template Reference

Implement read support for file types. More...

#include <io.hpp>

Inheritance diagram for sys::io::file_feature< FileT, read, Tail ... >:
[legend]
Collaboration diagram for sys::io::file_feature< FileT, read, Tail ... >:
[legend]

Public Member Functions

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...
 
- Public Member Functions inherited from sys::io::file_feature< FileT, Tail ... >
 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...
 

Additional Inherited Members

- Protected Member Functions inherited from sys::io::file_feature< FileT, Tail ... >
 operator FileT & ()
 Implicit cast up to inheriting file access type.
 
 file_feature (FILE *const handle)
 Construct from a FILE object pointer. More...
 
- Protected Attributes inherited from sys::io::file_feature< FileT, Tail ... >
FILE * handle
 A pointer to the underlying FILE object.
 

Detailed Description

template<class FileT, feature ... Tail>
class sys::io::file_feature< FileT, read, Tail ... >

Implement read support for file types.

Template Parameters
FileTThe file access type inheriting the feature
TailThe remaining features

Member Function Documentation

◆ getc()

template<class FileT , feature ... Tail>
int sys::io::file_feature< FileT, read, Tail ... >::getc ( )
inline

Read a single character from the file.

See also
fgetc()
Returns
The character or EOF

◆ gets()

template<class FileT , feature ... Tail>
template<auto Count>
bool sys::io::file_feature< FileT, read, Tail ... >::gets ( char(&)  dst[Count])
inline

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
CountThe maximum number of characters to read
Parameters
dstA reference to the destination buffer
Return values
trueCharacters have been read
falseCharacters could not be read

◆ read() [1/2]

template<class FileT , feature ... Tail>
template<typename T >
std::size_t sys::io::file_feature< FileT, read, Tail ... >::read ( T &  dst)
inline

Read the given object from the file.

See also
fread()
Template Parameters
TThe object type, should be a POD type
Parameters
dstA 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
TThe object type, should be a POD type
CountThe number of objects in the destination buffer
Parameters
dstA reference to an array of objects
countThe number of objects to read
Returns
The number of characters read

◆ scanf()

template<class FileT , feature ... Tail>
template<auto CountFmt, typename ... RefTs>
int sys::io::file_feature< FileT, read, Tail ... >::scanf ( char const (&)  fmt[CountFmt],
RefTs &...  refs 
)
inline

Read formatted input.

See also
fscanf()
Template Parameters
CountFmtThe number of characters in the format string
RefTsThe argument types to read
Parameters
fmtThe input format
refsA set of references to write to
Returns
The number of inputs successfully parsed
Return values
EOFNo inputs could be parsed due to end of file

The documentation for this class was generated from the following file: