MatrixConversionForm.cpp

Go to the documentation of this file.
00001 
00002 
00008 /*  
00009 */
00011 
00012 #include "MatrixConversionForm.h"
00013 #include <iomanip>
00014 namespace O_SESSAME {
00015 MatrixConversionForm::MatrixConversionForm()
00016 {
00017 }
00018 
00019 MatrixConversionForm::~MatrixConversionForm()
00020 {
00021 }
00022 void MatrixConversionForm::SetMatrix(const Matrix& _exportMatrix)
00023 {
00024     m_exportMatrix = _exportMatrix;
00025 }
00026 
00027 Matrix MatrixConversionForm::GetMatrix() const
00028 {
00029     return m_exportMatrix;
00030 }
00031 
00032 void MatrixConversionForm::InitializeData(int _sizeObject)
00033 {
00034 
00035 }
00036 
00037 Matrix* MatrixConversionForm::GetDataPtr() const
00038 {
00039     return &m_exportMatrix;
00040 }
00041 int MatrixConversionForm::GetDataSize() const
00042 {
00043     return sizeof(m_exportMatrix);
00044 }
00045 string MatrixConversionForm::GetHeader() const
00046 {
00047     string matrixHeader;
00048     matrixHeader = typeid(m_exportMatrix).name();
00049     return matrixHeader;
00050 }
00051 
00052 string MatrixConversionForm::GetBody() const
00053 {
00054     string matrixString;
00055     stringstream matrixStream;
00056     matrixStream << setprecision(15) << m_exportMatrix;
00057     matrixString = matrixStream.str();
00058 
00059     return matrixString;
00060 }
00061 
00062 string MatrixConversionForm::GetFooter() const
00063 {
00064     string matrixString;
00065     return matrixString;
00066 }
00067  
00068 void MatrixConversionForm::FromHeader(const string& _body)
00069 {
00070 
00071 }
00072 
00073 void MatrixConversionForm::FromBody(const string& _body)
00074 {
00075     char matrixValues[] = {'+', '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.'};
00076     int rowCount = 0;
00077     int columnCount = 0;
00078     int finder = 0;
00079     stringstream fileStream;
00080     string bodyLine;
00081     fileStream << _body;
00082     getline(fileStream,bodyLine,'\n');
00083     while((finder = bodyLine.find_first_of(matrixValues, finder+1))  != string::npos)
00084     {
00085         ++columnCount;
00086         finder = bodyLine.find(' ', finder+1);
00087     }    
00088 
00089     while(!fileStream.eof())
00090     {
00091         getline(fileStream,bodyLine,'\n');
00092         ++rowCount;
00093     }
00094     // Check to see if there are numbers in the last line or if it is an extra linefeed
00095     if(((finder = bodyLine.find_first_of(matrixValues, finder+1))  == string::npos) && rowCount != 0)
00096         --rowCount;
00097 
00098     fileStream.clear();
00099     fileStream << _body;
00100     m_exportMatrix.initialize(rowCount, columnCount);
00101     for(int row = MatrixIndexBase; row <= rowCount; ++row)
00102         for(int col = MatrixIndexBase; col <= columnCount; ++col)
00103             if(!fileStream.eof())
00104                 fileStream >> m_exportMatrix(row,col);
00105 }
00106 
00107 void MatrixConversionForm::FromFooter(const string& _body)
00108 {
00109     
00110 //    ifile.open((GetFileLocation() + GetFilename() + GetExtension()).data(), ifstream::in);
00111 //    filebuf fb;
00112 //    fb.open ((GetFileLocation() + GetFilename() + GetExtension()).data(),ios::in);
00113 //    iostream ios(&fb);
00114   
00115 //    ios >> m_exportMatrix;
00116 //    fb.close();
00117     return;
00118 }
00119 } // close namespace O_SESSAME
00120 
00121 // Do not change the comments below - they will be added automatically by CVS
00122 /*****************************************************************************
00123 *       $Log: AttitudeHistory.cpp,v $
00124 *
00125 ******************************************************************************/

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