MercuryDPM
Trunk
|
This gives functionality to read information from binary formats like STL etc. This class is complete stand-alone and is tested with one any reference to other MecuryDPM code except Vections and Logger. More...
#include <BinaryReader.h>
Public Member Functions | |
BinaryReader (std::string) | |
Default constuction, requires to users to prove the name of the file that will be opened. More... | |
~BinaryReader () | |
Destructor, simple closes the file. More... | |
std::string | readString (unsigned int numChar) |
reads the next so many Characters (bytes) as a std::string More... | |
double | readDouble (unsigned int size) |
read the next so many bytes as a double More... | |
unsigned int | readUnsignedInt (unsigned int size) |
read the next so many bytes as a unsined int More... | |
double | readFloat (unsigned int size) |
read the next so many bytes as a double (not in this case they were saves as a float orgainlly) More... | |
void | ignoreChar (unsigned int size) |
read and ignore the next number of characters More... | |
Private Member Functions | |
void | openFile (std::string fileName) |
opens the file with fileName More... | |
void | closeFile () |
close the file with fileName More... | |
Private Attributes | |
std::ifstream | binaryFile_ |
The pointer for the binary file. More... | |
This gives functionality to read information from binary formats like STL etc. This class is complete stand-alone and is tested with one any reference to other MecuryDPM code except Vections and Logger.
Definition at line 36 of file BinaryReader.h.
|
explicit |
Default constuction, requires to users to prove the name of the file that will be opened.
in[ | fileName fileName of the binary file which is to be opened This is the default and only constuctor and it calls the private method openFile. |
Definition at line 41 of file BinaryReader.cc.
References openFile().
BinaryReader::~BinaryReader | ( | ) |
Destructor, simple closes the file.
This is the destructor it simple closes the file as this is the only memory that needs freeing up
Definition at line 49 of file BinaryReader.cc.
References closeFile().
|
private |
close the file with fileName
Simple function that closes the file; this is private and can only be called by the destructor
Definition at line 57 of file BinaryReader.cc.
References binaryFile_.
Referenced by ~BinaryReader().
void BinaryReader::ignoreChar | ( | unsigned int | size | ) |
read and ignore the next number of characters
[in] | size | number of bytpes to be ignored |
Reads and disgards the next size characters size*8 bytes from the binary file
Definition at line 133 of file BinaryReader.cc.
References binaryFile_.
Referenced by WallHandler::readTriangleWall().
|
private |
opens the file with fileName
[in] | fileName | fileName of the binary file which is to be opened |
This opens the file associated with fileName, note the file is points is stored in the private varibles binaryFile_
Definition at line 66 of file BinaryReader.cc.
References binaryFile_, ERROR, and logger.
Referenced by BinaryReader().
double BinaryReader::readDouble | ( | unsigned int | size | ) |
read the next so many bytes as a double
[in] | size | This is the size in bytes of the double stored in the file |
Usage myDouble = readDouble(4) would read a 8*4 = 32 bit double from the file; or myDouble = readDouble(8) would read a 64 bit double from the file.
Definition at line 94 of file BinaryReader.cc.
References binaryFile_.
double BinaryReader::readFloat | ( | unsigned int | size | ) |
read the next so many bytes as a double (not in this case they were saves as a float orgainlly)
[in] | size | This is the size in bytes of the float stored in the file |
Usage myDouble = readFloat(4) would read 32 bit float from file covert it to a double and then return this double.
Definition at line 108 of file BinaryReader.cc.
References binaryFile_.
Referenced by WallHandler::readTriangleWall().
std::string BinaryReader::readString | ( | unsigned int | numChar | ) |
reads the next so many Characters (bytes) as a std::string
[in] | numChar | The number of characters to be read in from the binary file. |
The usages is myString = readString(6) will read in the next 6 characters from the binaryfile as a string.
Definition at line 80 of file BinaryReader.cc.
References binaryFile_.
Referenced by WallHandler::readTriangleWall().
read the next so many bytes as a unsined int
[in] | size | This is the size in bytes of the unsigned int that is stored in the file. |
Usage myUnsignedInt = readUnsignedInt(4) woudl read a 32 bit (4*8) unsigned int from the file.
Definition at line 121 of file BinaryReader.cc.
References binaryFile_.
Referenced by WallHandler::readTriangleWall().
|
private |
The pointer for the binary file.
Definition at line 88 of file BinaryReader.h.
Referenced by closeFile(), ignoreChar(), openFile(), readDouble(), readFloat(), readString(), and readUnsignedInt().