#include #include #include "apstring.h" apstring parseOut(ifstream &, apstring); int main() { ifstream stdFile, headFile; ofstream output; char ch; apstring str1 = "", head = "", mid = "", tail = "", str2 = "", column = "", rootName, rootPage, rootPage2, temp1, temp2, head_torpg = "", mid_torpg = ""; int num; bool invisFlag; headFile.open("head.dat"); while (headFile.get(ch)) head = head + ch; headFile.close(); headFile.open("head_torpg.dat"); while (headFile.get(ch)) head_torpg = head_torpg + ch; headFile.close(); headFile.open("mid.dat"); while (headFile.get(ch)) mid = mid + ch; headFile.close(); headFile.open("mid_torpg.dat"); while (headFile.get(ch)) mid_torpg = mid_torpg + ch; headFile.close(); headFile.open("pages.dat"); output.open("pages2.dat"); while (headFile.get(ch)) output << ch; output.close(); headFile.close(); headFile.open("tail.dat"); while (headFile.get(ch)) tail = tail + ch; headFile.close(); stdFile.open("pages.dat"); while (stdFile >> str1) { column = ""; rootPage2 = ""; if (str1 == "") { invisFlag = true; stdFile >> str1; rootPage = str1; headFile.open("pages2.dat"); invisFlag = false; while (headFile >> temp1) { if (temp1 == "" || temp1 == "") { if (temp1 == "") invisFlag = false; else if (temp1 == "") invisFlag = true; headFile >> rootPage2; getline(headFile, temp1); if (!invisFlag) column = column + "" + temp1 + "
\n"; } else if (rootPage2 == rootPage && !invisFlag) { getline(headFile, temp2); column = column + "" + temp2 + "
\n"; } } headFile.close(); str2 = str1 + ".html"; output.open(str2.c_str()); getline(stdFile, str2); str2 = str1 + ".dat"; headFile.open(str2.c_str()); if (rootPage == "torpg") output << head_torpg << column << mid_torpg; else output << head << column << mid; output << parseOut(headFile, rootPage) << tail; headFile.close(); output.close(); } else { headFile.open("pages2.dat"); invisFlag = false; while (headFile >> temp1) { if (temp1 == "" || temp1 == "") { if (temp1 == "") invisFlag = false; else if (temp1 == "") invisFlag = true; headFile >> rootPage2; getline(headFile, temp1); if (!invisFlag) column = column + "" + temp1 + "
\n"; } else if (rootPage2 == rootPage && !invisFlag) { getline(headFile, temp2); column = column + "" + temp2 + "
\n"; } } headFile.close(); str2 = rootPage + '_' + str1 + ".html"; output.open(str2.c_str()); getline(stdFile, str2); str2 = rootPage + '_' + str1 + ".dat"; headFile.open(str2.c_str()); if (rootPage == "torpg") output << head_torpg << column << mid_torpg; else output << head << column << mid; output << parseOut(headFile, rootPage) << tail; headFile.close(); output.close(); } } stdFile.close(); cout << "Website build completed.\n"; return 0; } apstring parseOut(ifstream & inFile, apstring pageType) { apstring toReturn, temp, temp2; int count = 4, entries = 0; char ch; bool torpg = false; if (pageType == "torpg") torpg = true; while (getline(inFile, temp) && count <= 4) { if (temp == "") { count = 4; getline(inFile, temp2); getline(inFile, temp); toReturn += "\n"; toReturn += "\n"; toReturn += "\n"; toReturn += "
\n"; if (torpg) { toReturn += ""; toReturn += ""; toReturn = toReturn + "
" + temp; toReturn = toReturn + "
"; toReturn += "   "; } else { toReturn += ""; toReturn += ""; toReturn = toReturn + "
" + temp; toReturn = toReturn + "
"; toReturn += "   "; } getline(inFile, temp); toReturn = toReturn + "Contributed by:" + temp2 + "
"; } else if (temp == "") { count = 0; toReturn += "
  "; if (torpg) toReturn += "
\n
"; else toReturn += "\n
"; entries++; } else if (temp == "") { count = 5; } else if (temp == "") { count = 6; } if (entries == 5) { toReturn += "



ARCHIVED



\n"; entries++; } if (count == 4) toReturn = toReturn + temp; } if (count == 5) { while (inFile.get(ch)) { if (ch == '\n') toReturn += "
"; else toReturn += ch; } } else if (count == 6) { while (inFile.get(ch)) { toReturn += ch; } } toReturn += "

"; return toReturn; }