RecordDtd.cpp

Go to the documentation of this file.
00001 
00002 
00003 //-----------------------------------------------------------------------------
00004 // CVS: $Revision: 2866 $, $Date: 2006-09-15 12:04:57 +0100 (Fri, 15 Sep 2006) $, $Author: rsc $
00005 //-----------------------------------------------------------------------------
00006 #include <fstream>
00007 #include <stdexcept>
00008 
00009 #include "RecordDtd.h"
00010 
00011 using namespace std;
00012 //-----------------------------------------------------------------------------
00013 RecordDtd::RecordDtd(const string& aFileName)
00014   : vector<BinaryDatum*>(),
00015     mRecordSize(0)
00016 {
00017   ifstream dtdFile(aFileName.c_str());
00018   if (!dtdFile)
00019   {
00020     throw runtime_error(string("File not found: ") + aFileName);
00021   }
00022   while (dtdFile)
00023   {
00024     string dataType;
00025     dtdFile >> dataType;
00026     if (dataType ==  "float")
00027     {
00028       push_back(new SqlFloat(mRecordSize));
00029     }
00030     else if (dataType ==  "real")
00031     {
00032       push_back(new SqlReal(mRecordSize));
00033     }
00034     else if (dataType ==  "bigint")
00035     {
00036       push_back(new SqlBigInt(mRecordSize));
00037     }
00038     else if (dataType ==  "int")
00039     {
00040       push_back(new SqlInt(mRecordSize));
00041     }
00042     else if (dataType ==  "smallint")
00043     {
00044       push_back(new SqlSmallInt(mRecordSize));
00045     }
00046     else if (dataType ==  "tinyint")
00047     {
00048       push_back(new SqlTinyInt(mRecordSize));
00049     }
00050     else
00051     {
00052       // Reached end of file and don't want to increment record size so break
00053       break;
00054     }
00055     mRecordSize += back()->getNumBits();
00056   }
00057   dtdFile.close();
00058 } // RecordDtd
00059 //-----------------------------------------------------------------------------
00060 RecordDtd::~RecordDtd()
00061 {
00062   while (!empty())
00063   {
00064     delete back();
00065     pop_back();
00066   }
00067 }
00068 //-----------------------------------------------------------------------------
Generated on Mon Oct 4 10:39:55 2010 for Matching.kdevelop by  doxygen 1.6.3