02c727dfd2826086915ab38724c984bcf5ddd07f
[platform/upstream/doxygen.git] / src / docparser.h
1 /******************************************************************************
2  *
3  * 
4  *
5  *
6  * Copyright (C) 1997-2015 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
30 class DocNode;
31 class MemberDef;
32 class Definition;
33 class MemberGroup;
34 class SectionDict;
35
36 //---------------------------------------------------------------------------
37
38
39 /*! Main entry point for the documentation parser.
40  *  @param fileName  File in which the documentation block is found (or the
41  *                   name of the example file in case isExample is TRUE).
42  *  @param startLine Line at which the documentation block is found.
43  *  @param context   Class or namespace to which this block belongs.
44  *  @param md        Member definition to which the documentation belongs.
45  *                   Can be 0.
46  *  @param input     String representation of the documentation block.
47  *  @param indexWords Indicates whether or not words should be put in the 
48  *                   search index.
49  *  @param isExample TRUE if the documentation belongs to an example.
50  *  @param exampleName Base name of the example file (0 if isExample is FALSE).
51  *  @param singleLine Output should be presented on a single line, so without
52  *                   starting a new paragraph at the end.
53  *  @param linkFromIndex TRUE if the documentation is generated from an
54  *                   index page. In this case context is not used to determine
55  *                   the relative path when making a link.
56  *  @returns         Root node of the abstract syntax tree. Ownership of the
57  *                   pointer is handed over to the caller.
58  */
59 DocRoot *validatingParseDoc(const char *fileName,int startLine,
60                             Definition *context, MemberDef *md,
61                             const char *input,bool indexWords,
62                             bool isExample,const char *exampleName=0,
63                             bool singleLine=FALSE,bool linkFromIndex=FALSE);
64
65 /*! Main entry point for parsing simple text fragments. These 
66  *  fragments are limited to words, whitespace and symbols.
67  */
68 DocText *validatingParseText(const char *input);
69
70 /*! Searches for section and anchor commands in the input */
71 void docFindSections(const char *input,
72                      Definition *d,
73                      MemberGroup *m,
74                      const char *fileName);
75
76 //---------------------------------------------------------------------------
77
78 /** Abstract node interface with type information. */
79 class DocNode
80 {
81   public:
82     /*! Available node types. */
83     enum Kind { Kind_Root           = 0, 
84                 Kind_Word           = 1, 
85                 Kind_WhiteSpace     = 2, 
86                 Kind_Para           = 3, 
87                 Kind_AutoList       = 4, 
88                 Kind_AutoListItem   = 5,
89                 Kind_Symbol         = 6,
90                 Kind_URL            = 7,
91                 Kind_StyleChange    = 8,
92                 Kind_SimpleSect     = 9,
93                 Kind_Title          = 10,
94                 Kind_SimpleList     = 11,
95                 Kind_SimpleListItem = 12,
96                 Kind_Section        = 13,
97                 Kind_Verbatim       = 14,
98                 Kind_XRefItem       = 15,
99                 Kind_HtmlList       = 16,
100                 Kind_HtmlListItem   = 17,
101                 Kind_HtmlDescList   = 18,
102                 Kind_HtmlDescData   = 19,
103                 Kind_HtmlDescTitle  = 20,
104                 Kind_HtmlTable      = 21,
105                 Kind_HtmlRow        = 22,
106                 Kind_HtmlCell       = 23,
107                 Kind_HtmlCaption    = 24,
108                 Kind_LineBreak      = 25,
109                 Kind_HorRuler       = 26,
110                 Kind_Anchor         = 27,
111                 Kind_IndexEntry     = 28,
112                 Kind_Internal       = 29,
113                 Kind_HRef           = 30,
114                 Kind_Include        = 31,
115                 Kind_IncOperator    = 32,
116                 Kind_HtmlHeader     = 33,
117                 Kind_Image          = 34,
118                 Kind_DotFile        = 35,
119                 Kind_Link           = 36,
120                 Kind_Ref            = 37,
121                 Kind_Formula        = 38,
122                 Kind_SecRefItem     = 39,
123                 Kind_SecRefList     = 40,
124                 Kind_SimpleSectSep  = 41,
125                 Kind_LinkedWord     = 42,
126                 Kind_ParamSect      = 43,
127                 Kind_ParamList      = 44,
128                 Kind_InternalRef    = 45,
129                 Kind_Copy           = 46,
130                 Kind_Text           = 47,
131                 Kind_MscFile        = 48,
132                 Kind_HtmlBlockQuote = 49,
133                 Kind_VhdlFlow       = 50,
134                 Kind_ParBlock       = 51,
135                 Kind_DiaFile        = 52
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 /** Default accept implementation for compound nodes in the abstract
170  *  syntax tree.
171  */
172 template<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     const QList<DocNode> &children() const { return m_children; }
186     QList<DocNode> &children() { return m_children; }
187   
188   protected:
189     QList<DocNode> m_children;
190 };
191
192
193 /** Node representing a word 
194  */
195 class DocWord : public DocNode
196 {
197   public:
198     DocWord(DocNode *parent,const QCString &word);
199     QCString word() const { return m_word; }
200     Kind kind() const { return Kind_Word; }
201     void accept(DocVisitor *v) { v->visit(this); }
202
203   private:
204     QCString  m_word;
205 };
206
207 /** Node representing a word that can be linked to something
208  */
209 class DocLinkedWord : public DocNode
210 {
211   public:
212     DocLinkedWord(DocNode *parent,const QCString &word,
213                   const QCString &ref,const QCString &file,
214                   const QCString &anchor,const QCString &tooltip);
215     QCString word() const       { return m_word; }
216     Kind kind() const          { return Kind_LinkedWord; }
217     QCString file() const       { return m_file; }
218     QCString relPath() const    { return m_relPath; }
219     QCString ref() const        { return m_ref; }
220     QCString anchor() const     { return m_anchor; }
221     QCString tooltip() const    { return m_tooltip; }
222     void accept(DocVisitor *v) { v->visit(this); }
223
224   private:
225     QCString  m_word;
226     QCString  m_ref;
227     QCString  m_file;
228     QCString  m_relPath;
229     QCString  m_anchor;
230     QCString  m_tooltip;
231 };
232
233 /** Node representing an URL (or email address) */
234 class DocURL : public DocNode
235 {
236   public:
237     DocURL(DocNode *parent,const QCString &url,bool isEmail) : 
238       m_url(url), m_isEmail(isEmail) { m_parent=parent; }
239     QCString url() const        { return m_url; }
240     Kind kind() const          { return Kind_URL; }
241     void accept(DocVisitor *v) { v->visit(this); }
242     bool isEmail() const       { return m_isEmail; }
243
244   private:
245     QCString  m_url;
246     bool m_isEmail;
247 };
248
249 /** Node representing a line break */
250 class DocLineBreak : public DocNode
251 {
252   public:
253     DocLineBreak(DocNode *parent) { m_parent=parent; }
254     Kind kind() const          { return Kind_LineBreak; }
255     void accept(DocVisitor *v) { v->visit(this); }
256
257   private:
258 };
259
260 /** Node representing a horizonal ruler */
261 class DocHorRuler : public DocNode
262 {
263   public:
264     DocHorRuler(DocNode *parent) { m_parent = parent; }
265     Kind kind() const          { return Kind_HorRuler; }
266     void accept(DocVisitor *v) { v->visit(this); }
267
268   private:
269 };
270
271 /** Node representing an anchor */
272 class DocAnchor : public DocNode
273 {
274   public:
275     DocAnchor(DocNode *parent,const QCString &id,bool newAnchor);
276     Kind kind() const          { return Kind_Anchor; }
277     QCString anchor() const    { return m_anchor; }
278     QCString file() const      { return m_file; }
279     void accept(DocVisitor *v) { v->visit(this); }
280
281   private:
282     QCString  m_anchor;
283     QCString  m_file;
284 };
285
286 /** Node representing a citation of some bibliographic reference */
287 class DocCite : public DocNode
288 {
289   public:
290     DocCite(DocNode *parent,const QCString &target,const QCString &context);
291     Kind kind() const            { return Kind_Ref; }
292     QCString file() const        { return m_file; }
293     QCString relPath() const     { return m_relPath; }
294     QCString ref() const         { return m_ref; }
295     QCString anchor() const      { return m_anchor; }
296     QCString text() const        { return m_text; }
297     void accept(DocVisitor *v) { v->visit(this); }
298
299   private:
300     QCString   m_file;
301     QCString   m_relPath;
302     QCString   m_ref;
303     QCString   m_anchor;
304     QCString   m_text;
305 };
306
307
308 /** Node representing a style change */
309 class DocStyleChange : public DocNode
310 {
311   public:
312     enum Style { Bold          = (1<<0),
313                  Italic        = (1<<1),
314                  Code          = (1<<2),
315                  Center        = (1<<3),
316                  Small         = (1<<4),
317                  Subscript     = (1<<5),
318                  Superscript   = (1<<6),
319                  Preformatted  = (1<<7),
320                  Span          = (1<<8),
321                  Div           = (1<<9)
322                };
323
324     DocStyleChange(DocNode *parent,uint position,Style s,bool enable,
325                    const HtmlAttribList *attribs=0) : 
326       m_position(position), m_style(s), m_enable(enable)
327       { m_parent = parent; if (attribs) m_attribs=*attribs; }
328     Kind kind() const                     { return Kind_StyleChange; }
329     Style style() const                   { return m_style; }
330     const char *styleString() const;
331     bool enable() const                   { return m_enable; }
332     uint position() const                 { return m_position; }
333     void accept(DocVisitor *v)            { v->visit(this); }
334     const HtmlAttribList &attribs() const { return m_attribs; }
335
336   private:
337     uint     m_position;
338     Style    m_style;
339     bool     m_enable;
340     HtmlAttribList m_attribs;
341 };
342
343 /** Node representing a special symbol */
344 class DocSymbol : public DocNode
345 {
346   public:
347     enum SymType { Sym_Unknown = -1,
348                    Sym_nbsp, Sym_iexcl, Sym_cent, Sym_pound, Sym_curren,
349                    Sym_yen, Sym_brvbar, Sym_sect, Sym_uml, Sym_copy,
350                    Sym_ordf, Sym_laquo, Sym_not, Sym_shy, Sym_reg,
351                    Sym_macr, Sym_deg, Sym_plusmn, Sym_sup2, Sym_sup3,
352                    Sym_acute, Sym_micro, Sym_para, Sym_middot, Sym_cedil,
353                    Sym_sup1, Sym_ordm, Sym_raquo, Sym_frac14, Sym_frac12,
354                    Sym_frac34, Sym_iquest, Sym_Agrave, Sym_Aacute, Sym_Acirc,
355                    Sym_Atilde, Sym_Auml, Sym_Aring, Sym_AElig, Sym_Ccedil,
356                    Sym_Egrave, Sym_Eacute, Sym_Ecirc, Sym_Euml, Sym_Igrave,
357                    Sym_Iacute, Sym_Icirc, Sym_Iuml, Sym_ETH, Sym_Ntilde,
358                    Sym_Ograve, Sym_Oacute, Sym_Ocirc, Sym_Otilde, Sym_Ouml,
359                    Sym_times, Sym_Oslash, Sym_Ugrave, Sym_Uacute, Sym_Ucirc,
360                    Sym_Uuml, Sym_Yacute, Sym_THORN, Sym_szlig, Sym_agrave,
361                    Sym_aacute, Sym_acirc, Sym_atilde, Sym_auml, Sym_aring,
362                    Sym_aelig, Sym_ccedil, Sym_egrave, Sym_eacute, Sym_ecirc,
363                    Sym_euml, Sym_igrave, Sym_iacute, Sym_icirc, Sym_iuml,
364                    Sym_eth, Sym_ntilde, Sym_ograve, Sym_oacute, Sym_ocirc,
365                    Sym_otilde, Sym_ouml, Sym_divide, Sym_oslash, Sym_ugrave,
366                    Sym_uacute, Sym_ucirc, Sym_uuml, Sym_yacute, Sym_thorn,
367                    Sym_yuml, Sym_fnof, Sym_Alpha, Sym_Beta, Sym_Gamma,
368                    Sym_Delta, Sym_Epsilon, Sym_Zeta, Sym_Eta, Sym_Theta,
369                    Sym_Iota, Sym_Kappa, Sym_Lambda, Sym_Mu, Sym_Nu,
370                    Sym_Xi, Sym_Omicron, Sym_Pi, Sym_Rho, Sym_Sigma,
371                    Sym_Tau, Sym_Upsilon, Sym_Phi, Sym_Chi, Sym_Psi,
372                    Sym_Omega, Sym_alpha, Sym_beta, Sym_gamma, Sym_delta,
373                    Sym_epsilon, Sym_zeta, Sym_eta, Sym_theta, Sym_iota,
374                    Sym_kappa, Sym_lambda, Sym_mu, Sym_nu, Sym_xi,
375                    Sym_omicron, Sym_pi, Sym_rho, Sym_sigmaf, Sym_sigma,
376                    Sym_tau, Sym_upsilon, Sym_phi, Sym_chi, Sym_psi,
377                    Sym_omega, Sym_thetasym, Sym_upsih, Sym_piv, Sym_bull,
378                    Sym_hellip, Sym_prime, Sym_Prime, Sym_oline, Sym_frasl,
379                    Sym_weierp, Sym_image, Sym_real, Sym_trade, Sym_alefsym,
380                    Sym_larr, Sym_uarr, Sym_rarr, Sym_darr, Sym_harr,
381                    Sym_crarr, Sym_lArr, Sym_uArr, Sym_rArr, Sym_dArr,
382                    Sym_hArr, Sym_forall, Sym_part, Sym_exist, Sym_empty,
383                    Sym_nabla, Sym_isin, Sym_notin, Sym_ni, Sym_prod,
384                    Sym_sum, Sym_minus, Sym_lowast, Sym_radic, Sym_prop,
385                    Sym_infin, Sym_ang, Sym_and, Sym_or, Sym_cap,
386                    Sym_cup, Sym_int, Sym_there4, Sym_sim, Sym_cong,
387                    Sym_asymp, Sym_ne, Sym_equiv, Sym_le, Sym_ge,
388                    Sym_sub, Sym_sup, Sym_nsub, Sym_sube, Sym_supe,
389                    Sym_oplus, Sym_otimes, Sym_perp, Sym_sdot, Sym_lceil,
390                    Sym_rceil, Sym_lfloor, Sym_rfloor, Sym_lang, Sym_rang,
391                    Sym_loz, Sym_spades, Sym_clubs, Sym_hearts, Sym_diams,
392                    Sym_quot, Sym_amp, Sym_lt, Sym_gt, Sym_OElig,
393                    Sym_oelig, Sym_Scaron, Sym_scaron, Sym_Yuml, Sym_circ,
394                    Sym_tilde, Sym_ensp, Sym_emsp, Sym_thinsp, Sym_zwnj,
395                    Sym_zwj, Sym_lrm, Sym_rlm, Sym_ndash, Sym_mdash,
396                    Sym_lsquo, Sym_rsquo, Sym_sbquo, Sym_ldquo, Sym_rdquo,
397                    Sym_bdquo, Sym_dagger, Sym_Dagger, Sym_permil, Sym_lsaquo,
398                    Sym_rsaquo, Sym_euro,
399
400                    /* doxygen extensions */
401                    Sym_tm, Sym_apos,
402
403                    /* doxygen commands mapped */
404                    Sym_BSlash, Sym_At, Sym_Less, Sym_Greater, Sym_Amp,
405                    Sym_Dollar, Sym_Hash, Sym_DoubleColon, Sym_Percent, Sym_Pipe,
406                    Sym_Quot, Sym_Minus, Sym_Plus, Sym_Dot
407                  };
408     enum PerlType { Perl_unknown = 0, Perl_string, Perl_char, Perl_symbol, Perl_umlaut,
409                     Perl_acute, Perl_grave, Perl_circ, Perl_slash, Perl_tilde,
410                     Perl_cedilla, Perl_ring
411                   };
412     typedef struct PerlSymb {
413       const char     *symb;
414       const PerlType  type;
415     }PerlSymb;
416     DocSymbol(DocNode *parent,SymType s) : 
417       m_symbol(s) { m_parent = parent; }
418     SymType symbol() const     { return m_symbol; }
419     Kind kind() const          { return Kind_Symbol; }
420     void accept(DocVisitor *v) { v->visit(this); }
421     static SymType decodeSymbol(const QCString &symName);
422
423   private:
424     SymType  m_symbol;
425 };
426
427 /** Node representing some amount of white space */
428 class DocWhiteSpace : public DocNode
429 {
430   public:
431     DocWhiteSpace(DocNode *parent,const QCString &chars) : 
432       m_chars(chars) { m_parent = parent; }
433     Kind kind() const          { return Kind_WhiteSpace; }
434     QCString chars() const      { return m_chars; }
435     void accept(DocVisitor *v) { v->visit(this); }
436   private:
437     QCString  m_chars;
438 };
439
440 /** Node representing a verbatim, unparsed text fragment */
441 class DocVerbatim : public DocNode
442 {
443   public:
444     enum Type { Code, HtmlOnly, ManOnly, LatexOnly, RtfOnly, XmlOnly, Verbatim, Dot, Msc, DocbookOnly, PlantUML };
445     DocVerbatim(DocNode *parent,const QCString &context,
446                 const QCString &text, Type t,bool isExample,
447                 const QCString &exampleFile,bool isBlock=FALSE,const QCString &lang=QCString());
448     Kind kind() const            { return Kind_Verbatim; }
449     Type type() const            { return m_type; }
450     QCString text() const        { return m_text; }
451     QCString context() const     { return m_context; }
452     void accept(DocVisitor *v)   { v->visit(this); }
453     bool isExample() const       { return m_isExample; }
454     QCString exampleFile() const { return m_exampleFile; }
455     QCString relPath() const     { return m_relPath; }
456     QCString language() const    { return m_lang; }
457     bool isBlock() const         { return m_isBlock; }
458     bool hasCaption() const      { return !m_children.isEmpty(); }
459     QCString width() const       { return m_width; }
460     QCString height() const      { return m_height; }
461     const QList<DocNode> &children() const { return m_children; }
462     QList<DocNode> &children()   { return m_children; }
463     void setText(const QCString &t)   { m_text=t;   }
464     void setWidth(const QCString &w)  { m_width=w;  }
465     void setHeight(const QCString &h) { m_height=h; }
466
467   private:
468     QCString  m_context;
469     QCString  m_text;
470     Type      m_type;
471     bool      m_isExample;
472     QCString  m_exampleFile;
473     QCString  m_relPath;
474     QCString  m_lang;
475     bool      m_isBlock;
476     QCString  m_width;
477     QCString  m_height;
478     QList<DocNode> m_children;
479 };
480
481
482 /** Node representing an included text block from file */
483 class DocInclude : public DocNode
484 {
485   public:
486   enum Type { Include, DontInclude, VerbInclude, HtmlInclude, LatexInclude,
487               IncWithLines, Snippet , IncludeDoc, SnippetDoc, SnipWithLines};
488     DocInclude(DocNode *parent,const QCString &file,
489                const QCString context, Type t,
490                bool isExample,const QCString exampleFile,
491                const QCString blockId) : 
492       m_file(file), m_context(context), m_type(t),
493       m_isExample(isExample), m_exampleFile(exampleFile),
494       m_blockId(blockId) { m_parent = parent; }
495     Kind kind() const            { return Kind_Include; }
496     QCString file() const        { return m_file; }
497     QCString extension() const   { int i=m_file.findRev('.'); 
498                                    if (i!=-1) 
499                                      return m_file.right(m_file.length()-i); 
500                                    else 
501                                      return ""; 
502                                  }
503     Type type() const            { return m_type; }
504     QCString text() const        { return m_text; }
505     QCString context() const     { return m_context; }
506     QCString blockId() const     { return m_blockId; }
507     bool isExample() const       { return m_isExample; }
508     QCString exampleFile() const { return m_exampleFile; }
509     void accept(DocVisitor *v)   { v->visit(this); }
510     void parse();
511
512   private:
513     QCString  m_file;
514     QCString  m_context;
515     QCString  m_text;
516     Type      m_type;
517     bool      m_isExample;
518     QCString  m_exampleFile;
519     QCString  m_blockId;
520 };
521
522 /** Node representing a include/dontinclude operator block */
523 class DocIncOperator : public DocNode
524 {
525   public:
526     enum Type { Line, SkipLine, Skip, Until };
527     DocIncOperator(DocNode *parent,Type t,const QCString &pat,
528                    const QCString &context,bool isExample,const QCString &exampleFile) : 
529       m_type(t), m_pattern(pat), m_context(context), 
530       m_isFirst(FALSE), m_isLast(FALSE),
531       m_isExample(isExample), m_exampleFile(exampleFile) { m_parent = parent; }
532     Kind kind() const           { return Kind_IncOperator; }
533     Type type() const           { return m_type; }
534     QCString text() const        { return m_text; }
535     QCString pattern() const     { return m_pattern; }
536     QCString context() const     { return m_context; }
537     void accept(DocVisitor *v)  { v->visit(this); }
538     bool isFirst() const        { return m_isFirst; }
539     bool isLast() const         { return m_isLast; }
540     void markFirst(bool v=TRUE) { m_isFirst = v; }
541     void markLast(bool v=TRUE)  { m_isLast = v; }
542     bool isExample() const      { return m_isExample; }
543     QCString exampleFile() const { return m_exampleFile; }
544     QCString includeFileName() const { return m_includeFileName; }
545     void parse();
546
547   private:
548     Type     m_type;
549     QCString  m_text;
550     QCString  m_pattern;
551     QCString  m_context;
552     bool     m_isFirst;
553     bool     m_isLast;
554     bool     m_isExample;
555     QCString  m_exampleFile;
556     QCString m_includeFileName;
557 };
558
559 /** Node representing an item of a cross-referenced list */
560 class DocFormula : public DocNode
561 {
562   public:
563     DocFormula(DocNode *parent,int id);
564     Kind kind() const          { return Kind_Formula; }
565     QCString name() const       { return m_name; }
566     QCString text() const       { return m_text; }
567     QCString relPath() const    { return m_relPath; }
568     int id() const             { return m_id; }
569     void accept(DocVisitor *v) { v->visit(this); }
570     bool isInline()            { return m_text.length()>0 ? m_text.at(0)!='\\' : TRUE; }
571
572   private:
573     QCString  m_name;
574     QCString  m_text;
575     QCString  m_relPath;
576     int      m_id;
577 };
578
579 /** Node representing an entry in the index. */
580 class DocIndexEntry : public DocNode
581 {
582   public:
583     DocIndexEntry(DocNode *parent,Definition *scope,MemberDef *md) 
584       : m_scope(scope), m_member(md){ m_parent = parent; }
585     Kind kind() const { return Kind_IndexEntry; }
586     int parse();
587     Definition *scope() const    { return m_scope;  }
588     MemberDef *member() const    { return m_member; }
589     QCString entry() const        { return m_entry;  }
590     void accept(DocVisitor *v)   { v->visit(this);  }
591
592   private:
593     QCString     m_entry;
594     Definition *m_scope;
595     MemberDef  *m_member;
596 };
597
598 //-----------------------------------------------------------------------
599
600 /** Node representing a copy of documentation block. */
601 class DocCopy : public DocNode
602 {
603   public:
604     DocCopy(DocNode *parent,const QCString &link,bool copyBrief,bool copyDetails) 
605       : m_link(link), 
606         m_copyBrief(copyBrief), m_copyDetails(copyDetails) { m_parent = parent; }
607     Kind kind() const          { return Kind_Copy; }
608     QCString link() const       { return m_link; }
609     void accept(DocVisitor * /*v*/) { /*CompAccept<DocCopy>::accept(this,v);*/ }
610     void parse(QList<DocNode> &children);
611
612   private:
613     QCString  m_link;
614     bool     m_copyBrief;
615     bool     m_copyDetails;
616 };
617
618 /** Node representing an auto List */
619 class DocAutoList : public CompAccept<DocAutoList>, public DocNode
620 {
621   public:
622     DocAutoList(DocNode *parent,int indent,bool isEnumList,int depth);
623     Kind kind() const          { return Kind_AutoList; }
624     bool isEnumList() const    { return m_isEnumList; }
625     int  indent() const        { return m_indent; }
626     int depth() const          { return m_depth; }
627     void accept(DocVisitor *v) { CompAccept<DocAutoList>::accept(this,v); }
628     int parse();
629
630   private:
631     int      m_indent;
632     bool     m_isEnumList;
633     int      m_depth;
634 };
635
636 /** Node representing an item of a auto list */
637 class DocAutoListItem : public CompAccept<DocAutoListItem>, public DocNode
638 {
639   public:
640     DocAutoListItem(DocNode *parent,int indent,int num);
641     Kind kind() const          { return Kind_AutoListItem; }
642     int itemNumber() const     { return m_itemNum; }
643     void accept(DocVisitor *v) { CompAccept<DocAutoListItem>::accept(this,v); }
644     int parse();
645
646   private:
647     int m_indent;
648     int m_itemNum;
649 };
650
651
652
653 /** Node representing a simple section title */
654 class DocTitle : public CompAccept<DocTitle>, public DocNode
655 {
656   public:
657     DocTitle(DocNode *parent) { m_parent = parent; }
658     void parse();
659     void parseFromString(const QCString &title);
660     Kind kind() const          { return Kind_Title; }
661     void accept(DocVisitor *v) { CompAccept<DocTitle>::accept(this,v); }
662
663   private:
664 };
665
666 /** Node representing an item of a cross-referenced list */
667 class DocXRefItem : public CompAccept<DocXRefItem>, public DocNode
668 {
669   public:
670     DocXRefItem(DocNode *parent,int id,const char *key);
671     Kind kind() const          { return Kind_XRefItem; }
672     QCString file() const       { return m_file; }
673     QCString anchor() const     { return m_anchor; }
674     QCString title() const      { return m_title; }
675     QCString relPath() const    { return m_relPath; }
676     QCString key() const        { return m_key; }
677     void accept(DocVisitor *v) { CompAccept<DocXRefItem>::accept(this,v); }
678     bool parse();
679
680   private:
681     int      m_id;
682     QCString  m_key;
683     QCString  m_file;
684     QCString  m_anchor;
685     QCString  m_title;
686     QCString  m_relPath;
687 };
688
689 /** Node representing an image */
690 class DocImage : public CompAccept<DocImage>, public DocNode
691 {
692   public:
693     enum Type { Html, Latex, Rtf, DocBook };
694     DocImage(DocNode *parent,const HtmlAttribList &attribs,
695              const QCString &name,Type t,const QCString &url=QCString());
696     Kind kind() const           { return Kind_Image; }
697     Type type() const           { return m_type; }
698     QCString name() const       { return m_name; }
699     bool hasCaption() const     { return !m_children.isEmpty(); }
700     QCString width() const      { return m_width; }
701     QCString height() const     { return m_height; }
702     QCString relPath() const    { return m_relPath; }
703     QCString url() const        { return m_url; }
704     const HtmlAttribList &attribs() const { return m_attribs; }
705     void accept(DocVisitor *v) { CompAccept<DocImage>::accept(this,v); }
706     void parse();
707
708   private:
709     HtmlAttribList m_attribs;
710     QCString  m_name;
711     Type      m_type;
712     QCString  m_width;
713     QCString  m_height;
714     QCString  m_relPath;
715     QCString  m_url;
716 };
717
718 /** Node representing a dot file */
719 class DocDotFile : public CompAccept<DocDotFile>, public DocNode
720 {
721   public:
722     DocDotFile(DocNode *parent,const QCString &name,const QCString &context);
723     void parse();
724     Kind kind() const          { return Kind_DotFile; }
725     QCString name() const       { return m_name; }
726     QCString file() const       { return m_file; }
727     QCString relPath() const    { return m_relPath; }
728     bool hasCaption() const    { return !m_children.isEmpty(); }
729     QCString width() const      { return m_width; }
730     QCString height() const     { return m_height; }
731     QCString context() const    { return m_context; }
732     void accept(DocVisitor *v) { CompAccept<DocDotFile>::accept(this,v); }
733   private:
734     QCString  m_name;
735     QCString  m_file;
736     QCString  m_relPath;
737     QCString  m_width;
738     QCString  m_height;
739     QCString  m_context;
740 };
741
742 /** Node representing a msc file */
743 class DocMscFile : public CompAccept<DocMscFile>, public DocNode
744 {
745   public:
746     DocMscFile(DocNode *parent,const QCString &name,const QCString &context);
747     void parse();
748     Kind kind() const          { return Kind_MscFile; }
749     QCString name() const      { return m_name; }
750     QCString file() const      { return m_file; }
751     QCString relPath() const   { return m_relPath; }
752     bool hasCaption() const    { return !m_children.isEmpty(); }
753     QCString width() const     { return m_width; }
754     QCString height() const    { return m_height; }
755     QCString context() const   { return m_context; }
756     void accept(DocVisitor *v) { CompAccept<DocMscFile>::accept(this,v); }
757   private:
758     QCString  m_name;
759     QCString  m_file;
760     QCString  m_relPath;
761     QCString  m_width;
762     QCString  m_height;
763     QCString  m_context;
764 };
765
766 /** Node representing a dia file */
767 class DocDiaFile : public CompAccept<DocDiaFile>, public DocNode
768 {
769   public:
770     DocDiaFile(DocNode *parent,const QCString &name,const QCString &context);
771     void parse();
772     Kind kind() const          { return Kind_DiaFile; }
773     QCString name() const      { return m_name; }
774     QCString file() const      { return m_file; }
775     QCString relPath() const   { return m_relPath; }
776     bool hasCaption() const    { return !m_children.isEmpty(); }
777     QCString width() const     { return m_width; }
778     QCString height() const    { return m_height; }
779     QCString context() const   { return m_context; }
780     void accept(DocVisitor *v) { CompAccept<DocDiaFile>::accept(this,v); }
781   private:
782     QCString  m_name;
783     QCString  m_file;
784     QCString  m_relPath;
785     QCString  m_width;
786     QCString  m_height;
787     QCString  m_context;
788 };
789
790 /** Node representing a VHDL flow chart */
791 class DocVhdlFlow : public CompAccept<DocVhdlFlow>, public DocNode
792 {
793   public:
794     DocVhdlFlow(DocNode *parent);
795     void parse();
796     Kind kind() const    { return Kind_VhdlFlow; }
797     bool hasCaption()    { return !m_children.isEmpty(); }
798     void accept(DocVisitor *v) { CompAccept<DocVhdlFlow>::accept(this,v); }
799   private:
800 };
801
802 /** Node representing a link to some item */
803 class DocLink : public CompAccept<DocLink>, public DocNode
804 {
805   public:
806     DocLink(DocNode *parent,const QCString &target);
807     QCString parse(bool,bool isXmlLink=FALSE);
808     Kind kind() const          { return Kind_Link; }
809     QCString file() const       { return m_file; }
810     QCString relPath() const    { return m_relPath; }
811     QCString ref() const        { return m_ref; }
812     QCString anchor() const     { return m_anchor; }
813     void accept(DocVisitor *v) { CompAccept<DocLink>::accept(this,v); }
814
815   private:
816     QCString  m_file;
817     QCString  m_relPath;
818     QCString  m_ref;
819     QCString  m_anchor;
820     QCString  m_refText;
821 };
822
823 /** Node representing a reference to some item */
824 class DocRef : public CompAccept<DocRef>, public DocNode
825 {
826   public:
827     DocRef(DocNode *parent,const QCString &target,const QCString &context);
828     void parse();
829     Kind kind() const            { return Kind_Ref; }
830     QCString file() const         { return m_file; }
831     QCString relPath() const      { return m_relPath; }
832     QCString ref() const          { return m_ref; }
833     QCString anchor() const       { return m_anchor; }
834     QCString targetTitle() const  { return m_text; }
835     bool hasLinkText() const     { return !m_children.isEmpty(); }
836     bool refToAnchor() const     { return m_refType==Anchor; }
837     bool refToSection() const    { return m_refType==Section; }
838     bool refToTable() const      { return m_refType==Table; }
839     bool isSubPage() const       { return m_isSubPage; }
840     void accept(DocVisitor *v)   { CompAccept<DocRef>::accept(this,v); }
841
842   private:
843     enum RefType { Unknown, Anchor, Section, Table };
844     RefType    m_refType;
845     bool       m_isSubPage;
846     QCString   m_file;
847     QCString   m_relPath;
848     QCString   m_ref;
849     QCString   m_anchor;
850     QCString   m_text;
851 };
852
853 /** Node representing an internal reference to some item */
854 class DocInternalRef : public CompAccept<DocInternalRef>, public DocNode
855 {
856   public:
857     DocInternalRef(DocNode *parent,const QCString &target);
858     void parse();
859     Kind kind() const            { return Kind_Ref; }
860     QCString file() const         { return m_file; }
861     QCString relPath() const      { return m_relPath; }
862     QCString anchor() const       { return m_anchor; }
863     void accept(DocVisitor *v)   { CompAccept<DocInternalRef>::accept(this,v); }
864
865   private:
866     QCString   m_file;
867     QCString   m_relPath;
868     QCString   m_anchor;
869 };
870
871 /** Node representing a Hypertext reference */
872 class DocHRef : public CompAccept<DocHRef>, public DocNode
873 {
874   public:
875     DocHRef(DocNode *parent,const HtmlAttribList &attribs,const QCString &url,
876            const QCString &relPath) : 
877       m_attribs(attribs), m_url(url), m_relPath(relPath) { m_parent = parent; }
878     int parse();
879     QCString url() const        { return m_url; }
880     QCString relPath() const    { return m_relPath; }
881     Kind kind() const           { return Kind_HRef; }
882     void accept(DocVisitor *v)  { CompAccept<DocHRef>::accept(this,v); }
883     const HtmlAttribList &attribs() const { return m_attribs; }
884
885   private:
886     HtmlAttribList m_attribs;
887     QCString   m_url;
888     QCString   m_relPath;
889 };
890
891 /** Node Html heading */
892 class DocHtmlHeader : public CompAccept<DocHtmlHeader>, public DocNode
893 {
894   public:
895     DocHtmlHeader(DocNode *parent,const HtmlAttribList &attribs,int level) : 
896        m_level(level), m_attribs(attribs) { m_parent = parent; }
897     int level() const                     { return m_level; }
898     Kind kind() const                     { return Kind_HtmlHeader; }
899     const HtmlAttribList &attribs() const { return m_attribs; }
900     void accept(DocVisitor *v) { CompAccept<DocHtmlHeader>::accept(this,v); }
901     int parse();
902
903   private:
904     int           m_level;
905     HtmlAttribList m_attribs;
906 };
907
908 /** Node representing a Html description item */
909 class DocHtmlDescTitle : public CompAccept<DocHtmlDescTitle>, public DocNode
910 {
911   public:
912     DocHtmlDescTitle(DocNode *parent,const HtmlAttribList &attribs) : 
913       m_attribs(attribs) { m_parent = parent; }
914     Kind kind() const                     { return Kind_HtmlDescTitle; }
915     const HtmlAttribList &attribs() const { return m_attribs; }
916     void accept(DocVisitor *v) { CompAccept<DocHtmlDescTitle>::accept(this,v); }
917     int parse();
918
919   private:
920     HtmlAttribList m_attribs;
921 };
922
923 /** Node representing a Html description list */
924 class DocHtmlDescList : public CompAccept<DocHtmlDescList>, public DocNode
925 {
926   public:
927     DocHtmlDescList(DocNode *parent,const HtmlAttribList &attribs) :
928       m_attribs(attribs) { m_parent = parent; }
929     Kind kind() const                     { return Kind_HtmlDescList; }
930     const HtmlAttribList &attribs() const { return m_attribs; }
931     void accept(DocVisitor *v) { CompAccept<DocHtmlDescList>::accept(this,v); }
932     int parse();
933
934   private:
935     HtmlAttribList m_attribs;
936 };
937
938 /** Node representing a normal section */
939 class DocSection : public CompAccept<DocSection>, public DocNode
940 {
941   public:
942     DocSection(DocNode *parent,int level,const QCString &id) :
943       m_level(level), m_id(id) { m_parent = parent; } 
944     Kind kind() const          { return Kind_Section; }
945     int level() const          { return m_level; }
946     QCString title() const      { return m_title; }
947     QCString anchor() const     { return m_anchor; }
948     QCString id() const         { return m_id; }
949     QCString file() const       { return m_file; }
950     void accept(DocVisitor *v) { CompAccept<DocSection>::accept(this,v); }
951     int parse();
952
953   private:
954     int      m_level;
955     QCString  m_id;
956     QCString  m_title;
957     QCString  m_anchor;
958     QCString  m_file;
959 };
960
961 /** Node representing a reference to a section */
962 class DocSecRefItem : public CompAccept<DocSecRefItem>, public DocNode
963 {
964   public:
965     DocSecRefItem(DocNode *parent,const QCString &target) : 
966       m_target(target) { m_parent = parent; }
967     Kind kind() const          { return Kind_SecRefItem; }
968     QCString target() const     { return m_target; }
969     QCString file() const       { return m_file; }
970     QCString anchor() const     { return m_anchor; }
971     void accept(DocVisitor *v) { CompAccept<DocSecRefItem>::accept(this,v); }
972     void parse();
973
974   private:
975     QCString  m_target;
976     QCString  m_file;
977     QCString  m_anchor;
978 };
979
980 /** Node representing a list of section references */
981 class DocSecRefList : public CompAccept<DocSecRefList>, public DocNode
982 {
983   public:
984     DocSecRefList(DocNode *parent) { m_parent = parent; }
985     void parse();
986     Kind kind() const          { return Kind_SecRefList; }
987     void accept(DocVisitor *v) { CompAccept<DocSecRefList>::accept(this,v); }
988
989   private:
990 };
991
992 /** Node representing an internal section of documentation */
993 class DocInternal : public CompAccept<DocInternal>, public DocNode
994 {
995   public:
996     DocInternal(DocNode *parent) { m_parent = parent; }
997     int parse(int);
998     Kind kind() const          { return Kind_Internal; }
999     void accept(DocVisitor *v) { CompAccept<DocInternal>::accept(this,v); }
1000
1001   private:
1002 };
1003
1004 /** Node representing an block of paragraphs */
1005 class DocParBlock : public CompAccept<DocParBlock>, public DocNode
1006 {
1007   public:
1008     DocParBlock(DocNode *parent) { m_parent = parent; }
1009     int parse();
1010     Kind kind() const          { return Kind_ParBlock; }
1011     void accept(DocVisitor *v) { CompAccept<DocParBlock>::accept(this,v); }
1012
1013   private:
1014 };
1015
1016
1017 /** Node representing a simple list */
1018 class DocSimpleList : public CompAccept<DocSimpleList>, public DocNode
1019 {
1020   public:
1021     DocSimpleList(DocNode *parent) { m_parent = parent; }
1022     Kind kind() const          { return Kind_SimpleList; }
1023     void accept(DocVisitor *v) { CompAccept<DocSimpleList>::accept(this,v); }
1024     int parse();
1025
1026   private:
1027 };
1028
1029 /** Node representing a Html list */
1030 class DocHtmlList : public CompAccept<DocHtmlList>, public DocNode
1031 {
1032   public:
1033     enum Type { Unordered, Ordered };
1034     DocHtmlList(DocNode *parent,const HtmlAttribList &attribs,Type t) : 
1035       m_type(t), m_attribs(attribs) { m_parent = parent; }
1036     Kind kind() const          { return Kind_HtmlList; }
1037     Type type() const          { return m_type; }
1038     void accept(DocVisitor *v) { CompAccept<DocHtmlList>::accept(this,v); }
1039     const HtmlAttribList &attribs() const { return m_attribs; }
1040     int parse();
1041     int parseXml();
1042
1043   private:
1044     Type          m_type;
1045     HtmlAttribList m_attribs;
1046 };
1047
1048 /** Node representing a simple section */
1049 class DocSimpleSect : public CompAccept<DocSimpleSect>, public DocNode
1050 {
1051   public:
1052     enum Type 
1053     {  
1054        Unknown, See, Return, Author, Authors, Version, Since, Date,
1055        Note, Warning, Copyright, Pre, Post, Invar, Remark, Attention, User, Rcs
1056     };
1057     DocSimpleSect(DocNode *parent,Type t);
1058     virtual ~DocSimpleSect();
1059     Kind kind() const       { return Kind_SimpleSect; }
1060     Type type() const       { return m_type; }
1061     QCString typeString() const;
1062     void accept(DocVisitor *v);
1063     int parse(bool userTitle,bool needsSeparator);
1064     int parseRcs();
1065     int parseXml();
1066     void appendLinkWord(const QCString &word);
1067
1068   private:
1069     Type            m_type;
1070     DocTitle *      m_title;
1071 };
1072
1073 /** Node representing a separator between two simple sections of the
1074  *  same type. 
1075  */
1076 class DocSimpleSectSep : public DocNode
1077 {
1078   public:
1079     DocSimpleSectSep(DocNode *parent) { m_parent = parent; }
1080     Kind kind() const { return Kind_SimpleSectSep; }
1081     void accept(DocVisitor *v) { v->visit(this); }
1082
1083   private:
1084 };
1085
1086 /** Node representing a parameter section */
1087 class DocParamSect : public CompAccept<DocParamSect>, public DocNode
1088 {
1089     friend class DocParamList;
1090   public:
1091     enum Type 
1092     {  
1093        Unknown, Param, RetVal, Exception, TemplateParam
1094     };
1095     enum Direction
1096     {
1097        In=1, Out=2, InOut=3, Unspecified=0
1098     };
1099     DocParamSect(DocNode *parent,Type t) 
1100       : m_type(t), m_hasInOutSpecifier(FALSE), m_hasTypeSpecifier(FALSE) 
1101     { m_parent = parent; }
1102     int parse(const QCString &cmdName,bool xmlContext,Direction d);
1103     Kind kind() const          { return Kind_ParamSect; }
1104     Type type() const          { return m_type; }
1105     void accept(DocVisitor *v) { CompAccept<DocParamSect>::accept(this,v); }
1106     bool hasInOutSpecifier() const { return m_hasInOutSpecifier; }
1107     bool hasTypeSpecifier() const  { return m_hasTypeSpecifier; }
1108
1109   private:
1110     Type            m_type;
1111     bool            m_hasInOutSpecifier;
1112     bool            m_hasTypeSpecifier;
1113 };
1114
1115 /** Node representing a paragraph in the documentation tree */
1116 class DocPara : public CompAccept<DocPara>, public DocNode
1117 {
1118   public:
1119     DocPara(DocNode *parent) : 
1120              m_isFirst(FALSE), m_isLast(FALSE) { m_parent = parent; }
1121     int parse();
1122     Kind kind() const           { return Kind_Para; }
1123     bool isEmpty() const        { return m_children.isEmpty(); }
1124     void accept(DocVisitor *v)  { CompAccept<DocPara>::accept(this,v); }
1125     void markFirst(bool v=TRUE) { m_isFirst=v; }
1126     void markLast(bool v=TRUE)  { m_isLast=v; }
1127     bool isFirst() const        { return m_isFirst; }
1128     bool isLast() const         { return m_isLast; }
1129
1130     int handleCommand(const QCString &cmdName);
1131     int handleHtmlStartTag(const QCString &tagName,const HtmlAttribList &tagHtmlAttribs);
1132     int handleHtmlEndTag(const QCString &tagName);
1133     int handleSimpleSection(DocSimpleSect::Type t,bool xmlContext=FALSE);
1134     int handleXRefItem();
1135     int handleParamSection(const QCString &cmdName,DocParamSect::Type t,
1136                            bool xmlContext,
1137                            int direction);
1138     void handleIncludeOperator(const QCString &cmdName,DocIncOperator::Type t);
1139     void handleImage(const QCString &cmdName);
1140     template<class T> void handleFile(const QCString &cmdName);
1141     void handleInclude(const QCString &cmdName,DocInclude::Type t);
1142     void handleLink(const QCString &cmdName,bool isJavaLink);
1143     void handleCite();
1144     void handleRef(const QCString &cmdName);
1145     void handleSection(const QCString &cmdName);
1146     void handleInheritDoc();
1147     void handleVhdlFlow();
1148     int handleStartCode();
1149     int handleHtmlHeader(const HtmlAttribList &tagHtmlAttribs,int level);
1150
1151     bool injectToken(int tok,const QCString &tokText);
1152
1153   private:
1154     QCString  m_sectionId;
1155     bool     m_isFirst;
1156     bool     m_isLast;
1157 };
1158
1159 /** Node representing a parameter list. */
1160 class DocParamList : public DocNode
1161 {
1162   public:
1163     DocParamList(DocNode *parent,DocParamSect::Type t,DocParamSect::Direction d) 
1164       : m_type(t), m_dir(d), m_isFirst(TRUE), m_isLast(TRUE)
1165     { m_paragraphs.setAutoDelete(TRUE); 
1166       m_params.setAutoDelete(TRUE); 
1167       m_paramTypes.setAutoDelete(TRUE);
1168       m_parent = parent; 
1169     }
1170     virtual ~DocParamList()         { }
1171     Kind kind() const               { return Kind_ParamList; }
1172     const QList<DocNode> &parameters()    { return m_params; }
1173     const QList<DocNode> &paramTypes()    { return m_paramTypes; }
1174     DocParamSect::Type type() const { return m_type; }
1175     DocParamSect::Direction direction() const { return m_dir; }
1176     void markFirst(bool b=TRUE)     { m_isFirst=b; }
1177     void markLast(bool b=TRUE)      { m_isLast=b; }
1178     bool isFirst() const            { return m_isFirst; }
1179     bool isLast() const             { return m_isLast; }
1180     void accept(DocVisitor *v)
1181     { 
1182       v->visitPre(this); 
1183       QListIterator<DocPara> cli(m_paragraphs);
1184       DocNode *n;
1185       for (cli.toFirst();(n=cli.current());++cli) n->accept(v);
1186       v->visitPost(this); 
1187     }
1188     int parse(const QCString &cmdName);
1189     int parseXml(const QCString &paramName);
1190
1191   private:
1192     QList<DocPara>          m_paragraphs;
1193     QList<DocNode>          m_params;
1194     QList<DocNode>          m_paramTypes;
1195     DocParamSect::Type      m_type;
1196     DocParamSect::Direction m_dir;
1197     bool                    m_isFirst;
1198     bool                    m_isLast;
1199 };
1200
1201 /** Node representing a simple list item */
1202 class DocSimpleListItem : public DocNode
1203 {
1204   public:
1205     DocSimpleListItem(DocNode *parent)
1206     { m_paragraph=new DocPara(this); m_parent = parent; }
1207     int parse();
1208     virtual ~DocSimpleListItem() { delete m_paragraph; }
1209     Kind kind() const            { return Kind_SimpleListItem; }
1210     void accept(DocVisitor *v)
1211     {
1212       v->visitPre(this); 
1213       m_paragraph->accept(v);
1214       v->visitPost(this); 
1215     }
1216
1217   private:
1218     DocPara *m_paragraph;
1219 };
1220
1221 /** Node representing a HTML list item */
1222 class DocHtmlListItem : public CompAccept<DocHtmlListItem>, public DocNode
1223 {
1224   public:
1225     DocHtmlListItem(DocNode *parent,const HtmlAttribList &attribs,int num) : 
1226       m_attribs(attribs), m_itemNum(num) { m_parent = parent; }
1227     Kind kind() const                     { return Kind_HtmlListItem; }
1228     int itemNumber() const                { return m_itemNum; }
1229     const HtmlAttribList &attribs() const { return m_attribs; }
1230     void accept(DocVisitor *v) { CompAccept<DocHtmlListItem>::accept(this,v); }
1231     int parse();
1232     int parseXml();
1233
1234   private:
1235     HtmlAttribList m_attribs;
1236     int            m_itemNum;
1237 };
1238
1239 /** Node representing a HTML description data */
1240 class DocHtmlDescData : public CompAccept<DocHtmlDescData>, public DocNode
1241 {
1242   public:
1243     DocHtmlDescData(DocNode *parent) { m_parent = parent; }
1244     Kind kind() const                     { return Kind_HtmlDescData; }
1245     const HtmlAttribList &attribs() const { return m_attribs; }
1246     void accept(DocVisitor *v) { CompAccept<DocHtmlDescData>::accept(this,v); }
1247     int parse();
1248
1249   private:
1250     HtmlAttribList m_attribs;
1251 };
1252
1253 /** Node representing a HTML table cell */
1254 class DocHtmlCell : public CompAccept<DocHtmlCell>, public DocNode
1255 {
1256     friend class DocHtmlTable;
1257   public:
1258     enum Alignment { Left, Right, Center };
1259     DocHtmlCell(DocNode *parent,const HtmlAttribList &attribs,bool isHeading) : 
1260        m_isHeading(isHeading), 
1261        m_isFirst(FALSE), m_isLast(FALSE), m_attribs(attribs),
1262        m_rowIdx(-1), m_colIdx(-1) { m_parent = parent; }
1263     bool isHeading() const      { return m_isHeading; }
1264     bool isFirst() const        { return m_isFirst; }
1265     bool isLast() const         { return m_isLast; }
1266     Kind kind() const           { return Kind_HtmlCell; }
1267     void accept(DocVisitor *v)  { CompAccept<DocHtmlCell>::accept(this,v); }
1268     void markFirst(bool v=TRUE) { m_isFirst=v; }
1269     void markLast(bool v=TRUE)  { m_isLast=v; }
1270     const HtmlAttribList &attribs() const { return m_attribs; }
1271     int parse();
1272     int parseXml();
1273     int rowIndex() const        { return m_rowIdx; }
1274     int columnIndex() const     { return m_colIdx; }
1275     int rowSpan() const;
1276     int colSpan() const;
1277     Alignment alignment() const;
1278
1279   private:
1280     void setRowIndex(int idx)    { m_rowIdx = idx; }
1281     void setColumnIndex(int idx) { m_colIdx = idx; }
1282     bool           m_isHeading;
1283     bool           m_isFirst;
1284     bool           m_isLast;
1285     HtmlAttribList m_attribs;
1286     int            m_rowIdx;
1287     int            m_colIdx;
1288 };
1289
1290 /** Node representing a HTML table caption */
1291 class DocHtmlCaption : public CompAccept<DocHtmlCaption>, public DocNode
1292 {
1293   public:
1294     DocHtmlCaption(DocNode *parent,const HtmlAttribList &attribs);
1295     Kind kind() const          { return Kind_HtmlCaption; }
1296     void accept(DocVisitor *v) { CompAccept<DocHtmlCaption>::accept(this,v); }
1297     const HtmlAttribList &attribs() const { return m_attribs; }
1298     int parse();
1299     bool hasCaptionId() const { return m_hasCaptionId; }
1300     QCString file() const     { return m_file;         }
1301     QCString anchor() const   { return m_anchor;       }
1302
1303   private:
1304     HtmlAttribList m_attribs;
1305     bool           m_hasCaptionId;
1306     QCString       m_file;
1307     QCString       m_anchor;
1308 };
1309
1310 /** Node representing a HTML table row */
1311 class DocHtmlRow : public CompAccept<DocHtmlRow>, public DocNode
1312 {
1313     friend class DocHtmlTable;
1314   public:
1315     DocHtmlRow(DocNode *parent,const HtmlAttribList &attribs) : 
1316       m_attribs(attribs), m_visibleCells(-1), m_rowIdx(-1) { m_parent = parent; }
1317     Kind kind() const          { return Kind_HtmlRow; }
1318     uint numCells() const      { return m_children.count(); }
1319     void accept(DocVisitor *v) { CompAccept<DocHtmlRow>::accept(this,v); }
1320     const HtmlAttribList &attribs() const { return m_attribs; }
1321     int parse();
1322     int parseXml(bool header);
1323     bool isHeading() const     { // a row is a table heading if all cells are marked as such
1324                                  bool heading=TRUE;
1325                                  QListIterator<DocNode> it(m_children);
1326                                  DocNode *n;
1327                                  for (;(n=it.current());++it)
1328                                  {
1329                                    if (n->kind()==Kind_HtmlCell)
1330                                    {
1331                                      heading = heading && ((DocHtmlCell*)n)->isHeading();
1332                                    }
1333                                  }
1334                                  return m_children.count()>0 && heading;
1335                                }
1336     void setVisibleCells(int n) { m_visibleCells = n; }
1337     int visibleCells() const    { return m_visibleCells; }
1338     int rowIndex() const        { return m_rowIdx; }
1339
1340   private:
1341     void setRowIndex(int idx)    { m_rowIdx = idx; }
1342     HtmlAttribList m_attribs;
1343     int m_visibleCells;
1344     int m_rowIdx;
1345 };
1346
1347 /** Node representing a HTML table */
1348 class DocHtmlTable : public CompAccept<DocHtmlTable>, public DocNode
1349 {
1350   public:
1351     DocHtmlTable(DocNode *parent,const HtmlAttribList &attribs) 
1352       : m_attribs(attribs) { m_caption=0; m_parent = parent; }
1353     ~DocHtmlTable()         { delete m_caption; }
1354     Kind kind() const       { return Kind_HtmlTable; }
1355     uint numRows() const    { return m_children.count(); }
1356     bool hasCaption()       { return m_caption!=0; }
1357     const HtmlAttribList &attribs() const { return m_attribs; }
1358     int parse();
1359     int parseXml();
1360     uint numColumns() const { return m_numCols; }
1361     void accept(DocVisitor *v);
1362     DocHtmlCaption *caption() const { return m_caption; }
1363     DocHtmlRow *firstRow() const {
1364                              DocNode *n = m_children.getFirst();
1365                              if (n && n->kind()==Kind_HtmlRow) return (DocHtmlRow*)n;
1366                              return 0;
1367                            }
1368
1369   private:
1370     void computeTableGrid();
1371     DocHtmlCaption    *m_caption;
1372     HtmlAttribList     m_attribs;
1373     int m_numCols;
1374 };
1375
1376 /** Node representing an HTML blockquote */
1377 class DocHtmlBlockQuote : public CompAccept<DocHtmlBlockQuote>, public DocNode
1378 {
1379   public:
1380     DocHtmlBlockQuote(DocNode *parent,const HtmlAttribList &attribs)
1381       : m_attribs(attribs) { m_parent = parent; }
1382     Kind kind() const       { return Kind_HtmlBlockQuote; }
1383     int parse();
1384     void accept(DocVisitor *v) { CompAccept<DocHtmlBlockQuote>::accept(this,v); }
1385     const HtmlAttribList &attribs() const { return m_attribs; }
1386
1387   private:
1388     HtmlAttribList m_attribs;
1389 };
1390
1391 /** Root node of a text fragment */
1392 class DocText : public CompAccept<DocText>, public DocNode
1393 {
1394   public:
1395     DocText() {}
1396     Kind kind() const       { return Kind_Text; }
1397     void accept(DocVisitor *v) { CompAccept<DocText>::accept(this,v); }
1398     void parse();
1399     bool isEmpty() const    { return m_children.isEmpty(); }
1400 };
1401
1402 /** Root node of documentation tree */
1403 class DocRoot : public CompAccept<DocRoot>, public DocNode
1404 {
1405   public:
1406     DocRoot(bool indent,bool sl) : m_indent(indent), m_singleLine(sl) {}
1407     Kind kind() const       { return Kind_Root; }
1408     void accept(DocVisitor *v) { CompAccept<DocRoot>::accept(this,v); }
1409     void parse();
1410     bool indent() const { return m_indent; }
1411     bool singleLine() const { return m_singleLine; }
1412     bool isEmpty() const { return m_children.isEmpty(); }
1413
1414   private:
1415     bool m_indent;
1416     bool m_singleLine;
1417 };
1418
1419
1420 #endif