CMS 3D CMS Logo

binary_ofstream Class Reference

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

List of all members.

Public Member Functions

 binary_ofstream (const std::string &name)
 binary_ofstream (const char *name)
void close ()
binary_ofstreamoperator<< (const std::string &n)
binary_ofstreamoperator<< (bool n)
binary_ofstreamoperator<< (double n)
binary_ofstreamoperator<< (float n)
binary_ofstreamoperator<< (unsigned long n)
binary_ofstreamoperator<< (long n)
binary_ofstreamoperator<< (unsigned int n)
binary_ofstreamoperator<< (int n)
binary_ofstreamoperator<< (unsigned short n)
binary_ofstreamoperator<< (short n)
binary_ofstreamoperator<< (unsigned char n)
binary_ofstreamoperator<< (char n)
 ~binary_ofstream ()

Private Member Functions

void init (const char *name)

Private Attributes

FILE * file_


Detailed Description

Definition at line 7 of file binary_ofstream.h.


Constructor & Destructor Documentation

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

Definition at line 8 of file binary_ofstream.cc.

References init().

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

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

Definition at line 13 of file binary_ofstream.cc.

References init().

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

binary_ofstream::~binary_ofstream (  ) 

Definition at line 28 of file binary_ofstream.cc.

References close().

00029 {
00030     close();
00031 }


Member Function Documentation

void binary_ofstream::close ( void   ) 

Definition at line 32 of file binary_ofstream.cc.

References file_.

Referenced by ~binary_ofstream().

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

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

Definition at line 18 of file binary_ofstream.cc.

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

Referenced by binary_ofstream().

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

binary_ofstream & binary_ofstream::operator<< ( const std::string &  n  ) 

Definition at line 66 of file binary_ofstream.cc.

References file_.

00066                                                                 {
00067   (*this) << s.size();
00068   fwrite( s.data(), 1, s.size(), file_);
00069   return *this;
00070 }

binary_ofstream& binary_ofstream::operator<< ( bool  n  ) 

binary_ofstream & binary_ofstream::operator<< ( double  n  ) 

Definition at line 59 of file binary_ofstream.cc.

References file_.

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

binary_ofstream & binary_ofstream::operator<< ( float  n  ) 

Definition at line 57 of file binary_ofstream.cc.

References file_.

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

binary_ofstream & binary_ofstream::operator<< ( unsigned long  n  ) 

Definition at line 55 of file binary_ofstream.cc.

References file_.

00055                                                              {
00056     fwrite( &n, sizeof(n), 1, file_); return *this;}

binary_ofstream & binary_ofstream::operator<< ( long  n  ) 

Definition at line 53 of file binary_ofstream.cc.

References file_.

00053                                                     {
00054     fwrite( &n, sizeof(n), 1, file_); return *this;}

binary_ofstream & binary_ofstream::operator<< ( unsigned int  n  ) 

Definition at line 51 of file binary_ofstream.cc.

References file_.

00051                                                             {
00052     fwrite( &n, sizeof(n), 1, file_); return *this;}

binary_ofstream & binary_ofstream::operator<< ( int  n  ) 

Definition at line 49 of file binary_ofstream.cc.

References file_.

00049                                                    {
00050     fwrite( &n, sizeof(n), 1, file_); return *this;}

binary_ofstream & binary_ofstream::operator<< ( unsigned short  n  ) 

Definition at line 47 of file binary_ofstream.cc.

References file_.

00047                                                               {
00048     fwrite( &n, sizeof(n), 1, file_); return *this;}

binary_ofstream & binary_ofstream::operator<< ( short  n  ) 

Definition at line 45 of file binary_ofstream.cc.

References file_.

00045                                                      {
00046     fwrite( &n, sizeof(n), 1, file_); return *this;}

binary_ofstream & binary_ofstream::operator<< ( unsigned char  n  ) 

Definition at line 41 of file binary_ofstream.cc.

References file_.

00041                                                              {
00042     fputc( n, file_); return *this;
00043 }

binary_ofstream & binary_ofstream::operator<< ( char  n  ) 

Definition at line 38 of file binary_ofstream.cc.

References file_.

00038                                                     {
00039     fputc( n, file_); return *this;
00040 }


Member Data Documentation

FILE* binary_ofstream::file_ [private]

Definition at line 37 of file binary_ofstream.h.

Referenced by close(), 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