00001 /****************************************************************************** 00002 * 00003 * $Id: util.h,v 1.49 2001/03/19 19:27:42 root Exp $ 00004 * 00005 * Copyright (C) 1997-2008 by Dimitri van Heesch. 00006 * 00007 * Permission to use, copy, modify, and distribute this software and its 00008 * documentation under the terms of the GNU General Public License is hereby 00009 * granted. No representations are made about the suitability of this software 00010 * for any purpose. It is provided "as is" without express or implied warranty. 00011 * See the GNU General Public License for more details. 00012 * 00013 * Documents produced by Doxygen are derivative works derived from the 00014 * input used in their production; they are not affected by this license. 00015 * 00016 */ 00017 00018 #ifndef UTIL_H 00019 #define UTIL_H 00020 00025 #include "qtbc.h" 00026 #include <qlist.h> 00027 #include <qtextstream.h> 00028 #include <ctype.h> 00029 #include "sortdict.h" 00030 00031 //-------------------------------------------------------------------- 00032 00033 class ClassDef; 00034 class FileDef; 00035 class MemberList; 00036 class NamespaceDef; 00037 class FileNameDict; 00038 class ArgumentList; 00039 class OutputList; 00040 class OutputDocInterface; 00041 class MemberDef; 00042 class ExampleSDict; 00043 class ClassSDict; 00044 class BaseClassList; 00045 class GroupDef; 00046 class NamespaceSDict; 00047 class ClassList; 00048 class MemberGroupSDict; 00049 struct TagInfo; 00050 class MemberNameInfoSDict; 00051 struct ListItemInfo; 00052 class PageDef; 00053 struct SectionInfo; 00054 class QDir; 00055 class Definition; 00056 00057 //-------------------------------------------------------------------- 00058 00059 class TextGeneratorIntf 00060 { 00061 public: 00062 virtual ~TextGeneratorIntf() {} 00063 virtual void writeString(const char *,bool) const = 0; 00064 virtual void writeBreak() const = 0; 00065 virtual void writeLink(const char *extRef,const char *file, 00066 const char *anchor,const char *text 00067 ) const = 0; 00068 }; 00069 00070 class TextGeneratorOLImpl : public TextGeneratorIntf 00071 { 00072 public: 00073 virtual ~TextGeneratorOLImpl() {} 00074 TextGeneratorOLImpl(OutputDocInterface &od); 00075 void writeString(const char *s,bool keepSpaces) const; 00076 void writeBreak() const; 00077 void writeLink(const char *extRef,const char *file, 00078 const char *anchor,const char *text 00079 ) const; 00080 private: 00081 OutputDocInterface &m_od; 00082 }; 00083 00084 //-------------------------------------------------------------------- 00085 00086 enum SrcLangExt 00087 { 00088 SrcLangExt_IDL = 0x0008, 00089 SrcLangExt_Java = 0x0010, 00090 SrcLangExt_CSharp = 0x0020, 00091 SrcLangExt_D = 0x0040, 00092 SrcLangExt_PHP = 0x0080, 00093 SrcLangExt_ObjC = 0x0100, 00094 SrcLangExt_Cpp = 0x0200, 00095 SrcLangExt_JS = 0x0400, 00096 SrcLangExt_Python = 0x0800, 00097 SrcLangExt_F90 = 0x1000, 00098 SrcLangExt_VHDL = 0x2000 00099 }; 00100 00101 //-------------------------------------------------------------------- 00102 00103 void linkifyText(const TextGeneratorIntf &ol, 00104 Definition *scope, 00105 FileDef *fileScope, 00106 const char *name, 00107 const char *text, 00108 bool autoBreak=FALSE, 00109 bool external=TRUE, 00110 bool keepSpaces=FALSE 00111 ); 00112 00113 void setAnchors(ClassDef *cd,char id,MemberList *ml,int groupId=-1); 00114 00115 QCString fileToString(const char *name,bool filter=FALSE); 00116 00117 QCString dateToString(bool); 00118 00119 bool getDefs(const QCString &scopeName, 00120 const QCString &memberName, 00121 const char *, 00122 MemberDef *&md, 00123 ClassDef *&cd, 00124 FileDef *&fd, 00125 NamespaceDef *&nd, 00126 GroupDef *&gd, 00127 bool forceEmptyScope=FALSE, 00128 FileDef *currentFile=0, 00129 bool checkCV=FALSE 00130 ); 00131 00132 QCString getFileFilter(const char* name); 00133 00134 bool resolveRef(/* in */ const char *scName, 00135 /* in */ const char *name, 00136 /* in */ bool inSeeBlock, 00137 /* out */ Definition **resContext, 00138 /* out */ MemberDef **resMember 00139 ); 00140 00141 bool resolveLink(/* in */ const char *scName, 00142 /* in */ const char *lr, 00143 /* in */ bool inSeeBlock, 00144 /* out */ Definition **resContext, 00145 /* out */ QCString &resAnchor 00146 ); 00147 00148 bool generateRef(OutputDocInterface &od,const char *, 00149 const char *,bool inSeeBlock,const char * =0); 00150 00151 bool generateLink(OutputDocInterface &od,const char *, 00152 const char *,bool inSeeBlock,const char *); 00153 00154 void generateFileRef(OutputDocInterface &od,const char *, 00155 const char *linkTxt=0); 00156 00157 void writePageRef(OutputDocInterface &od,const char *cn,const char *mn); 00158 00159 QCString getCanonicalTemplateSpec(Definition *d,FileDef *fs,const QCString& spec); 00160 00161 bool matchArguments2(Definition *srcScope,FileDef *srcFileScope,ArgumentList *srcAl, 00162 Definition *dstScope,FileDef *dstFileScope,ArgumentList *dstAl, 00163 bool checkCV 00164 ); 00165 00166 void mergeArguments(ArgumentList *,ArgumentList *,bool forceNameOverwrite=FALSE); 00167 00168 QCString substituteClassNames(const QCString &s); 00169 00170 QCString substitute(const char *s,const char *src,const char *dst); 00171 00172 QCString resolveDefines(const char *n); 00173 00174 ClassDef *getClass(const char *key); 00175 00176 ClassDef *getResolvedClass(Definition *scope, 00177 FileDef *fileScope, 00178 const char *key, 00179 MemberDef **pTypeDef=0, 00180 QCString *pTemplSpec=0, 00181 bool mayBeUnlinkable=FALSE, 00182 bool mayBeHidden=FALSE, 00183 QCString *pResolvedType=0); 00184 00185 NamespaceDef *getResolvedNamespace(const char *key); 00186 00187 FileDef *findFileDef(const FileNameDict *fnDict,const char *n, 00188 bool &ambig); 00189 00190 QCString showFileDefMatches(const FileNameDict *fnDict,const char *n); 00191 00192 int guessSection(const char *name); 00193 00194 bool isId(int c); 00195 00196 QCString removeRedundantWhiteSpace(const QCString &s); 00197 00198 QCString argListToString(ArgumentList *al,bool useCanonicalType=FALSE); 00199 00200 QCString tempArgListToString(ArgumentList *al); 00201 00202 QCString generateMarker(int id); 00203 00204 void writeExample(OutputList &ol,ExampleSDict *el); 00205 00206 QCString stripAnonymousNamespaceScope(const QCString &s); 00207 00208 QCString stripFromPath(const QCString &path); 00209 00210 QCString stripFromIncludePath(const QCString &path); 00211 00212 bool rightScopeMatch(const QCString &scope, const QCString &name); 00213 00214 bool leftScopeMatch(const QCString &scope, const QCString &name); 00215 00216 QCString substituteKeywords(const QCString &s,const char *title,const QCString &relPath=""); 00217 00218 int getPrefixIndex(const QCString &name); 00219 00220 QCString removeAnonymousScopes(const QCString &s); 00221 00222 QCString replaceAnonymousScopes(const QCString &s,const char *replacement=0); 00223 00224 void initClassHierarchy(ClassSDict *cl); 00225 00226 bool hasVisibleRoot(BaseClassList *bcl); 00227 00228 int minClassDistance(const ClassDef *cd,const ClassDef *bcd,int level=0); 00229 00230 QCString convertNameToFile(const char *name,bool allowDots=FALSE); 00231 00232 void extractNamespaceName(const QCString &scopeName, 00233 QCString &className,QCString &namespaceName, 00234 bool allowEmptyClass=FALSE); 00235 00236 QCString insertTemplateSpecifierInScope(const QCString &scope,const QCString &templ); 00237 00238 QCString stripScope(const char *name); 00239 00240 QCString convertToHtml(const char *s,bool keepEntities=TRUE); 00241 00242 QCString convertToXML(const char *s); 00243 00244 QCString getOverloadDocs(); 00245 00246 void addMembersToMemberGroup(/* in */ MemberList *ml, 00247 /* in,out */ MemberGroupSDict **ppMemberGroupSDict, 00248 /* in */ Definition *context); 00249 00250 int extractClassNameFromType(const QCString &type,int &pos, 00251 QCString &name,QCString &templSpec); 00252 00253 QCString substituteTemplateArgumentsInString( 00254 const QCString &name, 00255 ArgumentList *formalArgs, 00256 ArgumentList *actualArgs); 00257 00258 ArgumentList *copyArgumentList(const ArgumentList *src); 00259 00260 QList<ArgumentList> *copyArgumentLists(const QList<ArgumentList> *srcLists); 00261 00262 QCString stripTemplateSpecifiersFromScope(const QCString &fullName, 00263 bool parentOnly=TRUE, 00264 QCString *lastScopeStripped=0); 00265 00266 QCString resolveTypeDef(Definition *d,const QCString &name, 00267 Definition **typedefContext=0); 00268 00269 QCString mergeScopes(const QCString &leftScope,const QCString &rightScope); 00270 00271 int getScopeFragment(const QCString &s,int p,int *l); 00272 00273 int filterCRLF(char *buf,int len); 00274 00275 void addRefItem(const QList<ListItemInfo> *sli,const char *prefix, 00276 const char *name,const char *title,const char *args=0); 00277 00278 PageDef *addRelatedPage(const char *name,const QCString &ptitle, 00279 const QCString &doc,QList<SectionInfo> *anchors, 00280 const char *fileName,int startLine, 00281 const QList<ListItemInfo> *sli, 00282 GroupDef *gd=0, 00283 TagInfo *tagInfo=0 00284 ); 00285 00286 QCString escapeCharsInString(const char *name,bool allowDots); 00287 00288 void addGroupListToTitle(OutputList &ol,Definition *d); 00289 00290 void filterLatexString(QTextStream &t,const char *str, 00291 bool insideTabbing=FALSE,bool insidePre=FALSE, 00292 bool insideItem=FALSE); 00293 00294 QCString rtfFormatBmkStr(const char *name); 00295 00296 QCString linkToText(const char *link,bool isFileName); 00297 00298 QCString stripExtension(const char *fName); 00299 00300 void replaceNamespaceAliases(QCString &scope,int i); 00301 00302 int isAccessibleFrom(Definition *scope,FileDef *fileScope,Definition *item); 00303 00304 int isAccessibleFromWithExpScope(Definition *scope,FileDef *fileScope,Definition *item, 00305 const QCString &explicitScopePart); 00306 00307 int computeQualifiedIndex(const QCString &name); 00308 00309 void addDirPrefix(QCString &fileName); 00310 00311 QCString relativePathToRoot(const char *name); 00312 00313 void createSubDirs(QDir &d); 00314 00315 QCString stripPath(const char *s); 00316 00317 bool containsWord(const QCString &s,const QCString &word); 00318 00319 bool findAndRemoveWord(QCString &s,const QCString &word); 00320 00321 QCString stripLeadingAndTrailingEmptyLines(const QCString &s); 00322 00323 void stringToSearchIndex(const QCString &docUrlBase,const QCString &title, 00324 const QCString &str, bool priority=FALSE, 00325 const QCString &anchor=""); 00326 00327 SrcLangExt getLanguageFromFileName(const QCString fileName); 00328 00329 bool checkIfTypedef(Definition *scope,FileDef *fileScope,const char *n); 00330 00331 ClassDef *newResolveTypedef(FileDef *fileScope,MemberDef *md, 00332 MemberDef **pMemType=0,QCString *pTemplSpec=0, 00333 QCString *pResolvedType=0); 00334 00335 QCString parseCommentAsText(const QString &doc,const QCString &fileName,int lineNr); 00336 00337 QCString transcodeCharacterStringToUTF8(const QCString &input); 00338 00339 QCString recodeString(const QCString &str,const char *fromEncoding,const char *toEncoding); 00340 00341 QCString extractAliasArgs(const QCString &args,int pos); 00342 00343 int countAliasArguments(const QCString argList); 00344 00345 QCString replaceAliasArguments(const QCString &aliasValue,const QCString &argList); 00346 00347 QCString resolveAliasCmd(const QCString aliasCmd); 00348 QCString expandAlias(const QCString &aliasName,const QCString &aliasValue); 00349 00350 void writeTypeConstraints(OutputList &ol,Definition *d,ArgumentList *al); 00351 00352 QCString convertCharEntitiesToUTF8(const QCString &s); 00353 00354 #endif 00355