ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 #ifndef ROOT_TNamed
24 #include "TNamed.h"
25 #endif
26 
27 
28 class TClass;
29 class TDocParser;
30 class TDocOutput;
31 class THtml;
32 class TLatex;
33 class TMacro;
34 class TVirtualPad;
35 
36 class TDocDirective: public TNamed {
37 protected:
38  TDocParser* fDocParser; // parser invoking this handler
39  THtml* fHtml; // parser's THtml object
40  TDocOutput* fDocOutput; // parser invoking this handler
41  TString fParameters; // parameters to the directive
42  Int_t fCounter; // counter to generate unique names, -1 to ignore
43 
44  virtual void AddParameter(const TString& /*name*/, const char* /*value*/ = 0) {}
45 
47  TDocDirective(const char* name):
48  TNamed(name, ""), fDocParser(0), fHtml(0), fDocOutput(0), fCounter(-1) {};
49  virtual ~TDocDirective() {}
50 
51  const char* GetName() const { return TNamed::GetName(); }
52  void GetName(TString& name) const;
53  TDocParser* GetDocParser() const { return fDocParser; }
54  TDocOutput* GetDocOutput() const { return fDocOutput; }
55  THtml* GetHtml() const { return fHtml; }
56  const char* GetOutputDir() const;
57 
58  void SetParser(TDocParser* parser);
59  void SetParameters(const char* params);
60  void SetTag(const char* tag) { SetTitle(tag); }
61  void SetCounter(Int_t count) { fCounter = count; }
62  virtual void DeleteOutputFiles(const char* ext) const;
63 
64 public:
65  // get the tag ending this directive
66  virtual const char* GetEndTag() const = 0;
67 
68  // add a line to the directive's text
69  virtual void AddLine(const TSubString& line) = 0;
70 
71  // retrieve the result (replacement) of the directive; return false if invalid
72  virtual Bool_t GetResult(TString& result) = 0;
73 
74  // Delete output for the parser's current class or module.
75  virtual void DeleteOutput() const {}
76 
77  friend class TDocParser;
78 
79  ClassDef(TDocDirective, 0); // THtml directive handler
80 };
81 
83 private:
84  TString fText; // HTML text to be kept
85  Bool_t fVerbatim; // whether we are in a <pre></pre> block
86 public:
88  virtual ~TDocHtmlDirective() {}
89 
90  virtual void AddLine(const TSubString& line);
91  virtual const char* GetEndTag() const { return "end_html"; }
92  virtual Bool_t GetResult(TString& result);
93 
94  ClassDef(TDocHtmlDirective, 0); // Handler for "Begin_Html"/"End_Html" for raw HTML in documentation comments
95 };
96 
98 private:
99  TMacro* fMacro; // macro to be executed
100  Bool_t fNeedGraphics; // if set, we cannot switch to batch mode
101  Bool_t fShowSource; // whether a source tab should be created
102  Bool_t fIsFilename; // whether the directive is a failename to be executed
103 
104  virtual void AddParameter(const TString& name, const char* value = 0);
106 
107 public:
109  TDocDirective("MACRO"), fMacro(0), fNeedGraphics(kFALSE),
111  virtual ~TDocMacroDirective();
112 
113  virtual void AddLine(const TSubString& line);
114  virtual const char* GetEndTag() const { return "end_macro"; }
115  virtual Bool_t GetResult(TString& result);
116  // Delete output for the parser's current class or module.
117  virtual void DeleteOutput() const { DeleteOutputFiles(".gif"); }
118 
119  static void SubProcess(const TString& what, const TString& out);
120 
121  ClassDef(TDocMacroDirective, 0); // Handler for "Begin_Macro"/"End_Macro" for code that is executed and that can generate an image for documentation
122 };
123 
125 protected:
126  TMacro* fLatex; // collection of lines
127  Int_t fFontSize; // fontsize for current latex block, in pixels
128  TString fSeparator; // column separator, often "="
129  Bool_t fSepIsRegexp; // whether fSeparator is a regexp expression
130  TString fAlignment; // column alignment: 'l' for justify left, 'c' for center, 'r' for right
131  TVirtualPad* fBBCanvas; // canvas for bounding box determination
132 
133  virtual void CreateLatex(const char* filename);
134  virtual void AddParameter(const TString& name, const char* value = 0);
135  virtual void GetBoundingBox(TLatex& latex, const char* text, Float_t& width, Float_t& height);
136 
137 public:
139  TDocDirective("LATEX"), fLatex(0), fFontSize(16),
140  fSepIsRegexp(kFALSE), fBBCanvas(0) {};
141  virtual ~TDocLatexDirective();
142 
143  virtual void AddLine(const TSubString& line);
144  virtual const char* GetEndTag() const {return "end_latex";}
145 
146  const char* GetAlignment() const {return fAlignment;}
147  const char* GetSeparator() const {return fSeparator;}
149  Int_t GetFontSize() const {return fFontSize;}
150  TList* GetListOfLines() const;
151 
152  virtual Bool_t GetResult(TString& result);
153  // Delete output for the parser's current class or module.
154  virtual void DeleteOutput() const { DeleteOutputFiles(".gif"); }
155 
156  ClassDef(TDocLatexDirective, 0); // Handler for "Begin_Latex"/"End_Latex" to generate an image from latex
157 };
158 
159 #endif // ROOT_TDocDirective
A zero length substring is legal.
Definition: TString.h:83
TLine * line
ClassDef(TDocHtmlDirective, 0)
float Float_t
Definition: RtypesCore.h:53
TVirtualPad * fBBCanvas
void SetTag(const char *tag)
Definition: TDocDirective.h:60
Int_t GetFontSize() const
virtual Bool_t GetResult(TString &result)=0
virtual void AddLine(const TSubString &line)
Add a line of HTML.
static const char * filename()
const char * GetAlignment() const
Class supporting a collection of lines with C++ code.
Definition: TMacro.h:33
Basic string class.
Definition: TString.h:137
TDocOutput * GetDocOutput() const
Definition: TDocDirective.h:54
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
const Bool_t kFALSE
Definition: Rtypes.h:92
virtual void AddParameter(const TString &, const char *=0)
Definition: TDocDirective.h:44
virtual void DeleteOutput() const
Bool_t SeparatorIsRegexp() const
virtual void DeleteOutputFiles(const char *ext) const
Delete all output generated by the directive beginning with Name() and ending with ext...
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.
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
TDocDirective(const char *name)
Definition: TDocDirective.h:47
To draw Mathematical Formula.
Definition: TLatex.h:33
void SetCounter(Int_t count)
Definition: TDocDirective.h:61
const char * GetOutputDir() const
Get the directory for documentation output.
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h:59
void SetParser(TDocParser *parser)
Set the parser, and fDocOutput, fHtml from that.
char * out
Definition: TBase64.cxx:29
virtual ~TDocMacroDirective()
Destructor.
A doubly linked list.
Definition: TList.h:47
static const char * what
Definition: stlLoader.cc:6
virtual Bool_t GetResult(TString &result)
Get the result (i.e.
virtual void DeleteOutput() const
Definition: TDocDirective.h:75
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 * GetName() const
Returns name of object.
Definition: TDocDirective.h:51
virtual ~TDocHtmlDirective()
Definition: TDocDirective.h:88
virtual void AddParameter(const TString &name, const char *value=0)
Setting fNeedGraphics if name is "GUI", setting fShowSource if name is "SOURCE".
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:81
TString fParameters
Definition: TDocDirective.h:41
const char * GetSeparator() const
ClassDef(TDocLatexDirective, 0)
ClassDef(TDocDirective, 0)
void SetParameters(const char *params)
Given a string containing parameters in params, we call AddParameter() for each of them...
TText * text
ClassDef(TDocMacroDirective, 0)
virtual ~TDocLatexDirective()
Destructor.
virtual void AddLine(const TSubString &line)
Add a macro line.
TDocOutput * fDocOutput
Definition: TDocDirective.h:40
static void SubProcess(const TString &what, const TString &out)
#define name(a, b)
Definition: linkTestLib0.cpp:5
virtual const char * GetEndTag() const =0
virtual ~TDocDirective()
Definition: TDocDirective.h:49
virtual const char * GetEndTag() const
TString CreateSubprocessInputFile()
Create the input file for SubProcess().
virtual void AddLine(const TSubString &line)
Add a latex line.
THtml * GetHtml() const
Definition: TDocDirective.h:55
virtual void DeleteOutput() const
TDocParser * GetDocParser() const
Definition: TDocDirective.h:53
double result[121]
TDocParser * fDocParser
Definition: TDocDirective.h:38
TList * GetListOfLines() const
Get the list of lines as TObjStrings.
virtual const char * GetEndTag() const
Definition: TDocDirective.h:91
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual void SetTitle(const char *title="")
Change (i.e. set) the title of the TNamed.
Definition: TNamed.cxx:152
virtual const char * GetEndTag() const
float value
Definition: math.cpp:443
Definition: THtml.h:44
virtual void CreateLatex(const char *filename)
Create a gif file named filename from a latex expression in fLatex.
virtual void AddLine(const TSubString &line)=0