ASCIIConverter.cpp

Go to the documentation of this file.
00001 
00002 
00008 /*  
00009 */
00011 
00012 #include "ASCIIConverter.h"
00013 #include <iomanip>
00014 #include <fstream>
00015 using namespace std;
00016 
00017 namespace O_SESSAME {
00018 ASCIIConverter::ASCIIConverter(const string& _newFilename, string _newExtension, string _newFileLocation) : Converter(_newFilename, _newExtension, _newFileLocation)
00019 {
00020 }
00021 
00022 void ASCIIConverter::Export(const ConversionForm& _exportConvForm)
00023 {
00025     ofstream ofile;
00026     ofile.open((GetFileLocation() + GetFilename() + GetExtension()).data(), ofstream::out);
00027     ofile << _exportConvForm.GetBody() << endl;
00028     ofile.close();
00029 }
00030 Matrix ASCIIConverter::Import(const ConversionForm& _importConvForm)
00031 {
00032     int length;
00033     char * buffer;
00034     ifstream ifile;
00035     ifile.open((GetFileLocation() + GetFilename() + GetExtension()).data(), ifstream::in);
00036 
00037  // get length of file:
00038     ifile.seekg (0, ios::end);
00039     length = ifile.tellg();
00040     ifile.seekg (0, ios::beg);
00041 
00042     // allocate memory:
00043     buffer = new char [length];
00044 
00045     // read data as a block:
00046     ifile.read (buffer,length);
00047     ifile.close();
00048 
00049     string fileString(buffer);
00050 
00051     _importConvForm.FromBody(fileString);
00052 }
00053 } // close namespace O_SESSAME
00054 
00055 // Do not change the comments below - they will be added automatically by CVS
00056 /*****************************************************************************
00057 *       $Log: AttitudeHistory.cpp,v $
00058 *
00059 ******************************************************************************/

Generated on Wed Aug 6 12:58:42 2003 for Open-Sessame Framework by doxygen1.3