Harmonic Flow Framework (libhffwk)
Cross platform C++ 2D Game Engine Framework
Public Types | Public Member Functions | List of all members
HFCore::Storage Class Referenceabstract

Interface for Storage and File IO stuff. More...

#include <Storage.h>

Inheritance diagram for HFCore::Storage:
Inheritance graph
[legend]

Public Types

enum  Result { STORAGE_OK = 0, STORAGE_FAIL = 1 }
 Storage result enum. More...
 
enum  ModeFlags {
  STORAGE_MODE_READ = 0x0001, STORAGE_MODE_WRITE = 0x0002, STORAGE_MODE_MASK = 0x000F, STORAGE_MUST_EXIST = 0x0010,
  STORAGE_OPEN_ALWAYS = 0x0020, STORAGE_DISPO_MASK = 0x00F0
}
 Storage mode flags enum. More...
 

Public Member Functions

 Storage ()
 Constructor.
 
virtual ~Storage ()
 Destructor.
 
virtual Result FileOpen (const int8_hf *pFilePathUtf8, int32_hf modeFlags, HF_FileHandle *pFileHandleOut)=0
 Open a file. More...
 
virtual Result FileRead (HF_FileHandle fileHandle, void *pBuffer, int32_hf readSizeBytes)=0
 Reads an array of size readSizeBytes and stores them in the block of memory specified by pBuffer. More...
 
virtual Result FileWrite (HF_FileHandle fileHandle, const void *pBuffer, int32_hf writeSizeBytes)=0
 Write block of pBuffer to file. More...
 
virtual Result FileClose (HF_FileHandle fileHandle)=0
 Close a file. More...
 
virtual int32_hf FileGetSize (HF_FileHandle openFileHandle)=0
 Get the size of file in bytes. More...
 
virtual PFILEGetFilePtr (HF_FileHandle hFile)=0
 Get internal HFCore::PFILE for file. More...
 
virtual int8_hfGetFileContents (const int8_hf *pFilePathUtf8, int32_hf *outSizeRead)=0
 Get file contents (open and read contents of file). More...
 
Result FileGetSize (const int8_hf *pFilePath, int32_hf *pSizeBytesOut)
 Get the size of file in bytes. More...
 

Detailed Description

Interface for Storage and File IO stuff.

Definition at line 36 of file Storage.h.

Member Enumeration Documentation

◆ ModeFlags

Storage mode flags enum.

Enumerator
STORAGE_MODE_READ 

Storage mode: Read.

STORAGE_MODE_WRITE 

Storage mode: Write.

STORAGE_MODE_MASK 

Storage mode: Mask.

STORAGE_MUST_EXIST 

Storage. Must exist.

STORAGE_OPEN_ALWAYS 

Storage: Open always.

STORAGE_DISPO_MASK 

Storage: Mask.

Definition at line 51 of file Storage.h.

◆ Result

Storage result enum.

Enumerator
STORAGE_OK 

OK.

STORAGE_FAIL 

Failure.

Definition at line 42 of file Storage.h.

Member Function Documentation

◆ FileClose()

virtual Result HFCore::Storage::FileClose ( HF_FileHandle  fileHandle)
pure virtual

Close a file.

Parameters
fileHandleHF_FileHandle of file to close.
Returns
Storage::Result enum.

Implemented in HFCore::GenericStorage.

◆ FileGetSize() [1/2]

virtual int32_hf HFCore::Storage::FileGetSize ( HF_FileHandle  openFileHandle)
pure virtual

Get the size of file in bytes.

Parameters
openFileHandleHF_FileHandle of file.
Returns
Size of file in bytes.

Implemented in HFCore::GenericStorage.

◆ FileGetSize() [2/2]

Storage::Result Storage::FileGetSize ( const int8_hf pFilePath,
int32_hf pSizeBytesOut 
)

Get the size of file in bytes.

Parameters
pFilePathPath to file.
[out]pSizeBytesOutSize in bytes of file.
Returns
Storage::Result enum.

Definition at line 35 of file Storage.cpp.

◆ FileOpen()

virtual Result HFCore::Storage::FileOpen ( const int8_hf pFilePathUtf8,
int32_hf  modeFlags,
HF_FileHandle pFileHandleOut 
)
pure virtual

Open a file.

Parameters
pFilePathUtf8Path to file to open.
modeFlagsMode flags (read/write and a create/open flag).
[out]pFileHandleOutHF_FileHandle of the opened file.
Returns
Storage::Result enum.

Implemented in HFCore::GenericStorage.

◆ FileRead()

virtual Result HFCore::Storage::FileRead ( HF_FileHandle  fileHandle,
void *  pBuffer,
int32_hf  readSizeBytes 
)
pure virtual

Reads an array of size readSizeBytes and stores them in the block of memory specified by pBuffer.

Parameters
fileHandleHF_FileHandle of opened file to read from.
pBufferBuffer which will hold the result.
readSizeBytesSize to read.
Returns
Storage::Result enum.

Implemented in HFCore::GenericStorage.

◆ FileWrite()

virtual Result HFCore::Storage::FileWrite ( HF_FileHandle  fileHandle,
const void *  pBuffer,
int32_hf  writeSizeBytes 
)
pure virtual

Write block of pBuffer to file.

Parameters
fileHandleHF_FileHandle of file to write to.
pBufferBuffer to write from.
writeSizeBytesSize to write.
Returns
Storage::Result enum.

Implemented in HFCore::GenericStorage.

◆ GetFileContents()

virtual int8_hf* HFCore::Storage::GetFileContents ( const int8_hf pFilePathUtf8,
int32_hf outSizeRead 
)
pure virtual

Get file contents (open and read contents of file).

Parameters
pFilePathUtf8Path to file to open and read content from.
[out]outSizeReadSize in bytes of content read.
Returns
File contents as int8_hf pointer.

Implemented in HFCore::GenericStorage.

◆ GetFilePtr()

virtual PFILE* HFCore::Storage::GetFilePtr ( HF_FileHandle  hFile)
pure virtual

Get internal HFCore::PFILE for file.

Parameters
hFileHF_FileHandle of file.
Returns
HFCore::PFILE for file.

Implemented in HFCore::GenericStorage.


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