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
00038 ifile.seekg (0, ios::end);
00039 length = ifile.tellg();
00040 ifile.seekg (0, ios::beg);
00041
00042
00043 buffer = new char [length];
00044
00045
00046 ifile.read (buffer,length);
00047 ifile.close();
00048
00049 string fileString(buffer);
00050
00051 _importConvForm.FromBody(fileString);
00052 }
00053 }
00054
00055
00056
00057
00058
00059