Logo ROOT   6.21/01
Reference Guide
TDocDirective.h
Go to the documentation of this file.
1 // @(#)root/html:$Id$
2 // Author: Axel Naumann 2007-01-25
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TDocDirective
13 #define ROOT_TDocDirective
14 
15 ////////////////////////////////////////////////////////////////////////////
16 // //
17 // TDocDirective //
18 // //
19 // Special treatment of comments, like HTML source, a macro, or latex. //
20 // //
21 ////////////////////////////////////////////////////////////////////////////
22 
23 #include "TNamed.h"
24 
25 
26 class TClass;
27 class TDocParser;
28 class TDocOutput;
29 class THtml;
30 class TLatex;
31 class TMacro;
32 class TVirtualPad;
33 
34 class TDocDirective: public TNamed {
35 protected:
36  TDocParser* fDocParser; // parser invoking this handler
37  THtml* fHtml; // parser's THtml object
38  TDocOutput* fDocOutput; // parser invoking this handler
39  TString fParameters; // parameters to the directive
40  Int_t fCounter; // counter to generate unique names, -1 to ignore
41 
42  virtual void AddParameter(const TString& /*name*/, const char* /*value*/ = 0) {}
43 
45  TDocDirective(const char* name):
46  TNamed(name, ""), fDocParser(0), fHtml(0), fDocOutput(0), fCounter(-1) {};
47  virtual ~TDocDirective() {}
48 
49  const char* GetName() const { return TNamed::GetName(); }
50  void GetName(TString& name) const;
51  TDocParser* GetDocParser() const { return fDocParser; }
52  TDocOutput* GetDocOutput() const { return fDocOutput; }
53  THtml* GetHtml() const { return fHtml; }
54  const char* GetOutputDir() const;
55 
56  void SetParser(TDocParser* parser);
57  void SetParameters(const char* params);
58  void SetTag(const char* tag) { SetTitle(tag); }
59  void SetCounter(Int_t count) { fCounter = count; }
60  virtual void DeleteOutputFiles(const char* ext) const;
61 
62 public:
63  // get the tag ending this directive
64  virtual const char* GetEndTag() const = 0;
65 
66  // add a line to the directive's text
67  virtual void AddLine(const TSubString& line) = 0;
68 
69  // retrieve the result (replacement) of the directive; return false if invalid
70  virtual Bool_t GetResult(TString& result) = 0;
71 
72  // Delete output for the parser's current class or module.
73  virtual void DeleteOutput() const {}
74 
75  friend class TDocParser;
76 
77  ClassDef(TDocDirective, 0); // THtml directive handler
78 };
79 
81 private:
82  TString fText; // HTML text to be kept
83  Bool_t fVerbatim; // whether we are in a <pre></pre> block
84 public:
86  virtual ~TDocHtmlDirective() {}
87 
88  virtual void AddLine(const TSubString& line);
89  virtual const char* GetEndTag() const { return "end_html"; }
90  virtual Bool_t GetResult(TString& result);
91 
92  ClassDef(TDocHtmlDirective, 0); // Handler for "Begin_Html"/"End_Html" for raw HTML in documentation comments
93 };
94 
96 private:
97  TMacro* fMacro; // macro to be executed
98  Bool_t fNeedGraphics; // if set, we cannot switch to batch mode
99  Bool_t fShowSource; // whether a source tab should be created
100  Bool_t fIsFilename; // whether the directive is a failename to be executed
101 
102  virtual void AddParameter(const TString& name, const char* value = 0);
104 
105 public:
107  TDocDirective("MACRO"), fMacro(0), fNeedGraphics(kFALSE),
109  virtual ~TDocMacroDirective();
110 
111  virtual void AddLine(const TSubString& line);
112  virtual const char* GetEndTag() const { return "end_macro"; }
113  virtual Bool_t GetResult(TString& result);
114  // Delete output for the parser's current class or module.
115  virtual void DeleteOutput() const { DeleteOutputFiles(".gif"); }
116 
117  static void SubProcess(const TString& what, const TString& out);
118 
119  ClassDef(TDocMacroDirective, 0); // Handler for "Begin_Macro"/"End_Macro" for code that is executed and that can generate an image for documentation
120 };
121 
123 protected:
124  TMacro* fLatex; // collection of lines
125  Int_t fFontSize; // fontsize for current latex block, in pixels
126  TString fSeparator; // column separator, often "="
127  Bool_t fSepIsRegexp; // whether fSeparator is a regexp expression
128  TString fAlignment; // column alignment: 'l' for justify left, 'c' for center, 'r' for right
129  TVirtualPad* fBBCanvas; // canvas for bounding box determination
130 
131  virtual void CreateLatex(const char* filename);
132  virtual void AddParameter(const TString& name, const char* value = 0);
133  virtual void GetBoundingBox(TLatex& latex, const char* text, Float_t& width, Float_t& height);
134 
135 public:
137  TDocDirective("LATEX"), fLatex(0), fFontSize(16),
138  fSepIsRegexp(kFALSE), fBBCanvas(0) {};
139  virtual ~TDocLatexDirective();
140 
141  virtual void AddLine(const TSubString& line);
142  virtual const char* GetEndTag() const {return "end_latex";}
143 
144  const char* GetAlignment() const {return fAlignment;}
145  const char* GetSeparator() const {return fSeparator;}
147  Int_t GetFontSize() const {return fFontSize;}
148  TList* GetListOfLines() const;
149 
150  virtual Bool_t GetResult(TString& result);
151  // Delete output for the parser's current class or module.
152  virtual void DeleteOutput() const { DeleteOutputFiles(".gif"); }
153 
154  ClassDef(TDocLatexDirective, 0); // Handler for "Begin_Latex"/"End_Latex" to generate an image from latex
155 };
156 
157 #endif // ROOT_TDocDirective
A zero length substring is legal.
Definition: TString.h:77
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
Bool_t SeparatorIsRegexp() const
virtual const char * GetEndTag() const
const char * GetOutputDir() const
Get the directory for documentation output.
TLine * line
float Float_t
Definition: RtypesCore.h:53
virtual void DeleteOutputFiles(const char *ext) const
Delete all output generated by the directive beginning with Name() and ending with ext...
TVirtualPad * fBBCanvas
void SetTag(const char *tag)
Definition: TDocDirective.h:58
virtual Bool_t GetResult(TString &result)=0
const char * GetSeparator() const
TList * GetListOfLines() const
Get the list of lines as TObjStrings.
virtual void AddLine(const TSubString &line)
Add a line of HTML.
Class supporting a collection of lines with C++ code.
Definition: TMacro.h:31
Basic string class.
Definition: TString.h:131
int Int_t
Definition: RtypesCore.h:41
virtual void AddParameter(const TString &name, const char *value=0)
Parse fParameters, setting fFontSize, fAlignment, and fSeparator.
bool Bool_t
Definition: RtypesCore.h:59
virtual void AddParameter(const TString &, const char *=0)
Definition: TDocDirective.h:42
TDocParser * GetDocParser() const
Definition: TDocDirective.h:51
virtual Bool_t GetResult(TString &result)
Set result to the HTML code that was passed in via AddLine().
virtual void GetBoundingBox(TLatex &latex, const char *text, Float_t &width, Float_t &height)
Determines the bounding box for text as height and width.
#define ClassDef(name, id)
Definition: Rtypes.h:326
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
TDocDirective(const char *name)
Definition: TDocDirective.h:45
THtml * GetHtml() const
Definition: TDocDirective.h:53
To draw Mathematical Formula.
Definition: TLatex.h:18
void SetCounter(Int_t count)
Definition: TDocDirective.h:59
virtual void DeleteOutput() const
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h:49
void SetParser(TDocParser *parser)
Set the parser, and fDocOutput, fHtml from that.
virtual ~TDocMacroDirective()
Destructor.
virtual void DeleteOutput() const
A doubly linked list.
Definition: TList.h:44
virtual Bool_t GetResult(TString &result)
Get the result (i.e.
virtual Bool_t GetResult(TString &result)
convert fLatex to a gif by creating a TLatex, drawing it on a temporary canvas, and saving that to a ...
const char * GetAlignment() const
const char * GetName() const
Returns name of object.
Definition: TDocDirective.h:49
virtual ~TDocHtmlDirective()
Definition: TDocDirective.h:86
virtual void AddParameter(const TString &name, const char *value=0)
Setting fNeedGraphics if name is "GUI", setting fShowSource if name is "SOURCE".
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:75
TString fParameters
Definition: TDocDirective.h:39
const Bool_t kFALSE
Definition: RtypesCore.h:88
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
void SetParameters(const char *params)
Given a string containing parameters in params, we call AddParameter() for each of them...
TText * text
virtual const char * GetEndTag() const
Definition: TDocDirective.h:89
virtual ~TDocLatexDirective()
Destructor.
virtual void AddLine(const TSubString &line)
Add a macro line.
TDocOutput * fDocOutput
Definition: TDocDirective.h:38
virtual const char * GetEndTag() const
static void SubProcess(const TString &what, const TString &out)
virtual const char * GetEndTag() const =0
virtual ~TDocDirective()
Definition: TDocDirective.h:47
TString CreateSubprocessInputFile()
Create the input file for SubProcess().
virtual void AddLine(const TSubString &line)
Add a latex line.
TDocParser * fDocParser
Definition: TDocDirective.h:36
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:164
const Bool_t kTRUE
Definition: RtypesCore.h:87
Definition: THtml.h:40
Int_t GetFontSize() const
char name[80]
Definition: TGX11.cxx:109
virtual void DeleteOutput() const
Definition: TDocDirective.h:73
virtual void CreateLatex(const char *filename)
Create a gif file named filename from a latex expression in fLatex.
TDocOutput * GetDocOutput() const
Definition: TDocDirective.h:52
virtual void AddLine(const TSubString &line)=0