warfighter67

help 3

Oct 17th, 2013
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.84 KB | None | 0 0
  1. void generateWebpage(string filename, string name, vector<string> general, vector<string>  specific, vector<grant> grants)
  2. {
  3.     ofstream fout;
  4.     string isPI = "";
  5.  
  6.     fout.open(filename);
  7.  
  8.     if(!fout)
  9.     {
  10.         cout << filename << " could not be opened for writing!" << endl;
  11.         exit(0);
  12.     }
  13.  
  14.     fout << "<!DOCTYPE html>\n<html>\n\t<body>" << endl;
  15.     fout << "\t\t<h1>Research of " << name << "</h1>" << endl;  //print heading
  16.     fout << "\t\t<hr/>" << endl;                                //print horizontal line
  17.  
  18.  
  19.     fout << "\t\t<h2>In General:</h2>" << endl;                 //print first subheading
  20.     fout << "\t\t<ul>" << endl;                                 //start unordered list
  21.  
  22.     for(vector<string>::iterator i = general.begin(); i < general.end(); i++)
  23.     {
  24.         fout << "\t\t\t<li>" << *i << "</li>" << endl;
  25.     }
  26.  
  27.     fout << "\t\t</ul>" << endl;                                //end unordered list
  28.     fout << "\t\t<hr/>" << endl;                                //print horizontal line
  29.  
  30.  
  31.     fout << "\t\t<h2>In Specific:</h2>" << endl;                //print second subheading
  32.     fout << "\t\t<ul>" << endl;                                 //start unordered list
  33.  
  34.     for(vector<string>::iterator i = specific.begin(); i < specific.end(); i++)
  35.     {
  36.         fout << "\t\t\t<li>" << *i << "</li>" << endl;
  37.     }
  38.  
  39.     fout << "\t\t</ul>" << endl;                                //end unordered list
  40.     fout << "\t\t<hr/>" << endl;                                //print horizontal line
  41.  
  42.  
  43.     fout << "\t\t<h2>Research Grants:</h2>" << endl;            //print third subheading
  44.     fout << "\t\t<ul>" << endl;                                 //start unordered list
  45.  
  46.     for(vector<grant>::iterator i = grants.begin(); i < grants.end(); i++)
  47.     {
  48.         if((*i).IsPI)
  49.             isPI = "PI.";
  50.         else
  51.             isPI = "Co-PI.";
  52.  
  53.         fout << "\t\t\t<li>";
  54.         fout << "<b>" << (*i).title << "</b>, " << (*i).agency << ", " << IntToDollar((*i).amount) << ", " << (*i).period << ", " << isPI;
  55.         fout << "</li>" << endl;
  56.     }
  57.  
  58.     fout << "\t\t</ul>" << endl;                                //end unordered list
  59.     fout << "\t</body>\n</html>" << endl;
  60.  
  61.     return;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment