Source: include/hpconvert.H


Annotated List
Files
Globals
Hierarchy
Index
/* -------------------------------------------------------------------------
   hpconvert.H - Conversion Class for HpTrans Program
   -------------------------------------------------------------------------
   Copyright (C) 2000-2001 Eric R. Schendel
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.
 
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
 
   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.               
   ------------------------------------------------------------------------- */

#ifndef HPCONVERT_H
#define HPCONVERT_H

#include "status.H"
#include "hp49calc.H"

namespace HpConvertNamespace {

using namespace StatusMsgs;
using namespace Hp49Calc;

const int HPC_BUFSIZE = 8 * 1024;

class HpConvertFile {

   public:

      HpConvertFile(LogLevel lvl = NONE);

      /**
       * If possible, this method converts an Hp49File to a usable text file.
       * For now, the only convertable Hp49File types are string files. Every
       * other type is saved "as is".
       *
       * @param ofile  Hp49 file to convert from (if possible)
       * @param nfile  Text file to convert to
       * @param binary Allow binary save if convert not possible? Otherwise
       *               return an Error. Default is true.
       */
      Error fromHp49File(string ofile, string nfile, bool binary = true);

      /**
       * If possible, this method converts a usable text file to an Hp49File.
       * For now, only able to convert a text file to a Hp49File string. Every
       * other type is saved "as is", which is mostlikely a Hp49 binary file.
       *
       * @param ofile  Text file to convert from (if possible)
       * @param nfile  Hp49 file to convert to
       * @param binary Allow binary save if file already converted? Otherwise
       *               return a MINOR Error. Default is true.
       */
      Error toHp49File(string ofile, string nfile, bool binary = true);

      Error toBinaryFile(string ofile, string nfile)
      { return save_binary_file(ofile, nfile); }

      bool checkFile(string file);

   private:
      Log log;

      Error save_binary_file(string& ofile, string& nfile, bool binary = true);
      Error convert_from_string_file(Hp49FileRead& hf, string& file);
      Error convert_to_string_file(string& ofile, Hp49FileWrite& hf);
};

} // namespace HpConvertNamespace //

#endif

Generated on Fri Mar 9 02:04:42 2001, using kdoc 2.0a43.