![]() |
![]() |
00001 #ifndef binary_ifstream_H 00002 #define binary_ifstream_H 00003 00004 #include <string> 00005 #include <cstdio> 00006 00007 class binary_ifstream { 00008 public: 00009 00010 explicit binary_ifstream( const char* name); 00011 explicit binary_ifstream( const std::string& name); 00012 00013 ~binary_ifstream(); 00014 00015 binary_ifstream& operator>>( char& n); 00016 binary_ifstream& operator>>( unsigned char& n); 00017 00018 binary_ifstream& operator>>( short& n); 00019 binary_ifstream& operator>>( unsigned short& n); 00020 00021 binary_ifstream& operator>>( int& n); 00022 binary_ifstream& operator>>( unsigned int& n); 00023 00024 binary_ifstream& operator>>( long& n); 00025 binary_ifstream& operator>>( unsigned long& n); 00026 00027 binary_ifstream& operator>>( float& n); 00028 binary_ifstream& operator>>( double& n); 00029 00030 binary_ifstream& operator>>( bool& n); 00031 binary_ifstream& operator>>( std::string& n); 00032 00033 void close(); 00034 00036 bool good() const; 00037 bool eof() const; 00038 bool fail() const; 00039 bool bad() const; 00040 bool operator!() const; 00041 operator bool() const; 00042 00043 private: 00044 00045 FILE* file_; 00046 00047 void init( const char* name); 00048 00049 }; 00050 00051 #endif