/***************************************************************
 * PrMatlab.h
 *
 * This class provides methods to save data in matlab format.
 *
 ****************************************************************/

/*
 * modification history
 *----------------------
 *
 * 04/01/98: K.C. Chang: created.
 */

#ifndef _PrMatlab_h
#define _PrMatlab_h

#include <stdio.h>

#define PR_MATLAB_ERROR 0
#define PR_MATLAB_OK    1

/* matlab types */
typedef enum { 
  PR_MATLAB_DOUBLE=0, PR_MATLAB_FLOAT=10, PR_MATLAB_INT=20 
} PrMatlabType;

class PrMatlab
{
public:
  PrMatlab();

  ~PrMatlab();

  // returns PR_MATLAB_OK if okay, 
  // otherwise, returns PR_MATLAB_ERROR
  // Note: the name of the output file should end with ".mat"
  //       in order to save the data in Matlab format. 
  int start(char *filename);

  void save(char *name,PrMatlabType type,void *data,int row,int col);

  void end(); 

private:
  int endian_;
  FILE *filePtr_;

  // little endian
  //   [0] [1] [2] [3]
  //    1   0   0   0
  // big endian
  //   [0] [1] [2] [3]
  //    0   0   0   1
  int Endian();

  // copy is not allowed.
  PrMatlab(const PrMatlab &) {}
};


#endif // _PrMatlab_h
