#ifndef ROOT_THtml
#define ROOT_THtml
#ifndef ROOT_THashList
#include "THashList.h"
#endif
#ifndef ROOT_THashTable
#include "THashTable.h"
#endif
#ifndef ROOT_TExMap
#include "TExMap.h"
#endif
#include <map>
class TClass;
class TClassDocInfo;
class TGClient;
class TVirtualMutex;
class THtml: public TObject {
public:
class THelperBase: public TObject {
public:
THelperBase(): fHtml(0) {}
virtual ~THelperBase();
void SetOwner(THtml* html);
THtml* GetOwner() const { return fHtml; }
private:
THtml* fHtml;
ClassDef(THelperBase, 0);
};
class TFileSysEntry;
class TModuleDefinition: public THelperBase {
public:
virtual bool GetModule(TClass* cl, TFileSysEntry* fse, TString& out_modulename) const;
ClassDef(TModuleDefinition, 0);
};
class TFileDefinition: public THelperBase {
public:
virtual bool GetDeclFileName(const TClass* cl, TString& out_filename, TString& out_fsys,
TFileSysEntry** fse = 0) const;
virtual bool GetImplFileName(const TClass* cl, TString& out_filename, TString& out_fsys,
TFileSysEntry** fse = 0) const;
protected:
virtual bool GetFileName(const TClass* cl, bool decl, TString& out_filename, TString& out_fsys,
TFileSysEntry** fse = 0) const;
TString MatchFileSysName(TString& filename, TFileSysEntry** fse = 0) const;
void SplitClassIntoDirFile(const TString& clname, TString& dir, TString& filename) const;
void NormalizePath(TString& path) const;
void ExpandSearchPath(TString& path) const;
ClassDef(TFileDefinition, 0);
};
class TPathDefinition: public THelperBase {
public:
virtual bool GetMacroPath(const TString& module, TString& out_dir) const;
virtual bool GetIncludeAs(TClass* cl, TString& out_include_as) const;
virtual bool GetFileNameFromInclude(const char* included, TString& out_fsname) const;
virtual bool GetDocDir(const TString& module, TString& doc_dir) const;
protected:
ClassDef(TPathDefinition, 0);
};
class TFileSysDir;
class TFileSysDB;
class TFileSysEntry: public TObject {
public:
TFileSysEntry(const char* name, TFileSysDir* parent):
fName(name), fParent(parent), fLevel(parent ? parent->GetLevel() + 1 : 0) {}
const char* GetName() const { return fName; }
virtual ULong_t Hash() const { return fName.Hash(); }
virtual void GetFullName(TString& fullname, Bool_t asIncluded) const {
if (fParent) {
fParent->GetFullName(fullname, asIncluded);
if (fullname[0])
fullname += "/";
} else
fullname = "";
fullname += fName;
}
TFileSysDir* GetParent() const { return fParent; }
Int_t GetLevel() const { return fLevel; }
protected:
TString fName;
TFileSysDir* fParent;
Int_t fLevel;
ClassDef(TFileSysEntry, 0);
};
class TFileSysDir: public TFileSysEntry {
public:
TFileSysDir(const char* name, TFileSysDir* parent):
TFileSysEntry(name, parent)
{ fFiles.SetOwner(); fDirs.SetOwner(); }
const TList* GetFiles() const { return &fFiles; }
const TList* GetSubDirs() const { return &fDirs; }
void Recurse(TFileSysDB* db, const char* path);
protected:
TList fFiles;
TList fDirs;
ClassDef(TFileSysDir, 0);
};
class TFileSysRoot: public TFileSysDir {
public:
TFileSysRoot(const char* name, TFileSysDB* parent):
TFileSysDir(name, parent) {}
void GetFullName(TString& fullname, Bool_t asIncluded) const {
fullname = "";
if (!asIncluded)
fullname += fName;
}
ClassDef(TFileSysRoot, 0);
};
class TFileSysDB: public TFileSysDir {
public:
TFileSysDB(const char* path, const char* ignr, Int_t maxdirlevel):
TFileSysDir(path, 0), fEntries(1009, 5), fIgnorePath(ignr), fMaxLevel(maxdirlevel)
{ Fill(); }
TExMap& GetMapIno() { return fMapIno; }
THashTable& GetEntries() { return fEntries; }
const TString& GetIgnore() const { return fIgnorePath; }
Int_t GetMaxLevel() const { return fMaxLevel; }
protected:
void Fill();
private:
TExMap fMapIno;
THashTable fEntries;
TString fIgnorePath;
Int_t fMaxLevel;
ClassDef(TFileSysDB, 0);
};
struct PathInfo_t {
enum EDotAccess {
kDotUnknown,
kDotFound,
kDotNotFound
};
PathInfo_t():
fFoundDot(kDotUnknown),
#ifdef R__WIN32
fInputPath("./;src/;include/"),
#else
fInputPath("./:src/:include/"),
#endif
fIncludePath("include"),
fIgnorePath("\\b(include|CVS|test|tutorials|doc|lib|python|demo|freetype-|gdk|libAfterImage|etc|config|build|bin)\\b"),
fDocPath("doc"),
fMacroPath("macros:."),
fOutputDir("htmldoc") {}
EDotAccess fFoundDot;
TString fInputPath;
TString fIncludePath;
TString fIgnorePath;
TString fDocPath;
TString fMacroPath;
TString fDotDir;
TString fEtcDir;
TString fOutputDir;
};
public:
enum EConvertOutput {
kNoOutput,
kInterpretedOutput,
kCompiledOutput,
kForceOutput = 0x10,
kSeparateProcessOutput = 0x20
};
THtml();
virtual ~THtml();
static void LoadAllLibs();
void Convert(const char *filename, const char *title,
const char *dirname = "", const char *relpath="../",
Int_t includeOutput = kNoOutput,
const char* context = "");
void CreateHierarchy();
void MakeAll(Bool_t force=kFALSE, const char *filter="*",
int numthreads = 1);
void MakeClass(const char *className, Bool_t force=kFALSE);
void MakeIndex(const char *filter="*");
void MakeTree(const char *className, Bool_t force=kFALSE);
void SetModuleDefinition(const TModuleDefinition& md);
void SetFileDefinition(const TFileDefinition& fd);
void SetPathDefinition(const TPathDefinition& pd);
void SetProductName(const char* product) { fProductName = product; }
void SetOutputDir(const char *dir);
void SetInputDir(const char *dir);
void SetSourceDir(const char *dir) { SetInputDir(dir); }
void SetIncludePath(const char* dir) { fPathInfo.fIncludePath = dir; }
void SetEtcDir(const char* dir) { fPathInfo.fEtcDir = dir; }
void SetDocPath(const char* path) { fPathInfo.fDocPath = path; }
void SetDotDir(const char* dir) { fPathInfo.fDotDir = dir; fPathInfo.fFoundDot = PathInfo_t::kDotUnknown; }
void SetRootURL(const char* url) { fLinkInfo.fROOTURL = url; }
void SetLibURL(const char* lib, const char* url) { fLinkInfo.fLibURLs[lib] = url; }
void SetXwho(const char *xwho) { fLinkInfo.fXwho = xwho; }
void SetMacroPath(const char* path) {fPathInfo.fMacroPath = path;}
void AddMacroPath(const char* path);
void SetCounterFormat(const char* format) { fCounterFormat = format; }
void SetClassDocTag(const char* tag) { fDocSyntax.fClassDocTag = tag; }
void SetAuthorTag(const char* tag) { fDocSyntax.fAuthorTag = tag; }
void SetLastUpdateTag(const char* tag) { fDocSyntax.fLastUpdateTag = tag; }
void SetCopyrightTag(const char* tag) { fDocSyntax.fCopyrightTag = tag; }
void SetHeader(const char* file) { fOutputStyle.fHeader = file; }
void SetFooter(const char* file) { fOutputStyle.fFooter = file; }
void SetHomepage(const char* url) { fLinkInfo.fHomepage = url; }
void SetSearchStemURL(const char* url) { fLinkInfo.fSearchStemURL = url; }
void SetSearchEngine(const char* url) { fLinkInfo.fSearchEngine = url; }
void SetViewCVS(const char* url) { fLinkInfo.fViewCVS = url; }
void SetWikiURL(const char* url) { fLinkInfo.fWikiURL = url; }
void SetCharset(const char* charset) { fOutputStyle.fCharset = charset; }
void SetDocStyle(const char* style) { fDocSyntax.fDocStyle = style; }
const TModuleDefinition& GetModuleDefinition() const;
const TFileDefinition& GetFileDefinition() const;
const TPathDefinition& GetPathDefinition() const;
const TString& GetProductName() const { return fProductName; }
const TString& GetInputPath() const { return fPathInfo.fInputPath; }
const TString& GetOutputDir(Bool_t createDir = kTRUE) const;
virtual const char* GetEtcDir() const;
const TString& GetModuleDocPath() const { return fPathInfo.fDocPath; }
const TString& GetDotDir() const { return fPathInfo.fDotDir; }
const char* GetURL(const char* lib = 0) const;
const TString& GetXwho() const { return fLinkInfo.fXwho; }
const TString& GetMacroPath() const { return fPathInfo.fMacroPath; }
const char* GetCounterFormat() const { return fCounterFormat; }
const TString& GetClassDocTag() const { return fDocSyntax.fClassDocTag; }
const TString& GetAuthorTag() const { return fDocSyntax.fAuthorTag; }
const TString& GetLastUpdateTag() const { return fDocSyntax.fLastUpdateTag; }
const TString& GetCopyrightTag() const { return fDocSyntax.fCopyrightTag; }
const TString& GetHeader() const { return fOutputStyle.fHeader; }
const TString& GetFooter() const { return fOutputStyle.fFooter; }
const TString& GetHomepage() const { return fLinkInfo.fHomepage; }
const TString& GetSearchStemURL() const { return fLinkInfo.fSearchStemURL; }
const TString& GetSearchEngine() const { return fLinkInfo.fSearchEngine; }
const TString& GetViewCVS() const { return fLinkInfo.fViewCVS; }
const TString& GetWikiURL() const { return fLinkInfo.fWikiURL; }
const TString& GetCharset() const { return fOutputStyle.fCharset; }
const TString& GetDocStyle() const { return fDocSyntax.fDocStyle; }
Bool_t CopyFileFromEtcDir(const char* filename) const;
virtual void CreateAuxiliaryFiles() const;
virtual TClass* GetClass(const char *name) const;
const char* ShortType(const char *name) const;
const char* GetCounter() const { return fCounter; }
void GetModuleMacroPath(const TString& module, TString& out_path) const { GetPathDefinition().GetMacroPath(module, out_path); }
virtual bool GetDeclFileName(TClass* cl, Bool_t filesys, TString& out_name) const;
void GetDerivedClasses(TClass* cl, std::map<TClass*, Int_t>& derived) const;
static const char* GetDirDelimiter() {
#ifdef R__WIN32
return ";";
#else
return ":";
#endif
}
virtual bool GetImplFileName(TClass* cl, Bool_t filesys, TString& out_name) const;
virtual void GetHtmlFileName(TClass *classPtr, TString& filename) const;
virtual const char* GetHtmlFileName(const char* classname) const;
TList* GetLibraryDependencies() { return &fDocEntityInfo.fLibDeps; }
void SortListOfModules() { fDocEntityInfo.fModules.Sort(); }
const TList* GetListOfModules() const { return &fDocEntityInfo.fModules; }
const TList* GetListOfClasses() const { return &fDocEntityInfo.fClasses; }
TFileSysDB* GetLocalFiles() const { if (!fLocalFiles) SetLocalFiles(); return fLocalFiles; }
TVirtualMutex* GetMakeClassMutex() const { return fMakeClassMutex; }
virtual void GetModuleNameForClass(TString& module, TClass* cl) const;
const PathInfo_t& GetPathInfo() const { return fPathInfo; }
Bool_t HaveDot();
void HelperDeleted(THelperBase* who);
static Bool_t IsNamespace(const TClass*cl);
void SetDeclFileName(TClass* cl, const char* filename);
void SetFoundDot(Bool_t found = kTRUE);
void SetImplFileName(TClass* cl, const char* filename);
void SetBatch(Bool_t batch = kTRUE) { fBatch = batch; }
Bool_t IsBatch() const { return fBatch; }
void ReplaceSpecialChars(std::ostream&, const char*) {
Error("ReplaceSpecialChars",
"Removed, call TDocOutput::ReplaceSpecialChars() instead!"); }
void SetEscape(char ='\\') {}
protected:
struct DocSyntax_t {
TString fClassDocTag;
TString fAuthorTag;
TString fLastUpdateTag;
TString fCopyrightTag;
TString fDocStyle;
};
struct LinkInfo_t {
TString fXwho;
TString fROOTURL;
std::map<std::string, TString> fLibURLs;
TString fHomepage;
TString fSearchStemURL;
TString fSearchEngine;
TString fViewCVS;
TString fWikiURL;
};
struct OutputStyle_t {
TString fHeader;
TString fFooter;
TString fCharset;
};
struct DocEntityInfo_t {
DocEntityInfo_t(): fClasses(503, 3) {}
TString fClassFilter;
THashList fClasses;
mutable THashList fShortClassNames;
THashList fModules;
THashList fLibDeps;
};
protected:
virtual void CreateJavascript() const;
virtual void CreateStyleSheet() const;
void CreateListOfTypes();
void CreateListOfClasses(const char* filter);
virtual bool GetDeclImplFileName(TClass* cl, bool filesys, bool decl, TString& out_name) const;
void MakeClass(void* cdi, Bool_t force=kFALSE);
TClassDocInfo *GetNextClass();
void SetLocalFiles() const;
static void *MakeClassThreaded(void* info);
protected:
TString fCounter;
TString fCounterFormat;
TString fProductName;
TIter *fThreadedClassIter;
Int_t fThreadedClassCount;
TVirtualMutex *fMakeClassMutex;
TGClient *fGClient;
DocSyntax_t fDocSyntax;
LinkInfo_t fLinkInfo;
OutputStyle_t fOutputStyle;
mutable PathInfo_t fPathInfo;
DocEntityInfo_t fDocEntityInfo;
mutable TPathDefinition *fPathDef;
mutable TModuleDefinition *fModuleDef;
mutable TFileDefinition* fFileDef;
mutable TFileSysDB *fLocalFiles;
Bool_t fBatch;
ClassDef(THtml,0)
};
R__EXTERN THtml *gHtml;
#endif