59 const char* entry = 0;
80 outfilename.
Remove(posExt, outfilename.
Length() - posExt);
129 if (posAssign !=
kNPOS) {
132 if (value[0] ==
'\'')
134 else if (value[0] ==
'"')
170 if (line.
Start() == -1)
return;
172 TPRegexp pretag(
"</?[pP][rR][eE][ >]");
180 while (posPre !=
kNPOS && posPre > 0) {
181 Bool_t isOpen = line[posPre + 1 - line.
Start()] !=
'/';
183 if (posClose ==
kNPOS)
break;
184 Ssiz_t len = posClose - posPre;
221 result =
"</pre><!-- TDocHtmlDirective start -->";
222 result += fText +
"<!-- TDocHtmlDirective end --><pre>";
260 Int_t sleepCycles = 50;
267 ::Error(
"TDocMacroDirective::HandleDirective_Macro",
268 "Error processing macro for %s!", out.
Data());
278 typeid(*objRet).name();
279 objRet =
dynamic_cast<const TObject*
>(objRet);
290 ::Info(
"TDocMacroDirective::HandleDirective_Macro",
291 "Saving returned %s to file %s.",
294 if (!
gROOT->IsBatch()) {
302 if (!
gROOT->IsBatch()) {
310 #ifdef R__BEPAEPSTLICHERALSDERPAPST 312 if (objRet !=
gPad && padSave ==
gPad)
329 fMacro =
new TMacro(name);
337 fMacro->AddLine(sLine);
338 fIsFilename &= !sLine.
Contains(
'{');
350 fMacro->SaveSource(fileSysName);
356 TIter iLine(fMacro->GetListOfLines());
357 while (filename.
Length() == 0)
367 if (modulename.
Length()) {
371 const char* pathDelimiter =
":";
381 osDir->
String() += filenameDirPart;
382 macroPath += osDir->
String() + pathDelimiter;
394 if (posOpen !=
kNPOS) {
395 params = filename(posOpen, filename.
Length());
402 Error(
"GetResult",
"Cannot find macro '%s' in path '%s'!",
406 fileSysName += params;
407 fileSysName += plusplus;
412 std::ifstream ifMacro(fileSysName);
413 fMacro->GetListOfLines()->Delete();
418 fMacro->AddLine(line);
434 if (!fMacro->GetListOfLines()
435 || !fMacro->GetListOfLines()->First()) {
436 Warning(
"GetResult",
"Empty directive found!");
443 Info(
"HandleDirective_Macro",
"executing macro \"%s\" with %d lines.",
444 fMacro->GetName(), fMacro->GetListOfLines() ? fMacro->GetListOfLines()->GetEntries() + 1 : 0);
448 if (!wasBatch && !fNeedGraphics)
450 else if (fNeedGraphics) {
452 Warning(
"GetResult()",
"Will not initialize the graphics system; skipping macro %s!",
GetName());
462 outFileName +=
".gif";
467 TString subProcInputFile = CreateSubprocessInputFile();
472 TString invoc(
"root.exe -l -q ");
476 invoc +=
"-e 'TDocMacroDirective::SubProcess(\"" 477 + subProcInputFile +
"\",\"" + outFileName +
"\");'";
481 if (exitCode &&
gDebug > 0) {
482 Info(
"GetResult()",
"Subprocess exited with status %d\n", exitCode);
483 }
else if (!fIsFilename) {
490 result =
"<span class=\"macro\"><img class=\"macro\" alt=\"output of ";
491 result += outFileName;
493 result +=
"\" title=\"MACRO\" src=\"";
495 result +=
"\" /></span>";
500 TIter iLine(fMacro->GetListOfLines());
502 std::stringstream ssRaw;
504 ssRaw << osLine->
String() << std::endl;
510 std::stringstream ssConverted;
514 fMacro->GetListOfLines()->
Delete();
516 while (!ssConverted.fail()) {
519 fMacro->AddLine(line);
523 id =
id(0,
id.Length()-4);
525 TString tags(
"</pre><div class=\"tabs\">\n" 526 "<a id=\"" +
id +
"_A0\" class=\"tabsel\" href=\"" +
gSystem->
BaseName(outFileName) +
"\" onclick=\"javascript:return SetDiv('" +
id +
"',0);\">Picture</a>\n" 527 "<a id=\"" +
id +
"_A1\" class=\"tab\" href=\"#\" onclick=\"javascript:return SetDiv('" +
id +
"',1);\">Source</a>\n" 528 "<br /></div><div class=\"tabcontent\">\n" 529 "<div id=\"" +
id +
"_0\" class=\"tabvisible\">" + result +
"</div>\n" 530 "<div id=\"" +
id +
"_1\" class=\"tabhidden\"><div class=\"listing\"><pre class=\"code\">");
534 if (!
TString(osLine->String().Strip()).EndsWith(
"*HIDE*"))
535 tags += osLine->String() +
"\n";
536 if (tags.EndsWith(
"\n"))
537 tags.
Remove(tags.Length()-1);
538 tags +=
"</pre></div></div><div class=\"clear\"></div></div><pre>";
542 result.
ReplaceAll(
"<span class=\"comment\">",
"<span class=\"codecomment\">");
555 fNeedGraphics =
kTRUE;
558 else Warning(
"AddParameter",
"Unknown option %s!", name.
Data());
569 std::vector<Float_t> fWidths;
575 fHeight(0.), fColumns(columns) {
if (columns) fWidths.resize(
Size());}
578 Float_t& Height() {
return fHeight;}
585 void Delete() {
delete fColumns; }
629 fLatex =
new TMacro(name);
637 fLatex->AddLine(sLine);
647 || !fLatex->GetListOfLines()
648 || !fLatex->GetListOfLines()->First())
659 const Float_t canvSize = 1200.;
663 Form(
"new TCanvas(\"R__TDocLatexDirective_BBCanvas\",\"fBBCanvas\",%g,%g);", -(canvSize + 4.), canvSize + 28.));
665 Error(
"CreateLatex",
"Cannot create a TCanvas via the interpreter!");
668 fBBCanvas->SetBorderMode(0);
669 fBBCanvas->SetFillColor(
kWhite);
673 std::list<TLatexLine> latexLines;
674 std::vector<Float_t> maxWidth(20);
676 Float_t totalHeight = gLinePadding;
684 TIter iterLine(fLatex->GetListOfLines());
687 if (fSeparator.Length()) {
690 }
else fSepIsRegexp =
kFALSE;
693 const TString& str = line->String();
699 if (!fSeparator.Length())
703 split = regexp.
MatchS(str);
707 if (fSeparator.Index(str[pos]) !=
kNPOS) {
717 latexLines.push_back(TLatexLine(split));
725 TString* strCol = latexLines.back()[col];
727 GetBoundingBox(latex, *strCol, widthLatex, heightLatex);
728 if (heightLine < heightLatex) heightLine = heightLatex;
729 if (maxWidth.size() < col)
730 maxWidth.resize(col * 2);
731 if (maxWidth[col] < widthLatex)
732 maxWidth[col] = widthLatex;
733 latexLines.back().Width(col) = widthLatex;
735 latexLines.back().Height() = heightLine;
736 totalHeight += heightLine + gLinePadding;
739 std::vector<Float_t> posX(numColumns + 1);
740 for (
UInt_t col = 0; col <= numColumns; ++col) {
741 if (col == 0) posX[col] = gColumnPadding;
742 else posX[col] = posX[col - 1] + maxWidth[col - 1] + gColumnPadding;
744 Float_t totalWidth = posX[numColumns];
750 Float_t padSizeY = totalHeight + 8.;
753 Form(
"new TCanvas(\"R__TDocLatexDirective_padImg\",\"padImg\",-(Int_t)%g,(Int_t)%g);",
754 padSizeX + 4.5, padSizeY + 28.5));
760 for (std::list<TLatexLine>::iterator iLine = latexLines.begin();
761 iLine != latexLines.end(); ++iLine) {
762 posY += iLine->Height()/2. + gLinePadding;
763 for (
UInt_t iCol = 0; iCol < iLine->Size(); ++iCol) {
767 if ((
UInt_t)fAlignment.Length() > iCol)
768 align = fAlignment[(
Int_t)iCol];
772 case 'r': x += maxWidth[iCol] - iLine->Width(iCol);
break;
773 case 'c': x += 0.5*(maxWidth[iCol] - iLine->Width(iCol));
break;
775 if (iLine == latexLines.begin())
776 Error(
"CreateLatex",
"Invalid alignment character '%c'!", align);
778 latex.
DrawLatex( x / padSizeX, 1. - posY / padSizeY, str->
Data());
780 posY += iLine->Height()/2.;
783 padImg->
Print(filename);
786 for (std::list<TLatexLine>::iterator iLine = latexLines.begin();
787 iLine != latexLines.end(); ++iLine) {
820 return fLatex ? fLatex->GetListOfLines() : 0;
834 TString latexFilename(firstLine);
835 for (
Ssiz_t namepos = 0; namepos < latexFilename.
Length(); ++namepos)
837 latexFilename.
Remove(namepos, 1);
841 filename += latexFilename;
849 result =
"<span class=\"latex\"><img class=\"latex\" alt=\"";
851 result +=
"\" title=\"LATEX\" src=\"";
853 result +=
"\" /></span>";
858 Info(
"HandleDirective_Latex",
"Writing Latex \"%s\" to file %s.",
859 fLatex->GetName(), filename.
Data());
861 CreateLatex(filename);
872 if (!value || !value[0])
873 Error(
"AddParameter",
"Option \"fontsize\" needs a value!");
874 else fFontSize = atol(value);
876 if (!value || !value[0])
877 Error(
"AddParameter",
"Option \"separator\" needs a value!");
878 else fSeparator = value;
880 if (!value || !value[0])
881 Error(
"AddParameter",
"Option \"align\" needs a value!");
882 else fAlignment = value;
884 Warning(
"AddParameter",
"Unknown option %s!", name.
Data());
A zero length substring is legal.
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
const char * GetOutputDir() const
Get the directory for documentation output.
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
virtual void SetBorderMode(Short_t bordermode)=0
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Collectable string class.
virtual void DeleteOutputFiles(const char *ext) const
Delete all output generated by the directive beginning with Name() and ending with ext...
TString & ReplaceAll(const TString &s1, const TString &s2)
std::istream & ReadLine(std::istream &str, Bool_t skipWhite=kTRUE)
Read a line from stream upto newline skipping any whitespace.
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
TObjArray * MatchS(const TString &s, const TString &mods="", Int_t start=0, Int_t nMaxMatch=10)
Returns a TObjArray of matched substrings as TObjString's.
TList * GetListOfLines() const
Get the list of lines as TObjStrings.
virtual void AddLine(const TSubString &line)
Add a line of HTML.
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Class supporting a collection of lines with C++ code.
virtual void AddParameter(const TString &name, const char *value=0)
Parse fParameters, setting fFontSize, fAlignment, and fSeparator.
virtual const char * DirName(const char *pathname)
Return the directory name in pathname.
virtual void AddParameter(const TString &, const char *=0)
void GetCurrentModule(TString &out_module) const
Return the name of module for which sources are currently parsed.
TString & Prepend(const char *cs)
TObject * At(Int_t idx) const
virtual TVirtualPad * cd(Int_t subpadnumber=0)=0
TDocParser * GetDocParser() const
virtual Bool_t GetResult(TString &result)
Set result to the HTML code that was passed in via AddLine().
virtual const char * FindFile(const char *search, TString &file, EAccessMode mode=kFileExists)
Find location of file in a search path.
virtual void GetBoundingBox(TLatex &latex, const char *text, Float_t &width, Float_t &height)
Determines the bounding box for text as height and width.
virtual void SetTextFont(Font_t tfont=62)
Set the text font.
virtual const char * GetDirEntry(void *dirp)
Get a directory entry. Returns 0 if no more entries.
virtual int Unlink(const char *name)
Unlink, i.e. remove, a file.
virtual void SetText(Double_t x, Double_t y, const char *text)
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
virtual void SaveAs(const char *filename="", Option_t *option="") const
Save this object in the file specified by filename.
To draw Mathematical Formula.
void Convert(std::ostream &out, std::istream &in, const char *relpath, Bool_t isCode, Bool_t interpretDirectives)
Parse text file "in", add links etc, and write output to "out".
TLatex * DrawLatex(Double_t x, Double_t y, const char *text)
Make a copy of this object with the new parameters And copy object attributes.
virtual const char * PrependPathName(const char *dir, TString &name)
Concatenate a directory and a file name.
static Bool_t Strip(TString &s)
strips ' ', tabs, and newlines from both sides of str
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
virtual const char * TempDirectory() const
Return a user configured or systemwide directory to create temporary files in.
TVirtualPad is an abstract base class for the Pad and Canvas classes.
virtual void GetModuleNameForClass(TString &module, TClass *cl) const
Return the module name for a given class.
void SetParser(TDocParser *parser)
Set the parser, and fDocOutput, fHtml from that.
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
virtual ~TDocMacroDirective()
Destructor.
static Bool_t IsWord(UChar_t c)
Check if c is a valid first character for C++ name.
virtual Bool_t GetResult(TString &result)
Get the result (i.e.
virtual void Delete(Option_t *option="")
Delete this object.
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 ...
R__EXTERN TSystem * gSystem
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
virtual const char * ReplaceSpecialChars(char c)
Replace ampersand, less-than and greater-than character, writing to out.
virtual void NameSpace2FileName(TString &name)
Replace "::" in name by "__" Replace "<", ">", " ", ",", "~", "=" in name by "_" Replace "A::X<A::Y>"...
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
const char * GetName() const
Returns name of object.
virtual void AddParameter(const TString &name, const char *value=0)
Setting fNeedGraphics if name is "GUI", setting fShowSource if name is "SOURCE".
Int_t GetEntriesFast() const
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
char * Form(const char *fmt,...)
TSubString Strip(EStripType s=kTrailing, char c=' ') const
Return a substring of self stripped at beginning and/or end.
void GetBoundingBox(UInt_t &w, UInt_t &h, Bool_t angle=kFALSE)
Return text size in pixels.
const TString & GetOutputDir(Bool_t createDir=kTRUE) const
Return the output directory as set by SetOutputDir().
virtual Int_t Exec(const char *shellcmd)
Execute a command.
virtual void FreeDirectory(void *dirp)
Free a directory.
TString & Remove(Ssiz_t pos)
void SetParameters(const char *params)
Given a string containing parameters in params, we call AddParameter() for each of them...
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
Ssiz_t Last(char c) const
Find last occurrence of a character c.
virtual ~TDocLatexDirective()
Destructor.
virtual void AddLine(const TSubString &line)
Add a macro line.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
#define R__LOCKGUARD(mutex)
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
virtual void GetHtmlFileName(TClass *classPtr, TString &filename) const
Return real HTML filename.
static void SubProcess(const TString &what, const TString &out)
void GetModuleMacroPath(const TString &module, TString &out_path) const
Mother of all ROOT objects.
TDocOutput * GetDocOutput() const
TString CreateSubprocessInputFile()
Create the input file for SubProcess().
virtual void AddLine(const TSubString &line)
Add a latex line.
Int_t GetEntries() const
Return the number of objects in array (i.e.
virtual void * OpenDirectory(const char *name)
Open a directory. Returns 0 if directory does not exist.
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
virtual const char * GetName() const
Returns name of object.
TClass * GetCurrentClass() const
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void CreateLatex(const char *filename)
Create a gif file named filename from a latex expression in fLatex.
virtual const char * GetTitle() const
Returns title of object.
TDocOutput * GetDocOutput() const
virtual void Print(const char *filename="") const =0
Print function.
const char * Data() const