|
SUMO - Simulation of Urban MObility
|
Encapsulates binary reading operations on a file. More...
#include <BinaryInputDevice.h>
Public Member Functions | |
| BinaryInputDevice (const std::string &name) throw () | |
| Constructor. | |
| bool | good () const throw () |
| Returns whether the file can be used (is good()) | |
| ~BinaryInputDevice () throw () | |
| 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) throw () |
| Reads an int from the file (input operator) | |
| BinaryInputDevice & | operator>> (BinaryInputDevice &os, long &l) throw () |
| Reads a long from the file (input operator) | |
| BinaryInputDevice & | operator>> (BinaryInputDevice &os, std::string &s) throw () |
| Reads a string from the file (input operator) | |
| BinaryInputDevice & | operator>> (BinaryInputDevice &os, bool &b) throw () |
| Reads a bool from the file (input operator) | |
| BinaryInputDevice & | operator>> (BinaryInputDevice &os, SUMOReal &f) throw () |
| Reads a SUMOReal from the file (input operator) | |
| BinaryInputDevice & | operator>> (BinaryInputDevice &os, unsigned int &i) throw () |
| Reads an unsigned int 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 54 of file BinaryInputDevice.h.
| BinaryInputDevice::BinaryInputDevice | ( | const std::string & | name | ) | throw () |
Constructor.
| [in] | name | The name of the file to open for reading |
Definition at line 46 of file BinaryInputDevice.cpp.
| BinaryInputDevice::~BinaryInputDevice | ( | ) | throw () |
Destructor.
Definition at line 50 of file BinaryInputDevice.cpp.
| bool BinaryInputDevice::good | ( | ) | const throw () |
Returns whether the file can be used (is good())
Definition at line 54 of file BinaryInputDevice.cpp.
References myStream.
| BinaryInputDevice& operator>> | ( | BinaryInputDevice & | os, |
| int & | i | ||
| ) | throw () [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 60 of file BinaryInputDevice.cpp.
| BinaryInputDevice& operator>> | ( | BinaryInputDevice & | os, |
| long & | l | ||
| ) | throw () [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 103 of file BinaryInputDevice.cpp.
| BinaryInputDevice& operator>> | ( | BinaryInputDevice & | os, |
| std::string & | s | ||
| ) | throw () [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 89 of file BinaryInputDevice.cpp.
| BinaryInputDevice& operator>> | ( | BinaryInputDevice & | os, |
| bool & | b | ||
| ) | throw () [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 81 of file BinaryInputDevice.cpp.
| BinaryInputDevice& operator>> | ( | BinaryInputDevice & | os, |
| SUMOReal & | f | ||
| ) | throw () [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 74 of file BinaryInputDevice.cpp.
| BinaryInputDevice& operator>> | ( | BinaryInputDevice & | os, |
| unsigned int & | i | ||
| ) | throw () [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 67 of file BinaryInputDevice.cpp.
char BinaryInputDevice::myBuffer[1000] [private] |
The buffer used for string parsing.
Definition at line 139 of file BinaryInputDevice.h.
std::ifstream BinaryInputDevice::myStream [private] |