src/GamIO/ML5Tag.cc
/* These are the functions which will input a tag in MATLAB ".mat" binary
   format, version 5.  Note that in a valid MATLAB MAT file, this tag will
   associated with a "Data Element", a combination of Tag + Data 

		Input           ML5T    : MAT version 5 tag (this)
           			fp	: Input file stream
				bigend  : Data storage endian type
                                warn     : Warning output level
                                                0 = no warnings
                                                1 = warnings
                                               >1 = fatal warnings
		Output		void    : ML5T is set from values found
					  in the input stream
		Note			: No care is taken to insure the
					  tag is read from the top of a data
					  element (as it should be in MATLAB)*/
These are the functions which will input a tag in MATLAB ".mat" binary
format, version 5.  Note that in a valid MATLAB MAT file, this tag will
associated with a "Data Element", a combination of Tag + Data


These are the functions which will input a tag in MATLAB " . mat " binary format version 5 . Note that in a valid MATLAB MAT file this tag will associated with a " Data Element " a combination of Tag + Data
int MatLab5Tag::read(std::fstream& fp, int bigend, int warn)
  {
  for(int i=0; i<8; i++)			
    { 						
    if(!fp || fp.eof())				
      {						
      if(warn)					
        {					
        MLT5error(1, 1);			
        if(warn>1) MLT5fatality(11);
        else       MLT5error(11,1);
        }
      return 0;
      }
    fp.read(&(EightBytes[i]), sizeof(char));
    }
  SetCompressed(bigend);			
  int swap = 0;					
  if(bigend != int(WeRBigEnd())) swap++;		
  if(Compressed)				
    {						
    shortchars IC; 				
    IC.chars[0] = EightBytes[0];		
    IC.chars[1] = EightBytes[1];		
    if(swap) Swap(IC.shortval);			
    if(bigend) NBytes = IC.shortval;
    else       DType  = IC.shortval; 
    IC.chars[0] = EightBytes[2];
    IC.chars[1] = EightBytes[3];
    if(swap) Swap(IC.shortval);
    if(bigend) DType  = IC.shortval;
    else       NBytes = IC.shortval;
    }
  else
    {
    longchars LC;				
    LC.chars[0] = EightBytes[0];		
    LC.chars[1] = EightBytes[1];		
    LC.chars[2] = EightBytes[2];		
    LC.chars[3] = EightBytes[3];		
    if(swap) Swap(LC.longval);
    DType = LC.longval;
    LC.chars[0] = EightBytes[4];		
    LC.chars[1] = EightBytes[5];		
    LC.chars[2] = EightBytes[6];		
    LC.chars[3] = EightBytes[7];
    if(swap) Swap(LC.longval);
    NBytes = LC.longval;
    }
  return 1;
  }
int MatLab5Tag :: read ( std :: fstream & fp , int bigend , int warn ) { for ( int i = 0 ; i < 8 ; i ++ ) { if ( ! fp || fp . eof ( ) ) { if ( warn ) { MLT5error ( 1 , 1 ) ; if ( warn > 1 ) MLT5fatality ( 11 ) ; else MLT5error ( 11 , 1 ) ; } return 0 ; } fp . read ( & ( EightBytes [ i ] ) , sizeof ( char ) ) ; } SetCompressed ( bigend ) ; int swap = 0 ; if ( bigend != int ( WeRBigEnd ( ) ) ) swap ++ ; if ( Compressed ) { shortchars IC ; IC . chars [ 0 ] = EightBytes [ 0 ] ; IC . chars [ 1 ] = EightBytes [ 1 ] ; if ( swap ) Swap ( IC . shortval ) ; if ( bigend ) NBytes = IC . shortval ; else DType = IC . shortval ; IC . chars [ 0 ] = EightBytes [ 2 ] ; IC . chars [ 1 ] = EightBytes [ 3 ] ; if ( swap ) Swap ( IC . shortval ) ; if ( bigend ) DType = IC . shortval ; else NBytes = IC . shortval ; } else { longchars LC ; LC . chars [ 0 ] = EightBytes [ 0 ] ; LC . chars [ 1 ] = EightBytes [ 1 ] ; LC . chars [ 2 ] = EightBytes [ 2 ] ; LC . chars [ 3 ] = EightBytes [ 3 ] ; if ( swap ) Swap ( LC . longval ) ; DType = LC . longval ; LC . chars [ 0 ] = EightBytes [ 4 ] ; LC . chars [ 1 ] = EightBytes [ 5 ] ; LC . chars [ 2 ] = EightBytes [ 6 ] ; LC . chars [ 3 ] = EightBytes [ 7 ] ; if ( swap ) Swap ( LC . longval ) ; NBytes = LC . longval ; } return 1 ; }
These are the functions which will input a tag in MATLAB ".mat" binary
format, version 5.
These are the functions which will input a tag in MATLAB " . mat " binary format version 5 .
// Just input 8 char bytes // as the tag 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 // See if tag input compressed // Assume no byte swapping, // but check and see // See if tag indicates the // data element is comrpessed // If so, NBytes will be in the // first two bytes and the data // type will be in the 2nd pair // of bytes // Now we clip out the data // type. This tells us how // the data is stored. Most // times this is MATLAB form, // indicated by type 14 // Next we clip out the # of // bytes stored in the data // element.