3 Ssiz_t& copiedToCommentUpTo)
21 copiedToCommentUpTo = pos;
36 if (begin && line[pos] ==
'(') {
37 std::list<char> waitForClosing;
39 for (; endParam < line.
Length()
40 && (line[endParam] !=
')' || !waitForClosing.empty()); ++endParam) {
41 const char c = line[endParam];
42 if (!waitForClosing.empty() && waitForClosing.back() ==
c) {
43 waitForClosing.pop_back();
48 if (waitForClosing.empty() || waitForClosing.back() !=
'\'')
49 waitForClosing.push_back(
'"');
52 if (waitForClosing.empty() || waitForClosing.back() !=
'"')
53 waitForClosing.push_back(
'\'');
56 if (waitForClosing.empty() || (waitForClosing.back() !=
'"' && waitForClosing.back() !=
'\''))
57 waitForClosing.push_back(
')');
65 if (waitForClosing.empty()) {
66 params =
line(pos + 1, endParam - (pos + 1));
67 pos += params.
Length() + 2;
74 const char* endTag = directive->
GetEndTag();
75 Ssiz_t lenEndTag = strlen(endTag);
77 if (line[posEndTag - 1] ==
'"') {
78 posEndTag += lenEndTag;
83 if (posEndTag !=
kNPOS) {
99 while (pos < line.
Length())
104 copiedToCommentUpTo = line.
Length();
113 else pos += word.
Length() - 2;
118 Warning(
"HandleDirective",
"Cannot find directive handler object %s !",
140 copiedToCommentUpTo = pos;
188 for (std::list<UInt_t>::const_reverse_iterator iPC =
fParseContext.rbegin();
190 if (!lowerContext || ((lowerContext && ((*iPC & kParseContextMask) == lowerContext))
191 && (!contextFlag || (contextFlag && (*iPC & contextFlag)))))
282 if (pos > 0 && line[pos - 1] ==
'"')
308 if (
gDebug > 0 && !clDirective)
309 Warning(
"IsDirective",
"Unknown THtml directive %s in line %d!", word.
Data(),
fLineNo);
330 if (isalnum(c) || c ==
'_' || c ==
'~')
353 if (isalpha(c) || c ==
'_' || c ==
'~')
370 Bool_t& isconst, std::ostream &srcOut,
371 TString &anchor, std::ifstream& sourceFile,
374 typedef std::map<std::string ,
Int_t > MethodCount_t;
377 if (posMethodName ==
kNPOS) {
382 if (posQuote !=
kNPOS && (posBlock ==
kNPOS || posQuote < posBlock))
384 if (posBlock ==
kNPOS)
386 for (MethodCount_t::iterator iMethodName =
fMethodCounts.begin();
388 TString lookFor(iMethodName->first);
390 if (posMethodName !=
kNPOS && posMethodName < posBlock
391 && (posMethodName == 0 || !
IsWord(
fLineRaw[posMethodName - 1]))) {
396 if (
fLineRaw[posMethodEnd] ==
'(') {
398 srcOut, anchor, sourceFile, allowPureVirtual);
412 while (ret.Length() && (
IsName(ret[ret.Length() - 1]) || ret[ret.Length()-1] ==
':'))
413 ret.Remove(ret.Length() - 1, 1);
416 while (didSomething) {
418 if (ret.BeginsWith(
"inline ")) {
419 didSomething =
kTRUE;
422 if (ret.BeginsWith(
"static ")) {
423 didSomething =
kTRUE;
426 if (ret.BeginsWith(
"virtual ")) {
427 didSomething =
kTRUE;
436 if (posParam ==
kNPOS ||
438 ret.Contains(
"{") || ret.Contains(
"}") || ret.Contains(
"(") || ret.Contains(
")")
439 || ret.Contains(
"=")) {
448 Ssiz_t checkOpBracketParam = posParam + 1;
449 while (isspace((
UChar_t)name[checkOpBracketParam]))
450 ++checkOpBracketParam;
451 if (name[checkOpBracketParam] ==
')') {
452 ++checkOpBracketParam;
453 while (isspace((
UChar_t)name[checkOpBracketParam]))
454 ++checkOpBracketParam;
455 if (name[checkOpBracketParam] ==
'(')
456 posParam = checkOpBracketParam;
460 if (posParam ==
kNPOS) {
467 params =
name(posParam, name.
Length() - posParam);
479 if (iMethodName ==
fMethodCounts.end() || iMethodName->second <= 0) {
488 Int_t bracketLevel = 1;
489 while (bracketLevel) {
490 const char* paramEnd = strpbrk(params.
Data() + posParamEnd,
")(\"'");
498 srcOut <<
"<a name=\"" << anchor <<
"\"></a>";
505 if (sourceFile.eof()) {
506 Error(
"LocateMethodInCurrentLine",
507 "Cannot find end of signature for function %s!",
521 posParamEnd = params.
Length();
524 posParamEnd = paramEnd - params.
Data();
525 switch (params[posParamEnd]) {
526 case '(': ++bracketLevel; ++posParamEnd;
break;
527 case ')': --bracketLevel; ++posParamEnd;
break;
530 while (params.
Length() > posParamEnd && params[posParamEnd] !=
'"') {
532 if (params[posParamEnd] ==
'\\') ++posParamEnd;
535 if (params.
Length() <= posParamEnd) {
546 if (params[posParamEnd] ==
'\\') ++posParamEnd;
557 isconst = pastParams.
BeginsWith(
"const") && !(isalnum(pastParams[5]) || pastParams[5] ==
'_');
561 Ssiz_t posSemicolon = params.
Index(
';', posParamEnd);
562 Ssiz_t posPureVirt = params.
Index(
'=', posParamEnd);
563 if (posSemicolon !=
kNPOS)
564 if ((posBlock ==
kNPOS || (posSemicolon < posBlock)) &&
565 (posPureVirt ==
kNPOS || !allowPureVirtual)
566 && !allowPureVirtual)
570 params.
Remove(posParamEnd);
578 posMethodName = posParam + posParamEnd;
633 Bool_t lookForSourceInfo ,
636 const char* methodPattern ,
637 const char* sourceExt )
639 TString sourceFileName(filename);
641 if (!sourceFileName.
Length()) {
643 Error(
"LocateMethods",
"Can't find source file '%s' for class %s!",
647 std::ifstream sourceFile(sourceFileName.
Data());
648 if (!sourceFile || !sourceFile.good()) {
649 Error(
"LocateMethods",
"Can't open file '%s' for reading!", sourceFileName.
Data());
653 TPMERegexp patternRE(methodPattern ? methodPattern :
"");
665 std::ofstream srcHtmlOut;
667 if (sourceExt && sourceExt[0]) {
675 srcHtmlOutName +=
".h.html";
683 while (!sourceFile.eof()) {
689 if (sourceFile.eof())
break;
706 Strip(strippedComment);
707 if (strippedComment.
Length() > 0) {
722 while ((posLastScope =
name.Index(
"::")) !=
kNPOS)
723 name.Remove(0, posLastScope + 2);
726 if (posName !=
kNPOS) {
727 Ssiz_t posClosingParen = posName +
name.Length();
728 while (isspace(
fLineStripped[posClosingParen])) ++posClosingParen;
742 if (methodName.
Length() && !wroteMethodNowWaitingForOpenBlock) {
744 if (useDocxxStyle && docxxComment.
Length()) {
748 WriteMethod(out, methodRet, methodName, methodParam, methodIsConst,
751 if (savedComment[0]) {
756 if (!wroteMethodNowWaitingForOpenBlock) {
762 if (posPattern !=
kNPOS && methodPattern) {
764 static const char vetoChars[] =
"{\"";
765 for (
int ich = 0; posPattern !=
kNPOS && vetoChars[ich]; ++ich) {
767 if (posVeto !=
kNPOS && posVeto < posPattern)
771 if (posPattern !=
kNPOS || !methodPattern) {
774 posPattern += patternRE[0].Length();
777 methodParam, methodIsConst, srcHtmlOut,
778 anchor, sourceFile, allowPureVirtual);
779 if (methodName.
Length()) {
781 needAnchor = !anchor.
Length();
800 if (methodName.
Length() && !wroteMethodNowWaitingForOpenBlock) {
802 if (!codeOneLiner.
Length() &&
812 else if (!methodName.
Length() && !useDocxxStyle)
818 srcHtmlOut <<
"<a name=\"" << anchor <<
"\"></a>";
825 if (lookForSourceInfo)
843 if (methodName.
Length()) {
844 if (useDocxxStyle && docxxComment.
Length())
846 WriteMethod(out, methodRet, methodName, methodParam, methodIsConst,
852 srcHtmlOut <<
"</pre>" << std::endl;
856 srcHtmlOut <<
"</div>" << std::endl;
880 pattern.Remove(0, posLastScope + 2);
888 if (posGt !=
kNPOS) {
891 if (posLt !=
kNPOS && posLt < posGt) {
892 pattern.Replace(posLt + 1, posGt - posLt - 1,
".*");
913 pattern.Remove(0, posLastScope + 1);
921 if (posGt !=
kNPOS) {
924 if (posLt !=
kNPOS && posLt < posGt) {
925 pattern.Replace(posLt + 1, posGt - posLt - 1,
".*");
943 kTRUE , 0,
".h.html");
978 while ((mustDealWithCommentAtBOL && posSpanEnd !=
kNPOS) || posComment !=
kNPOS) {
981 while (spanLevel > 1 || (posSpan !=
kNPOS && posSpan < posSpanEnd)) {
983 if (posSpan !=
kNPOS && posSpan < posSpanEnd) {
993 if (posSpanEnd !=
kNPOS) {
995 commentLine.Remove(posSpanEnd, 7);
996 if (posComment !=
kNPOS)
997 commentLine.Remove(posComment, 22);
999 mustDealWithCommentAtBOL =
kFALSE;
1006 if (posComment !=
kNPOS)
1007 commentLine.Remove(posComment, 22);
1022 char start_or_end = 0;
1024 if (commentLine.Length()>1 && commentLine[0] ==
'/'
1025 && (commentLine[1] ==
'/' || commentLine[1] ==
'*')) {
1026 start_or_end = commentLine[1];
1027 commentLine.Remove(0, 2);
1030 if (start_or_end !=
'/' && commentLine.Length()>1
1031 && commentLine[commentLine.Length() - 2] ==
'*'
1032 && commentLine[commentLine.Length() - 1] ==
'/') {
1033 start_or_end = commentLine[commentLine.Length() - 2];
1034 commentLine.Remove(commentLine.Length()-2);
1038 if (start_or_end && commentLine.Length() > 3) {
1039 TString lineAllOneChar(commentLine.Strip());
1043 Char_t c = lineAllOneChar[len - 1];
1044 if (c == lineAllOneChar[len - 2] && c == lineAllOneChar[len - 3]) {
1046 Strip(lineAllOneCharStripped);
1047 if (!lineAllOneCharStripped.
Length()) {
1048 commentLine.Remove(0);
1063 if (commentLine.Length() > 0 && start_or_end == commentLine[commentLine.Length() - 1])
1068 while (commentLine.Length() > 2
1069 && !
IsWord(commentLine[0])
1070 && commentLine[0] == commentLine[commentLine.Length() - 1])
1074 while (start_or_end && commentLine[0] == start_or_end)
1075 commentLine.Remove(0, 1);
1090 for (std::list<UInt_t>::iterator iContext =
fParseContext.begin();
1092 if (*iContext == lookFor) iComment =iContext;
1102 Bool_t changed = str[0] ==
' ' || str[0] ==
'\t' || str[0] ==
'\n';
1104 && (str[str.
Length() - 1] ==
' ' || str[str.
Length() - 1] ==
'\t'
1105 || str[str.
Length() - 1] ==
'\n');
1106 if (!changed)
return kFALSE;
1108 while (str[i] ==
' ' || str[i] ==
'\t' || str[i] ==
'\n')
1112 while (i >= 0 && (str[i] ==
' ' || str[i] ==
'\t' || str[i] ==
'\n'))
1132 static void RemoveUnneededSpaces(
TString& s) {
1139 if (((isalnum(p) || p ==
'_') && (isalnum(n) || n ==
'_'))
1140 || (p ==
'>' && n ==
'>')) {
1143 while (isspace(s[i])) {
1151 static void ParseParameters(
TString& strippedParams,
TList& paramArr) {
1156 bool quoted =
false;
1159 for (
Ssiz_t i = 0; i < len; ++i) {
1160 switch (strippedParams[i]) {
1163 case '[': ++nest;
break;
1166 case ']': --nest;
break;
1167 case '=': init =
true;
break;
1168 case '\'': ++i;
if (strippedParams[i] ==
'\\') ++i; ++i;
continue;
1169 case '\\': ++i;
continue;
break;
1170 case '"': quoted = !quoted;
break;
1172 if (!quoted && !nest) {
1182 arg += strippedParams[i];
1186 if (strippedLastArg.Length()) {
1196 TIter iCandidate(candidates);
1197 int nparams = paramArr->
GetSize();
1198 for (
int iparam = 0; iparam < nparams && candidates->
GetSize() > 1; ++iparam) {
1201 while (noParName.Length()
1202 && (isalnum(noParName[noParName.Length() - 1]) || noParName[noParName.Length() - 1] ==
'_'))
1203 noParName.Remove(noParName.Length() - 1);
1206 if (noParName.Length()) {
1207 RemoveUnneededSpaces(noParName);
1209 RemoveUnneededSpaces(srcArg);
1214 for (
int comparison = 0; comparison < 5; ++comparison) {
1215 if (comparison == 1 && noParName == srcArg)
1224 RemoveUnneededSpaces(sMethArg);
1225 bool matches =
false;
1226 switch (comparison) {
1227 case 0: matches = (srcArg == sMethArg);
break;
1228 case 1: matches = (noParName == sMethArg);
break;
1229 case 2: matches = srcArg.
Contains(sMethArg) || sMethArg.
Contains(srcArg);
break;
1232 suppressed.
Add(method);
1246 if (candidates->
GetSize() > 1) {
1276 TString strippedParams(params);
1277 if (strippedParams[0] ==
'(') {
1278 strippedParams.
Remove(0, 1);
1285 ParseParameters(strippedParams, paramArr);
1286 int nparams = paramArr.
GetSize();
1290 for (
int access = 0; access < 3; ++access) {
1292 if (!methList)
continue;
1294 TIter nextMethod(methList);
1300 candidates.
Add(method);
1305 if (nparams && candidates.
GetSize() > 1) {
1306 MatchOverloadSignatures(&candidates, ¶mArr);
1310 if (candidates.
GetSize() == 1) {
1316 fComment, codeOneLiner, guessedMethod);
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
Collectable string class.
TMethod * LocateMethodInCurrentLine(Ssiz_t &posMethodName, TString &ret, TString &name, TString ¶ms, Bool_t &isconst, std::ostream &srcOut, TString &anchor, std::ifstream &sourcefile, Bool_t allowPureVirtual)
Search for a method starting at posMethodName, and return its return type, its name, and its arguments.
enum TDocParser::@111 fClassDocState
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.
void SetTag(const char *tag)
virtual Bool_t GetResult(TString &result)=0
TString fSourceInfoTags[kNumSourceInfos]
static const char * filename()
void DecrementMethodCount(const char *name)
reduce method count for method called name, removing it from fMethodCounts once the count reaches 0...
void ToLower()
Change string to lower-case.
Each ROOT method (see TMethod) has a linked list of its arguments.
TString & Prepend(const char *cs)
void WriteClassDoc(std::ostream &out, Bool_t first=kTRUE)
Write the class description depending (among others) on fClassDocState.
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
virtual void DecorateEntityBegin(TString &str, Ssiz_t &pos, TDocParser::EParseContext type)
Add some colors etc to a source entity, contained in str.
virtual void AddLast(TObject *obj)
Add object at the end of the list.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
const TList * GetListForObject(const char *name) const
Return the THashTable's list (bucket) in which obj can be found based on its hash; see THashTable::Ge...
void RemoveCommentContext(Bool_t cxxcomment)
remove the top-most comment context that matches cxxcomment,
const char * Data() const
virtual void InitKeywords() const
fill C++ keywords into fgKeywords
virtual Bool_t ProcessComment()
void WriteSourceLine(std::ostream &out)
Write fLineSource to out.
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Return a pointer to a newly allocated object of this class.
void SetCounter(Int_t count)
virtual TObjLink * LastLink() const
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
void WriteHtmlFooter(std::ostream &out, const char *dir, const char *lastUpdate, const char *author, const char *copyright, const char *footer)
Write HTML footer.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
static std::set< std::string > fgKeywords
void SetParser(TDocParser *parser)
Set the parser, and fDocOutput, fHtml from that.
virtual void Parse(std::ostream &out)
Locate methods, starting in the source file, then inline, then immediately inside the class declarati...
static Bool_t IsWord(UChar_t c)
Check if c is a valid first character for C++ name.
virtual void AdjustSourcePath(TString &line, const char *relpath="../")
adjust the path of links for source files, which are in src/, but need to point to relpath (usually "...
virtual TList * GetListOfMethodArgs()
Returns methodarg list and additionally updates fDataMember in TMethod by calling FindDataMember();...
void WriteMethod(std::ostream &out, TString &ret, TString &name, TString ¶ms, Bool_t isconst, const char *file, TString &anchor, TString &codeOneLiner)
Write a method, forwarding to TClassDocOutput.
R__EXTERN TSystem * gSystem
TString fCurrentMethodTag
virtual const char * ReplaceSpecialChars(char c)
Replace ampersand, less-than and greater-than character, writing to out.
static void AnchorFromLine(const TString &line, TString &anchor)
Create an anchor from the given line, by hashing it and convertig the hash into a custom base64 strin...
virtual void NameSpace2FileName(TString &name)
Replace "::" in name by "__" Replace "<", ">", " ", ",", "~", "=" in name by "_" Replace "A::X<A::Y>"...
virtual TObject * Remove(TObject *obj)
Remove object from the list.
virtual Bool_t HandleDirective(TString &keyword, Ssiz_t &pos, TString &word, Ssiz_t &copiedToCommentUpTo)
Collection abstract base class.
static Bool_t IsName(UChar_t c)
Check if c is a valid C++ name character.
Bool_t TestBit(UInt_t f) const
std::map< std::string, Int_t > fMethodCounts
virtual const char * GetName() const
Returns name of object.
TSubString Strip(EStripType s=kTrailing, char c= ' ') const
Return a substring of self stripped at beginning and/or end.
The ROOT global object gROOT contains a list of all defined classes.
void LocateMethodsInHeaderInline(std::ostream &out)
Given fCurrentClass, look for methods in its header file, and extract documentation to out...
virtual TClass * IsDirective(const TString &line, Ssiz_t pos, const TString &word, Bool_t &begin) const
return whether word at line's pos is a valid directive, and returns its TDocDirective's TClass object...
Long_t Property() const
Get property description word. For meaning of bits see EProperty.
virtual TMethod * GetMethod() const =0
Int_t CountChar(Int_t c) const
Return number of times character c occurs in the string.
virtual void DeleteDirectiveOutput() const
Delete output generated by prior runs of all known directives; the output file names might have chang...
const TString & GetDocStyle() const
EParseContext Context() const
void LocateMethodsInHeaderClassDecl(std::ostream &out)
Given fCurrentClass, look for methods in its header file's class declaration block, and extract documentation to out, while beautifying the header file in parallel.
virtual void FixupAuthorSourceInfo(TString &authors)
Special author treatment; called when TDocParser::fSourceInfo[kInfoAuthor] is set.
virtual TObject * Last() const
Return the last object in the list. Returns 0 when list is empty.
TString & Remove(Ssiz_t pos)
virtual bool GetDeclFileName(TClass *cl, Bool_t filesys, TString &out_name) const
Return declaration file name; return the full path if filesys is true.
TString fSourceInfo[kNumSourceInfos]
void SetParameters(const char *params)
Given a string containing parameters in params, we call AddParameter() for each of them...
std::set< UInt_t > fExtraLinesWithAnchor
virtual Int_t GetSize() const
virtual const char * GetName() const
Returns name of object.
virtual void DecorateKeywords(std::ostream &out, const char *text)
Expand keywords in text, writing to out.
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
virtual void Clear(Option_t *option="")
Remove all objects from the list.
void WriteLineNumbers(std::ostream &out, Long_t nLines, const TString &infileBase) const
Create a div containing the line numbers (for a source listing) 1 to nLines.
std::list< UInt_t > fParseContext
Int_t Match(const TString &s, UInt_t start=0)
Runs a match on s against the regex 'this' was created with.
virtual const char * GetEndTag() const =0
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
const char * GetFullTypeName() const
Get full type description of method argument, e.g.: "class TDirectory*".
virtual void Add(TObject *obj)
Wrapper for PCRE library (Perl Compatible Regular Expressions).
virtual void RemoveAll(TCollection *col)
Remove all objects in collection col from this collection.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Each ROOT class (see TClass) has a linked list of methods.
void LocateMethods(std::ostream &out, const char *filename, Bool_t lookForSourceInfo=kTRUE, Bool_t useDocxxStyle=kFALSE, Bool_t allowPureVirtual=kFALSE, const char *methodPattern=0, const char *sourceExt=0)
Collect methods from the source or header file called filename.
ClassImp(TSlaveInfo) Int_t TSlaveInfo const TSlaveInfo * si
Used to sort slaveinfos by ordinal.
TMethod * GetMethodAny(const char *method)
Return pointer to method without looking at parameters.
UInt_t InContext(Int_t context) const
checks whether we are in a parse context, return the entry closest to the current context...
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
const char * AsString() const
Return the date & time as a string (ctime() format).
virtual bool GetImplFileName(TClass *cl, Bool_t filesys, TString &out_name) const
Return implementation file name.
Ssiz_t First(char c) const
Find first occurrence of a character c.
void LocateMethodsInSource(std::ostream &out)
Given fCurrentClass, look for methods in its source file, and extract documentation to out...
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
virtual void AddLine(const TSubString &line)=0
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.