Root/
Source at commit 1322 created 12 years 8 months ago. By meklort, Add doxygen to utils folder | |
---|---|
1 | /******************************************************************************␊ |
2 | *␊ |
3 | * $Id: util.h,v 1.49 2001/03/19 19:27:42 root Exp $␊ |
4 | *␊ |
5 | * Copyright (C) 1997-2011 by Dimitri van Heesch.␊ |
6 | *␊ |
7 | * Permission to use, copy, modify, and distribute this software and its␊ |
8 | * documentation under the terms of the GNU General Public License is hereby ␊ |
9 | * granted. No representations are made about the suitability of this software ␊ |
10 | * for any purpose. It is provided "as is" without express or implied warranty.␊ |
11 | * See the GNU General Public License for more details.␊ |
12 | *␊ |
13 | * Documents produced by Doxygen are derivative works derived from the␊ |
14 | * input used in their production; they are not affected by this license.␊ |
15 | *␊ |
16 | */␊ |
17 | ␊ |
18 | #ifndef UTIL_H␊ |
19 | #define UTIL_H␊ |
20 | ␊ |
21 | /*! \file util.h ␊ |
22 | * \brief A bunch of utility functions.␊ |
23 | */␊ |
24 | ␊ |
25 | #include "qtbc.h"␊ |
26 | #include <qlist.h>␊ |
27 | #include <qtextstream.h>␊ |
28 | #include <ctype.h>␊ |
29 | #include "sortdict.h"␊ |
30 | ␊ |
31 | //--------------------------------------------------------------------␊ |
32 | ␊ |
33 | class ClassDef;␊ |
34 | class FileDef;␊ |
35 | class MemberList;␊ |
36 | class NamespaceDef;␊ |
37 | class FileNameDict;␊ |
38 | class ArgumentList;␊ |
39 | class OutputList;␊ |
40 | class OutputDocInterface;␊ |
41 | class MemberDef;␊ |
42 | class ExampleSDict;␊ |
43 | class ClassSDict;␊ |
44 | class BaseClassList;␊ |
45 | class GroupDef;␊ |
46 | class NamespaceSDict;␊ |
47 | class ClassList;␊ |
48 | class MemberGroupSDict;␊ |
49 | struct TagInfo;␊ |
50 | class MemberNameInfoSDict;␊ |
51 | struct ListItemInfo;␊ |
52 | class PageDef;␊ |
53 | struct SectionInfo;␊ |
54 | class QDir;␊ |
55 | class Definition;␊ |
56 | class BufStr;␊ |
57 | class QFileInfo;␊ |
58 | class QStrList;␊ |
59 | class FTextStream;␊ |
60 | ␊ |
61 | //--------------------------------------------------------------------␊ |
62 | ␊ |
63 | class TextGeneratorIntf␊ |
64 | {␊ |
65 | public:␊ |
66 | virtual ~TextGeneratorIntf() {}␊ |
67 | virtual void writeString(const char *,bool) const = 0;␊ |
68 | virtual void writeBreak() const = 0;␊ |
69 | virtual void writeLink(const char *extRef,const char *file,␊ |
70 | const char *anchor,const char *text␊ |
71 | ) const = 0; ␊ |
72 | };␊ |
73 | ␊ |
74 | class TextGeneratorOLImpl : public TextGeneratorIntf␊ |
75 | {␊ |
76 | public:␊ |
77 | virtual ~TextGeneratorOLImpl() {}␊ |
78 | TextGeneratorOLImpl(OutputDocInterface &od);␊ |
79 | void writeString(const char *s,bool keepSpaces) const;␊ |
80 | void writeBreak() const;␊ |
81 | void writeLink(const char *extRef,const char *file,␊ |
82 | const char *anchor,const char *text␊ |
83 | ) const;␊ |
84 | private:␊ |
85 | OutputDocInterface &m_od;␊ |
86 | };␊ |
87 | ␊ |
88 | //--------------------------------------------------------------------␊ |
89 | ␊ |
90 | enum SrcLangExt␊ |
91 | {␊ |
92 | SrcLangExt_Unknown = 0x0000,␊ |
93 | SrcLangExt_IDL = 0x0008,␊ |
94 | SrcLangExt_Java = 0x0010,␊ |
95 | SrcLangExt_CSharp = 0x0020,␊ |
96 | SrcLangExt_D = 0x0040,␊ |
97 | SrcLangExt_PHP = 0x0080,␊ |
98 | SrcLangExt_ObjC = 0x0100,␊ |
99 | SrcLangExt_Cpp = 0x0200,␊ |
100 | SrcLangExt_JS = 0x0400,␊ |
101 | SrcLangExt_Python = 0x0800,␊ |
102 | SrcLangExt_F90 = 0x1000,␊ |
103 | SrcLangExt_VHDL = 0x2000,␊ |
104 | SrcLangExt_XML = 0x4000␊ |
105 | };␊ |
106 | ␊ |
107 | //--------------------------------------------------------------------␊ |
108 | ␊ |
109 | void linkifyText(const TextGeneratorIntf &ol,␊ |
110 | Definition *scope,␊ |
111 | FileDef *fileScope,␊ |
112 | const char *name,␊ |
113 | const char *text,␊ |
114 | bool autoBreak=FALSE,␊ |
115 | bool external=TRUE,␊ |
116 | bool keepSpaces=FALSE␊ |
117 | );␊ |
118 | ␊ |
119 | void setAnchors(ClassDef *cd,char id,MemberList *ml,int groupId=-1);␊ |
120 | ␊ |
121 | QCString fileToString(const char *name,bool filter=FALSE,bool isSourceCode=FALSE);␊ |
122 | ␊ |
123 | QCString dateToString(bool);␊ |
124 | ␊ |
125 | bool getDefs(const QCString &scopeName,␊ |
126 | const QCString &memberName, ␊ |
127 | const char *, ␊ |
128 | MemberDef *&md, ␊ |
129 | ClassDef *&cd,␊ |
130 | FileDef *&fd, ␊ |
131 | NamespaceDef *&nd,␊ |
132 | GroupDef *&gd,␊ |
133 | bool forceEmptyScope=FALSE,␊ |
134 | FileDef *currentFile=0,␊ |
135 | bool checkCV=FALSE␊ |
136 | );␊ |
137 | ␊ |
138 | QCString getFileFilter(const char* name,bool isSourceCode);␊ |
139 | ␊ |
140 | bool resolveRef(/* in */ const char *scName,␊ |
141 | /* in */ const char *name,␊ |
142 | /* in */ bool inSeeBlock,␊ |
143 | /* out */ Definition **resContext,␊ |
144 | /* out */ MemberDef **resMember,␊ |
145 | /* in */ bool lookForSpecializations = TRUE,␊ |
146 | /* in */ FileDef *currentFile = 0,␊ |
147 | /* in */ bool checkScope = FALSE␊ |
148 | );␊ |
149 | ␊ |
150 | bool resolveLink(/* in */ const char *scName,␊ |
151 | /* in */ const char *lr,␊ |
152 | /* in */ bool inSeeBlock,␊ |
153 | /* out */ Definition **resContext,␊ |
154 | /* out */ QCString &resAnchor␊ |
155 | );␊ |
156 | ␊ |
157 | //bool generateRef(OutputDocInterface &od,const char *,␊ |
158 | // const char *,bool inSeeBlock,const char * =0);␊ |
159 | ␊ |
160 | bool generateLink(OutputDocInterface &od,const char *,␊ |
161 | const char *,bool inSeeBlock,const char *);␊ |
162 | ␊ |
163 | void generateFileRef(OutputDocInterface &od,const char *,␊ |
164 | const char *linkTxt=0);␊ |
165 | ␊ |
166 | void writePageRef(OutputDocInterface &od,const char *cn,const char *mn);␊ |
167 | ␊ |
168 | QCString getCanonicalTemplateSpec(Definition *d,FileDef *fs,const QCString& spec);␊ |
169 | ␊ |
170 | bool matchArguments2(Definition *srcScope,FileDef *srcFileScope,ArgumentList *srcAl,␊ |
171 | Definition *dstScope,FileDef *dstFileScope,ArgumentList *dstAl,␊ |
172 | bool checkCV␊ |
173 | );␊ |
174 | ␊ |
175 | void mergeArguments(ArgumentList *,ArgumentList *,bool forceNameOverwrite=FALSE);␊ |
176 | ␊ |
177 | QCString substituteClassNames(const QCString &s);␊ |
178 | ␊ |
179 | QCString substitute(const char *s,const char *src,const char *dst);␊ |
180 | ␊ |
181 | QCString clearBlock(const char *s,const char *begin,const char *end);␊ |
182 | ␊ |
183 | QCString selectBlock(const QCString& s,const QCString &name,bool which);␊ |
184 | ␊ |
185 | QCString resolveDefines(const char *n);␊ |
186 | ␊ |
187 | ClassDef *getClass(const char *key);␊ |
188 | ␊ |
189 | ClassDef *getResolvedClass(Definition *scope,␊ |
190 | FileDef *fileScope,␊ |
191 | const char *key,␊ |
192 | MemberDef **pTypeDef=0,␊ |
193 | QCString *pTemplSpec=0,␊ |
194 | bool mayBeUnlinkable=FALSE,␊ |
195 | bool mayBeHidden=FALSE,␊ |
196 | QCString *pResolvedType=0);␊ |
197 | ␊ |
198 | NamespaceDef *getResolvedNamespace(const char *key);␊ |
199 | ␊ |
200 | FileDef *findFileDef(const FileNameDict *fnDict,const char *n,␊ |
201 | bool &ambig);␊ |
202 | ␊ |
203 | QCString showFileDefMatches(const FileNameDict *fnDict,const char *n);␊ |
204 | ␊ |
205 | int guessSection(const char *name);␊ |
206 | ␊ |
207 | inline bool isId(int c)␊ |
208 | {␊ |
209 | return c=='_' || c>=128 || c<0 || isalnum(c);␊ |
210 | }␊ |
211 | ␊ |
212 | QCString removeRedundantWhiteSpace(const QCString &s);␊ |
213 | ␊ |
214 | QCString argListToString(ArgumentList *al,bool useCanonicalType=FALSE,bool showDefVals=TRUE);␊ |
215 | ␊ |
216 | QCString tempArgListToString(ArgumentList *al);␊ |
217 | ␊ |
218 | QCString generateMarker(int id);␊ |
219 | ␊ |
220 | void writeExample(OutputList &ol,ExampleSDict *el);␊ |
221 | ␊ |
222 | QCString stripAnonymousNamespaceScope(const QCString &s);␊ |
223 | ␊ |
224 | QCString stripFromPath(const QCString &path);␊ |
225 | ␊ |
226 | QCString stripFromIncludePath(const QCString &path);␊ |
227 | ␊ |
228 | bool rightScopeMatch(const QCString &scope, const QCString &name);␊ |
229 | ␊ |
230 | bool leftScopeMatch(const QCString &scope, const QCString &name);␊ |
231 | ␊ |
232 | QCString substituteKeywords(const QCString &s,const char *title);␊ |
233 | ␊ |
234 | int getPrefixIndex(const QCString &name);␊ |
235 | ␊ |
236 | QCString removeAnonymousScopes(const QCString &s);␊ |
237 | ␊ |
238 | QCString replaceAnonymousScopes(const QCString &s,const char *replacement=0);␊ |
239 | ␊ |
240 | void initClassHierarchy(ClassSDict *cl);␊ |
241 | ␊ |
242 | bool hasVisibleRoot(BaseClassList *bcl);␊ |
243 | ␊ |
244 | int minClassDistance(const ClassDef *cd,const ClassDef *bcd,int level=0);␊ |
245 | ␊ |
246 | QCString convertNameToFile(const char *name,bool allowDots=FALSE,bool allowUnderscore=FALSE);␊ |
247 | ␊ |
248 | void extractNamespaceName(const QCString &scopeName,␊ |
249 | QCString &className,QCString &namespaceName,␊ |
250 | bool allowEmptyClass=FALSE);␊ |
251 | ␊ |
252 | QCString insertTemplateSpecifierInScope(const QCString &scope,const QCString &templ);␊ |
253 | ␊ |
254 | QCString stripScope(const char *name);␊ |
255 | ␊ |
256 | QCString convertToHtml(const char *s,bool keepEntities=TRUE);␊ |
257 | ␊ |
258 | QCString convertToXML(const char *s);␊ |
259 | ␊ |
260 | QCString convertToJSString(const char *s);␊ |
261 | ␊ |
262 | QCString getOverloadDocs();␊ |
263 | ␊ |
264 | void addMembersToMemberGroup(/* in */ MemberList *ml,␊ |
265 | /* in,out */ MemberGroupSDict **ppMemberGroupSDict,␊ |
266 | /* in */ Definition *context);␊ |
267 | ␊ |
268 | int extractClassNameFromType(const QCString &type,int &pos,␊ |
269 | QCString &name,QCString &templSpec);␊ |
270 | ␊ |
271 | QCString substituteTemplateArgumentsInString(␊ |
272 | const QCString &name,␊ |
273 | ArgumentList *formalArgs,␊ |
274 | ArgumentList *actualArgs);␊ |
275 | ␊ |
276 | ArgumentList *copyArgumentList(const ArgumentList *src);␊ |
277 | ␊ |
278 | QList<ArgumentList> *copyArgumentLists(const QList<ArgumentList> *srcLists);␊ |
279 | ␊ |
280 | QCString stripTemplateSpecifiersFromScope(const QCString &fullName,␊ |
281 | bool parentOnly=TRUE,␊ |
282 | QCString *lastScopeStripped=0);␊ |
283 | ␊ |
284 | QCString resolveTypeDef(Definition *d,const QCString &name,␊ |
285 | Definition **typedefContext=0);␊ |
286 | ␊ |
287 | QCString mergeScopes(const QCString &leftScope,const QCString &rightScope);␊ |
288 | ␊ |
289 | int getScopeFragment(const QCString &s,int p,int *l);␊ |
290 | ␊ |
291 | int filterCRLF(char *buf,int len);␊ |
292 | ␊ |
293 | void addRefItem(const QList<ListItemInfo> *sli,const char *prefix,␊ |
294 | const char *key,␊ |
295 | const char *name,const char *title,const char *args);␊ |
296 | ␊ |
297 | PageDef *addRelatedPage(const char *name,const QCString &ptitle,␊ |
298 | const QCString &doc,QList<SectionInfo> *anchors,␊ |
299 | const char *fileName,int startLine,␊ |
300 | const QList<ListItemInfo> *sli,␊ |
301 | GroupDef *gd=0,␊ |
302 | TagInfo *tagInfo=0␊ |
303 | );␊ |
304 | ␊ |
305 | QCString escapeCharsInString(const char *name,bool allowDots,bool allowUnderscore=FALSE);␊ |
306 | ␊ |
307 | void addGroupListToTitle(OutputList &ol,Definition *d);␊ |
308 | ␊ |
309 | void filterLatexString(FTextStream &t,const char *str,␊ |
310 | bool insideTabbing=FALSE,bool insidePre=FALSE,␊ |
311 | bool insideItem=FALSE);␊ |
312 | ␊ |
313 | QCString rtfFormatBmkStr(const char *name);␊ |
314 | ␊ |
315 | QCString linkToText(const char *link,bool isFileName);␊ |
316 | ␊ |
317 | QCString stripExtension(const char *fName);␊ |
318 | ␊ |
319 | void replaceNamespaceAliases(QCString &scope,int i);␊ |
320 | ␊ |
321 | int isAccessibleFrom(Definition *scope,FileDef *fileScope,Definition *item);␊ |
322 | ␊ |
323 | int isAccessibleFromWithExpScope(Definition *scope,FileDef *fileScope,Definition *item,␊ |
324 | const QCString &explicitScopePart);␊ |
325 | ␊ |
326 | int computeQualifiedIndex(const QCString &name);␊ |
327 | ␊ |
328 | void addDirPrefix(QCString &fileName);␊ |
329 | ␊ |
330 | QCString relativePathToRoot(const char *name);␊ |
331 | ␊ |
332 | void createSubDirs(QDir &d);␊ |
333 | ␊ |
334 | QCString stripPath(const char *s);␊ |
335 | ␊ |
336 | bool containsWord(const QCString &s,const QCString &word);␊ |
337 | ␊ |
338 | bool findAndRemoveWord(QCString &s,const QCString &word);␊ |
339 | ␊ |
340 | QCString stripLeadingAndTrailingEmptyLines(const QCString &s);␊ |
341 | ␊ |
342 | //void stringToSearchIndex(const QCString &docUrlBase,const QCString &title,␊ |
343 | // const QCString &str, bool priority=FALSE,␊ |
344 | // const QCString &anchor="");␊ |
345 | ␊ |
346 | bool updateLanguageMapping(const QCString &extension,const QCString &parser);␊ |
347 | SrcLangExt getLanguageFromFileName(const QCString fileName);␊ |
348 | void initDefaultExtensionMapping();␊ |
349 | ␊ |
350 | bool checkIfTypedef(Definition *scope,FileDef *fileScope,const char *n);␊ |
351 | ␊ |
352 | ClassDef *newResolveTypedef(FileDef *fileScope,MemberDef *md,␊ |
353 | MemberDef **pMemType=0,QCString *pTemplSpec=0,␊ |
354 | QCString *pResolvedType=0,␊ |
355 | ArgumentList *actTemplParams=0);␊ |
356 | ␊ |
357 | QCString parseCommentAsText(const Definition *scope,const MemberDef *member,const QCString &doc,const QCString &fileName,int lineNr);␊ |
358 | ␊ |
359 | QCString transcodeCharacterStringToUTF8(const QCString &input);␊ |
360 | ␊ |
361 | QCString recodeString(const QCString &str,const char *fromEncoding,const char *toEncoding);␊ |
362 | ␊ |
363 | QCString extractAliasArgs(const QCString &args,int pos);␊ |
364 | ␊ |
365 | int countAliasArguments(const QCString argList);␊ |
366 | ␊ |
367 | QCString replaceAliasArguments(const QCString &aliasValue,const QCString &argList);␊ |
368 | ␊ |
369 | QCString resolveAliasCmd(const QCString aliasCmd);␊ |
370 | QCString expandAlias(const QCString &aliasName,const QCString &aliasValue);␊ |
371 | ␊ |
372 | void writeTypeConstraints(OutputList &ol,Definition *d,ArgumentList *al);␊ |
373 | ␊ |
374 | QCString convertCharEntitiesToUTF8(const QCString &s);␊ |
375 | ␊ |
376 | bool usingTreeIndex();␊ |
377 | void stackTrace();␊ |
378 | ␊ |
379 | bool readInputFile(const char *fileName,BufStr &inBuf);␊ |
380 | QCString filterTitle(const QCString &title);␊ |
381 | ␊ |
382 | bool patternMatch(const QFileInfo &fi,const QStrList *patList);␊ |
383 | ␊ |
384 | void writeSummaryLink(OutputList &ol,const char *label,const char *title,␊ |
385 | bool &first);␊ |
386 | ␊ |
387 | QCString externalLinkTarget();␊ |
388 | QCString externalRef(const QCString &relPath,const QCString &ref,bool href);␊ |
389 | int nextUtf8CharPosition(const QCString &utf8Str,int len,int startPos);␊ |
390 | ␊ |
391 | struct ColoredImgDataItem␊ |
392 | {␊ |
393 | const char *name;␊ |
394 | unsigned short width;␊ |
395 | unsigned short height;␊ |
396 | unsigned char *content;␊ |
397 | unsigned char *alpha;␊ |
398 | };␊ |
399 | ␊ |
400 | void writeColoredImgData(const char *dir,ColoredImgDataItem data[]);␊ |
401 | QCString replaceColorMarkers(const char *str);␊ |
402 | ␊ |
403 | #endif␊ |
404 | ␊ |
405 |