#ifndef ROOT_TDocParser
#define ROOT_TDocParser
#include <list>
#include <set>
#include <map>
#ifndef ROOT_TObject
#include "TObject.h"
#endif
#ifndef ROOT_THashList
#include "THashList.h"
#endif
#ifndef ROOT_TString
#include "TString.h"
#endif
#ifndef ROOT_Riosfwd
#include "Riosfwd.h"
#endif
class TBaseClass;
class TClass;
class TClassDocOutput;
class TDocOutput;
class THtml;
class TDocMethodWrapper: public TObject {
public:
virtual TMethod* GetMethod() const = 0;
virtual Int_t GetOverloadIdx() const = 0;
};
class TDocParser: public TObject {
protected:
enum EDocContext {
kIgnore,
kDocFunc,
kDocClass,
kNumDocContexts
};
public:
enum ESourceInfo {
kInfoLastUpdate,
kInfoAuthor,
kInfoCopyright,
kInfoLastChanged,
kInfoLastGenerated,
kNumSourceInfos
};
enum EAccess {
kPrivate,
kProtected,
kPublic
};
enum EParseContext {
kNoContext,
kCode,
kComment,
kDirective,
kString,
kKeyword,
kCPP,
kVerbatim,
kNumParseContexts,
kParseContextMask = BIT(4) - 1
};
enum EParseContextFlag {
kCXXComment = BIT(4),
kParseContextFlagMask = (UInt_t)(~(BIT(4) - 1))
};
protected:
THtml* fHtml;
TDocOutput* fDocOutput;
UInt_t fLineNo;
TString fLineRaw;
TString fLineStripped;
TString fLineComment;
TString fLineSource;
TString fComment;
TString fFirstClassDoc;
TString fLastClassDoc;
TClass* fCurrentClass;
TClass* fRecentClass;
TString fCurrentModule;
TString fCurrentMethodTag;
Int_t fDirectiveCount;
Long_t fLineNumber;
TString fCurrentFile;
std::map<std::string , Int_t > fMethodCounts;
EDocContext fDocContext;
std::list<UInt_t> fParseContext;
Bool_t fCheckForMethod;
enum {
kClassDoc_Uninitialized,
kClassDoc_LookingNothingFound,
kClassDoc_LookingHaveSomething,
kClassDoc_Written,
kClassDoc_Ignore,
kClassDoc_NumStates
} fClassDocState;
Bool_t fCommentAtBOL;
TString fClassDescrTag;
TString fSourceInfoTags[kNumSourceInfos];
TList fDirectiveHandlers;
Bool_t fAllowDirectives;
std::set<UInt_t> fExtraLinesWithAnchor;
TString fSourceInfo[kNumSourceInfos];
THashList fMethods[3];
TList fDataMembers[6];
static std::set<std::string> fgKeywords;
void AddClassMethodsRecursively(TBaseClass* bc);
void AddClassDataMembersRecursively(TBaseClass* bc);
EParseContext Context() const { return fParseContext.empty() ? kComment : (EParseContext)(fParseContext.back() & kParseContextMask); }
virtual void ExpandCPPLine(TString& line, Ssiz_t& pos);
virtual Bool_t HandleDirective(TString& keyword, Ssiz_t& pos,
TString& word, Ssiz_t& copiedToCommentUpTo);
virtual void InitKeywords() const;
virtual TClass* IsDirective(const TString& line, Ssiz_t pos, const TString& word, Bool_t& begin) const;
TMethod* LocateMethodInCurrentLine(Ssiz_t& posMethodName, TString& ret,
TString& name, TString& params, std::ostream &srcOut, TString &anchor,
std::ifstream& sourcefile, Bool_t allowPureVirtual);
void LocateMethodsInSource(std::ostream& out);
void LocateMethodsInHeaderInline(std::ostream& out);
void LocateMethodsInHeaderClassDecl(std::ostream& out);
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);
virtual Bool_t ProcessComment();
void RemoveCommentContext(Bool_t cxxcomment);
void WriteClassDoc(std::ostream& out, Bool_t first = kTRUE);
void WriteMethod(std::ostream& out, TString& ret,
TString& name, TString& params,
const char* file, TString& anchor,
TString& codeOneLiner);
void WriteSourceLine(std::ostream& out);
public:
TDocParser(TClassDocOutput& docOutput, TClass* cl);
TDocParser(TDocOutput& docOutput);
virtual ~TDocParser();
static void AnchorFromLine(const TString& line, TString& anchor);
void Convert(std::ostream& out, std::istream& in, const char* relpath,
Bool_t isCode, Bool_t interpretDirectives);
void DecrementMethodCount(const char* name);
virtual void DecorateKeywords(std::ostream& out, const char* text);
virtual void DecorateKeywords(TString& text);
virtual void DeleteDirectiveOutput() const;
const TList* GetMethods(EAccess access) const { return &fMethods[access]; }
TClass* GetCurrentClass() const { return fCurrentClass; }
void GetCurrentModule(TString& out_module) const;
TDocOutput* GetDocOutput() const { return fDocOutput; }
Long_t GetLineNumber() const { return fLineNumber; }
const TList* GetDataMembers(EAccess access) const { return &fDataMembers[access]; }
const TList* GetEnums(EAccess access) const { return &fDataMembers[access+3]; }
const char* GetSourceInfo(ESourceInfo type) const { return fSourceInfo[type]; }
void SetCurrentModule(const char* module) { fCurrentModule = module; }
UInt_t InContext(Int_t context) const;
static Bool_t IsName(UChar_t c);
static Bool_t IsWord(UChar_t c);
virtual void Parse(std::ostream& out);
static Bool_t Strip(TString& s);
ClassDef(TDocParser,0);
};
#endif // ROOT_TDocParser