00001 #ifndef binary_ofstream_H 00002 #define binary_ofstream_H 00003 00004 #include <string> 00005 #include <cstdio> 00006 00007 class binary_ofstream { 00008 public: 00009 00010 explicit binary_ofstream( const char* name); 00011 explicit binary_ofstream( const std::string& name); 00012 00013 ~binary_ofstream(); 00014 00015 binary_ofstream& operator<<( char n); 00016 binary_ofstream& operator<<( unsigned char n); 00017 00018 binary_ofstream& operator<<( short n); 00019 binary_ofstream& operator<<( unsigned short n); 00020 00021 binary_ofstream& operator<<( int n); 00022 binary_ofstream& operator<<( unsigned int n); 00023 00024 binary_ofstream& operator<<( long n); 00025 binary_ofstream& operator<<( unsigned long n); 00026 00027 binary_ofstream& operator<<( float n); 00028 binary_ofstream& operator<<( double n); 00029 00030 binary_ofstream& operator<<( bool n); 00031 binary_ofstream& operator<<( const std::string& n); 00032 00033 void close(); 00034 00035 private: 00036 00037 FILE* file_; 00038 00039 void init( const char* name); 00040 00041 }; 00042 00043 #endif