DUtils::BinaryFile Class Reference
Manages files in binary format.
More...
#include <BinaryFile.h>
List of all members.
Detailed Description
Manages files in binary format.
Constructor & Destructor Documentation
BinaryFile::BinaryFile |
( |
void |
|
) |
|
Creates a binary file with no file
BinaryFile::~BinaryFile |
( |
void |
|
) |
|
BinaryFile::BinaryFile |
( |
const char * |
filename, |
|
|
const FILE_MODES |
mode | |
|
) |
| | |
Creates a binary file by opening a file
- Parameters:
-
| filename | |
| mode,: | READ or WRITE |
- Exceptions:
-
BinaryFile::BinaryFile |
( |
const string & |
filename, |
|
|
const FILE_MODES |
mode | |
|
) |
| | |
Creates a binary file by opening a file
- Parameters:
-
| filename | |
| mode,: | READ or WRITE |
- Exceptions:
-
Member Function Documentation
unsigned int BinaryFile::BytesRead |
( |
|
) |
|
Returns the number of bytes read in reading mode
- Returns:
- number of bytes read
void BinaryFile::Close |
( |
|
) |
|
Closes any opened file. It is not necessary to call this function explicitly
void BinaryFile::DiscardBytes |
( |
int |
count |
) |
|
Reads n bytes and discards them
- Parameters:
-
| count | number of bytes to discard |
- Exceptions:
-
void DUtils::BinaryFile::DiscardNextByte |
( |
|
) |
[inline] |
Reads the next byte and throws it away
- Exceptions:
-
bool BinaryFile::Eof |
( |
|
) |
[inline] |
Says whether the end of the file has been reached. Requires to read the end of the file to return true
- Returns:
- true iff the end of the file has been already read
- Exceptions:
-
void BinaryFile::hton_d |
( |
double |
d, |
|
|
char |
buf[8] | |
|
) |
| | const [protected] |
Converts a double into 8 bytes in network order
- Parameters:
-
| d | double value |
| buf | (out) byte buffer output |
void BinaryFile::hton_f |
( |
float |
v, |
|
|
char |
buf[8] | |
|
) |
| | const [protected] |
Converts a float into 4 bytes in network order
- Parameters:
-
| v | float value |
| buf | (out) byte buffer output. Only buf[0..3] is used |
void BinaryFile::Init |
( |
const char * |
filename, |
|
|
const FILE_MODES |
mode | |
|
) |
| | [protected] |
Initializes the object by opening a file
- Parameters:
-
| filename | file to open |
| mode | opening mode |
- Exceptions:
-
bool DUtils::BinaryFile::isLittleEndian |
( |
|
) |
const [inline, protected] |
Returns if this machine uses little endian
- Returns:
- true iff little endian
double BinaryFile::ntoh_d |
( |
char |
buf[8] |
) |
const [protected] |
Converts an array of bytes in network order into a 8 byte double
- Parameters:
-
- Returns:
- double value
float BinaryFile::ntoh_f |
( |
char |
buf[8] |
) |
const [protected] |
Converts an array of bytes in network order into a 4 byte float
- Parameters:
-
| buf | byte array. only buf[0..3] is used |
- Returns:
- float value
void DUtils::BinaryFile::OpenForAppending |
( |
const string & |
filename |
) |
[inline] |
Opens a file for writing at the end. It closes any other opened file
- Parameters:
-
- Exceptions:
-
void BinaryFile::OpenForAppending |
( |
const char * |
filename |
) |
|
Opens a file for writing at the end. It closes any other opened file
- Parameters:
-
- Exceptions:
-
void DUtils::BinaryFile::OpenForReading |
( |
const string & |
filename |
) |
[inline] |
Opens a file for reading. It closes any other opened file
- Parameters:
-
- Exceptions:
-
void BinaryFile::OpenForReading |
( |
const char * |
filename |
) |
|
Opens a file for reading. It closes any other opened file
- Parameters:
-
- Exceptions:
-
void DUtils::BinaryFile::OpenForWriting |
( |
const string & |
filename |
) |
[inline] |
Opens a file for writing. It closes any other opened file
- Parameters:
-
- Exceptions:
-
void BinaryFile::OpenForWriting |
( |
const char * |
filename |
) |
|
Opens a file for writing. It closes any other opened file
- Parameters:
-
- Exceptions:
-
Writes a 8 byte float value
- Exceptions:
-
Writes a 4 byte float value
- Exceptions:
-
Writes a 4 byte integer value
- Exceptions:
-
Writes a byte char
- Exceptions:
-
BinaryFile & BinaryFile::operator>> |
( |
double & |
v |
) |
|
Reads a 8 byte float value
- Exceptions:
-
Reads a 4 byte float value
- Exceptions:
-
Reads a 4 byte integer value
- Exceptions:
-
Reads a byte char
- Exceptions:
-
void BinaryFile::setEndianness |
( |
|
) |
[protected] |
Checks the endianness of this machine
The documentation for this class was generated from the following files: