summaryrefslogtreecommitdiffstats
path: root/src/docparser.h
blob: bbe5575d0837be9365e2df5a9856012a78c778e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
/******************************************************************************
 *
 * 
 *
 *
 * Copyright (C) 1997-2002 by Dimitri van Heesch.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation under the terms of the GNU General Public License is hereby 
 * granted. No representations are made about the suitability of this software 
 * for any purpose. It is provided "as is" without express or implied warranty.
 * See the GNU General Public License for more details.
 *
 * Documents produced by Doxygen are derivative works derived from the
 * input used in their production; they are not affected by this license.
 *
 */

#ifndef _DOCPARSER_H
#define _DOCPARSER_H

#include <qlist.h>
#include <qstrlist.h>
#include <stdio.h>

#include "docvisitor.h"
#include "doctokenizer.h"

//---------------------------------------------------------------------------

/*! Main entry point */
void validatingParseDoc(const char *fileName,int startLine,const char *input);

//---------------------------------------------------------------------------

/*! Abstract node interface with type information. */
class DocNode
{
  public:
    enum Kind { Kind_Root           = 0, 
                Kind_Word           = 1, 
                Kind_WhiteSpace     = 2, 
                Kind_Para           = 3, 
                Kind_AutoList       = 4, 
                Kind_AutoListItem   = 5,
                Kind_Symbol         = 6,
                Kind_URL            = 7,
                Kind_StyleChange    = 8,
                Kind_SimpleSect     = 9,
                Kind_Title          = 10,
                Kind_SimpleList     = 11,
                Kind_SimpleListItem = 12,
                Kind_Section        = 13,
                Kind_Verbatim       = 14,
                Kind_XRefItem       = 15,
                Kind_HtmlList       = 16,
                Kind_HtmlListItem   = 17,
                Kind_HtmlPre        = 18,
                Kind_HtmlDescList   = 19,
                Kind_HtmlDescData   = 20,
                Kind_HtmlDescTitle  = 21,
                Kind_HtmlTable      = 22,
                Kind_HtmlRow        = 23,
                Kind_HtmlCell       = 24,
                Kind_HtmlCaption    = 25,
                Kind_LineBreak      = 26,
                Kind_HorRuler       = 27,
                Kind_Anchor         = 28,
                Kind_IndexEntry     = 29,
                Kind_Internal       = 30,
                Kind_HRef           = 31,
                Kind_Copy           = 32,
                Kind_Include        = 33,
                Kind_IncOperator    = 34,
                Kind_HtmlHeader     = 35,
                Kind_Image          = 36,
                Kind_DotFile        = 37,
                Kind_Link           = 38,
                Kind_Ref            = 39,
                Kind_Formula        = 40,
                Kind_SecRefItem     = 41,
                Kind_SecRefList     = 42,
                Kind_Language       = 43
              };
    virtual ~DocNode() {}
    virtual Kind kind() const = 0;
    virtual DocNode *parent() const = 0;
    virtual void accept(DocVisitor *) = 0;
};

/*! Default accept implementation for compound nodes in the abstract
 *  syntax tree.
 */
template<class T> class CompAccept
{
  public:
    CompAccept() { m_children.setAutoDelete(TRUE); }
    void accept(T *obj, DocVisitor *v) 
    { 
      v->visitPre(obj); 
      QListIterator<DocNode> cli(m_children);
      DocNode *n;
      for (cli.toFirst();(n=cli.current());++cli) n->accept(v);
      v->visitPost(obj); 
    }
  
  protected:
    QList<DocNode> m_children;
};


/*! Node representing a word 
 */
// TODO: check for word starting \# or having () and try to link to them
class DocWord : public DocNode
{
  public:
    DocWord(DocNode *parent,const QCString &word) : 
      m_parent(parent), m_word(word) {}
    QCString word() const { return m_word; }
    Kind kind() const { return Kind_Word; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { v->visit(this); }

  private:
    DocNode *m_parent;
    QCString m_word;
};

/*! Node representing an URL (or email address) */
class DocURL : public DocNode
{
  public:
    DocURL(DocNode *parent,const QCString &url) : 
      m_parent(parent), m_url(url) {}
    QCString url() const { return m_url; }
    Kind kind() const { return Kind_URL; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { v->visit(this); }

  private:
    DocNode *m_parent;
    QCString m_url;
};

/*! Node representing a line break */
class DocLineBreak : public DocNode
{
  public:
    DocLineBreak(DocNode *parent) : 
      m_parent(parent) {}
    Kind kind() const { return Kind_LineBreak; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { v->visit(this); }

  private:
    DocNode *m_parent;
};

/*! Node representing a horizonal ruler */
class DocHorRuler : public DocNode
{
  public:
    DocHorRuler(DocNode *parent) : 
      m_parent(parent) {}
    Kind kind() const { return Kind_HorRuler; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { v->visit(this); }

  private:
    DocNode *m_parent;
};

/*! Node representing an anchor */
// TODO: not just ignore </a>...
class DocAnchor : public DocNode
{
  public:
    DocAnchor(DocNode *parent,const QCString &anchor) : 
      m_parent(parent), m_anchor(anchor) {}
    Kind kind() const { return Kind_Anchor; }
    DocNode *parent() const { return m_parent; }
    QCString anchor() const { return m_anchor; }
    void accept(DocVisitor *v) { v->visit(this); }

  private:
    DocNode *m_parent;
    QCString m_anchor;
};

/*! Node representing a style change */
class DocStyleChange : public DocNode
{
  public:
    enum Style { Bold, Italic, Code, Center, Small, 
                 Subscript, Superscript 
               };
    DocStyleChange(DocNode *parent,uint position,Style s,bool enable) : 
      m_parent(parent), m_position(position), m_style(s), m_enable(enable) {}
    Kind kind() const { return Kind_StyleChange; }
    Style style() const { return m_style; }
    bool enable() const { return m_enable; }
    uint position() const { return m_position; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { v->visit(this); }

  private:
    DocNode *m_parent;
    uint m_position;
    Style m_style;
    bool m_enable;
};

/*! Node representing a special symbol */
class DocSymbol : public DocNode
{
  public:
    enum SymType { Unknown=0, BSlash,At,Less,Greater,Amp,Dollar,Hash,Percent, 
                   Copy, Apos, Quot, Uml, Acute, Grave, Circ, Tilde, Szlig,
                   Cedil, Ring, Nbsp
                 };
    DocSymbol(DocNode *parent,SymType s,char letter='\0') : 
      m_parent(parent), m_symbol(s), m_letter(letter) {}
    SymType symbol() const { return m_symbol; }
    char letter() const { return m_letter; }
    Kind kind() const { return Kind_Symbol; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { v->visit(this); }
    static SymType decodeSymbol(const QCString &symName,char *letter);

  private:
    DocNode *m_parent;
    SymType m_symbol;
    char m_letter;
};

/*! Node representing some amount of white space */
class DocWhiteSpace : public DocNode
{
  public:
    DocWhiteSpace(DocNode *parent,const QCString &chars) : 
      m_parent(parent), m_chars(chars) {}
    Kind kind() const { return Kind_WhiteSpace; }
    QCString chars() const { return m_chars; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { v->visit(this); }
  private:
    DocNode *m_parent;
    QCString m_chars;
};

/*! Verbatim, unparsed text fragment */
class DocVerbatim : public DocNode
{
  public:
    enum Type { Code, HtmlOnly, LatexOnly, Verbatim };
    DocVerbatim(DocNode *parent,const QCString &text, Type t) : 
      m_parent(parent), m_text(text), m_type(t) {}
    Kind kind() const { return Kind_Verbatim; }
    Type type() const { return m_type; }
    QCString text() const { return m_text; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { v->visit(this); }

  private:
    DocNode *m_parent;
    QCString m_text;
    Type m_type;
};

/*! "to be copied" documentation block */
// TODO: Find the matching block and insert it.
//       (This should be a separate pass, or can we do it in one pass?).
class DocCopy : public DocNode
{
  public:
    DocCopy(DocNode *parent,const QCString &link) : 
      m_parent(parent), m_link(link) {}
    Kind kind() const { return Kind_Copy; }
    QCString link() const { return m_link; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { v->visit(this); }

  private:
    DocNode *m_parent;
    QCString m_link;
};

/*! include/dontinclude block */
// TODO: locate the file and handle it.
class DocInclude : public DocNode
{
  public:
    enum Type { Include, DontInclude, VerbInclude, HtmlInclude };
    DocInclude(DocNode *parent,const QCString &file,Type t) : 
      m_parent(parent), m_file(file), m_type(t) {}
    Kind kind() const { return Kind_Include; }
    QCString file() const { return m_file; }
    Type type() const { return m_type; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { v->visit(this); }

  private:
    DocNode *m_parent;
    QCString m_file;
    Type     m_type;
};

/*! include/dontinclude operator block */
// TODO: check which file we should be working on and do the operation
class DocIncOperator : public DocNode
{
  public:
    enum Type { Line, SkipLine, Skip, Until };
    DocIncOperator(DocNode *parent,Type t,const QCString &pat) : 
      m_parent(parent), m_type(t), m_pattern(pat) {}
    Kind kind() const { return Kind_IncOperator; }
    Type type() const { return m_type; }
    QCString pattern() const { return m_pattern; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { v->visit(this); }

  private:
    DocNode *m_parent;
    Type m_type;
    QCString m_pattern;
};

/*! Item of a cross-referenced list */
// TODO: lookup id and insert parsed documentation 
// (second pass to avoid context saving in the scanner?)
class DocXRefItem : public DocNode
{
  public:
    enum Type { Bug, Test, Todo, Deprecated };
    DocXRefItem(DocNode *parent,int id,Type t) : 
      m_parent(parent), m_id(id), m_type(t) {}
    Kind kind() const { return Kind_XRefItem; }
    Type type() const { return m_type; }
    int id() const { return m_id; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { v->visit(this); }

  private:
    DocNode *m_parent;
    int  m_id;
    Type m_type;
};

/*! Item of a cross-referenced list */
class DocFormula : public DocNode
{
  public:
    DocFormula(DocNode *parent,int id) : 
      m_parent(parent), m_id(id) {}
    Kind kind() const { return Kind_Formula; }
    int id() const { return m_id; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { v->visit(this); }

  private:
    DocNode *m_parent;
    int  m_id;
};

/*! Node representing a entry in the index */
class DocIndexEntry : public CompAccept<DocIndexEntry>, public DocNode
{
  public:
    DocIndexEntry(DocNode *parent) : m_parent(parent) { }
    Kind kind() const { return Kind_IndexEntry; }
    int parse();
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { CompAccept<DocIndexEntry>::accept(this,v); }

