// col.h: interface for the Col class. // // #include #ifndef CLASSES_H #define CLASSES_H using namespace std; extern TAG tagextractor(fstream &fin); extern void tagprocessor(TAG &ReturnedTag, fstream &fin, ofstream &fout); extern TAG ReturnedTag; extern char inp; extern string buffer; class Row; class Col; class Table; void DealRow(fstream &sin, ofstream &sout,int &tablenum, int &rows); void DealCol(fstream &sin, ofstream &sout,int &tablenum, int &row, int &cols); int scope = 0; // Table class definition // ////////////////////////////////////////////////////////////////////// class Table { public: Table(); void ExtractTableDetails(fstream &sin, ofstream &sout); int tablenum; bool open; int rows; }; Table::Table(){ open = true; rows = 0; tablenum = 0; } // Extracts the details of a table void Table::ExtractTableDetails(fstream &sin, ofstream &sout){ scope++; while( open ){ sin.get(inp); if(inp == '<'){ ReturnedTag = tagextractor(sin); if(ReturnedTag == TR){ //Extracts the details of a row DealRow(sin, sout, tablenum, rows); } else if(ReturnedTag == CTABLE){ open = false; //or break scope--; } } } } // Page class definition // ////////////////////////////////////////////////////////////////////// class Page { public: Page(); void AddTable(fstream &sin, ofstream &sout); int tables; }; Page::Page(){ tables = 0; } void Page::AddTable(fstream &sin, ofstream &sout){ Table Tchild; ++tables; Tchild.tablenum = tables; Tchild.ExtractTableDetails(sin,sout); } // Row class definition // ////////////////////////////////////////////////////////////////////// class Row { public: Row(); void ExtractColumns(fstream &sin, ofstream &sout, int &tablenum); int rownum; int cols; }; Row::Row(){ cols = 0; rownum = 0; } void Row::ExtractColumns(fstream &sin, ofstream &sout, int &tablenum){ while( !sin.eof() ){ sin.get(inp); if(inp == '<'){ ReturnedTag = tagextractor(sin); if(ReturnedTag == TD){ //row++; DealCol(sin, sout, tablenum, rownum, cols); } else if(ReturnedTag == CTR){ return; } } } } // Column class definition // ////////////////////////////////////////////////////////////////////// class Col { public: Col(); void ExtractData(fstream &sin, ofstream &sout, int &tablenum, int &rownum); int colnum; int tables; }; Col::Col(){ colnum = 0; tables = 0; } void Col::ExtractData(fstream &sin, ofstream &sout, int &tablenum, int &rownum){ while( !sin.eof() ){ sin.get(inp); if(inp == '<'){ ReturnedTag = tagextractor(sin); if(ReturnedTag == TD){ } //Throw away Scripts or Style Sheet entries else if(ReturnedTag == SCRIPT){ tagprocessor(ReturnedTag, sin, sout); ReturnedTag = tagextractor(sin); } else if(ReturnedTag == STYLE){ tagprocessor(ReturnedTag, sin, sout); ReturnedTag = tagextractor(sin); } else if(ReturnedTag == TABLE){ // Parent->subtables += 1 ; //enforce scope in output for(int j=0; j < scope; j++) sout<< " "; sout << "( " << tablenum << " " << rownum << " " << colnum << ": "<< endl; Table CTable; tables++; CTable.tablenum = tables; CTable.ExtractTableDetails(sin, sout); //enforce scope in output for(int k=0; k < scope; k++) sout<< " "; sout << ")" << endl; } else if(ReturnedTag == CTD){ break; } } else{ int count = 0; string temp; while( inp != '<') { while( inp == '&' ){ while(inp != ';'){ sin.get(inp); } sin.get(inp); } if(inp == '<') break; count++; if( inp!= 10 && inp!= 13) temp.append(&inp); sin.get(inp); } sin.putback(inp); // NOTE: Must insert statement to throw away all whitespace strings if(count > 0){ //enforce scope in output for(int j=0; j < scope; j++) sout<< " "; sout << " " << tablenum << " " << rownum << " " << colnum << " = "; sout << temp; sout <