Chameleon

Chameleon Svn Source Tree

Root/branches/xZenu/src/util/doxygen/src/docparser.h

Source at commit 1322 created 9 years 5 months ago.
By meklort, Add doxygen to utils folder
1/******************************************************************************
2 *
3 * $Id: $
4 *
5 *
6 * Copyright (C) 1997-2011 by Dimitri van Heesch.
7 *
8 * Permission to use, copy, modify, and distribute this software and its
9 * documentation under the terms of the GNU General Public License is hereby
10 * granted. No representations are made about the suitability of this software
11 * for any purpose. It is provided "as is" without express or implied warranty.
12 * See the GNU General Public License for more details.
13 *
14 * Documents produced by Doxygen are derivative works derived from the
15 * input used in their production; they are not affected by this license.
16 *
17 */
18
19#ifndef _DOCPARSER_H
20#define _DOCPARSER_H
21
22#include <stdio.h>
23
24#include <qlist.h>
25#include <qcstring.h>
26
27#include "docvisitor.h"
28#include "htmlattrib.h"
29
30class DocNode;
31class MemberDef;
32class Definition;
33class MemberGroup;
34class SectionDict;
35
36//---------------------------------------------------------------------------
37
38/*! Initialize the documentation parser */
39void initDocParser();
40/*! Cleanup the documentation parser */
41void finializeDocParser();
42
43/*! Main entry point for the documentation parser.
44 * @param fileName File in which the documentation block is found (or the
45 * name of the example file in case isExample is TRUE).
46 * @param startLine Line at which the documentation block is found.
47 * @param context Class or namespace to which this block belongs.
48 * @param md Member definition to which the documentation belongs.
49 * Can be 0.
50 * @param input String representation of the documentation block.
51 * @param indexWords Indicates whether or not words should be put in the
52 * search index.
53 * @param isExample TRUE if the documentation belongs to an example.
54 * @param exampleName Base name of the example file (0 if isExample is FALSE).
55 * @param singleLine Output should be presented on a single line, so without
56 * starting a new paragraph at the end.
57 * @param linkFromIndex TRUE if the documentation is generated from an
58 * index page. In this case context is not used to determine
59 * the relative path when making a link.
60 * @returns Root node of the abstract syntax tree. Ownership of the
61 * pointer is handed over to the caller.
62 */
63DocNode *validatingParseDoc(const char *fileName,int startLine,
64 Definition *context, MemberDef *md,
65 const char *input,bool indexWords,
66 bool isExample,const char *exampleName=0,
67 bool singleLine=FALSE,bool linkFromIndex=FALSE);
68
69/*! Main entry point for parsing simple text fragments. These
70 * fragments are limited to words, whitespace and symbols.
71 */
72DocNode *validatingParseText(const char *input);
73
74/*! Searches for section and anchor commands in the input */
75void docFindSections(const char *input,
76 Definition *d,
77 MemberGroup *m,
78 const char *fileName);
79
80//---------------------------------------------------------------------------
81
82/*! @brief Abstract node interface with type information. */
83class DocNode
84{
85 public:
86 /*! Available node types. */
87 enum Kind { Kind_Root = 0,
88 Kind_Word = 1,
89 Kind_WhiteSpace = 2,
90 Kind_Para = 3,
91 Kind_AutoList = 4,
92 Kind_AutoListItem = 5,
93 Kind_Symbol = 6,
94 Kind_URL = 7,
95 Kind_StyleChange = 8,
96 Kind_SimpleSect = 9,
97 Kind_Title = 10,
98 Kind_SimpleList = 11,
99 Kind_SimpleListItem = 12,
100 Kind_Section = 13,
101 Kind_Verbatim = 14,
102 Kind_XRefItem = 15,
103 Kind_HtmlList = 16,
104 Kind_HtmlListItem = 17,
105 Kind_HtmlDescList = 18,
106 Kind_HtmlDescData = 19,
107 Kind_HtmlDescTitle = 20,
108 Kind_HtmlTable = 21,
109 Kind_HtmlRow = 22,
110 Kind_HtmlCell = 23,
111 Kind_HtmlCaption = 24,
112 Kind_LineBreak = 25,
113 Kind_HorRuler = 26,
114 Kind_Anchor = 27,
115 Kind_IndexEntry = 28,
116 Kind_Internal = 29,
117 Kind_HRef = 30,
118 Kind_Include = 31,
119 Kind_IncOperator = 32,
120 Kind_HtmlHeader = 33,
121 Kind_Image = 34,
122 Kind_DotFile = 35,
123 Kind_Link = 36,
124 Kind_Ref = 37,
125 Kind_Formula = 38,
126 Kind_SecRefItem = 39,
127 Kind_SecRefList = 40,
128 Kind_SimpleSectSep = 41,
129 Kind_LinkedWord = 42,
130 Kind_ParamSect = 43,
131 Kind_ParamList = 44,
132 Kind_InternalRef = 45,
133 Kind_Copy = 46,
134 Kind_Text = 47,
135 Kind_MscFile = 48
136 };
137 /*! Creates a new node */
138 DocNode() : m_parent(0), m_insidePre(FALSE) {}
139
140 /*! Destroys a node. */
141 virtual ~DocNode() {}
142
143 /*! Returns the kind of node. Provides runtime type information */
144 virtual Kind kind() const = 0;
145
146 /*! Returns the parent of this node or 0 for the root node. */
147 DocNode *parent() const { return m_parent; }
148
149 /*! Sets a new parent for this node. */
150 void setParent(DocNode *parent) { m_parent = parent; }
151
152 /*! Acceptor function for node visitors. Part of the visitor pattern.
153 * @param v Abstract visitor.
154 */
155 virtual void accept(DocVisitor *v) = 0;
156
157 /*! Returns TRUE iff this node is inside a preformatted section */
158 bool isPreformatted() const { return m_insidePre; }
159
160 protected:
161 /*! Sets whether or not this item is inside a preformatted section */
162 void setInsidePreformatted(bool p) { m_insidePre = p; }
163 DocNode *m_parent;
164 private:
165
166 bool m_insidePre;
167};
168
169/*! @brief Default accept implementation for compound nodes in the abstract
170 * syntax tree.
171 */
172template<class T> class CompAccept
173{
174 public:
175 CompAccept() { m_children.setAutoDelete(TRUE); }
176 virtual ~CompAccept() {}
177 void accept(T *obj, DocVisitor *v)
178 {
179 v->visitPre(obj);
180 QListIterator<DocNode> cli(m_children);
181 DocNode *n;
182 for (cli.toFirst();(n=cli.current());++cli) n->accept(v);
183 v->visitPost(obj);
184 }
185
186 protected:
187 QList<DocNode> m_children;
188};
189
190
191/*! @brief Node representing a word
192 */
193class DocWord : public DocNode
194{
195 public:
196 DocWord(DocNode *parent,const QCString &word);
197 QCString word() const { return m_word; }
198 Kind kind() const { return Kind_Word; }
199 void accept(DocVisitor *v) { v->visit(this); }
200
201 private:
202 QCString m_word;
203};
204
205/*! @brief Node representing a word that can be linked to something
206 */
207class DocLinkedWord : public DocNode
208{
209 public:
210 DocLinkedWord(DocNode *parent,const QCString &word,
211 const QCString &ref,const QCString &file,
212 const QCString &anchor,const QCString &tooltip);
213 QCString word() const { return m_word; }
214 Kind kind() const { return Kind_LinkedWord; }
215 QCString file() const { return m_file; }
216 QCString relPath() const { return m_relPath; }
217 QCString ref() const { return m_ref; }
218 QCString anchor() const { return m_anchor; }
219 QCString tooltip() const { return m_tooltip; }
220 void accept(DocVisitor *v) { v->visit(this); }
221
222 private:
223 QCString m_word;
224 QCString m_ref;
225 QCString m_file;
226 QCString m_relPath;
227 QCString m_anchor;
228 QCString m_tooltip;
229};
230
231/*! @brief Node representing an URL (or email address) */
232class DocURL : public DocNode
233{
234 public:
235 DocURL(DocNode *parent,const QCString &url,bool isEmail) :
236 m_url(url), m_isEmail(isEmail) { m_parent=parent; }
237 QCString url() const { return m_url; }
238 Kind kind() const { return Kind_URL; }
239 void accept(DocVisitor *v) { v->visit(this); }
240 bool isEmail() const { return m_isEmail; }
241
242 private:
243 QCString m_url;
244 bool m_isEmail;
245};
246
247/*! @brief Node representing a line break */
248class DocLineBreak : public DocNode
249{
250 public:
251 DocLineBreak(DocNode *parent) { m_parent=parent; }
252 Kind kind() const { return Kind_LineBreak; }
253 void accept(DocVisitor *v) { v->visit(this); }
254
255 private:
256};
257
258/*! @brief Node representing a horizonal ruler */
259class DocHorRuler : public DocNode
260{
261 public:
262 DocHorRuler(DocNode *parent) { m_parent = parent; }
263 Kind kind() const { return Kind_HorRuler; }
264 void accept(DocVisitor *v) { v->visit(this); }
265
266 private:
267};
268
269/*! @brief Node representing an anchor */
270class DocAnchor : public DocNode
271{
272 public:
273 DocAnchor(DocNode *parent,const QCString &id,bool newAnchor);
274 Kind kind() const { return Kind_Anchor; }
275 QCString anchor() const { return m_anchor; }
276 QCString file() const { return m_file; }
277 void accept(DocVisitor *v) { v->visit(this); }
278
279 private:
280 QCString m_anchor;
281 QCString m_file;
282};
283
284/*! @brief Node representing a style change */
285class DocStyleChange : public DocNode
286{
287 public:
288 enum Style { Bold, Italic, Code, Center, Small,
289 Subscript, Superscript, Preformatted,
290 Span, Div
291 };
292 DocStyleChange(DocNode *parent,uint position,Style s,bool enable,
293 const HtmlAttribList *attribs=0) :
294 m_position(position), m_style(s), m_enable(enable)
295 { m_parent = parent; if (attribs) m_attribs=*attribs; }
296 Kind kind() const { return Kind_StyleChange; }
297 Style style() const { return m_style; }
298 const char *styleString() const;
299 bool enable() const { return m_enable; }
300 uint position() const { return m_position; }
301 void accept(DocVisitor *v) { v->visit(this); }
302 const HtmlAttribList &attribs() const { return m_attribs; }
303
304 private:
305 uint m_position;
306 Style m_style;
307 bool m_enable;
308 HtmlAttribList m_attribs;
309};
310
311/*! @brief Node representing a special symbol */
312class DocSymbol : public DocNode
313{
314 public:
315 enum SymType { Unknown=0, BSlash, At, Less, Greater, Amp, Dollar, Hash,
316 DoubleColon, Percent, Copy, Tm, Reg, Apos, Quot, Uml, Acute,
317 Grave, Circ, Tilde, Szlig, Cedil, Ring, Nbsp, Slash,
318 Lsquo, Rsquo, Ldquo, Rdquo, Ndash, Mdash, Aelig, AElig
319 };
320 DocSymbol(DocNode *parent,SymType s,char letter='\0') :
321 m_symbol(s), m_letter(letter) { m_parent = parent; }
322 SymType symbol() const { return m_symbol; }
323 char letter() const { return m_letter; }
324 Kind kind() const { return Kind_Symbol; }
325 void accept(DocVisitor *v) { v->visit(this); }
326 static SymType decodeSymbol(const QCString &symName,char *letter);
327
328 private:
329 SymType m_symbol;
330 char m_letter;
331};
332
333/*! @brief Node representing some amount of white space */
334class DocWhiteSpace : public DocNode
335{
336 public:
337 DocWhiteSpace(DocNode *parent,const QCString &chars) :
338 m_chars(chars) { m_parent = parent; }
339 Kind kind() const { return Kind_WhiteSpace; }
340 QCString chars() const { return m_chars; }
341 void accept(DocVisitor *v) { v->visit(this); }
342 private:
343 QCString m_chars;
344};
345
346/*! @brief Node representing a verbatim, unparsed text fragment */
347class DocVerbatim : public DocNode
348{
349 public:
350 enum Type { Code, HtmlOnly, ManOnly, LatexOnly, XmlOnly, Verbatim, Dot, Msc };
351 DocVerbatim(DocNode *parent,const QCString &context,
352 const QCString &text, Type t,bool isExample,
353 const QCString &exampleFile);
354 Kind kind() const { return Kind_Verbatim; }
355 Type type() const { return m_type; }
356 QCString text() const { return m_text; }
357 QCString context() const { return m_context; }
358 void accept(DocVisitor *v) { v->visit(this); }
359 bool isExample() const { return m_isExample; }
360 QCString exampleFile() const { return m_exampleFile; }
361 QCString relPath() const { return m_relPath; }
362
363 private:
364 QCString m_context;
365 QCString m_text;
366 Type m_type;
367 bool m_isExample;
368 QCString m_exampleFile;
369 QCString m_relPath;
370};
371
372
373/*! @brief Node representing an included text block from file */
374class DocInclude : public DocNode
375{
376 public:
377 enum Type { Include, DontInclude, VerbInclude, HtmlInclude, IncWithLines };
378 DocInclude(DocNode *parent,const QCString &file,
379 const QCString context, Type t,
380 bool isExample,const QCString exampleFile) :
381 m_file(file), m_context(context), m_type(t),
382 m_isExample(isExample), m_exampleFile(exampleFile) { m_parent = parent; }
383 Kind kind() const { return Kind_Include; }
384 QCString file() const { return m_file; }
385 QCString extension() const { int i=m_file.findRev('.');
386 if (i!=-1)
387 return m_file.right(m_file.length()-i);
388 else
389 return "";
390 }
391 Type type() const { return m_type; }
392 QCString text() const { return m_text; }
393 QCString context() const { return m_context; }
394 bool isExample() const { return m_isExample; }
395 QCString exampleFile() const { return m_exampleFile; }
396 void accept(DocVisitor *v) { v->visit(this); }
397 void parse();
398
399 private:
400 QCString m_file;
401 QCString m_context;
402 QCString m_text;
403 Type m_type;
404 bool m_isExample;
405 QCString m_exampleFile;
406};
407
408/*! @brief Node representing a include/dontinclude operator block */
409class DocIncOperator : public DocNode
410{
411 public:
412 enum Type { Line, SkipLine, Skip, Until };
413 DocIncOperator(DocNode *parent,Type t,const QCString &pat,
414 const QCString &context,bool isExample,const QCString &exampleFile) :
415 m_type(t), m_pattern(pat), m_context(context),
416 m_isFirst(FALSE), m_isLast(FALSE),
417 m_isExample(isExample), m_exampleFile(exampleFile) { m_parent = parent; }
418 Kind kind() const { return Kind_IncOperator; }
419 Type type() const { return m_type; }
420 QCString text() const { return m_text; }
421 QCString pattern() const { return m_pattern; }
422 QCString context() const { return m_context; }
423 void accept(DocVisitor *v) { v->visit(this); }
424 bool isFirst() const { return m_isFirst; }
425 bool isLast() const { return m_isLast; }
426 void markFirst(bool v=TRUE) { m_isFirst = v; }
427 void markLast(bool v=TRUE) { m_isLast = v; }
428 bool isExample() const { return m_isExample; }
429 QCString exampleFile() const { return m_exampleFile; }
430 void parse();
431
432 private:
433 Type m_type;
434 QCString m_text;
435 QCString m_pattern;
436 QCString m_context;
437 bool m_isFirst;
438 bool m_isLast;
439 bool m_isExample;
440 QCString m_exampleFile;
441};
442
443/*! @brief Node representing an item of a cross-referenced list */
444class DocFormula : public DocNode
445{
446 public:
447 DocFormula(DocNode *parent,int id);
448 Kind kind() const { return Kind_Formula; }
449 QCString name() const { return m_name; }
450 QCString text() const { return m_text; }
451 QCString relPath() const { return m_relPath; }
452 int id() const { return m_id; }
453 void accept(DocVisitor *v) { v->visit(this); }
454 bool isInline() { return m_text.length()>0 ? m_text.at(0)!='\\' : TRUE; }
455
456 private:
457 QCString m_name;
458 QCString m_text;
459 QCString m_relPath;
460 int m_id;
461};
462
463/*! @brief Node representing an entry in the index. */
464class DocIndexEntry : public DocNode
465{
466 public:
467 DocIndexEntry(DocNode *parent,Definition *scope,MemberDef *md)
468 : m_scope(scope), m_member(md) { m_parent = parent; }
469 Kind kind() const { return Kind_IndexEntry; }
470 int parse();
471 Definition *scope() const { return m_scope; }
472 MemberDef *member() const { return m_member; }
473 QCString entry() const { return m_entry; }
474 void accept(DocVisitor *v) { v->visit(this); }
475
476 private:
477 QCString m_entry;
478 Definition *m_scope;
479 MemberDef *m_member;
480};
481
482//-----------------------------------------------------------------------
483
484/*! @brief Node representing a copy of documentation block. */
485class DocCopy : public CompAccept<DocCopy>, public DocNode
486{
487 public:
488 DocCopy(DocNode *parent,const QCString &link,bool copyBrief,bool copyDetails)
489 : m_link(link),
490 m_copyBrief(copyBrief), m_copyDetails(copyDetails) { m_parent = parent; }
491 Kind kind() const { return Kind_Copy; }
492 QCString link() const { return m_link; }
493 void accept(DocVisitor *v) { CompAccept<DocCopy>::accept(this,v); }
494 void parse();
495
496 private:
497 QCString m_link;
498 bool m_copyBrief;
499 bool m_copyDetails;
500};
501
502/*! @brief Node representing an auto List */
503class DocAutoList : public CompAccept<DocAutoList>, public DocNode
504{
505 public:
506 DocAutoList(DocNode *parent,int indent,bool isEnumList,
507 int depth) :
508 m_indent(indent), m_isEnumList(isEnumList),
509 m_depth(depth) { m_parent = parent; }
510 Kind kind() const { return Kind_AutoList; }
511 bool isEnumList() const { return m_isEnumList; }
512 int indent() const { return m_indent; }
513 int depth() const { return m_depth; }
514 void accept(DocVisitor *v) { CompAccept<DocAutoList>::accept(this,v); }
515 int parse();
516
517 private:
518 int m_indent;
519 bool m_isEnumList;
520 int m_depth;
521};
522
523
524/*! @brief Node representing a simple section title */
525class DocTitle : public CompAccept<DocTitle>, public DocNode
526{
527 public:
528 DocTitle(DocNode *parent) { m_parent = parent; }
529 void parse();
530 void parseFromString(const QCString &title);
531 Kind kind() const { return Kind_Title; }
532 void accept(DocVisitor *v) { CompAccept<DocTitle>::accept(this,v); }
533
534 private:
535};
536
537/*! @brief Node representing an item of a cross-referenced list */
538class DocXRefItem : public CompAccept<DocXRefItem>, public DocNode
539{
540 public:
541 //enum Type { Bug, Test, Todo, Deprecated };
542 DocXRefItem(DocNode *parent,int id,const char *key);
543 Kind kind() const { return Kind_XRefItem; }
544 QCString file() const { return m_file; }
545 QCString anchor() const { return m_anchor; }
546 QCString title() const { return m_title; }
547 QCString relPath() const { return m_relPath; }
548 QCString key() const { return m_key; }
549 void accept(DocVisitor *v) { CompAccept<DocXRefItem>::accept(this,v); }
550 bool parse();
551 const QList<DocNode> &children() const { return m_children; }
552
553 private:
554 int m_id;
555 QCString m_key;
556 QCString m_file;
557 QCString m_anchor;
558 QCString m_title;
559 QCString m_relPath;
560};
561
562/*! @brief Node representing an image */
563class DocImage : public CompAccept<DocImage>, public DocNode
564{
565 public:
566 enum Type { Html, Latex, Rtf };
567 DocImage(DocNode *parent,const HtmlAttribList &attribs,const QCString &name,Type t);
568 Kind kind() const { return Kind_Image; }
569 Type type() const { return m_type; }
570 QCString name() const { return m_name; }
571 bool hasCaption() const { return !m_children.isEmpty(); }
572 QCString width() const { return m_width; }
573 QCString height() const { return m_height; }
574 QCString relPath() const { return m_relPath; }
575 const HtmlAttribList &attribs() const { return m_attribs; }
576 void accept(DocVisitor *v) { CompAccept<DocImage>::accept(this,v); }
577 void parse();
578
579 private:
580 HtmlAttribList m_attribs;
581 QCString m_name;
582 Type m_type;
583 QCString m_width;
584 QCString m_height;
585 QCString m_relPath;
586};
587
588/*! @brief Node representing a dot file */
589class DocDotFile : public CompAccept<DocDotFile>, public DocNode
590{
591 public:
592 DocDotFile(DocNode *parent,const QCString &name,const QCString &context);
593 void parse();
594 Kind kind() const { return Kind_DotFile; }
595 QCString name() const { return m_name; }
596 QCString file() const { return m_file; }
597 QCString relPath() const { return m_relPath; }
598 bool hasCaption() const { return !m_children.isEmpty(); }
599 QCString width() const { return m_width; }
600 QCString height() const { return m_height; }
601 QCString context() const { return m_context; }
602 void accept(DocVisitor *v) { CompAccept<DocDotFile>::accept(this,v); }
603 private:
604 QCString m_name;
605 QCString m_file;
606 QCString m_relPath;
607 QCString m_width;
608 QCString m_height;
609 QCString m_context;
610};
611
612/*! @brief Node representing a msc file */
613class DocMscFile : public CompAccept<DocMscFile>, public DocNode
614{
615 public:
616 DocMscFile(DocNode *parent,const QCString &name,const QCString &context);
617 void parse();
618 Kind kind() const { return Kind_MscFile; }
619 QCString name() const { return m_name; }
620 QCString file() const { return m_file; }
621 QCString relPath() const { return m_relPath; }
622 bool hasCaption() const { return !m_children.isEmpty(); }
623 QCString width() const { return m_width; }
624 QCString height() const { return m_height; }
625 QCString context() const { return m_context; }
626 void accept(DocVisitor *v) { CompAccept<DocMscFile>::accept(this,v); }
627 private:
628 QCString m_name;
629 QCString m_file;
630 QCString m_relPath;
631 QCString m_width;
632 QCString m_height;
633 QCString m_context;
634};
635
636
637/*! @brief Node representing a link to some item */
638class DocLink : public CompAccept<DocLink>, public DocNode
639{
640 public:
641 DocLink(DocNode *parent,const QCString &target);
642 QCString parse(bool,bool isXmlLink=FALSE);
643 Kind kind() const { return Kind_Link; }
644 QCString file() const { return m_file; }
645 QCString relPath() const { return m_relPath; }
646 QCString ref() const { return m_ref; }
647 QCString anchor() const { return m_anchor; }
648 void accept(DocVisitor *v) { CompAccept<DocLink>::accept(this,v); }
649
650 private:
651 QCString m_file;
652 QCString m_relPath;
653 QCString m_ref;
654 QCString m_anchor;
655 QCString m_refText;
656};
657
658/*! @brief Node representing a reference to some item */
659class DocRef : public CompAccept<DocRef>, public DocNode
660{
661 public:
662 DocRef(DocNode *parent,const QCString &target,const QCString &context);
663 void parse();
664 Kind kind() const { return Kind_Ref; }
665 QCString file() const { return m_file; }
666 QCString relPath() const { return m_relPath; }
667 QCString ref() const { return m_ref; }
668 QCString anchor() const { return m_anchor; }
669 QCString targetTitle() const { return m_text; }
670 bool hasLinkText() const { return !m_children.isEmpty(); }
671 bool refToAnchor() const { return m_refToAnchor; }
672 bool refToSection() const { return m_refToSection; }
673 void accept(DocVisitor *v) { CompAccept<DocRef>::accept(this,v); }
674
675 private:
676 bool m_refToSection;
677 bool m_refToAnchor;
678 QCString m_file;
679 QCString m_relPath;
680 QCString m_ref;
681 QCString m_anchor;
682 QCString m_text;
683};
684
685/*! @brief Node representing an internal reference to some item */
686class DocInternalRef : public CompAccept<DocInternalRef>, public DocNode
687{
688 public:
689 DocInternalRef(DocNode *parent,const QCString &target);
690 void parse();
691 Kind kind() const { return Kind_Ref; }
692 QCString file() const { return m_file; }
693 QCString relPath() const { return m_relPath; }
694 QCString anchor() const { return m_anchor; }
695 void accept(DocVisitor *v) { CompAccept<DocInternalRef>::accept(this,v); }
696
697 private:
698 QCString m_file;
699 QCString m_relPath;
700 QCString m_anchor;
701};
702
703/*! @brief Node representing a Language specific section */
704//class DocLanguage : public CompAccept<DocLanguage>, public DocNode
705//{
706// public:
707// DocLanguage(DocNode *parent,const QCString &id) :
708// m_parent(parent), m_id(id) {}
709// QCString id() const { return m_id; }
710// Kind kind() const { return Kind_Language; }
711// DocNode *parent() const { return m_parent; }
712// void accept(DocVisitor *v) { CompAccept<DocLanguage>::accept(this,v); }
713// int parse();
714//
715// private:
716// DocNode * m_parent;
717// QCString m_id;
718//};
719
720/*! @brief Node representing a Hypertext reference */
721class DocHRef : public CompAccept<DocHRef>, public DocNode
722{
723 public:
724 DocHRef(DocNode *parent,const HtmlAttribList &attribs,const QCString &url) :
725 m_attribs(attribs), m_url(url) { m_parent = parent; }
726 int parse();
727 QCString url() const { return m_url; }
728 Kind kind() const { return Kind_HRef; }
729 void accept(DocVisitor *v) { CompAccept<DocHRef>::accept(this,v); }
730 const HtmlAttribList &attribs() const { return m_attribs; }
731
732 private:
733 HtmlAttribList m_attribs;
734 QCString m_url;
735};
736
737/*! @brief Node Html heading */
738class DocHtmlHeader : public CompAccept<DocHtmlHeader>, public DocNode
739{
740 public:
741 DocHtmlHeader(DocNode *parent,const HtmlAttribList &attribs,int level) :
742 m_level(level), m_attribs(attribs) { m_parent = parent; }
743 int level() const { return m_level; }
744 Kind kind() const { return Kind_HtmlHeader; }
745 const HtmlAttribList &attribs() const { return m_attribs; }
746 void accept(DocVisitor *v) { CompAccept<DocHtmlHeader>::accept(this,v); }
747 int parse();
748
749 private:
750 int m_level;
751 HtmlAttribList m_attribs;
752};
753
754/*! @brief Node representing a Html description item */
755class DocHtmlDescTitle : public CompAccept<DocHtmlDescTitle>, public DocNode
756{
757 public:
758 DocHtmlDescTitle(DocNode *parent,const HtmlAttribList &attribs) :
759 m_attribs(attribs) { m_parent = parent; }
760 Kind kind() const { return Kind_HtmlDescTitle; }
761 const HtmlAttribList &attribs() const { return m_attribs; }
762 void accept(DocVisitor *v) { CompAccept<DocHtmlDescTitle>::accept(this,v); }
763 int parse();
764
765 private:
766 HtmlAttribList m_attribs;
767};
768
769/*! @brief Node representing a Html description list */
770class DocHtmlDescList : public CompAccept<DocHtmlDescList>, public DocNode
771{
772 public:
773 DocHtmlDescList(DocNode *parent,const HtmlAttribList &attribs) :
774 m_attribs(attribs) { m_parent = parent; }
775 Kind kind() const { return Kind_HtmlDescList; }
776 const HtmlAttribList &attribs() const { return m_attribs; }
777 void accept(DocVisitor *v) { CompAccept<DocHtmlDescList>::accept(this,v); }
778 int parse();
779
780 private:
781 HtmlAttribList m_attribs;
782};
783
784/*! @brief Node representing a normal section */
785class DocSection : public CompAccept<DocSection>, public DocNode
786{
787 public:
788 DocSection(DocNode *parent,int level,const QCString &id) :
789 m_level(level), m_id(id) { m_parent = parent; }
790 Kind kind() const { return Kind_Section; }
791 int level() const { return m_level; }
792 QCString title() const { return m_title; }
793 QCString anchor() const { return m_anchor; }
794 QCString id() const { return m_id; }
795 QCString file() const { return m_file; }
796 void accept(DocVisitor *v) { CompAccept<DocSection>::accept(this,v); }
797 int parse();
798
799 private:
800 int m_level;
801 QCString m_id;
802 QCString m_title;
803 QCString m_anchor;
804 QCString m_file;
805};
806
807/*! @brief Node representing a reference to a section */
808class DocSecRefItem : public CompAccept<DocSecRefItem>, public DocNode
809{
810 public:
811 DocSecRefItem(DocNode *parent,const QCString &target) :
812 m_target(target) { m_parent = parent; }
813 Kind kind() const { return Kind_SecRefItem; }
814 QCString target() const { return m_target; }
815 QCString file() const { return m_file; }
816 QCString anchor() const { return m_anchor; }
817 void accept(DocVisitor *v) { CompAccept<DocSecRefItem>::accept(this,v); }
818 void parse();
819 const QList<DocNode> &children() const { return m_children; }
820
821 private:
822 QCString m_target;
823 QCString m_file;
824 QCString m_anchor;
825};
826
827/*! @brief Node representing a list of section references */
828class DocSecRefList : public CompAccept<DocSecRefList>, public DocNode
829{
830 public:
831 DocSecRefList(DocNode *parent) { m_parent = parent; }
832 void parse();
833 Kind kind() const { return Kind_SecRefList; }
834 void accept(DocVisitor *v) { CompAccept<DocSecRefList>::accept(this,v); }
835
836 private:
837};
838
839/*! @brief Node representing an internal section of documentation */
840class DocInternal : public CompAccept<DocInternal>, public DocNode
841{
842 public:
843 DocInternal(DocNode *parent) { m_parent = parent; }
844 int parse(int);
845 Kind kind() const { return Kind_Internal; }
846 void accept(DocVisitor *v) { CompAccept<DocInternal>::accept(this,v); }
847
848 private:
849};
850
851/*! @brief Node representing a simple list */
852class DocSimpleList : public CompAccept<DocSimpleList>, public DocNode
853{
854 public:
855 DocSimpleList(DocNode *parent) { m_parent = parent; }
856 Kind kind() const { return Kind_SimpleList; }
857 void accept(DocVisitor *v) { CompAccept<DocSimpleList>::accept(this,v); }
858 int parse();
859
860 private:
861};
862
863/*! @brief Node representing a Html list */
864class DocHtmlList : public CompAccept<DocHtmlList>, public DocNode
865{
866 public:
867 enum Type { Unordered, Ordered };
868 DocHtmlList(DocNode *parent,const HtmlAttribList &attribs,Type t) :
869 m_type(t), m_attribs(attribs) { m_parent = parent; }
870 Kind kind() const { return Kind_HtmlList; }
871 Type type() const { return m_type; }
872 void accept(DocVisitor *v) { CompAccept<DocHtmlList>::accept(this,v); }
873 const HtmlAttribList &attribs() const { return m_attribs; }
874 int parse();
875 int parseXml();
876
877 private:
878 Type m_type;
879 HtmlAttribList m_attribs;
880};
881
882/*! Node representing a simple section */
883class DocSimpleSect : public CompAccept<DocSimpleSect>, public DocNode
884{
885 public:
886 enum Type
887 {
888 Unknown, See, Return, Author, Authors, Version, Since, Date,
889 Note, Warning, Pre, Post, Invar, Remark, Attention, User, Rcs
890 };
891 DocSimpleSect(DocNode *parent,Type t);
892 virtual ~DocSimpleSect();
893 Kind kind() const { return Kind_SimpleSect; }
894 Type type() const { return m_type; }
895 QCString typeString() const;
896 void accept(DocVisitor *v);
897 int parse(bool userTitle,bool needsSeparator);
898 int parseRcs();
899 int parseXml();
900 void appendLinkWord(const QCString &word);
901 const QList<DocNode> &children() const { return m_children; }
902
903 private:
904 Type m_type;
905 DocTitle * m_title;
906};
907
908/*! Node representing a separator between two simple sections of the
909 * same type.
910 */
911class DocSimpleSectSep : public DocNode
912{
913 public:
914 DocSimpleSectSep(DocNode *parent) { m_parent = parent; }
915 Kind kind() const { return Kind_SimpleSectSep; }
916 void accept(DocVisitor *v) { v->visit(this); }
917
918 private:
919};
920
921/*! Node representing a parameter section */
922class DocParamSect : public CompAccept<DocParamSect>, public DocNode
923{
924 friend class DocParamList;
925 public:
926 enum Type
927 {
928 Unknown, Param, RetVal, Exception, TemplateParam
929 };
930 enum Direction
931 {
932 In=1, Out=2, InOut=3, Unspecified=0
933 };
934 DocParamSect(DocNode *parent,Type t)
935 : m_type(t), m_dir(Unspecified),
936 m_hasInOutSpecifier(FALSE), m_hasTypeSpecifier(FALSE)
937 { m_parent = parent; }
938 int parse(const QCString &cmdName,bool xmlContext,Direction d);
939 Kind kind() const { return Kind_ParamSect; }
940 Type type() const { return m_type; }
941 void accept(DocVisitor *v) { CompAccept<DocParamSect>::accept(this,v); }
942 bool hasInOutSpecifier() const { return m_hasInOutSpecifier; }
943 bool hasTypeSpecifier() const { return m_hasTypeSpecifier; }
944
945 private:
946 Type m_type;
947 Direction m_dir;
948 bool m_hasInOutSpecifier;
949 bool m_hasTypeSpecifier;
950};
951
952/*! Node representing a paragraph in the documentation tree */
953class DocPara : public CompAccept<DocPara>, public DocNode
954{
955 public:
956 DocPara(DocNode *parent) :
957 m_isFirst(FALSE), m_isLast(FALSE) { m_parent = parent; }
958 int parse();
959 Kind kind() const { return Kind_Para; }
960 bool isEmpty() const { return m_children.isEmpty(); }
961 void accept(DocVisitor *v) { CompAccept<DocPara>::accept(this,v); }
962 void markFirst(bool v=TRUE) { m_isFirst=v; }
963 void markLast(bool v=TRUE) { m_isLast=v; }
964 bool isFirst() const { return m_isFirst; }
965 bool isLast() const { return m_isLast; }
966 const QList<DocNode> &children() const { return m_children; }
967 QList<DocNode> &children() { return m_children; }
968
969 int handleCommand(const QCString &cmdName);
970 int handleHtmlStartTag(const QCString &tagName,const HtmlAttribList &tagHtmlAttribs);
971 int handleHtmlEndTag(const QCString &tagName);
972 int handleSimpleSection(DocSimpleSect::Type t,bool xmlContext=FALSE);
973 int handleXRefItem();
974 int handleParamSection(const QCString &cmdName,DocParamSect::Type t,
975 bool xmlContext,
976 int direction);
977 void handleIncludeOperator(const QCString &cmdName,DocIncOperator::Type t);
978 void handleImage(const QCString &cmdName);
979 void handleDotFile(const QCString &cmdName);
980 void handleMscFile(const QCString &cmdName);
981 void handleInclude(const QCString &cmdName,DocInclude::Type t);
982 void handleLink(const QCString &cmdName,bool isJavaLink);
983 void handleRef(const QCString &cmdName);
984 void handleSection(const QCString &cmdName);
985 void handleInheritDoc();
986 int handleStartCode();
987 int handleHtmlHeader(const HtmlAttribList &tagHtmlAttribs,int level);
988 bool injectToken(int tok,const QCString &tokText);
989
990 private:
991 QCString m_sectionId;
992 bool m_isFirst;
993 bool m_isLast;
994};
995
996/*! @brief Node representing a parameter list. */
997class DocParamList : public DocNode
998{
999 public:
1000 DocParamList(DocNode *parent,DocParamSect::Type t,DocParamSect::Direction d)
1001 : m_type(t), m_dir(d), m_isFirst(TRUE), m_isLast(TRUE)
1002 { m_paragraphs.setAutoDelete(TRUE);
1003 m_params.setAutoDelete(TRUE);
1004 m_paramTypes.setAutoDelete(TRUE);
1005 m_parent = parent;
1006 }
1007 virtual ~DocParamList() { }
1008 Kind kind() const { return Kind_ParamList; }
1009 const QList<DocNode> &parameters() { return m_params; }
1010 const QList<DocNode> &paramTypes() { return m_paramTypes; }
1011 DocParamSect::Type type() const { return m_type; }
1012 DocParamSect::Direction direction() const { return m_dir; }
1013 void markFirst(bool b=TRUE) { m_isFirst=b; }
1014 void markLast(bool b=TRUE) { m_isLast=b; }
1015 bool isFirst() const { return m_isFirst; }
1016 bool isLast() const { return m_isLast; }
1017 void accept(DocVisitor *v)
1018 {
1019 v->visitPre(this);
1020 QListIterator<DocPara> cli(m_paragraphs);
1021 DocNode *n;
1022 for (cli.toFirst();(n=cli.current());++cli) n->accept(v);
1023 v->visitPost(this);
1024 }
1025 int parse(const QCString &cmdName);
1026 int parseXml(const QCString &paramName);
1027
1028 private:
1029 QList<DocPara> m_paragraphs;
1030 QList<DocNode> m_params;
1031 QList<DocNode> m_paramTypes;
1032 DocParamSect::Type m_type;
1033 DocParamSect::Direction m_dir;
1034 bool m_isFirst;
1035 bool m_isLast;
1036};
1037
1038/*! @brief Node representing an item of a auto list */
1039class DocAutoListItem : public DocNode
1040{
1041 public:
1042 DocAutoListItem(DocNode *parent,int num) : m_itemNum(num)
1043 { m_paragraph=new DocPara(this); m_parent = parent; }
1044 virtual ~DocAutoListItem() { delete m_paragraph; }
1045 Kind kind() const { return Kind_AutoListItem; }
1046 int itemNumber() const { return m_itemNum; }
1047 void accept(DocVisitor *v)
1048 {
1049 v->visitPre(this);
1050 m_paragraph->accept(v);
1051 v->visitPost(this);
1052 }
1053 int parse();
1054
1055 private:
1056 DocPara *m_paragraph;
1057 int m_itemNum;
1058};
1059
1060/*! @brief Node representing a simple list item */
1061class DocSimpleListItem : public DocNode
1062{
1063 public:
1064 DocSimpleListItem(DocNode *parent)
1065 { m_paragraph=new DocPara(this); m_parent = parent; }
1066 int parse();
1067 virtual ~DocSimpleListItem() { delete m_paragraph; }
1068 Kind kind() const { return Kind_SimpleListItem; }
1069 void accept(DocVisitor *v)
1070 {
1071 v->visitPre(this);
1072 m_paragraph->accept(v);
1073 v->visitPost(this);
1074 }
1075
1076 private:
1077 DocPara *m_paragraph;
1078};
1079
1080/*! @brief Node representing a HTML list item */
1081class DocHtmlListItem : public CompAccept<DocHtmlListItem>, public DocNode
1082{
1083 public:
1084 DocHtmlListItem(DocNode *parent,const HtmlAttribList &attribs,int num) :
1085 m_attribs(attribs), m_itemNum(num) { m_parent = parent; }
1086 Kind kind() const { return Kind_HtmlListItem; }
1087 int itemNumber() const { return m_itemNum; }
1088 const HtmlAttribList &attribs() const { return m_attribs; }
1089 void accept(DocVisitor *v) { CompAccept<DocHtmlListItem>::accept(this,v); }
1090 int parse();
1091 int parseXml();
1092 const QList<DocNode> &children() const { return m_children; }
1093
1094 private:
1095 HtmlAttribList m_attribs;
1096 int m_itemNum;
1097};
1098
1099/*! @brief Node representing a HTML description data */
1100class DocHtmlDescData : public CompAccept<DocHtmlDescData>, public DocNode
1101{
1102 public:
1103 DocHtmlDescData(DocNode *parent) { m_parent = parent; }
1104 Kind kind() const { return Kind_HtmlDescData; }
1105 const HtmlAttribList &attribs() const { return m_attribs; }
1106 void accept(DocVisitor *v) { CompAccept<DocHtmlDescData>::accept(this,v); }
1107 int parse();
1108 const QList<DocNode> &children() const { return m_children; }
1109
1110 private:
1111 HtmlAttribList m_attribs;
1112};
1113
1114/*! @brief Node representing a HTML table cell */
1115class DocHtmlCell : public CompAccept<DocHtmlCell>, public DocNode
1116{
1117 public:
1118 DocHtmlCell(DocNode *parent,const HtmlAttribList &attribs,bool isHeading) :
1119 m_isHeading(isHeading),
1120 m_isFirst(FALSE), m_isLast(FALSE), m_attribs(attribs) { m_parent = parent; }
1121 bool isHeading() const { return m_isHeading; }
1122 bool isFirst() const { return m_isFirst; }
1123 bool isLast() const { return m_isLast; }
1124 Kind kind() const { return Kind_HtmlCell; }
1125 void accept(DocVisitor *v) { CompAccept<DocHtmlCell>::accept(this,v); }
1126 void markFirst(bool v=TRUE) { m_isFirst=v; }
1127 void markLast(bool v=TRUE) { m_isLast=v; }
1128 const HtmlAttribList &attribs() const { return m_attribs; }
1129 const QList<DocNode> &children() const { return m_children; }
1130 int parse();
1131 int parseXml();
1132
1133 private:
1134 bool m_isHeading;
1135 bool m_isFirst;
1136 bool m_isLast;
1137 HtmlAttribList m_attribs;
1138};
1139
1140/*! @brief Node representing a HTML table caption */
1141class DocHtmlCaption : public CompAccept<DocHtmlCaption>, public DocNode
1142{
1143 public:
1144 DocHtmlCaption(DocNode *parent,const HtmlAttribList &attribs) :
1145 m_attribs(attribs) { m_parent = parent; }
1146 Kind kind() const { return Kind_HtmlCaption; }
1147 void accept(DocVisitor *v) { CompAccept<DocHtmlCaption>::accept(this,v); }
1148 const HtmlAttribList &attribs() const { return m_attribs; }
1149 int parse();
1150
1151 private:
1152 HtmlAttribList m_attribs;
1153 bool m_atTop;
1154};
1155
1156/*! @brief Node representing a HTML table row */
1157class DocHtmlRow : public CompAccept<DocHtmlRow>, public DocNode
1158{
1159 public:
1160 DocHtmlRow(DocNode *parent,const HtmlAttribList &attribs) :
1161 m_attribs(attribs) { m_parent = parent; }
1162 Kind kind() const { return Kind_HtmlRow; }
1163 uint numCells() const { return m_children.count(); }
1164 void accept(DocVisitor *v) { CompAccept<DocHtmlRow>::accept(this,v); }
1165 const HtmlAttribList &attribs() const { return m_attribs; }
1166 int parse();
1167 int parseXml(bool header);
1168
1169 private:
1170 HtmlAttribList m_attribs;
1171};
1172
1173/*! @brief Node representing a HTML table */
1174class DocHtmlTable : public CompAccept<DocHtmlTable>, public DocNode
1175{
1176 public:
1177 DocHtmlTable(DocNode *parent,const HtmlAttribList &attribs)
1178 : m_attribs(attribs) { m_caption=0; m_parent = parent; }
1179 ~DocHtmlTable() { delete m_caption; }
1180 Kind kind() const { return Kind_HtmlTable; }
1181 uint numRows() const { return m_children.count(); }
1182 bool hasCaption() { return m_caption!=0; }
1183 const HtmlAttribList &attribs() const { return m_attribs; }
1184 int parse();
1185 int parseXml();
1186 uint numCols() const;
1187 void accept(DocVisitor *v);
1188
1189 private:
1190 DocHtmlCaption *m_caption;
1191 HtmlAttribList m_attribs;
1192};
1193
1194/*! @brief Root node of a text fragment */
1195class DocText : public CompAccept<DocText>, public DocNode
1196{
1197 public:
1198 DocText() {}
1199 Kind kind() const { return Kind_Text; }
1200 void accept(DocVisitor *v) { CompAccept<DocText>::accept(this,v); }
1201 void parse();
1202};
1203
1204/*! @brief Root node of documentation tree */
1205class DocRoot : public CompAccept<DocRoot>, public DocNode
1206{
1207 public:
1208 DocRoot(bool indent,bool sl) : m_indent(indent), m_singleLine(sl) {}
1209 Kind kind() const { return Kind_Root; }
1210 void accept(DocVisitor *v) { CompAccept<DocRoot>::accept(this,v); }
1211 void parse();
1212 bool indent() const { return m_indent; }
1213 bool singleLine() const { return m_singleLine; }
1214
1215 private:
1216 bool m_indent;
1217 bool m_singleLine;
1218};
1219
1220
1221#endif
1222

Archive Download this file

Revision: 1322