cppassist  1.0.0.f4fab4f962ff
C++ sanctuary for small but powerful and frequently required, stand alone features.
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
cppassist::RawFile Class Reference

Raw data file loader. More...

#include <cppassist/include/cppassist/fs/RawFile.h>

Public Member Functions

 RawFile ()
 Constructor. More...
 
 ~RawFile ()
 Destructor. More...
 
bool load (const std::string &filePath)
 Load file contents. More...
 
bool reload ()
 Reload file contents. More...
 
const char * data () const
 Get plain C pointer to file contents. More...
 
size_t size () const
 Get number of bytes in file. More...
 
bool isValid () const
 Get validity of file contents. More...
 
const std::string & filePath () const
 Get file path. More...
 

Protected Member Functions

bool readFile ()
 Load contents from file path. More...
 

Protected Attributes

std::string m_filePath
 File path. More...
 
std::string m_data
 Loaded file contents. More...
 
bool m_valid
 Validity of loaded file contents. More...
 

Detailed Description

Raw data file loader.

This class allows for loading raw data (e.g., textures) from files. You have to exactly know how to interpret the content of the file, e.g., you need to know the format and size of the texture, the file does not provide this information. To create raw textures, you can use for example glraw (https://github.com/cginternals/glraw).

Constructor & Destructor Documentation

◆ RawFile()

cppassist::RawFile::RawFile ( )

Constructor.

◆ ~RawFile()

cppassist::RawFile::~RawFile ( )

Destructor.

Member Function Documentation

◆ load()

bool cppassist::RawFile::load ( const std::string &  filePath)

Load file contents.

Parameters
[in]filePathPath to the file to load
Returns
true if file contents could be loaded successfully, else false
Remarks
Uses the passed file path and stores it for subsequent reloads.

◆ reload()

bool cppassist::RawFile::reload ( )

Reload file contents.

Returns
true if file contents could be loaded successfully, else false
Remarks
Uses the last passed file path to load.

◆ data()

const char* cppassist::RawFile::data ( ) const

Get plain C pointer to file contents.

Returns
Plain C pointer to file contents if successfully loaded, nullptr else

◆ size()

size_t cppassist::RawFile::size ( ) const

Get number of bytes in file.

Returns
Number of bytes in file if successfully loaded, 0 else

◆ isValid()

bool cppassist::RawFile::isValid ( ) const

Get validity of file contents.

Returns
true if file contents could be loaded successfully, else false

◆ filePath()

const std::string& cppassist::RawFile::filePath ( ) const

Get file path.

Returns
File path

◆ readFile()

bool cppassist::RawFile::readFile ( )
protected

Load contents from file path.

Returns
true if file contents could be loaded successfully, else false

Member Data Documentation

◆ m_filePath

std::string cppassist::RawFile::m_filePath
protected

File path.

◆ m_data

std::string cppassist::RawFile::m_data
protected

Loaded file contents.

◆ m_valid

bool cppassist::RawFile::m_valid
protected

Validity of loaded file contents.


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