Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00039
00040
00041 #include <iostream>
00042 #include <fstream>
00043 #include <string>
00044 #include <sstream>
00045 #include <vector>
00046
00047
00048
00049
00050
00051 int MakeDeanHTML (std::string const& InFileName, std::string const& OutFileName)
00052 {
00053
00054 std::ifstream InFile(InFileName.c_str());
00055 if (!InFile.is_open()) {
00056 std::cerr << "ERROR: cannot open input file" << std::endl;
00057 return 1;
00058 }
00059
00060
00061 std::ofstream OutFile(OutFileName.c_str());
00062 if (!OutFile.is_open()) {
00063 std::cerr << "ERROR: cannot open output file" << std::endl;
00064 return 1;
00065 }
00066
00067
00068 OutFile << "<html>\n<body>\n\n";
00069
00070
00071 std::string FirstLine;
00072 std::getline(InFile, FirstLine);
00073 std::istringstream LineStream;
00074 LineStream.str(FirstLine);
00075 std::string Width;
00076 std::vector<std::string> Widths;
00077 while (LineStream >> Width) {
00078 Widths.push_back(Width);
00079 }
00080 while (InFile.peek() == '#') {
00081 std::getline(InFile, FirstLine);
00082 OutFile << std::string(FirstLine.begin()+1, FirstLine.end()) << std::endl;
00083 }
00084
00085 OutFile << "<hr>\n<table>\n\n";
00086
00087 while (!InFile.eof()) {
00088 OutFile << " <tr>\n";
00089 std::string OneLine;
00090 for (size_t iCol = 0; iCol != Widths.size(); ++iCol) {
00091 std::getline(InFile, OneLine);
00092 bool const BlankLine = OneLine == "" ? true : false;
00093
00094 OutFile << " <td width=\"" << Widths[iCol] << "\">\n";
00095 if (!BlankLine) {
00096 std::string const PlotName(OneLine.begin(), OneLine.begin()+OneLine.find(":"));
00097 std::string const ThumbName = std::string(PlotName.begin(), PlotName.begin() + PlotName.find(".gif")) + "_small.gif";
00098 std::string const Caption(OneLine.begin()+OneLine.find(":")+1, OneLine.end());
00099 OutFile << " <center>\n";
00100 OutFile << " <a href=\"" << PlotName << "\">\n";
00101 OutFile << " <img src=\"" << ThumbName << "\">\n";
00102 OutFile << " </a><br>\n";
00103 OutFile << " " << Caption << "\n";
00104 OutFile << " </center>\n";
00105 }
00106 OutFile << " </td>\n";
00107 }
00108 OutFile << " </tr>\n\n";
00109
00110 std::getline(InFile, OneLine);
00111 }
00112
00113 OutFile << "</table>\n\n</body>\n</html>";
00114
00115 OutFile.close();
00116 InFile.close();
00117
00118 return 0;
00119 }
00120
00121
00122 int main (int argc, char* argv[])
00123 {
00124 if (argc != 3) {
00125 std::cerr << "Usage: " << argv[0] << " [InFile] [OutFile]" << std::endl;
00126 return 1;
00127 }
00128
00129 MakeDeanHTML(argv[1], argv[2]);
00130
00131 return 0;
00132 }