galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
galaxy::fs::PhysfsStream Class Reference

Custom SFML input stream using PhysFS. More...

#include <PhysfsStream.hpp>

+ Inheritance diagram for galaxy::fs::PhysfsStream:
+ Collaboration diagram for galaxy::fs::PhysfsStream:

Public Member Functions

 PhysfsStream () noexcept
 Constructor.
 
 PhysfsStream (const std::string &filename) noexcept
 Argument constructor.
 
virtual ~PhysfsStream () noexcept
 Virtual destructor.
 
bool is_open () const noexcept
 Is the physfs file open.
 
bool open (const std::string &filename) noexcept
 Open file in physfs.
 
void close () noexcept
 Close the open physfs handle.
 
std::optional< std::size_t > read (void *data, std::size_t size) override
 Read data from the stream.
 
std::optional< std::size_t > seek (std::size_t position) override
 Change the current reading position.
 
std::optional< std::size_t > tell () override
 Get the current reading position in the stream.
 
std::optional< std::size_t > getSize () override
 Return the size of the stream.
 

Private Member Functions

 PhysfsStream (const PhysfsStream &)=delete
 Copy constructor.
 
PhysfsStreamoperator= (const PhysfsStream &)=delete
 Copy assignment operator.
 
 PhysfsStream (PhysfsStream &&)=delete
 Move constructor.
 
PhysfsStreamoperator= (PhysfsStream &&)=delete
 Move assignment operator.
 

Private Attributes

PHYSFS_File * m_file
 Handle to physfs file data.
 

Detailed Description

Custom SFML input stream using PhysFS.

Definition at line 24 of file PhysfsStream.hpp.

Constructor & Destructor Documentation

◆ PhysfsStream() [1/4]

galaxy::fs::PhysfsStream::PhysfsStream ( )
noexcept

Constructor.

Definition at line 18 of file PhysfsStream.cpp.

◆ PhysfsStream() [2/4]

galaxy::fs::PhysfsStream::PhysfsStream ( const std::string & filename)
noexcept

Argument constructor.

Does not actually read any data.

Parameters
filenameName of file in VFS to read.

Definition at line 23 of file PhysfsStream.cpp.

◆ ~PhysfsStream()

galaxy::fs::PhysfsStream::~PhysfsStream ( )
virtualnoexcept

Virtual destructor.

Definition at line 29 of file PhysfsStream.cpp.

+ Here is the call graph for this function:

◆ PhysfsStream() [3/4]

galaxy::fs::PhysfsStream::PhysfsStream ( const PhysfsStream & )
privatedelete

Copy constructor.

◆ PhysfsStream() [4/4]

galaxy::fs::PhysfsStream::PhysfsStream ( PhysfsStream && )
privatedelete

Move constructor.

Member Function Documentation

◆ is_open()

bool galaxy::fs::PhysfsStream::is_open ( ) const
nodiscardnoexcept

Is the physfs file open.

Returns
True if open.

Definition at line 34 of file PhysfsStream.cpp.

+ Here is the caller graph for this function:

◆ open()

bool galaxy::fs::PhysfsStream::open ( const std::string & filename)
noexcept

Open file in physfs.

Does not actually read any data.

Parameters
filenameName of file in VFS to read.
Returns
True if successful.

Definition at line 39 of file PhysfsStream.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ close()

void galaxy::fs::PhysfsStream::close ( )
noexcept

Close the open physfs handle.

Definition at line 55 of file PhysfsStream.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read()

std::optional< std::size_t > galaxy::fs::PhysfsStream::read ( void * data,
std::size_t size )
nodiscardoverride

Read data from the stream.

After reading, the stream's reading position must be advanced by the amount of bytes read.

Parameters
dataBuffer where to copy the read data.
sizeDesired number of bytes to read.
Returns
The number of bytes actually read, or std::nullopt on error.

Definition at line 64 of file PhysfsStream.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ seek()

std::optional< std::size_t > galaxy::fs::PhysfsStream::seek ( std::size_t position)
nodiscardoverride

Change the current reading position.

Parameters
positionThe position to seek to, from the beginning.
Returns
The position actually sought to, or std::nullopt on error.

Definition at line 76 of file PhysfsStream.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tell()

std::optional< std::size_t > galaxy::fs::PhysfsStream::tell ( )
nodiscardoverride

Get the current reading position in the stream.

Returns
The current position, or std::nullopt on error.

Definition at line 94 of file PhysfsStream.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSize()

std::optional< std::size_t > galaxy::fs::PhysfsStream::getSize ( )
nodiscardoverride

Return the size of the stream.

Returns
The total number of bytes available in the stream, or std::nullopt on error.

Definition at line 105 of file PhysfsStream.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator=() [1/2]

PhysfsStream & galaxy::fs::PhysfsStream::operator= ( const PhysfsStream & )
privatedelete

Copy assignment operator.

◆ operator=() [2/2]

PhysfsStream & galaxy::fs::PhysfsStream::operator= ( PhysfsStream && )
privatedelete

Move assignment operator.

Member Data Documentation

◆ m_file

PHYSFS_File* galaxy::fs::PhysfsStream::m_file
private

Handle to physfs file data.

Definition at line 136 of file PhysfsStream.hpp.


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