  private:
    DocNode *m_parent;
};

/*! Auto List */
class DocAutoList : public CompAccept<DocAutoList>, public DocNode
{
  public:
    DocAutoList(DocNode *parent,int indent,bool isEnumList) : 
      m_parent(parent), m_indent(indent), m_isEnumList(isEnumList) {}
    Kind kind() const { return Kind_AutoList; }
    int parse();
    bool isEnumList() const { return m_isEnumList; }
    int  indent() const { return m_indent; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { CompAccept<DocAutoList>::accept(this,v); }

  private:
    DocNode *m_parent;
    int m_indent;
    bool m_isEnumList;
};


/*! Simple section title */
class DocTitle : public CompAccept<DocTitle>, public DocNode
{
  public:
    DocTitle(DocNode *parent) : m_parent(parent) {}
    void parse();
    Kind kind() const { return Kind_Title; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { CompAccept<DocTitle>::accept(this,v); }

  private:
    DocNode *m_parent;
};

/*! Image */
class DocImage : public CompAccept<DocImage>, public DocNode
{
  public:
    enum Type { Html, Latex, Rtf };
    DocImage(DocNode *parent,const QCString &name,Type t) : 
      m_parent(parent), m_name(name), m_type(t) {}
    void parse();
    Kind kind() const { return Kind_Image; }
    Type type() const { return m_type; }
    QCString name() const { return m_name; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { CompAccept<DocImage>::accept(this,v); }

  private:
    DocNode  *m_parent;
    QCString  m_name;
    Type      m_type;
};

/*! Node representing a dot file */
class DocDotFile : public CompAccept<DocDotFile>, public DocNode
{
  public:
    DocDotFile(DocNode *parent,const QCString &name) : 
      m_parent(parent), m_name(name) { }
    void parse();
    Kind kind() const { return Kind_DotFile; }
    QCString name() const { return m_name; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { CompAccept<DocDotFile>::accept(this,v); }

  private:
    DocNode  *m_parent;
    QCString  m_name;
};

/*! Node representing a link to some item */
// TODO: resolve link
class DocLink : public CompAccept<DocLink>, public DocNode
{
  public:
    DocLink(DocNode *parent,const QCString &target) : 
      m_parent(parent), m_target(target) {}
    QCString parse(bool);
    Kind kind() const { return Kind_Link; }
    QCString target() const { return m_target; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { CompAccept<DocLink>::accept(this,v); }

  private:
    DocNode  *m_parent;
    QCString  m_target;
};

/*! Node representing a reference to some item */
// TODO: resolve reference
class DocRef : public CompAccept<DocRef>, public DocNode
{
  public:
    DocRef(DocNode *parent,const QCString &target) : 
      m_parent(parent), m_target(target) {}
    void parse();
    Kind kind() const       { return Kind_Ref; }
    QCString target() const { return m_target; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { CompAccept<DocRef>::accept(this,v); }

  private:
    DocNode *      m_parent;
    QCString       m_target;
};

/*! Simple section */
class DocSimpleSect : public DocNode
{
  public:
    enum Type 
    {  
       Unknown, See, Return, Author, Version, Since, Date,
       Note, Warning, Pre, Post, Invar, Remark, Attention, User,
       Param, RetVal, Exception 
    };
    DocSimpleSect(DocNode *parent,Type t); 
    virtual ~DocSimpleSect();
    int parse(bool userTitle);
    Kind kind() const { return Kind_SimpleSect; }
    void addParam(const QCString &name);
    const QStrList &parameters() const { return m_params; }
    Type sectionType() const { return m_type; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v);

