__________________________________________________[C++IMPLEMENTATION] Name: TMrbTidy Purpose: MARaBOU utilities: tidy interface Description: Implements class methods to interface the tidy library Keywords: Author: R. Lutter Mailto: <a href=mailto:rudi.lutter@physik.uni-muenchen.de>R. Lutter</a> Revision: $Id: TMrbTidy.cxx,v 1.34 2007/08/03 10:11:05 Rudolf.Lutter Exp $ Date:/* Example of a HTML document (file "tidy.html")
<!DOCTYPE HTML PUBLIC "-// IETF/DTD HTML 2.0// EN"> <html> <!-- Author: Marabou team (marabou@physik.uni-muenchen.de) --> <head><title>TMrbTidyDoc.html</title></head> <body bgcolor="#ebfcb0"> <h1>TMrbTidyDoc: A MARaBOU class interfacing Dave Raggett's TidyLib</h1> </body> </html>
ROOT script to invoke TIDY:
{
gSystem->Load("$MARABOU/lib/libTMrbUtils.so");
gSystem->Load("$MARABOU/lib/libTMrbTidy.so");
gSystem->Load("$MARABOU/lib/libTidy.so");
TMrbTidyDoc * tdoc = new TMrbTidyDoc("demo", "tidy.html");
tdoc->Print();
}
Output from method TMrbTidyDoc::Print():
Document demo (file tidy.html): structure as analyzed by D. Raggett's TIDY ---------------------------------------------------------------------------------------------- [ 0] node root: type=Root(0) parent=root [ 1] . node HTML: type=DOCTYPE(1) parent=root text='<!DOCTYPE HTML><cr><cr>' PUBLIC= [ 1] . node html: type=StartTag(5) tagid=HTML(48) parent=root [ 2] .. node comment: type=Comment(2) parent=html text='<!-- Author: Marabou team (marabou@physik.uni-muenchen.de) --><cr><cr>' [ 2] .. node head: type=StartTag(5) tagid=HEAD(46) parent=html [ 3] ... node title: type=StartTag(5) tagid=TITLE(111) parent=head [ 4] .... node text: type=Text(4) parent=title text='TMrbTidyDoc.html<cr>' [ 2] .. node body: type=StartTag(5) tagid=BODY(16) parent=html bgcolor=#EBFCB0 [ 3] ... node h1: type=StartTag(5) tagid=H1(40) parent=body [ 4] .... node text: type=Text(4) parent=h1 text='TMrbTidyDoc: A MARaBOU class interfacing Dave Raggett's TidyLib<cr>'
*/
| Bool_t | CompareAttributes(TObjArray& LofAttr) |
| Int_t | DecodeAttrString(TObjArray& LofAttr, const Char_t* AttrStr) |
| virtual void | TObject::DoError(int level, const char* location, const char* fmt, va_list va) const |
| const Char_t* | Emphasize(TString& String, Bool_t Remove = kFALSE) |
| void | TObject::MakeZombie() |
| const Char_t* | MarkLinks(TString& Buffer) |
| const Char_t* | MarkSubstitutions(TString& Buffer) |
| Bool_t | OutputHtmlForMB(ostream& Out = cout) |
| Bool_t | OutputHtmlForMC(ostream& Out = cout) |
| Bool_t | OutputHtmlForMH(ostream& Out = cout) |
| Bool_t | OutputHtmlForMI(ostream& Out = cout) |
| Bool_t | OutputHtmlForMS(ostream& Out = cout) |
| Bool_t | OutputHtmlForMX(ostream& Out = cout) |
| const Char_t* | PrepareForCodeOutput(TString& Buffer) |
| const Char_t* | PrepareForHtmlOutput(TString& Buffer) |
| void | ProcessMnodeHeader(ostream& Out, const Char_t* CssClass, Int_t Level) |
| Int_t | ReadAttr() |
| TMrbTidyNode* | ScanTidyTree(TidyNode Node, const Char_t* AttrName, const Char_t* AttrString, TMrbTidyDoc* Doc = NULL) |
| enum EMrbTidySubstType { | kMrbTidySubstUndefined | |
| kMrbTidySubstLocalDef | ||
| kMrbTidySubstInherited | ||
| kMrbTidySubstInUse | ||
| kMrbTidySubstValueSet | ||
| }; | ||
| enum TObject::EStatusBits { | kCanDelete | |
| kMustCleanup | ||
| kObjInCanvas | ||
| kIsReferenced | ||
| kHasUUID | ||
| kCannotPick | ||
| kNoContextMenu | ||
| kInvalidObject | ||
| }; | ||
| enum TObject::[unnamed] { | kIsOnHeap | |
| kNotDeleted | ||
| kZombie | ||
| kBitMask | ||
| kSingleKey | ||
| kOverwrite | ||
| kWriteDelete | ||
| }; |
| TidyNode | fHandle | tidy node handle |
| Bool_t | fHasEndTag | kTRUE if end tag needed |
| Bool_t | TMrbNamedX::fHasTitle | |
| Int_t | fIndentLevel | indent level (code) |
| Int_t | TMrbNamedX::fIndex | |
| Bool_t | fIsMnode | is special marabou node |
| TMrbLofNamedX | fLofAttr | list of attributes |
| TMrbLofNamedX | fLofChilds | child nodes |
| TMrbLofNamedX | fLofLinks | current links |
| TMrbLofNamedX | fLofSubstitutions | current substitutions |
| TString | TNamed::fName | object identifier |
| TObject* | TMrbNamedX::fObject | |
| TMrbTidyNode* | fParent | parent node |
| Bool_t | TMrbNamedX::fSortedByName | |
| TMrbTidyDoc* | fTidyDoc | associated tidy document |
| TString | TNamed::fTitle | object title |
| Int_t | fTreeLevel | tree level (mnodes) |
| TidyNodeType | fType | type |

