BinaryConverter.cpp

Go to the documentation of this file.
00001 
00002 
00008 /*  
00009 */
00011 
00012 #include "BinaryConverter.h"
00013 #include <iomanip>
00014 #include <fstream>
00015 using namespace std;
00016 
00017 namespace O_SESSAME {
00018 BinaryConverter::BinaryConverter(const string& _newFilename, string _newExtension, string _newFileLocation) : Converter(_newFilename, _newExtension, _newFileLocation)
00019 {
00020 }
00021 
00022 void BinaryConverter::Export(const ConversionForm& _exportConvForm)
00023 {
00024     ofstream ofile;
00025     ofile.open((GetFileLocation() + GetFilename() + ".dat").data(), ios::binary);
00026     ofile.write(reinterpret_cast<char*>(_exportConvForm.GetDataPtr()),  _exportConvForm.GetDataSize());
00027     ofile.close();
00028 }
00029 Matrix BinaryConverter::Import(const ConversionForm& _importConvForm)
00030 {
00031     int sizeObject;
00032     ifstream ifile;
00033     ifile.open((GetFileLocation() + GetFilename() + ".dat").data(), ios::binary);
00034   
00035     // get length of file:
00036     ifile.seekg (0, ios::end);
00037     sizeObject = ifile.tellg();
00038     ifile.seekg (0, ios::beg);
00039     _importConvForm.InitializeData(sizeObject);
00040     ifile.read(reinterpret_cast<char*>(_importConvForm.GetDataPtr()),  sizeObject);
00041     ifile.close();
00042 }
00043 } // close namespace O_SESSAME
00044 
00045 // Do not change the comments below - they will be added automatically by CVS
00046 /*****************************************************************************
00047 *       $Log: AttitudeHistory.cpp,v $
00048 *
00049 ******************************************************************************/

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