00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <string>
00018 #include <fstream.h>
00019 #include <cstdlib>
00020 #include <unistd.h>
00021 #include <stdio.h>
00022 #include <utility>
00023 #include <list>
00024 #include <vector>
00025 #include <map>
00026 #include <stdexcept>
00027 #include <time.h>
00028 #include <assert.h>
00029 #include <algorithm>
00030
00031
00032 #define PR(x) cout << #x << " = " << (x) << endl;
00033
00034 typedef map<string, string, less<string> > keywordMap_type;
00035 typedef keywordMap_type::value_type keyword_type;
00036
00037 template<class A, class B>
00038 ostream& operator<<(ostream& out, const pair<A,B> &p)
00039 {
00040 out << p.first << " is defined in " << p.second;
00041 return out;
00042 }
00043
00044 int main(int argc, char* argv[])
00045 {
00046 if (argc < 2) {
00047 cerr << "Usage: " << argv[0] << " file ..." << endl;
00048 return 2;
00049 }
00050
00051
00052
00053
00054
00055
00056 keywordMap_type keywordMap;
00057 string htmlFile, keywordFile, baseName, line;
00058 size_t pos, nkeys;
00059 ifstream ifs;
00060 int i, j, k;
00061 for (i=1; i<argc; i++) {
00062 htmlFile = keywordFile = baseName = argv[i];
00063 pos = htmlFile.find(".html");
00064 if (pos == string::npos) {
00065 cerr << argv[0] << ": error, file must have extension '.html': "
00066 << htmlFile << endl;
00067 continue;
00068 }
00069 keywordFile.replace(pos, 5, ".keywords");
00070 baseName.erase(pos, 5);
00071 pos = baseName.rfind(".");
00072 if (pos != string::npos) baseName.erase(pos, line.size()-pos);
00073 ifs.open(keywordFile.c_str());
00074 if (!ifs) {
00075 keywordMap.insert(keyword_type(baseName, htmlFile));
00076 }
00077 else {
00078 nkeys = 0;
00079 while (ifs.good()) {
00080 getline(ifs, line, '\n');
00081 if (ifs.eof()) break;
00082 if (line.empty()) continue;
00083 nkeys++;
00084 keywordMap.insert(keyword_type(line, htmlFile));
00085 }
00086 if (nkeys == 0) keywordMap.insert(keyword_type(baseName, htmlFile));
00087 }
00088 ifs.close();
00089 }
00090 #ifdef DEBUG
00091 copy(keywordMap.begin(), keywordMap.end(), ostream_iterator<keyword_type>(cout, "\n"));
00092 #endif
00093
00094
00095
00096 const string indexName = "index.html";
00097 ofstream ofs(indexName.c_str());
00098 if (!ofs) {
00099 cerr << argv[0] << ": error, cannot create file " << indexName << endl;
00100 return 1;
00101 }
00102 cout << "writing index to " << indexName << " .";
00103 ofs << "<html>" << endl;
00104 ofs << "<!-- This code is generated automatically. Dont' modify it! -->" << endl;
00105 ofs << "<head>" << endl;
00106 ofs << "<title>StarClassLibrary: Class Browser</title>" << endl;
00107 ofs << "</head>" << endl;
00108 ofs << "<body bgcolor=#ffffff text=#000000>" << endl;
00109 ofs << "<table border=0 width=110% cellpadding=0>" << endl;
00110 ofs << "<tr bgcolor=darkblue>" << endl;
00111 ofs << "<td align=left valign=top>" << endl;
00112 ofs << "<ul>" << endl;
00113 ofs << "<h4><br></h4>" << endl;
00114 ofs << "<h1><font color=white>StarClassLibrary: </font><font color=red>"
00115 << "Class Browser Index</font></h1>" << endl;
00116 ofs << "</ul>" << endl;
00117 ofs << "</td>" << endl;
00118 ofs << "</tr>" << endl;
00119 ofs << "</table>" << endl;
00120 ofs << "<p>" << endl;
00121 ofs << "<table border=0 width=100% cellpadding=15>" << endl;
00122 ofs << "<tr>" << endl;
00123 ofs << "<td bgcolor=#eeeeee align=left valign=top>" << endl;
00124 ofs << "<ul>" << endl;
00125 keywordMap_type::const_iterator iter;
00126 for (iter = keywordMap.begin(); iter != keywordMap.end(); iter++) {
00127 cout << '.'; cout.flush();
00128 ofs << "<li><a href=" << iter->second << ">"
00129 << iter->first << "</a></li>" << endl;
00130 }
00131 ofs << "</ul>" << endl;
00132 ofs << "</td>" << endl;
00133 ofs << "<td align=left valign=top>" << endl;
00134 ofs << "<p>This reference guide is an alphabetical
00135 listing of all of the classes, algorithms, and function
00136 objects provided by <i>this</i> release of the Star C++
00137 Class Library. For each class, the reference begins with
00138 a synopsis, which indicates the header file(s) and the
00139 signature of a class object. It continues with
00140 the C++ code that describes the <i>public</i> interface.
00141 Please note, that the interface is displayed in its pure
00142 ANSI form. In a few rare cases and depending on your platform
00143 the actual code might differ slightly. </p>
00144 <p>This guide only shows the interfaces, i.e., the prototypes
00145 of the classes and function objects. For a more detailed description see the
00146 <font color=green><i>Star C++ Class Library User Guide and
00147 Reference Manual </i></font> which is available as a
00148 PostScript document. It contains information concerning the
00149 various platforms, installation procedures and a complete
00150 description of all classes including many example programs.
00151 Developers should also inspect the corrseponding header files.</p>
00152 This index and all other HTML pages referenced were
00153 generated automatically." << endl;
00154 ofs << "</td>" << endl;
00155 ofs << "</tr>" << endl;
00156 ofs << "</table>" << endl;
00157 time_t now = time(0);
00158 ofs << "<hr noshade=noshade>" << endl;
00159 ofs << "Index generated on " << ctime(&now);
00160 ofs << "</body>" << endl;
00161 ofs << "</html>" << endl;
00162
00163 ofs.close();
00164 cout << ". done" << endl;
00165 return 0;
00166 }