Waterflow
Visualize water in terrain
|
Used to store float arrays, and/or load them from files. More...
#include <fileHandler.h>
Public Member Functions | |
FileHandler (int dWidth, int dHeight) | |
Constructor, takes file path as parameter. | |
float ** | GetArray () |
Getter for the stored float array. | |
int | GetArrayLength () |
Getter for the stored float array length. | |
int | GetDataHeight () |
Getter for the data height. | |
int | GetDataWidth () |
Getter for the data width. | |
int | LoadData (std::string path) |
Loads data from a file specified by fPath into the object. | |
void | SaveData (std::string path) |
Stores data, both as variables in the object and as a file. | |
Private Attributes | |
int | arrayLength |
Length of the float array. | |
float * | fArray |
Pointer to the float array. | |
int | height |
Height (side information). | |
int | width |
Width (side information). |
Used to store float arrays, and/or load them from files.
Use the fileHandler class to either store a generic float array, with some side information, or to load side information and a float array from the specified path. When attempting to load a file that does not exist, LoadData() returns -1, otherwise 0.
Definition at line 18 of file fileHandler.h.
FileHandler::FileHandler | ( | int | dWidth, |
int | dHeight | ||
) |
Constructor, takes file path as parameter.
path must either point to a file saved with this class, or towards a location where data should be saved.
dWidth | Width of the data to save, these are also set automatically when loading) |
dHeight | Height of the data to save, these are also set automatically when loading) |
Definition at line 9 of file fileHandler.cpp.
float ** FileHandler::GetArray | ( | ) |
Getter for the stored float array.
Definition at line 94 of file fileHandler.cpp.
int FileHandler::GetArrayLength | ( | ) |
Getter for the stored float array length.
Definition at line 99 of file fileHandler.cpp.
int FileHandler::GetDataHeight | ( | ) |
Getter for the data height.
Definition at line 108 of file fileHandler.cpp.
int FileHandler::GetDataWidth | ( | ) |
Getter for the data width.
Definition at line 104 of file fileHandler.cpp.
int FileHandler::LoadData | ( | std::string | path | ) |
Loads data from a file specified by fPath into the object.
Note that this method simply interprets a file as if it were saved with SaveData(). If the file specified by fPath is of another origin, the data loaded could be flagged as being correctly loaded, but in reality make little sense.
Definition at line 44 of file fileHandler.cpp.
void FileHandler::SaveData | ( | std::string | path | ) |
Stores data, both as variables in the object and as a file.
specified by fPath. Note that the file indicated by fPath will be created if it does not exist, and it will be overwritten if it does exist.
path | Path to the file to save, should be specified in the XML file |
Definition at line 19 of file fileHandler.cpp.