  private:
    DocNode *       m_parent;
    DocPara *       m_paragraph;
    Type            m_type;
    DocTitle *      m_title;
    QStrList        m_params;
};

/*! Language specific node */
class DocLanguage : public CompAccept<DocLanguage>, public DocNode
{
  public:
    DocLanguage(DocNode *parent,const QCString &id) : 
      m_parent(parent), m_id(id) {}
    QCString id() const { return m_id; }
    int parse();
    Kind kind() const { return Kind_Language; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { CompAccept<DocLanguage>::accept(this,v); }
    
  private:
    DocNode * m_parent;
    QCString  m_id;
};

/*! Hypertext reference */
class DocHRef : public CompAccept<DocHRef>, public DocNode
{
  public:
    DocHRef(DocNode *parent,const QCString &url) : 
      m_parent(parent), m_url(url) {}
    int parse();
    QCString url() const { return m_url; }
    Kind kind() const { return Kind_HRef; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { CompAccept<DocHRef>::accept(this,v); }

  private:
    DocNode *           m_parent;
    QCString            m_url;
};

/*! Html heading */
class DocHtmlHeader : public CompAccept<DocHtmlHeader>, public DocNode
{
  public:
    DocHtmlHeader(DocNode *parent,int level) : 
       m_parent(parent), m_level(level) {}
    int parse();
    int level() const { return m_level; }
    Kind kind() const { return Kind_HtmlHeader; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { CompAccept<DocHtmlHeader>::accept(this,v); }

  private:
    DocNode *           m_parent;
    int                 m_level;
};

/*! Html description item */
class DocHtmlDescTitle : public CompAccept<DocHtmlDescTitle>, public DocNode
{
  public:
    DocHtmlDescTitle(DocNode *parent) : m_parent(parent) {}
    int parse();
    Kind kind() const { return Kind_HtmlDescTitle; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { CompAccept<DocHtmlDescTitle>::accept(this,v); }

  private:
    DocNode *           m_parent;
};

/*! Html description list */
class DocHtmlDescList : public CompAccept<DocHtmlDescList>, public DocNode
{
  public:
    DocHtmlDescList(DocNode *parent) : m_parent(parent) {}
    int parse();
    Kind kind() const { return Kind_HtmlDescList; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { CompAccept<DocHtmlDescList>::accept(this,v); }

  private:
    DocNode *       m_parent;
};

/*! Normal section */
class DocSection : public CompAccept<DocSection>, public DocNode
{
  public:
    DocSection(DocNode *parent,int level,const QCString &id) :
      m_parent(parent), m_level(level), m_id(id) {} 
    int parse();
    Kind kind() const { return Kind_Section; }
    int level() const { return m_level; }
    QCString id() const { return m_id; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { CompAccept<DocSection>::accept(this,v); }

  private:
    DocNode  *m_parent;
    int       m_level;
    QCString  m_id;
};

/*! Reference to a section */
class DocSecRefItem : public CompAccept<DocSecRefItem>, public DocNode
{
  public:
    DocSecRefItem(DocNode *parent,const QCString &target) : 
      m_parent(parent), m_target(target) {}
    void parse();
    Kind kind() const { return Kind_SecRefItem; }
    QCString target() const { return m_target; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { CompAccept<DocSecRefItem>::accept(this,v); }

  private:
    DocNode  *m_parent;
    QCString  m_target;
};

/*! List of section references */
class DocSecRefList : public CompAccept<DocSecRefList>, public DocNode
{
  public:
    DocSecRefList(DocNode *parent) : m_parent(parent) {}
    void parse();
    Kind kind() const { return Kind_SecRefList; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { CompAccept<DocSecRefList>::accept(this,v); }

  private:
    DocNode  *m_parent;
};

/*! Internal section of documentation */
// TODO: decide if it should be visible
// Separate pass to remove internal parts?
class DocInternal : public CompAccept<DocInternal>, public DocNode
{
  public:
    DocInternal(DocNode *parent) : m_parent(parent) {}
    int parse();
    Kind kind() const { return Kind_Internal; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { CompAccept<DocInternal>::accept(this,v); }

  private:
    DocNode  *m_parent;
};

/*! Simple list */
class DocSimpleList : public CompAccept<DocSimpleList>, public DocNode
{
  public:
    DocSimpleList(DocNode *parent) : m_parent(parent) {}
    Kind kind() const { return Kind_SimpleList; }
    int parse();
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { CompAccept<DocSimpleList>::accept(this,v); }

