#include #include #include #include "QuadFiler.h" #include "Quad.h" #include "Token.h" #include "pmglobs.h" void QuadFiler::store(char* filename) { strcpy(fname, filename); } void QuadFiler::createQuadFile() { remove(fname); //remove the old one if it exists fs.open(fname, ios::in | ios::out ); //open a new one } void QuadFiler::retrieveQuadFile() { fs.open(fname, ios::in | ios::out); //open a new one } void QuadFiler::removeQuadFile() { remove(fname); } void QuadFiler::seeQuadFile() { int k=1; int op, t1a, t1b, t2a, t2b, res; Quadruple q; Token opnd1, opnd2; retrieveQuadFile(); cout << "\n\nThe set of Quadruples for "<< fname << " is: \n\n"; cout << "Quad # Quadruple\n"; cout <<"--------------------------------------------------\n"; fs>>op>>t1a>>t1b>>t2a>>t2b>>res; while (!fs.eof()) { opnd1.setClass(TokenClass(t1a)); opnd1.setValue(t1b); opnd2.setClass(TokenClass(t2a)); opnd2.setValue(t2b); q.setQuad(op, opnd1, opnd2, res); cout.width(4); cout<>op>>t1a>>t1b>>t2a>>t2b>>res; k++; } closeQuadFile(); cout << "\nEnd of Quadruple file!"; } void QuadFiler::emitQuad(Quadruple q) { int t1a=q.opnd1.getClass(); int t1b=q.opnd1.getValue(); int t2a=q.opnd2.getClass(); int t2b=q.opnd2.getValue(); fs<>op>>t1a>>t1b>>t2a>>t2b>>res; opnd1.setClass(TokenClass(t1a));opnd1.setValue(t1b); opnd2.setClass(TokenClass(t2a));opnd2.setValue(t2b); q.setQuad(op, opnd1, opnd2, res); return q; }