CMS 3D CMS Logo

binary_ifstream Class Reference

#include <MagneticField/Interpolation/src/binary_ifstream.h>

List of all members.

Public Member Functions

bool bad () const
 binary_ifstream (const std::string &name)
 binary_ifstream (const char *name)
void close ()
bool eof () const
bool fail () const
bool good () const
 stream state checking
 operator bool () const
bool operator! () const
binary_ifstreamoperator>> (std::string &n)
binary_ifstreamoperator>> (bool &n)
binary_ifstreamoperator>> (double &n)
binary_ifstreamoperator>> (float &n)
binary_ifstreamoperator>> (unsigned long &n)
binary_ifstreamoperator>> (long &n)
binary_ifstreamoperator>> (unsigned int &n)
binary_ifstreamoperator>> (int &n)
binary_ifstreamoperator>> (unsigned short &n)
binary_ifstreamoperator>> (short &n)
binary_ifstreamoperator>> (unsigned char &n)
binary_ifstreamoperator>> (char &n)
 ~binary_ifstream ()

Private Member Functions

void init (const char *name)

Private Attributes

FILE * file_


Detailed Description

Definition at line 7 of file binary_ifstream.h.


Constructor & Destructor Documentation

binary_ifstream::binary_ifstream ( const char *  name  )  [explicit]

Definition at line 8 of file binary_ifstream.cc.

References init().

00008                                                   : file_(0)
00009 {
00010     init (name);
00011 }

binary_ifstream::binary_ifstream ( const std::string &  name  )  [explicit]

Definition at line 13 of file binary_ifstream.cc.

References init().

00013                                                        : file_(0)
00014 {
00015     init (name.c_str());
00016 }

binary_ifstream::~binary_ifstream (  ) 

Definition at line 28 of file binary_ifstream.cc.

References close().

00029 {
00030     close();
00031 }


Member Function Documentation

bool binary_ifstream::bad ( void   )  const

Definition at line 99 of file binary_ifstream.cc.

References fail().

Referenced by good(), and operator!().

00099 {return fail();}

void binary_ifstream::close ( void   ) 

Definition at line 32 of file binary_ifstream.cc.

References file_.

Referenced by ~binary_ifstream().

00033 {
00034     if (file_ != 0) fclose( file_);
00035     file_ = 0;
00036 }

bool binary_ifstream::eof ( void   )  const

Definition at line 88 of file binary_ifstream.cc.

References file_.

Referenced by good(), and operator!().

00089 {
00090     return feof( file_);
00091 }

bool binary_ifstream::fail (  )  const

Definition at line 93 of file binary_ifstream.cc.

References file_.

Referenced by bad(), and operator!().

00094 {
00095     return file_ == 0 || ferror( file_) != 0;
00096 }

bool binary_ifstream::good ( void   )  const

stream state checking

Definition at line 83 of file binary_ifstream.cc.

References bad(), and eof().

Referenced by operator bool().

00084 {
00085     return !bad() && !eof();
00086 }

void binary_ifstream::init ( const char *  name  )  [private]

Definition at line 18 of file binary_ifstream.cc.

References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), and file_.

Referenced by binary_ifstream().

00019 {
00020     file_ = fopen( name, "rb");
00021     if (file_ == 0) {
00022         std::cout << "file " << name << " cannot be opened for reading"
00023                   << std::endl;
00024         throw binary_ifstream_error();
00025     }
00026 }

binary_ifstream::operator bool ( void   )  const

Definition at line 105 of file binary_ifstream.cc.

References good().

00105                                      {
00106     return good();
00107 }

bool binary_ifstream::operator! (  )  const

Definition at line 101 of file binary_ifstream.cc.

References bad(), eof(), and fail().

00101 {return fail() || bad() || eof();}

binary_ifstream & binary_ifstream::operator>> ( std::string &  n  ) 

Definition at line 72 of file binary_ifstream.cc.

References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), file_, and tmp.

00072                                                           {
00073   unsigned int nchar;
00074   (*this) >> nchar;  
00075   char* tmp = new char[nchar+1];
00076   unsigned int nread = fread( tmp, 1, nchar, file_);
00077   if (nread != nchar) std::cout << "binary_ifstream error: read less then expected " << std::endl;
00078   n.assign( tmp, nread);
00079   delete[] tmp;
00080   return *this;
00081 }

binary_ifstream& binary_ifstream::operator>> ( bool n  ) 

binary_ifstream & binary_ifstream::operator>> ( double &  n  ) 

Definition at line 64 of file binary_ifstream.cc.

References file_.

00064                                                        {
00065     fread( &n, sizeof(n), 1, file_); return *this;}

binary_ifstream & binary_ifstream::operator>> ( float &  n  ) 

Definition at line 62 of file binary_ifstream.cc.

References file_.

00062                                                       {
00063     fread( &n, sizeof(n), 1, file_); return *this;}

binary_ifstream & binary_ifstream::operator>> ( unsigned long &  n  ) 

Definition at line 59 of file binary_ifstream.cc.

References file_.

00059                                                               {
00060     fread( &n, sizeof(n), 1, file_); return *this;}

binary_ifstream & binary_ifstream::operator>> ( long &  n  ) 

Definition at line 57 of file binary_ifstream.cc.

References file_.

00057                                                      {
00058     fread( &n, sizeof(n), 1, file_); return *this;}

binary_ifstream & binary_ifstream::operator>> ( unsigned int n  ) 

Definition at line 54 of file binary_ifstream.cc.

References file_.

00054                                                              {
00055     fread( &n, sizeof(n), 1, file_); return *this;}

binary_ifstream & binary_ifstream::operator>> ( int n  ) 

Definition at line 52 of file binary_ifstream.cc.

References file_.

00052                                                     {
00053     fread( &n, sizeof(n), 1, file_); return *this;}

binary_ifstream & binary_ifstream::operator>> ( unsigned short &  n  ) 

Definition at line 50 of file binary_ifstream.cc.

References file_.

00050                                                                {
00051     fread( &n, sizeof(n), 1, file_); return *this;}

binary_ifstream & binary_ifstream::operator>> ( short &  n  ) 

Definition at line 48 of file binary_ifstream.cc.

References file_.

00048                                                       {
00049     fread( &n, sizeof(n), 1, file_); return *this;}

binary_ifstream & binary_ifstream::operator>> ( unsigned char &  n  ) 

Definition at line 43 of file binary_ifstream.cc.

References file_.

00043                                                               {
00044     n = static_cast<unsigned char>(fgetc(file_));
00045     return *this;
00046 }

binary_ifstream & binary_ifstream::operator>> ( char &  n  ) 

Definition at line 38 of file binary_ifstream.cc.

References file_.

00038                                                      {
00039     n = static_cast<char>(fgetc(file_));
00040     return *this;
00041 }


Member Data Documentation

FILE* binary_ifstream::file_ [private]

Definition at line 45 of file binary_ifstream.h.

Referenced by close(), eof(), fail(), init(), and operator>>().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:15:01 2009 for CMSSW by  doxygen 1.5.4