__________________________________________________________________[C++ CTOR] Name: TMrbTidyNode Purpose: A tidy node Arguments: TidyTagId NodeId -- node id Char_t * NodeName -- name TMrbTidyNode * Parent -- link to parent node TidyOption NodeHandle -- ptr to tidy struct TMrbTidyDoc * Doc -- link to document Description: Ctor to instantiate a tidy node Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::GetText() Purpose: Get text from node Arguments: TString & Buffer -- where to store text Results: Char_t * BufPtr -- ptr to buffer data Exceptions: Description: Reads text portion from node. Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::HasTextChildsOnly() Purpose: Check if node has only text in it Arguments: -- Results: kTRUE/kFALSE Exceptions: Description: Checks node childs to be text nodes only. Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::CollectTextFromChilds() Purpose: Collect text from childs Arguments: TString & Buffer -- where to store text Results: Char_t * BufPtr -- ptr to buffer data Exceptions: Description: Collect text from childs if it is a pure text node. Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::CollectSubstUsedByChilds() Purpose: Collect substitutions from childs Arguments: TMrbLofNamedX & LofSubst -- list of substitutions Results: Int_t NofSubst -- number of subst in list Exceptions: Description: Collects substitutions used by childs. Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::FillTree() Purpose: Fill document tree Arguments: -- Results: -- Exceptions: Description: Fills document tree recursively. Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::IncludeExternalNode() Purpose: Insert node from external file Arguments: Char_t * File -- name of html file Char_t * Mtag -- marabou tag Results: TMrbTidyNode * Node -- root node of implanted tree Exceptions: Description: Opens a html file and searches for a node with given marabou tag. Implants tree starting with this node into local tree. If File and/or Mtag args are missing value will be taken from mfile= and mtag= attributes, resp. Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::ScanTidyTree() Purpose: Scan original tidy tree for a given attribute Arguments: TidyNode Node -- tidy node to start with Char_t * AttrName -- name of attribute Char_t * AttrString -- attr value TMrbTidyDoc * Doc -- document Results: TMrbTidyNode * Node -- node with given attr Exceptions: Description: Low-level method to scan original tidy tree. Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::DeleteTree() Purpose: Delete document tree Arguments: -- Results: -- Exceptions: Description: Removes any nodes from document tree. Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::ReadAttr Purpose: Read tidy attributes Arguments: -- Results: Int_t NofAttr -- number of attributes read Exceptions: Description: Reads node attributes via tidyAttrFirst()/Next() Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::CheckMnode Purpose: Check if special marabou node Arguments: -- Results: kTRUE/kFALSE Exceptions: Description: Checks if node is one of special marabou nodes (<mh>, <mb>, ...) Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::CheckEndTag Purpose: Check if node has end tag Arguments: -- Results: kTRUE/kFALSE Exceptions: Description: Checks if node needs to have an end tag Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::PrintTree Purpose: Print data recursively Arguments: ostream & Out -- output stream Bool_t Verbose -- kTRUE: print full text strings Bool_t HtmlFlag -- kTRUE: output html format Results: -- Exceptions: Description: Prints node data Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::StepTree Purpose: Step thru tree and collect nodes Arguments: TObjArray & LofNodes -- where to store nodes Results: Int_t NofNodes -- number of nodes Exceptions: Description: Steps thru node tree and stores nodes in array Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::Print Purpose: Print data Arguments: ostream & Out -- output stream Bool_t Verbose -- kTRUE: print full text strings Bool_t HtmlFlag -- kTRUE: output html format Results: -- Exceptions: Description: Prints node data Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::TraceBack Purpose: Output backtrace Arguments: ostream & Out -- output stream Int_t NofLevels -- number of levels Results: -- Exceptions: Description: Prints backtrace data Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::OutputHtmlTree Purpose: Output html data recursively Arguments: ostream & Out -- output stream Results: -- Exceptions: Description: Outputs node data in html format Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::OutputHtml Purpose: Output html data Arguments: ostream & Out -- output stream Results: Bool_t PopUp -- kTRUE if there is no need to process childs Exceptions: Description: Outputs html data. Special treatment for marabou nodes. Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::OutputHtmlForMnodes Purpose: Special html output for marabou nodes Arguments: ostream & Out -- output stream Results: Bool_t PopUp -- kTRUE if there is no need to process childs Exceptions: Description: Outputs html data for marabou nodes. Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::OutputHtmlForMB Purpose: Special html output for node <mb> Arguments: ostream & Out -- output stream Results: Bool_t PopUp -- kTRUE if there is no need to process childs Exceptions: Description: Outputs html data for <mb>...</mb> [body] Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::OutputHtmlForMH Purpose: Special html output for node <mh> Arguments: ostream & Out -- output stream Results: Bool_t PopUp -- kTRUE if there is no need to process childs Exceptions: Description: Outputs html data for <mh>...</mh> [header] Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::OutputHtmlForMX Purpose: Special html output for node <mx> Arguments: ostream & Out -- output stream Results: Bool_t PopUp -- kTRUE if there is no need to process childs Exceptions: Description: Outputs html data for <mx> [expand] Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::OutputHtmlForMC Purpose: Special html output for node <mc> Arguments: ostream & Out -- output stream Results: Bool_t PopUp -- kTRUE if there is no need to process childs Exceptions: Description: Outputs html data for <mc>...</mc> [code] Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::OutputHtmlForMS Purpose: Special html output for node <ms> Arguments: ostream & Out -- output stream Results: Bool_t PopUp -- kTRUE if there is no need to process childs Exceptions: Description: Outputs html data for <ms>...</ms> [switch] Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::OutputHtmlForMI Purpose: Special html output for node <mi> Arguments: ostream & Out -- output stream Results: Bool_t PopUp -- kTRUE if there is no need to process childs Exceptions: Description: Outputs html data for <mi> [include] Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::ProcessMnodeHeader Purpose: Special html output for node <mc> Arguments: ostream & Out -- output stream Char_t * CssClass -- class name in css style Int_t Level -- tree level as compared to <mb> tag Results: -- Exceptions: Description: Outputs html header for marabou nodes Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::Emphasize Purpose: Replace special chars by <b>, <i>, <u> etc. Arguments: TString String -- string containing meta chars Bool_t Remove -- kTRUE -> remove meta chars Results: Char_t * String -- string after replacement Exceptions: Description: Searches for pairs of replaces by ** <b></b> !! <i></i> __ <u></u> Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::SetIndentation Purpose: Set indentation level Arguments: -- Results: Int_t IndLevel -- indentation level Exceptions: Description: Calculates indentation from indent attr: indent="+n" increment by n indent="-n" decrement by n indent="n" set indentation to n Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::SetIndentLevel Purpose: Set indent level down the tree Arguments: -- Results: Int_t IndLevel -- indentation level Bool_t Recursive -- set recursively if kTRUE Exceptions: Description: Sets text indentation Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::InitSubstitutions Purpose: Fill substitution buffer Arguments: Bool_t Recursive -- step down the tree if kTRUE Bool_t ReInit -- re-initialize if set Results: Int_t NofSubst -- number of substitutions found Exceptions: Description: Resets subst buffer and fills it with items from "subst=..." string Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::InitLinks Purpose: Fill link buffer Arguments: Bool_t Recursive -- step down the tree if kTRUE Bool_t ReInit -- re-initialize if set Results: Int_t NofLinks -- number of links found Exceptions: Description: Resets link buffer and fills it with items from "xxx-links=..." string Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::PrintSubstitutions Purpose: Output substitutions Arguments: Bool_t Recursive -- step down the tree if kTRUE ostream & Out -- output stream Results: -- Exceptions: Description: Outputs subst names (and values) to stream Out. Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::ClearSubstitutions Purpose: Clear current substitution settings Arguments: Bool_t Recursive -- step down the tree if kTRUE Results: -- Exceptions: Description: Resets all substitutions to "n.a" (empty). Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::CheckSubstitutions Purpose: Check if substitutions are ok Arguments: Bool_t Recursive -- step down the tree if kTRUE Bool_t VerboseMode -- error/warning message if kTRUE Results: kTRUE/kFALSE Exceptions: Description: Checks if all substitutions have values assigned. If CheckCode=kTRUE it searches for #param# in text nodes and compares with entries in subst table. Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::GetSubstitutionType Purpose: Return type of substitution Arguments: Char_t * ParamName -- name of subst parameter Results: EMrbTidySubstType Type -- type: local, parent, cleared Exceptions: Description: Returns type of a substitution. Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::Substitute Purpose: Substitute param with value Arguments: Char_t * ParamName -- param name Char_t * ParamValue -- value to be substituted Bool_t Recursive -- step down the tree if kTRUE Bool_t Verbose -- kTRUE if verbose mode Results: kTRUE/kFALSE Exceptions: Description: Substitutes given param (#param#) with string. Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::Substitute Purpose: Substitute param with value Arguments: Char_t * ParamName -- param name Int_t ParamValue -- value to be substituted Int_t ParamBase -- num base to be used for conversion Bool_t Recursive -- step down the tree if kTRUE Bool_t Verbose -- kTRUE if verbose mode Results: kTRUE/kFALSE Exceptions: Description: Substitutes given param (#param#) with int. Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::Substitute Purpose: Substitute param with value Arguments: Char_t * ParamName -- param name Double_t ParamValue -- value to be substituted Bool_t Recursive -- step down the tree if kTRUE Bool_t Verbose -- kTRUE if verbose mode Results: kTRUE/kFALSE Exceptions: Description: Substitutes given param (#param#) with double. Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::OutputSubstituted Purpose: Output text with substitutions Arguments: Char_t * CaseString -- attribute "case=..." ostream & Out -- output stream Results: kTRUE/kFALSE Exceptions: Description: Replaces params by their substitutions and outputs text. Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::OutputSubstituted Purpose: Output text with substitutions Arguments: TObjArray & LofCaseStrings -- array containing attributes "case=..." ostream & Out -- output stream Results: kTRUE/kFALSE Exceptions: Description: Replaces params by their substitutions and outputs text. Works for pure text nodes as well as for nodes with attr "string=..." Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::PrepareForCodeOutput Purpose: Prepare buffer to be output as plain code Arguments: TString & Buffer -- buffer containing text Results: Char_t * BufPtr -- points to 'Buffer' Exceptions: Description: Do some finish before starting real code output. Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::PrepareForHtmlOutput Purpose: Prepare buffer to be output as html Arguments: TString & Buffer -- buffer containing text Results: Char_t * BufPtr -- points to 'Buffer' Exceptions: Description: Do some finish before starting html output. Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::MarkSubstitutions Purpose: Mark substitutions for html output Arguments: TString & Buffer -- buffer containing text Results: Char_t * BufPtr -- points to 'Buffer' Exceptions: Description: Marks (= changes background color) for all substitutions in text Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::MarkLinks Purpose: Mark links for html output Arguments: TString & Buffer -- buffer containing text Results: Char_t * BufPtr -- points to 'Buffer' Exceptions: Description: Marks (= inserts href tags) for all links in buffer Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::Find Purpose: Find a specified node Arguments: Char_t * NodeName -- name Char_t * NodeAttributes -- attributes Bool_t Recursive -- kTRUE if to be searched recursively Results: TMrbTidyNode * Node -- resulting node Exceptions: Description: Searches for a specified node Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::Find Purpose: Find a specified node Arguments: Char_t * NodeName -- name TObjArray & LofAttr -- attributes Bool_t Recursive -- kTRUE if to be searched recursively Results: TMrbTidyNode * Node -- resulting node Exceptions: Description: Searches for a specified node Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::Find Purpose: Find a specified node Arguments: TObjArray & LofNodes -- list of nodes Char_t * NodeName -- name Char_t * NodeAttributes -- attributes Bool_t Recursive -- kTRUE if to be searched recursively Results: Int_t NofNodes -- number of nodes found Exceptions: Description: Searches for a specified node Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::Find Purpose: Find a specified node Arguments: TObjArray & LofNodes -- list of nodes Char_t * NodeName -- name TObjArray & LofAttr -- attributes Bool_t Recursive -- kTRUE if to be searched recursively Results: Int_t NofNodes -- number of nodes found Exceptions: Description: Searches for a specified node Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::FindByAttr Purpose: Find a node by its attr Arguments: const Char_t * AttrName -- attr name const Char_t * AttrValue -- ... value Bool_t Recursive -- kTRUE if to be searched recursively Bool_t IncludeTopLevel -- start search from caller level Results: TMrbTidyNode * Node -- resulting node Exceptions: Description: Searches for a specified node Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::DecodeAttrString Purpose: Decode string of attributes Arguments: TObjArray & LofAttr -- attributes Char_t * NodeAttributes -- string of attributes Results: Int_t NofAttr -- number of attributes found Exceptions: Description: Decodes a string of attributes. Format: "attr1=val1 attr2=val2 ..." Keywords:
________________________________________________________________[C++ METHOD] Name: TMrbTidyNode::CompareAttributes Purpose: Compare attributes Arguments: TObjArray & LofAttr -- attributes Results: kTRUE/kFALSE Exceptions: Description: Compares attributes in list with node attributes. Keywords:
{ return((TMrbTidyNode *) fLofChilds.After((TMrbTidyNode *) Child)); }{ return((TMrbTidyNode *) fLofChilds.Before((TMrbTidyNode *) Child)); }{ return((TMrbTidyAttr *) fLofAttr.FindByIndex((Int_t) AttrId)); }{ return((TMrbTidyAttr *) fLofAttr.After((TMrbTidyAttr *) Attr)); }