RLLib  0.1
Public Member Functions | List of all members
rl::FileReader Class Reference

The file reader provides features to read bytes from a binary file. More...

#include <FileReader.hpp>

Public Member Functions

 FileReader (const FilePath &path)
 Creates and opens a file with reading permissions. More...
 
void open (const FilePath &path)
 Opens a file with reading permissions. More...
 
 operator bool () const
 Tells if the file is in a good state. More...
 
ByteStream read (std::size_t size)
 Reads a chunk of bytes from the file. More...
 
ByteStream read (std::size_t size, std::streampos pos)
 Reads a chunk of bytes from a specific position in the file. More...
 
ByteStream readAll ()
 Reads all bytes from the file. More...
 

Detailed Description

The file reader provides features to read bytes from a binary file.

Constructor & Destructor Documentation

◆ FileReader()

rl::FileReader::FileReader ( const FilePath path)
explicit

Creates and opens a file with reading permissions.

Parameters
pathThe path to the file

Member Function Documentation

◆ open()

void rl::FileReader::open ( const FilePath path)

Opens a file with reading permissions.

Parameters
pathThe path to the file

◆ operator bool()

rl::FileReader::operator bool ( ) const

Tells if the file is in a good state.

Returns
true if no errors occurred while reading the file, false if something went wrong

◆ read() [1/2]

ByteStream rl::FileReader::read ( std::size_t  size)

Reads a chunk of bytes from the file.

Parameters
sizeThe number of bytes that are to be read
Returns
A data stream containing the bytes

◆ read() [2/2]

ByteStream rl::FileReader::read ( std::size_t  size,
std::streampos  pos 
)

Reads a chunk of bytes from a specific position in the file.

Parameters
sizeThe number of bytes that are to be read
posThe position of the file cursor
Returns
A data stream containing the bytes

◆ readAll()

ByteStream rl::FileReader::readAll ( )

Reads all bytes from the file.

Returns
A data stream containing all bytes

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