📄 html.cc
字号:
{ int i; for(i = 0; i < list.size(); i++) if(list[i].hl) delete list[i].hl;}void writeHIERentry(HIERlist &list, FILE *f, Entry *entry){ int i; HIERlist *sub = 0; if(entry->pubChilds.size() > 0 || entry->proChilds.size() > 0) { sub = new HIERlist(); for(i = 0; i < entry->pubChilds.size(); i++) writeHIERentry(*sub, f, entry->pubChilds[i]); for(i = 0; i < entry->proChilds.size(); i++) writeHIERentry(*sub, f, entry->proChilds[i]); } list.addEntry(entry, sub);}void writeHIERrec(HIERlist &list, FILE *f, Entry *entry){ int i; for(i = 0; i < entry->sublist.size(); i++) { if(entry->sublist[i]->baseclasses.size() == 0) if(entry->sublist[i]->isClass() && entry->sublist[i]->proBaseclasses.size() == 0 && entry->sublist[i]->pubBaseclasses.size() == 0) writeHIERentry(list, f, entry->sublist[i]); writeHIERrec(list, f, entry->sublist[i]); }}void writeHIER(FILE *f){ HIERlist list; if(header.length() == 0 && ownHeader.length() == 0) fprintf(f, "%s", hierHeader.c_str()); else fprintf(f, "%s", header.c_str()); fprintf(f, _("<H1>Hierarchy of Classes</H1>\n")); fprintf(f, "<UL>\n"); writeHIERrec(list, f, root); list.sort(); list.write(f); fprintf(f, "</UL>\n"); fprintf(f, "%s", hierFooter.c_str()); copyright(f);}void MemberWriter::showSubMembers(Entry *e){ Entry *tmp; fprintf(f, "%s\n", startString()); for(tmp = e->sub; tmp; tmp = tmp->next) writeMember(tmp, true); fprintf(f, "%s\n", endString());}void printRefLabel(FILE *f, Entry *entry){ fprintf(f, "\n<A NAME=\"%s\"></A>\n<A NAME=\"DOC.", entry->name.c_str()); entry->dumpNumber(f); fprintf(f, "\"></A>\n");}void MemberWriter::writeMember(Entry *entry, bool link, bool withSub){ if(first) { fprintf(f, "%s\n%s", startString(), heading.c_str()); first = 0; } if(!subEntryIsToBeDocumented(entry) && link) printRefLabel(f, entry); fprintf(f, "<DT>\n"); if(entry->ownPage) { fprintf(f, "%s <B><A HREF=\"%s\">%s</A></B>%s\n", entry->htype, entry->fileName.c_str(), entry->hname, entry->hargs); if(strlen(entry->hmemo) > 0) fprintf(f, "<DD><I>%s</I>\n", entry->hmemo); } else { if(subEntryIsToBeDocumented(entry) && link) { fprintf(f, "<IMG ALT=\"[more]\" BORDER=0 SRC=icon1.gif>"); fprintf(f, "%s <B><A HREF=\"#DOC.", entry->htype); entry->dumpNumber(f); fprintf(f, "\">%s</A></B>%s", entry->hname, entry->hargs); if(entry->pureVirtual) fprintf(f, " = 0"); fprintf(f, "\n"); } else { if(entry->section != MANUAL_SEC) fprintf(f, "<IMG ALT=\"o\" SRC=icon2.gif>"); else fprintf(f, "<P>"); fprintf(f, "%s <B>%s</B>%s\n", entry->htype, entry->hname, entry->hargs); } if(link && strlen(entry->hmemo) > 0) fprintf(f, "<DD><I>%s</I>\n", entry->hmemo); } if(entry->sub && withSub) showSubMembers(entry);}void MemberWriter::startList(FILE *file, char *head, bool withLinks){ f = file; heading = head; first = 1; list.resize(0);}void MemberWriter::endList(){ int i; if(f == NULL) return; if(sortEntries) sort(); for(i = 0; i < list.size(); i++) writeMember(list[i].entry, list[i].links, list[i].withSub); if(!first) fprintf(f, "%s\n\n", endString());}void MemberWriterTable::writeMember(Entry *entry, bool link, bool withSub){ char *args, *type; if(first) { fprintf(f, "%s\n%s", startString(), heading.c_str()); first = 0; } fprintf(f, "<TR>\n"); fprintf(f, "<TD VALIGN=TOP>"); if(!subEntryIsToBeDocumented(entry) && link) printRefLabel(f, entry); if((entry->section & CLASS_SEC) || entry->section == NAMESPACE_SEC) { fprintf(f, "<DT><A HREF=\"%s\">%s <B>%s</B></A>\n", entry->fileName.c_str(), entry->htype, entry->hname); if(strlen(entry->hmemo) > 0) fprintf(f, "<DD><I>%s</I>\n", entry->hmemo); } else { if(subEntryIsToBeDocumented(entry) && link) { fprintf(f, "<A HREF=\"#DOC."); entry->dumpNumber(f); fprintf(f, "\"><IMG ALT=\"[more]\" BORDER=0 SRC=icon1.gif></A>"); } else if(entry->section != MANUAL_SEC) fprintf(f, "<IMG ALT=\"o\" SRC=icon2.gif>"); else fprintf(f, "<P>"); args = entry->hargs; type = entry->htype; fprintf(f, "%s ", type); fprintf(f, "</TD><TD>"); fprintf(f, "<B>%s</B> %s<BR>", entry->hname, args); if(link) fprintf(f, "\n<I>%s</I>\n", entry->hmemo); } if(entry->sub && withSub) showSubMembers(entry); fprintf(f, "</TD></TR>");}void ClassGraphWriter::writeJava(FILE *f, Entry *entry, bool directOnly){ ClassGraph cg(entry, 0); ClassGraph *cls = &cg; McString classes, before, after, indent; char first = 1; int numLines = 0, longest = 0; char buf[40]; cg.addBases(); if(directOnly) cg.addDirectChilds(); else cg.addAllChilds(); for(cls = cg.firstLine; cls; cls = cls->nextLine) { numLines++; if(first) first = 0; else { classes += ","; before += ","; after += ","; indent += ","; } if(cls->entry) { if(longest < cls->entry->name.size()) longest = cls->entry->name.size(); if(cls->entry->section & CLASS_SEC) classes += "C"; else classes += "I"; classes += cls->entry->name; classes += ",M"; classes += cls->entry->fileName; } else { if(longest < cls->name.size()) longest = cls->name.size(); classes += "M" + cls->name; classes += ",M"; } before += "M" + cls->before; after += "M" + cls->after; sprintf(buf, "%d", cls->indent); indent += buf; } fprintf(f, "<APPLET CODE=\"ClassGraph.class\" WIDTH=600 HEIGHT=%d>\n", numLines * 30 + 5); fprintf(f, "<param name=classes value=\"%s\">\n", classes.c_str()); fprintf(f, "<param name=before value=\"%s\">\n", before.c_str()); fprintf(f, "<param name=after value=\"%s\">\n", after.c_str()); fprintf(f, "<param name=indent value=\"%s\">\n", indent.c_str()); fprintf(f, "<param name=arrowdir value="); if(upArrows) fprintf(f, "\"up\">\n"); else fprintf(f, "\"down\">\n"); fprintf(f, "</APPLET>\n"); }void ClassGraphWriter::writeText(FILE *f, Entry *e){ int i; Entry *c; for(i = 0; i < max(1, e->baseclasses.size()); i++) { if(i < e->baseclasses.size() && e->baseclasses[i]->section == INTERFACE_SEC) { if(i == 0) fprintf(f, "<H3>%s</H3>\n", e->hname); continue; } fprintf(f, "<H3>%s\n", e->hname); c = e; while(c->baseclasses.size() > 0) { if(c == e) c = c->baseclasses[i]; else c = c->baseclasses[0]; if(c) fprintf(f, "- <A HREF=\"%s\">%s</A>\n", c->fileName.c_str(), c->hname); else fprintf(f, "- %s</A>\n", c->name.c_str()); } fprintf(f, "</H3>\n"); }}void ClassGraphWriter::write(FILE *f, Entry *e){ if(javaGraphs) writeJava(f, e); else writeText(f, e);}void ClassGraphWriter::writeImplements(FILE *f, Entry *e){ int i, first = 1; Entry *c; for(i = 0; i < e->baseclasses.size(); i++) { if(e->baseclasses[i]->section != INTERFACE_SEC) continue; if(first) fprintf(f, "<HR>\n<H2>Implements:</H2>\n"); first = 0; c = e->baseclasses[i]; if(i > 0) fprintf(f, ", "); if(c) fprintf(f, "<A HREF=\"%s\">%s</A>", c->fileName.c_str(), (const char*)(c->hname)); }}extern char *strToHtml(McString &in, char *dest = 0, Entry *ct = 0, bool withLinks = false, bool pureCode = false);extern char *seeToHtml(McString &in, Entry *ct = 0);void entry2link(McString& u, Entry *ref, const char *linkname){ Entry *globref = ref; if(globref != root) while(globref->parent && globref->parent != root && !globref->fileName.length()) globref = globref->parent; if(ref->fileName.length()) { u += "<!1><A HREF=\""; u += ref->fileName; if(!ref->ownPage) { u += "#DOC."; ref->dumpNumber(u); } u += "\">"; if(linkname) u += linkname; else u += ref->hname; u += "</A>"; } else if(globref) { u += "<!2><A HREF=\"" + globref->fileName + "#DOC."; ref->dumpNumber(u); u += "\">"; if(linkname) u += linkname; else u += ref->hname; u += "</A>"; }} void writeTOCentry(McString& out, Entry *e, bool memo, bool dup = false){ McString link = ""; if(e->fileName.length()) { link += "<A HREF=\""; if(e->parent) if(e->ownPage) { if(e->fileName.length() > 0) link += e->fileName; else { link += e->hname; link += htmlSuffix; } } else { if(e->parent->fileName.length() > 0) link += e->parent->fileName; else { link += e->parent->hname; link += htmlSuffix; } link += "#"; link += e->hname; } else { link += GENERAL_NAME; link += htmlSuffix; link += "#"; link += e->hname; } link += "\">"; link += ENTRY_NAME(e); link += "</A>"; } else entry2link(link, e, (const char *)(e->hname)); out += link; if(memo) if(e->memo.length()) { out += " <I>"; out += (const char *)e->hmemo; out += "</I>\n"; } else out += '\n'; }void writeTOCentry(FILE *f, Entry *e, bool memo, bool dup){ McString out; writeTOCentry(out, e, memo, dup); fprintf(f, "%s", out.c_str());}void writeHIERentry(FILE *f, Entry *k, bool memo){ int i; fprintf(f, "<LI>"); writeTOCentry(f, k, memo); if(k->pubChilds.size() || k->proChilds.size()) { fprintf(f, "<UL>\n"); for(i = 0; i < k->pubChilds.size(); i++) writeHIERentry(f, k->pubChilds[i], memo); for(i = 0; i < k->proChilds.size(); i++) writeHIERentry(f, k->proChilds[i], memo); fprintf(f, "</UL>\n"); }}struct { int sec; const char *name;} toc_sections[] = { { MANUAL_SEC, "General stuff" }, { PACKAGE_SEC, "Packages" }, { NAMESPACE_SEC, "Namespaces" }, { CLASS_SEC, "Classes" }, { INTERFACE_SEC, "Interfaces" }, { FUNCTION_SEC, "Functions" }, { VARIABLE_SEC, "Variables" }, { MACRO_SEC, "Macros" }, { UNION_SEC, "Enums, Unions, Structs" }, { TYPEDEF_SEC, "Typedefs" }, { 0, 0 }};void writeTOCRec(TOClist& list, FILE *f, Entry *root, int section, int& first){ int i, output = root->section == toc_sections[section].sec && root->name.length(); // Want to recurse down em all, but subtree only if output root TOClist *sub = 0; if(root->sublist.size()) { if(output) sub = new TOClist(); for(i = 0; i < root->sublist.size(); i++) if(output) writeTOCRec(*sub, f, root->sublist[i], section, first); else writeTOCRec(list, f, root->sublist[i], section, first); } if(output) list.addEntry(root, sub);}void writeTOC(FILE *f){ int first = 1; if(header.length() == 0 && ownHeader.length() == 0) fprintf(f, "%s", indexHeader.c_str()); else fprintf(f, "%s", header.c_str()); fprintf(f, _("\n<H1>Table of Contents</H1>\n")); for(int k = 0; toc_sections[k].name; k++) { first = 1; TOClist list; writeTOCRec(list, f, root, k, first); if(list.size() > 0) { list.sort(); fprintf(f, "<H2>%s</H2>\n", toc_sections[k].name); fprintf(f, "<UL>\n"); list.write(f); fprintf(f, "</UL>\n"); } // Javadoc compatibility: fairly sure this is what it does. if(java && toc_sections[k].sec == INTERFACE_SEC) break; } fprintf(f, "%s", indexFooter.c_str()); copyright(f);}void writeHIERrecJava(FILE *f, Entry *root){ int i; for(i = 0; i < root->sublist.size(); i++) { if(root->sublist[i]->baseclasses.size() == 0) if(root->sublist[i]->isClass() && root->sublist[i]->proBaseclasses.size() == 0 && root->sublist[i]->pubBaseclasses.size() == 0) ClassGraphWriter::writeJava(f, root->sublist[i], 0); writeHIERrecJava(f, root->sublist[i]); }}void writeHIERjava(FILE *f){ if(header.length() == 0 && ownHeader.length() == 0) fprintf(f, "%s", hierHeader.c_str()); else fprintf(f, "%s", header.c_str()); fprintf(f, _("<H1>Hierarchy of classes</H1>\n")); fprintf(f, "<UL>\n"); writeHIERrecJava(f, root); fprintf(f, "</UL>\n"); fprintf(f, _("<I><A HREF=\"index%s\"> alphabetic index</A></I><P>"), htmlSuffix.c_str()); copyright(f);}/** This class keeps track of overloading relationships. Insert mebers
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -