src/GamIO/ML5Hdr.cc
/* These are the functions which will output a header in MATLAB ".mat" binary
   format, version 5.  Note that in a valid MATLAB MAT file, this header will
   appear only once and reside at the beginning of the file.  Also note that
   this function should really output the default constructed header ONLY.
   But since this function should be private, used only by the friend class
   MatLabFile, we need only be carefull in that class.  If not there would be
   problems writing a header after reading it from a computer with a different
   byte storage order.

		Input           ML5H    : MAT version 5 header (this)
           			fp	: Output file stream
                                warn     : Warning output level
                                                0 = no warnings
                                                1 = warnings
                                               >1 = fatal warnings
		Output		void    : Output file stream is modified
					  by having the ML5H written to it
		Note			: No care is taken to insure the
					  header is written tothe top of the
					  file (as it should be in MATLAB)   */
These are the functions which will output a header in MATLAB ".mat" binary
format, version 5.  Note that in a valid MATLAB MAT file, this header will
appear only once and reside at the beginning of the file.  Also note that
this function should really output the default constructed header ONLY.
But since this function should be private, used only by the friend class
MatLabFile, we need only be carefull in that class.  If not there would be
problems writing a header after reading it from a computer with a different
byte storage order.


These are the functions which will output a header in MATLAB " . mat " binary format version 5 . Note that in a valid MATLAB MAT file this header will appear only once and reside at the beginning of the file . Also note that this function should really output the default constructed header ONLY . But since this function should be private used only by the friend class MatLabFile we need only be carefull in that class . If not there would be problems writing a header after reading it from a computer with a different byte storage order .
int MatLab5Hdr::write(fstream& fp, int warn) const
  {
  for(int i=0; i<124 && fp.is_open(); i++)		
    fp.write(&(TextField[i]), sizeof(char));	
  if(fp.is_open())					
    {						
    fp.write((char*)&Ver, sizeof(short));		
    fp.write((char*)&M,   sizeof(char));		
    fp.write((char*)&I,   sizeof(char));		
    }
  if(!fp)					
    {						
    if(warn)					
      {						
      MLH5error(1, 1);				
      if(warn>1) MLH5fatality(11);
      else       MLH5error(11);
      }
    return 0;
    }
  return 1;
  }
int MatLab5Hdr :: write ( fstream & fp , int warn ) const { for ( int i = 0 ; i < 124 && fp . is_open ( ) ; i ++ ) fp . write ( & ( TextField [ i ] ) , sizeof ( char ) ) ; if ( fp . is_open ( ) ) { fp . write ( ( char * ) & Ver , sizeof ( short ) ) ; fp . write ( ( char * ) & M , sizeof ( char ) ) ; fp . write ( ( char * ) & I , sizeof ( char ) ) ; } if ( ! fp ) { if ( warn ) { MLH5error ( 1 , 1 ) ; if ( warn > 1 ) MLH5fatality ( 11 ) ; else MLH5error ( 11 ) ; } return 0 ; } return 1 ; }
These are the functions which will output a header in MATLAB ".mat" binary
format, version 5.
These are the functions which will output a header in MATLAB " . mat " binary format version 5 .
// First output 124 char bytes // as the header text field // Continue writing as long // as output stream is OK //    short V = Ver; //    if(WeRBigEnd() == BigEndIn) Swap(V);	// Byte swap Ver if needed // Write the two byte version // Write out endian indicator // (two bytes MI)  // Check that output stream // is still OK.  If not, // we'll output a warning // if needed and even die // if the error is fatal