src/GamIO/ML5Hdr.cc
/* These are the functions which will input a header in MATLAB ".mat" binary
   format, version 5.  Note that in a valid MATLAB V5 MAT file this header will
   appear only once and reside at the beginning of the file.  These functions
   can not alter the MAT file, they can only alter where the file pointer is.
   Upon a read, any data will be byte swapped as required by computer byte
   ordering differences.  Upon header output, any header text input will be
   altered accordingly.                                                      
 
                Input           ML5H    : MAT version 5 header (this)
                                fp      : Input file stream
                                warn     : Warning output level
                                                0 = no warnings
                                                1 = warnings
                                               >1 = fatal warnings
                Output          void    : ML5H is set from values found
                                          in the input stream
                Note                    : No care is taken to insure the
                                          header is read from the top of the
                                          file (as it should be in MATLAB)   */
These are the functions which will input a header in MATLAB ".mat" binary
format, version 5.  Note that in a valid MATLAB V5 MAT file this header will
appear only once and reside at the beginning of the file.  These functions
can not alter the MAT file, they can only alter where the file pointer is.
Upon a read, any data will be byte swapped as required by computer byte
ordering differences.  Upon header output, any header text input will be
altered accordingly.


These are the functions which will input a header in MATLAB " . mat " binary format version 5 . Note that in a valid MATLAB V5 MAT file this header will appear only once and reside at the beginning of the file . These functions can not alter the MAT file they can only alter where the file pointer is . Upon a read any data will be byte swapped as required by computer byte ordering differences . Upon header output any header text input will be altered accordingly .
int MatLab5Hdr::read(fstream& fp, int warn)
  {
  for(int i=0; i<124; i++)			
    { 						
    if(!fp || fp.eof())				
      {						
      if(warn)					
        {					
        MLH5error(1, 1);			
        if(warn>1) MLH5fatality(11);
        else       MLH5error(11);
        }
      return 0;
      }
    fp.read(&(TextField[i]), sizeof(char));
    }
  fp.read((char*)&Ver, sizeof(short));			
  fp.read((char*)&M, sizeof(char));			
  fp.read((char*)&I, sizeof(char));
  (M=='M')?BigEndIn=1:BigEndIn=0;		
  if(int(WeRBigEnd()) == BigEndIn) Swap(Ver);	
  return 1;
  }
int MatLab5Hdr :: read ( fstream & fp , int warn ) { for ( int i = 0 ; i < 124 ; i ++ ) { if ( ! fp || fp . eof ( ) ) { if ( warn ) { MLH5error ( 1 , 1 ) ; if ( warn > 1 ) MLH5fatality ( 11 ) ; else MLH5error ( 11 ) ; } return 0 ; } fp . read ( & ( TextField [ i ] ) , sizeof ( char ) ) ; } fp . read ( ( char * ) & Ver , sizeof ( short ) ) ; fp . read ( ( char * ) & M , sizeof ( char ) ) ; fp . read ( ( char * ) & I , sizeof ( char ) ) ; ( M == ' ' ) ? BigEndIn = 1 : BigEndIn = 0 ; if ( int ( WeRBigEnd ( ) ) == BigEndIn ) Swap ( Ver ) ; return 1 ; }
These are the functions which will input a header in MATLAB ".mat" binary
format, version 5.
These are the functions which will input a header in MATLAB " . mat " binary format version 5 .
// First input 124 char bytes // as the header text field // Insure filestream is open // Here if bad filestream // We'll output a warning // if needed and even die // if the error is fatal // Read the two byte version // Read out endian indicator // Set input endian flag  // Byte swap Ver if needed