//=-- BreakoutRenderer.cpp - Output the HTML for a breakout... -----*- C++ -*-= // // This class is used to output the HTML that corresponds to the tree-looking // breakout. It tries to be flexible so that it can be useful for many // purposes as such, however, the interface can be kind of confusing. :) // //=---------------------------------------------------------------------------= // This file is copyright (c) 2000 Chris Lattner and stuff. //=---------------------------------------------------------------------------= #include "BreakoutRenderer.h" #include "Table.h" #include // For memset int BreakoutRenderer::HasSuccessiveSibling(Tree::Iterator I, int Depth) const { I++; // Skip current node... while (I) { int CurDepth = I->P; if (CurDepth < Depth) return 0; if (CurDepth == Depth) return 1; I++; } return 0; } int BreakoutRenderer::CalculateURLDepth(const String &URL) { int Depth = -1; // Start off '/' at depth 0. int Count = URL.strchr('/'); // if (URL.Length() == 0) return 0; while (Count != -1) { Depth++; Count = URL.strchr('/', Count+1); // Count how many /'s are in the URL } if (!URL.nCompare("http://", 7)) Depth -= 2; // Return +1 if the string didn't end in a / return (URL[URL.Length()-1] == '/') ? Depth : Depth + 1; } void BreakoutRenderer::OutputBreakout(const LinkedList &Header, const Tree &TheTree, const LinkedList &ColSettings ) const { String ThemeURL = Descriptor.PluginSourceURL; int ColWidth = ColSettings.GetLength(); if (Params.InTable("ImageURL")) ThemeURL = Params["ImageURL"]->GetStringValue(); O << "\n"; if (Header.GetLength() > 0) { LinkedList::Iterator I = Header.GetIterator(); LinkedList::Iterator Al = ColSettings.GetIterator(); O << "\n \n"; for (I++, Al++; I; I++, Al++) O << " \n"; O << "\n"; } O << "\n" " \n\n"; int Continuation[1000]; memset(Continuation, 0, 1000); Tree::Iterator I = TheTree.GetIterator(); for (; I; I++) { int Depth = I->P; const LinkedList &Captions = I->S; LinkedList::Iterator ColSets = ColSettings.GetIterator(); O << "\n \n"; for (; CI; CI++, ColSets++) O << " \n" << " \n"; O << "\n"; } O << "
" << *I << "" << *I << "
------------------------------------------
"; ColSets++; for (int i = 0; i < Depth; i++) { if (i == Depth-1) { // Try to do T or L nodes. Continuation[i] = HasSuccessiveSibling(I, Depth); if (Continuation[i]) O << "|- "; else O << "`- "; } else { if (Continuation[i]) O << "| "; else O << "  "; } } LinkedList::Iterator CI = Captions.GetIterator(); if (*CI) { O << *CI; CI++; } O << "" << *CI << "
\n"; }