  private:
    DocNode *m_parent;
};

/*! Html list */
class DocHtmlList : public CompAccept<DocHtmlList>, public DocNode
{
  public:
    enum Type { Unordered, Ordered };
    DocHtmlList(DocNode *parent,Type t) : m_parent(parent), m_type(t) {}
    Kind kind() const { return Kind_HtmlList; }
    Type type() const { return m_type; }
    int parse();
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { CompAccept<DocHtmlList>::accept(this,v); }

  private:
    DocNode *m_parent;
    Type m_type;
};

/*! Paragraph in the documentation tree */
class DocPara : public CompAccept<DocPara>, public DocNode
{
  public:
    DocPara(DocNode *parent) : m_parent(parent) {}
    int parse();
    Kind kind() const { return Kind_Para; }
    DocNode *parent() const { return m_parent; }
    bool isEmpty() const { return m_children.isEmpty(); }
    void accept(DocVisitor *v) { CompAccept<DocPara>::accept(this,v); }

    int handleCommand(const QCString &cmdName);
    int handleHtmlStartTag(const QCString &tagName,const QList<Option> &tagOptions);
    int handleHtmlEndTag(const QCString &tagName);
    int handleSimpleSection(DocSimpleSect::Type t);
    int handleXRefItem(DocXRefItem::Type t);
    int handleParamSection(const QCString &cmdName,DocSimpleSect::Type t);
    //void handleStyleEnter(DocStyleChange::Style t);
    //void handleStyleLeave(DocStyleChange::Style t,const char *tagName);
    //void handlePendingStyleCommands();
    void handleIncludeOperator(const QCString &cmdName,DocIncOperator::Type t);
    void handleImage(const QCString &cmdName);
    void handleDotFile(const QCString &cmdName);
    void handleInclude(const QCString &cmdName,DocInclude::Type t);
    void handleLink(const QCString &cmdName,bool isJavaLink);
    void handleRef(const QCString &cmdName);
    int handleLanguageSwitch();


  private:
    DocNode *m_parent;
    QCString m_sectionId;
};

/*! Node representing an item of a auto list */
class DocAutoListItem : public DocNode
{
  public:
    DocAutoListItem(DocNode *parent) : m_parent(parent) 
    { m_paragraph=new DocPara(this); }
    int parse();
    virtual ~DocAutoListItem() { delete m_paragraph; }
    Kind kind() const { return Kind_AutoListItem; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) 
    { 
      v->visitPre(this); 
      m_paragraph->accept(v);
      v->visitPost(this); 
    }
  private:
    DocNode *m_parent;
    DocPara *m_paragraph;
};

/*! Simple list item */
class DocSimpleListItem : public DocNode
{
  public:
    DocSimpleListItem(DocNode *parent) : m_parent(parent) 
    { m_paragraph=new DocPara(this); }
    int parse();
    virtual ~DocSimpleListItem() { delete m_paragraph; }
    Kind kind() const { return Kind_SimpleListItem; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v)
    {
      v->visitPre(this); 
      m_paragraph->accept(v);
      v->visitPost(this); 
    }

