TDocDirective.h

Go to the documentation of this file.
00001 // @(#)root/html:$Id: TDocDirective.h 35218 2010-09-10 09:58:44Z axel $
00002 // Author: Axel Naumann 2007-01-25
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TDocDirective
00013 #define ROOT_TDocDirective
00014 
00015 ////////////////////////////////////////////////////////////////////////////
00016 //                                                                        //
00017 // TDocDirective                                                          //
00018 //                                                                        //
00019 // Special treatment of comments, like HTML source, a macro, or latex.    //
00020 //                                                                        //
00021 ////////////////////////////////////////////////////////////////////////////
00022 
00023 #ifndef ROOT_TNamed
00024 #include "TNamed.h"
00025 #endif
00026 
00027 
00028 class TClass;
00029 class TDocParser;
00030 class TDocOutput;
00031 class THtml;
00032 class TLatex;
00033 class TMacro;
00034 class TVirtualPad;
00035 
00036 class TDocDirective: public TNamed {
00037 protected:
00038    TDocParser* fDocParser;  // parser invoking this handler
00039    THtml*      fHtml;       // parser's THtml object
00040    TDocOutput* fDocOutput;  // parser invoking this handler
00041    TString     fParameters; // parameters to the directive
00042    Int_t       fCounter;    // counter to generate unique names, -1 to ignore
00043 
00044    virtual void AddParameter(const TString& /*name*/, const char* /*value*/ = 0) {}
00045 
00046    TDocDirective() {}
00047    TDocDirective(const char* name):
00048       TNamed(name, ""), fDocParser(0), fHtml(0), fDocOutput(0), fCounter(-1) {};
00049    virtual ~TDocDirective() {}
00050 
00051    const char* GetName() const { return TNamed::GetName(); }
00052    void GetName(TString& name) const;
00053    TDocParser* GetDocParser() const { return fDocParser; }
00054    TDocOutput* GetDocOutput() const { return fDocOutput; }
00055    THtml*      GetHtml() const { return fHtml; }
00056    const char* GetOutputDir() const;
00057 
00058    void SetParser(TDocParser* parser);
00059    void SetParameters(const char* params);
00060    void SetTag(const char* tag) { SetTitle(tag); }
00061    void SetCounter(Int_t count) { fCounter = count; }
00062    virtual void DeleteOutputFiles(const char* ext) const;
00063 
00064 public:
00065    // get the tag ending this directive
00066    virtual const char* GetEndTag() const = 0;
00067 
00068    // add a line to the directive's text
00069    virtual void AddLine(const TSubString& line) = 0;
00070 
00071    // retrieve the result (replacement) of the directive; return false if invalid
00072    virtual Bool_t GetResult(TString& result) = 0;
00073 
00074    // Delete output for the parser's current class or module.
00075    virtual void DeleteOutput() const {}
00076 
00077    friend class TDocParser;
00078 
00079    ClassDef(TDocDirective, 0); // THtml directive handler
00080 };
00081 
00082 class TDocHtmlDirective: public TDocDirective {
00083 private:
00084    TString fText;     // HTML text to be kept
00085    Bool_t  fVerbatim; // whether we are in a <pre></pre> block
00086 public:
00087    TDocHtmlDirective(): TDocDirective("HTML"), fVerbatim(kFALSE) {}
00088    virtual ~TDocHtmlDirective() {}
00089 
00090    virtual void AddLine(const TSubString& line);
00091    virtual const char* GetEndTag() const { return "end_html"; }
00092    virtual Bool_t GetResult(TString& result);
00093 
00094    ClassDef(TDocHtmlDirective, 0); // Handler for "Begin_Html"/"End_Html" for raw HTML in documentation comments
00095 };
00096 
00097 class TDocMacroDirective: public TDocDirective {
00098 private:
00099    TMacro* fMacro;         // macro to be executed
00100    Bool_t  fNeedGraphics;  // if set, we cannot switch to batch mode
00101    Bool_t  fShowSource;    // whether a source tab should be created
00102    Bool_t  fIsFilename;    // whether the directive is a failename to be executed
00103 
00104    virtual void AddParameter(const TString& name, const char* value = 0);
00105 
00106 public:
00107    TDocMacroDirective(): 
00108       TDocDirective("MACRO"), fMacro(0), fNeedGraphics(kFALSE), 
00109       fShowSource(kFALSE), fIsFilename(kTRUE) {};
00110    virtual ~TDocMacroDirective();
00111 
00112    virtual void AddLine(const TSubString& line);
00113    virtual const char* GetEndTag() const { return "end_macro"; }
00114    virtual Bool_t GetResult(TString& result);
00115    // Delete output for the parser's current class or module.
00116    virtual void DeleteOutput() const { DeleteOutputFiles(".gif"); }
00117 
00118    ClassDef(TDocMacroDirective, 0); // Handler for "Begin_Macro"/"End_Macro" for code that is executed and that can generate an image for documentation
00119 };
00120 
00121 class TDocLatexDirective: public TDocDirective {
00122 protected:
00123    TMacro*      fLatex;       // collection of lines
00124    Int_t        fFontSize;    // fontsize for current latex block, in pixels
00125    TString      fSeparator;   // column separator, often "="
00126    Bool_t       fSepIsRegexp; // whether fSeparator is a regexp expression
00127    TString      fAlignment;   // column alignment: 'l' for justify left, 'c' for center, 'r' for right
00128    TVirtualPad* fBBCanvas;    // canvas for bounding box determination
00129 
00130    virtual void    CreateLatex(const char* filename);
00131    virtual void    AddParameter(const TString& name, const char* value = 0);
00132    virtual void GetBoundingBox(TLatex& latex, const char* text, Float_t& width, Float_t& height);
00133 
00134 public:
00135    TDocLatexDirective(): 
00136       TDocDirective("LATEX"), fLatex(0), fFontSize(16), 
00137       fSepIsRegexp(kFALSE), fBBCanvas(0) {};
00138    virtual ~TDocLatexDirective();
00139 
00140    virtual void AddLine(const TSubString& line);
00141    virtual const char* GetEndTag() const {return "end_latex";}
00142 
00143    const char* GetAlignment() const {return fAlignment;}
00144    const char* GetSeparator() const {return fSeparator;}
00145    Bool_t SeparatorIsRegexp() const {return fSepIsRegexp;}
00146    Int_t  GetFontSize() const {return fFontSize;}
00147    TList* GetListOfLines() const;
00148 
00149    virtual Bool_t GetResult(TString& result);
00150    // Delete output for the parser's current class or module.
00151    virtual void DeleteOutput() const { DeleteOutputFiles(".gif"); }
00152 
00153    ClassDef(TDocLatexDirective, 0); // Handler for "Begin_Latex"/"End_Latex" to generate an image from latex
00154 };
00155 
00156 #endif // ROOT_TDocDirective

Generated on Tue Jul 5 14:24:41 2011 for ROOT_528-00b_version by  doxygen 1.5.1