SUMO - Simulation of Urban MObility
|
Encapsulates binary reading operations on a file. More...
#include <BinaryInputDevice.h>
Public Member Functions | |
BinaryInputDevice (const std::string &name) | |
Constructor. | |
bool | good () const |
Returns whether the file can be used (is good()) | |
~BinaryInputDevice () | |
Destructor. | |
Private Attributes | |
char | myBuffer [1000] |
The buffer used for string parsing. | |
std::ifstream | myStream |
The encapsulated stream. | |
Friends | |
BinaryInputDevice & | operator>> (BinaryInputDevice &os, int &i) |
Reads an int from the file (input operator) | |
BinaryInputDevice & | operator>> (BinaryInputDevice &os, unsigned int &i) |
Reads an unsigned int from the file (input operator) | |
BinaryInputDevice & | operator>> (BinaryInputDevice &os, SUMOReal &f) |
Reads a SUMOReal from the file (input operator) | |
BinaryInputDevice & | operator>> (BinaryInputDevice &os, bool &b) |
Reads a bool from the file (input operator) | |
BinaryInputDevice & | operator>> (BinaryInputDevice &os, std::string &s) |
Reads a string from the file (input operator) | |
BinaryInputDevice & | operator>> (BinaryInputDevice &os, long &l) |
Reads a long from the file (input operator) |
Encapsulates binary reading operations on a file.
This class opens a binary file stream for reading and offers read access functions on it.
Please note that the byte order is undefined. Also the length of each type is not defined on a global scale and may differ across compilers or platforms.
Recheck whether this class could be replaced by a "normal InputDevice"
Maybe some kind of a well-defined types should be used (so that they have a well-defined length)
Maybe the byte-order should be defined
Definition at line 56 of file BinaryInputDevice.h.
BinaryInputDevice::BinaryInputDevice | ( | const std::string & | name | ) |
Constructor.
[in] | name | The name of the file to open for reading |
Definition at line 48 of file BinaryInputDevice.cpp.
Destructor.
Definition at line 52 of file BinaryInputDevice.cpp.
bool BinaryInputDevice::good | ( | ) | const |
Returns whether the file can be used (is good())
Definition at line 56 of file BinaryInputDevice.cpp.
References myStream.
BinaryInputDevice& operator>> | ( | BinaryInputDevice & | os, |
int & | i | ||
) | [friend] |
Reads an int from the file (input operator)
[in,out] | os | The BinaryInputDevice to read the int from |
[in] | i | The int to store the read value into |
Definition at line 62 of file BinaryInputDevice.cpp.
BinaryInputDevice& operator>> | ( | BinaryInputDevice & | os, |
unsigned int & | i | ||
) | [friend] |
Reads an unsigned int from the file (input operator)
[in,out] | os | The BinaryInputDevice to read the unsigned int from |
[in] | i | The unsigned int to store the read value into |
Definition at line 69 of file BinaryInputDevice.cpp.
BinaryInputDevice& operator>> | ( | BinaryInputDevice & | os, |
SUMOReal & | f | ||
) | [friend] |
Reads a SUMOReal from the file (input operator)
[in,out] | os | The BinaryInputDevice to read the SUMOReal from |
[in] | i | The SUMOReal to store the read value into |
Definition at line 76 of file BinaryInputDevice.cpp.
BinaryInputDevice& operator>> | ( | BinaryInputDevice & | os, |
bool & | b | ||
) | [friend] |
Reads a bool from the file (input operator)
[in,out] | os | The BinaryInputDevice to read the bool from |
[in] | i | The bool to store the read value into |
Definition at line 83 of file BinaryInputDevice.cpp.
BinaryInputDevice& operator>> | ( | BinaryInputDevice & | os, |
std::string & | s | ||
) | [friend] |
Reads a string from the file (input operator)
Reads the length of the string as an unsigned int, first. Reads then the specified number of chars into "myBuffer". Please note that the buffer has a fixed size - longer strings will cause an error.
[in,out] | os | The BinaryInputDevice to read the string from |
[in] | i | The string to store the read value into |
Definition at line 91 of file BinaryInputDevice.cpp.
BinaryInputDevice& operator>> | ( | BinaryInputDevice & | os, |
long & | l | ||
) | [friend] |
Reads a long from the file (input operator)
[in,out] | os | The BinaryInputDevice to read the long from |
[in] | i | The int to store the read value into |
Definition at line 105 of file BinaryInputDevice.cpp.
char BinaryInputDevice::myBuffer[1000] [private] |
The buffer used for string parsing.
Definition at line 141 of file BinaryInputDevice.h.
Referenced by operator>>().
std::ifstream BinaryInputDevice::myStream [private] |
The encapsulated stream.
Definition at line 138 of file BinaryInputDevice.h.
Referenced by good(), and operator>>().