//=-- BreakoutRenderer.h - 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.
//=---------------------------------------------------------------------------=

#ifndef BREAKOUT_RENDERER_H
#define BREAKOUT_RENDERER_H

#include "MSString.h"
#include "LinkedList.h"
#include "VarTable.h"
#include "Plugin.h"
#include <iostream.h>

class BreakoutRenderer {
public:
  // TreeRow is a tuple with <TreeDepth, [Labels]>
  typedef DataPair<int, LinkedList<String> > TreeRow;
  typedef LinkedList<TreeRow> Tree;

  inline BreakoutRenderer(ostream &o, const VarTable &p, const PluginDesc &d) 
    : O(o), Params(p), Descriptor(d) {}

  // Helper function to calculate the directory depth of a URL.
  static int CalculateURLDepth(const String &URL);

  // The main output function...
  //
  // ColSettings.GetLength() must equal the number of output columns.  This 
  // list is typically used to specify alignments and other settings for the
  // <td> tags in the tables.
  // 
  void OutputBreakout(const LinkedList<String> &Header,
                      const Tree &TheTree, 
                      const LinkedList<String> &ColSettings) const;

protected:
  int HasSuccessiveSibling(Tree::Iterator I, int Depth) const;

private:
  ostream &O;
  const VarTable &Params;
  const PluginDesc &Descriptor;
};

#endif
