#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <vector>
Go to the source code of this file.
Functions | |
int | main (int argc, char *argv[]) |
int | MakeDeanHTML (std::string const &InFileName, std::string const &OutFileName) |
int main | ( | int | argc, |
char * | argv[] | ||
) |
Definition at line 122 of file MakeDeanHTML.cc.
References benchmark_cfg::cerr, and MakeDeanHTML().
{ if (argc != 3) { std::cerr << "Usage: " << argv[0] << " [InFile] [OutFile]" << std::endl; return 1; } MakeDeanHTML(argv[1], argv[2]); return 0; }
int MakeDeanHTML | ( | std::string const & | InFileName, |
std::string const & | OutFileName | ||
) |
Definition at line 51 of file MakeDeanHTML.cc.
References benchmark_cfg::cerr.
Referenced by main().
{ // open the input file std::ifstream InFile(InFileName.c_str()); if (!InFile.is_open()) { std::cerr << "ERROR: cannot open input file" << std::endl; return 1; } // open the output file std::ofstream OutFile(OutFileName.c_str()); if (!OutFile.is_open()) { std::cerr << "ERROR: cannot open output file" << std::endl; return 1; } // print header OutFile << "<html>\n<body>\n\n"; // Read first 3 line which contains widths (and is the number of cols) std::string FirstLine; std::getline(InFile, FirstLine); std::istringstream LineStream; LineStream.str(FirstLine); std::string Width; std::vector<std::string> Widths; while (LineStream >> Width) { Widths.push_back(Width); } while (InFile.peek() == '#') { std::getline(InFile, FirstLine); OutFile << std::string(FirstLine.begin()+1, FirstLine.end()) << std::endl; } OutFile << "<hr>\n<table>\n\n"; while (!InFile.eof()) { OutFile << " <tr>\n"; std::string OneLine; for (size_t iCol = 0; iCol != Widths.size(); ++iCol) { std::getline(InFile, OneLine); bool const BlankLine = OneLine == "" ? true : false; OutFile << " <td width=\"" << Widths[iCol] << "\">\n"; if (!BlankLine) { std::string const PlotName(OneLine.begin(), OneLine.begin()+OneLine.find(":")); std::string const ThumbName = std::string(PlotName.begin(), PlotName.begin() + PlotName.find(".gif")) + "_small.gif"; std::string const Caption(OneLine.begin()+OneLine.find(":")+1, OneLine.end()); OutFile << " <center>\n"; OutFile << " <a href=\"" << PlotName << "\">\n"; OutFile << " <img src=\"" << ThumbName << "\">\n"; OutFile << " </a><br>\n"; OutFile << " " << Caption << "\n"; OutFile << " </center>\n"; } OutFile << " </td>\n"; } OutFile << " </tr>\n\n"; // Get a blank line std::getline(InFile, OneLine); } OutFile << "</table>\n\n</body>\n</html>"; OutFile.close(); InFile.close(); return 0; }