  private:
    DocNode *m_parent;
    DocPara *m_paragraph;
};

/*! Html list item */
class DocHtmlListItem : public CompAccept<DocHtmlListItem>, public DocNode
{
  public:
    DocHtmlListItem(DocNode *parent) : m_parent(parent) {}
    int parse();
    Kind kind() const { return Kind_HtmlListItem; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { CompAccept<DocHtmlListItem>::accept(this,v); }

  private:
    DocNode *m_parent;
};

/*! Html description data */
class DocHtmlDescData : public CompAccept<DocHtmlDescData>, public DocNode
{
  public:
    DocHtmlDescData(DocNode *parent) : m_parent(parent) {}
    int parse();
    Kind kind() const { return Kind_HtmlDescData; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { CompAccept<DocHtmlDescData>::accept(this,v); }

  private:
    DocNode *           m_parent;
};


/*! Html list item */
class DocHtmlPre : public CompAccept<DocHtmlPre>, public DocNode
{
  public:
    DocHtmlPre(DocNode *parent) : m_parent(parent) {}
    int parse();
    Kind kind() const { return Kind_HtmlPre; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { CompAccept<DocHtmlPre>::accept(this,v); }

  private:
    DocNode *m_parent;
};

/*! Html table cell */
class DocHtmlCell : public CompAccept<DocHtmlCell>, public DocNode
{
  public:
    DocHtmlCell(DocNode *parent,bool isHeading) : 
       m_parent(parent), m_isHeading(isHeading) {}
    int parse();
    bool isHeading() const { return m_isHeading; }
    Kind kind() const { return Kind_HtmlCell; }
    DocNode *parent() const { return m_parent; }
    uint numCells() const { return m_children.count(); }
    void accept(DocVisitor *v) { CompAccept<DocHtmlCell>::accept(this,v); }

  private:
    DocNode *      m_parent;
    bool           m_isHeading;
};

/*! Html table caption */
class DocHtmlCaption : public CompAccept<DocHtmlCaption>, public DocNode
{
  public:
    DocHtmlCaption(DocNode *parent) : m_parent(parent) {}
    int parse();
    Kind kind() const { return Kind_HtmlCaption; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { CompAccept<DocHtmlCaption>::accept(this,v); }

  private:
    DocNode * m_parent;
};

/*! Html table row */
class DocHtmlRow : public CompAccept<DocHtmlRow>, public DocNode
{
  public:
    DocHtmlRow(DocNode *parent) : m_parent(parent) {}
    int parse();
    Kind kind() const { return Kind_HtmlRow; }
    DocNode *parent() const { return m_parent; }
    uint numCells() const { return m_children.count(); }
    void accept(DocVisitor *v) { CompAccept<DocHtmlRow>::accept(this,v); }

  private:
    DocNode * m_parent;
};

/*! Html table */
class DocHtmlTable : public CompAccept<DocHtmlTable>, public DocNode
{
  public:
    DocHtmlTable(DocNode *parent) : m_parent(parent) { m_caption=0; }
    ~DocHtmlTable() { delete m_caption; }
    int parse();
    Kind kind() const { return Kind_HtmlTable; }
    DocNode *parent() const { return m_parent; }
    uint numRows() const { return m_children.count(); }
    uint numCols() const
    {
      uint cols=0;
      QListIterator<DocNode> cli(m_children);
      DocNode *n;
      for (cli.toFirst();(n=cli.current());++cli)
      {
        ASSERT(n->kind()==DocNode::Kind_HtmlRow);
        cols=QMAX(cols,((DocHtmlRow *)n)->numCells());
      }
      return cols;
    }
    void accept(DocVisitor *v) { CompAccept<DocHtmlTable>::accept(this,v); }

  private:
    DocNode *          m_parent;
    DocHtmlCaption    *m_caption;
};


/*! Root node of documentation tree */
class DocRoot : public CompAccept<DocRoot>, public DocNode
{
  public:
    DocRoot() {}
    void parse();
    Kind kind() const { return Kind_Root; }
    DocNode *parent() const { return 0; }
    void accept(DocVisitor *v) { CompAccept<DocRoot>::accept(this,v); }
};


#endif