#include <BinaryFile.h>
Public Member Functions | |
| BinaryFile (void) | |
| BinaryFile (const char *filename, const FILE_MODES mode) | |
| BinaryFile (const string &filename, const FILE_MODES mode) | |
| unsigned int | BytesRead () |
| void | Close () |
| void | DiscardBytes (int count) |
| void | DiscardNextByte () |
| bool | Eof () |
| void | OpenForAppending (const char *filename) |
| void | OpenForAppending (const string &filename) |
| void | OpenForReading (const char *filename) |
| void | OpenForReading (const string &filename) |
| void | OpenForWriting (const char *filename) |
| void | OpenForWriting (const string &filename) |
| BinaryFile & | operator<< (char v) |
| BinaryFile & | operator<< (int v) |
| BinaryFile & | operator<< (float v) |
| BinaryFile & | operator<< (double v) |
| BinaryFile & | operator>> (char &v) |
| BinaryFile & | operator>> (int &v) |
| BinaryFile & | operator>> (float &v) |
| BinaryFile & | operator>> (double &v) |
| ~BinaryFile (void) | |
Protected Member Functions | |
| void | hton_d (double d, char buf[8]) const |
| void | hton_f (float v, char buf[8]) const |
| void | Init (const char *filename, const FILE_MODES mode) |
| bool | isLittleEndian () const |
| double | ntoh_d (char buf[8]) const |
| float | ntoh_f (char buf[8]) const |
| void | setEndianness () |
Protected Attributes | |
| char | m_aux [8] |
| fstream | m_f |
| int | m_is_little_endian |
| FILE_MODES | m_mode |
Definition at line 36 of file BinaryFile.h.
| BinaryFile::BinaryFile | ( | void | ) |
Definition at line 47 of file BinaryFile.cpp.
| BinaryFile::~BinaryFile | ( | void | ) |
Definition at line 52 of file BinaryFile.cpp.
| BinaryFile::BinaryFile | ( | const char * | filename, |
| const FILE_MODES | mode | ||
| ) |
Definition at line 62 of file BinaryFile.cpp.
| BinaryFile::BinaryFile | ( | const string & | filename, |
| const FILE_MODES | mode | ||
| ) |
Definition at line 67 of file BinaryFile.cpp.
| unsigned int BinaryFile::BytesRead | ( | ) |
Returns the number of bytes read in reading mode
Definition at line 139 of file BinaryFile.cpp.
| void BinaryFile::Close | ( | ) |
Definition at line 57 of file BinaryFile.cpp.
| void BinaryFile::DiscardBytes | ( | int | count | ) |
Reads n bytes and discards them
| count | number of bytes to discard |
| DException | if wrong access mode |
Definition at line 124 of file BinaryFile.cpp.
| void DUtils::BinaryFile::DiscardNextByte | ( | ) | [inline] |
Reads the next byte and throws it away
| DException | if wrong access mode |
Definition at line 102 of file BinaryFile.h.
| bool BinaryFile::Eof | ( | ) | [inline] |
Definition at line 134 of file BinaryFile.cpp.
| void BinaryFile::hton_d | ( | double | d, |
| char | buf[8] | ||
| ) | const [protected] |
Converts a double into 8 bytes in network order
| v | double value |
| buf | (out) byte buffer output |
Definition at line 290 of file BinaryFile.cpp.
| void BinaryFile::hton_f | ( | float | v, |
| char | buf[8] | ||
| ) | const [protected] |
Converts a float into 4 bytes in network order
| v | float value |
| buf | (out) byte buffer output. Only buf[0..3] is used |
Definition at line 251 of file BinaryFile.cpp.
| void BinaryFile::Init | ( | const char * | filename, |
| const FILE_MODES | mode | ||
| ) | [protected] |
Initializes the object by opening a file
| filename | file to open |
| mode | opening mode |
| DException | if cannot open the file |
Definition at line 72 of file BinaryFile.cpp.
| bool DUtils::BinaryFile::isLittleEndian | ( | ) | const [inline, protected] |
Returns if this machine uses little endian
Definition at line 206 of file BinaryFile.h.
| double BinaryFile::ntoh_d | ( | char | buf[8] | ) | const [protected] |
Converts an array of bytes in network order into a 8 byte double
| buf | byte array |
Definition at line 316 of file BinaryFile.cpp.
| float BinaryFile::ntoh_f | ( | char | buf[8] | ) | const [protected] |
Converts an array of bytes in network order into a 4 byte float
| buf | byte array. only buf[0..3] is used |
Definition at line 269 of file BinaryFile.cpp.
| void BinaryFile::OpenForAppending | ( | const char * | filename | ) |
Definition at line 112 of file BinaryFile.cpp.
| void DUtils::BinaryFile::OpenForAppending | ( | const string & | filename | ) | [inline] |
Definition at line 81 of file BinaryFile.h.
| void BinaryFile::OpenForReading | ( | const char * | filename | ) |
Definition at line 88 of file BinaryFile.cpp.
| void DUtils::BinaryFile::OpenForReading | ( | const string & | filename | ) | [inline] |
Definition at line 61 of file BinaryFile.h.
| void BinaryFile::OpenForWriting | ( | const char * | filename | ) |
Definition at line 100 of file BinaryFile.cpp.
| void DUtils::BinaryFile::OpenForWriting | ( | const string & | filename | ) | [inline] |
Definition at line 71 of file BinaryFile.h.
| BinaryFile & BinaryFile::operator<< | ( | char | v | ) |
Definition at line 147 of file BinaryFile.cpp.
| BinaryFile & BinaryFile::operator<< | ( | int | v | ) |
Definition at line 159 of file BinaryFile.cpp.
| BinaryFile & BinaryFile::operator<< | ( | float | v | ) |
Definition at line 172 of file BinaryFile.cpp.
| BinaryFile & BinaryFile::operator<< | ( | double | v | ) |
Definition at line 185 of file BinaryFile.cpp.
| BinaryFile & BinaryFile::operator>> | ( | char & | v | ) |
Definition at line 198 of file BinaryFile.cpp.
| BinaryFile & BinaryFile::operator>> | ( | int & | v | ) |
Definition at line 210 of file BinaryFile.cpp.
| BinaryFile & BinaryFile::operator>> | ( | float & | v | ) |
Definition at line 224 of file BinaryFile.cpp.
| BinaryFile & BinaryFile::operator>> | ( | double & | v | ) |
Definition at line 237 of file BinaryFile.cpp.
| void BinaryFile::setEndianness | ( | ) | [protected] |
Checks the endianness of this machine
Definition at line 345 of file BinaryFile.cpp.
char DUtils::BinaryFile::m_aux[8] [protected] |
Definition at line 214 of file BinaryFile.h.
fstream DUtils::BinaryFile::m_f [protected] |
Definition at line 213 of file BinaryFile.h.
int DUtils::BinaryFile::m_is_little_endian [protected] |
Definition at line 217 of file BinaryFile.h.
FILE_MODES DUtils::BinaryFile::m_mode [protected] |
Definition at line 212 of file BinaryFile.h.