#include <datafile.h>
This class is the base for all data files used in framework. All data files has to use File object for reading and writing the data. This File object is creted and file is opend/close here.
Each descendant can define the type of data file (text / binary) in constructor and should define all virtual methods, especially LoadData and DeleteData.
Public Types | |
enum | LoadState { LS_UNLOADED, LS_BLOCK_LOADED, LS_LOADED } |
Public Member Functions | |
DataFile () | |
virtual | ~DataFile () |
virtual bool | Open (bool write=false) |
virtual void | Close () |
virtual ulong_t | LoadData () |
virtual bool | SaveData () |
void | SetFileName (const string &file_name) |
const string & | GetFileName () |
ulong_t | GetDataSize () |
LoadState | GetState () |
bool | TestState (LoadState state) |
bool | IsOpened () |
Protected Member Functions | |
virtual void | DeleteData ()=0 |
Protected Attributes | |
File * | file |
File object. This object is automatically creted in Open method and destroyed in Close method. | |
string | file_name |
File name with path (relative or absolute). | |
LoadState | state |
Loading state of the file. | |
bool | opened |
Whether file is opened or not. | |
bool | binary |
Whether file will be opened in binary mode. Set this property before opening the file. | |
ulong_t | data_size |
Whole size of loaded data. Data size should by calculated in LoadData method. |
enum DataFile::LoadState |
DataFile::DataFile | ( | ) |
Constructor.
DataFile::~DataFile | ( | ) | [virtual] |
Destructor.
bool DataFile::Open | ( | bool | write = false |
) | [virtual] |
Opens data file. Just creates File object for access to file in filesystem.
write | Whether file will be opened for writing. |
True
if successful. Reimplemented in FreeTypeFontFile, and OggAudioFile.
void DataFile::Close | ( | ) | [virtual] |
Close data file. Deletes data and File object. Data file has to be opened before.
Reimplemented in FreeTypeFontFile, and OggAudioFile.
ulong_t DataFile::LoadData | ( | ) | [virtual] |
Loads data from opened file. Data has to be unloaded before. This function should be redefined in derived classes.
Reimplemented in FreeTypeFontFile, OggAudioFile, TgaImageFile, and ImageFile.
bool DataFile::SaveData | ( | ) | [virtual] |
Saves data into the file. Data has to be loaded before. This function can be redefined in derived classes.
True
if successful. Reimplemented in TgaImageFile.
void DataFile::SetFileName | ( | const string & | file_name | ) | [inline] |
const string & DataFile::GetFileName | ( | ) | [inline] |
ulong_t DataFile::GetDataSize | ( | ) | [inline] |
Returns data size.
DataFile::LoadState DataFile::GetState | ( | ) | [inline] |
Returns load state of the file.
bool DataFile::TestState | ( | LoadState | state | ) | [inline] |
Tests given state.
state | Loading state to be tested. |
True
if given state is same as state of the file. bool DataFile::IsOpened | ( | ) | [inline] |
Returns opening state.
virtual void DataFile::DeleteData | ( | ) | [protected, pure virtual] |
File* DataFile::file [protected] |
File object. This object is automatically creted in Open method and destroyed in Close method.
string DataFile::file_name [protected] |
File name with path (relative or absolute).
LoadState DataFile::state [protected] |
Loading state of the file.
bool DataFile::opened [protected] |
Whether file is opened or not.
bool DataFile::binary [protected] |
Whether file will be opened in binary mode. Set this property before opening the file.
ulong_t DataFile::data_size [protected] |
Whole size of loaded data. Data size should by calculated in LoadData method.