summaryrefslogtreecommitdiffstats
path: root/src/docparser.h
blob: 1a79812d84536119cc10cae85ba2d80ac32f8768 (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
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
/******************************************************************************
 *
 * 
 *
 *
 * 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 <stdio.h>

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

#include "docvisitor.h"
#include "htmlattrib.h"

class DocNode;
class MemberDef;

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

/*! Main entry point for the documentation parser.
 *  @param fileName  File in which the documentation block is found (or the
 *                   name of the example file in case isExample is TRUE).
 *  @param startLine Line at which the documentation block is found.
 *  @param context   Class or namespace in which of the item to which this
 *                   block belongs.
 *  @param md        Member definition to which the documentation belongs.
 *                   Can be 0.
 *  @param input     String representation of the documentation block.
 *  @param isExample TRUE if the documentation belongs to an example.
 *  @returns         Root node of the abstract syntax tree. Ownership of the
 *                   pointer is handed over to the caller.
 */
DocNode *validatingParseDoc(const char *fileName,int startLine,
                            const char *context, MemberDef *md,
                            const char *input,bool isExample);

/*! Main entry point for parsing simple text fragments. These 
 *  fragments are limited to words, whitespace and symbols.
 */
DocNode *validatingParseText(const char *input);

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

/*! @brief Abstract node interface with type information. */
class DocNode
{
  public:
    /*! Available node types. */
    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_Include        = 32,
                Kind_IncOperator    = 33,
                Kind_HtmlHeader     = 34,
                Kind_Image          = 35,
                Kind_DotFile        = 36,
                Kind_Link           = 37,
                Kind_Ref            = 38,
                Kind_Formula        = 39,
                Kind_SecRefItem     = 40,
                Kind_SecRefList     = 41,
                Kind_Language       = 42,
                Kind_LinkedWord     = 43,
                Kind_ParamSect      = 44,
                Kind_ParamList      = 45,
                Kind_InternalRef    = 46,
                Kind_Copy           = 47,
                Kind_Text           = 48
              };
    /*! Destructor. */
    virtual ~DocNode() {}
    /*! Returns the kind of node. Provides runtime type information */
    virtual Kind kind() const = 0;
    /*! Returns the parent of this node or 0 for the root node. */
    virtual DocNode *parent() const = 0;
    /*! Acceptor function for node visitors. Part of the visitor pattern. 
     *  @param v Abstract visitor.
     */
    virtual void accept(DocVisitor *v) = 0;
};

/*! @brief 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;
};


/*! @brief Node representing a word 
 */
class DocWord : public DocNode
{
  public:
    DocWord(DocNode *parent,const QString &word) : 
      m_parent(parent), m_word(word) {}
    QString 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;
    QString  m_word;
};

/*! @brief Node representing a word that can be linked to something
 */
class DocLinkedWord : public DocNode
{
  public:
    DocLinkedWord(DocNode *parent,const QString &word,
                  const QString &ref,const QString &file,
                  const QString &anchor) : 
      m_parent(parent), m_word(word), m_ref(ref), 
      m_file(file), m_anchor(anchor) {}
    QString word() const      { return m_word; }
    Kind kind() const          { return Kind_Word; }
    DocNode *parent() const    { return m_parent; }
    QString file() const      { return m_file; }
    QString ref() const       { return m_ref; }
    QString anchor() const    { return m_anchor; }
    void accept(DocVisitor *v) { v->visit(this); }

  private:
    DocNode *m_parent;
    QString  m_word;
    QString  m_ref;
    QString  m_file;
    QString  m_anchor;
};

/*! @brief Node representing an URL (or email address) */
class DocURL : public DocNode
{
  public:
    DocURL(DocNode *parent,const QString &url) : 
      m_parent(parent), m_url(url) {}
    QString 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;
    QString  m_url;
};

/*! @brief 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;
};

/*! @brief 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;
};

/*! @brief Node representing an anchor */
class DocAnchor : public DocNode
{
  public:
    DocAnchor(DocNode *parent,const QString &id,bool newAnchor);
    Kind kind() const { return Kind_Anchor; }
    DocNode *parent() const { return m_parent; }
    QString anchor() const { return m_anchor; }
    QString file() const { return m_file; }
    void accept(DocVisitor *v) { v->visit(this); }

  private:
    DocNode *m_parent;
    QString  m_anchor;
    QString  m_file;
};

/*! @brief 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;
};

/*! @brief 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 QString &symName,char *letter);

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

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

/*! @brief Node representing a verbatim, unparsed text fragment */
class DocVerbatim : public DocNode
{
  public:
    enum Type { Code, HtmlOnly, LatexOnly, Verbatim };
    DocVerbatim(DocNode *parent,const QString &context,
                const QString &text, Type t,bool isExample,
                const QString &exampleFile) : 
      m_parent(parent), m_context(context), m_text(text), m_type(t),
      m_isExample(isExample), m_exampleFile(exampleFile) {}
    Kind kind() const { return Kind_Verbatim; }
    Type type() const { return m_type; }
    QString text() const { return m_text; }
    QString context() const { return m_context; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { v->visit(this); }
    bool isExample() const { return m_isExample; }
    QString exampleFile() const { return m_exampleFile; }

  private:
    DocNode *m_parent;
    QString  m_context;
    QString  m_text;
    Type     m_type;
    bool     m_isExample;
    QString  m_exampleFile;
};

/*! @brief Node representing an included text block from file */
class DocInclude : public DocNode
{
  public:
    enum Type { Include, DontInclude, VerbInclude, HtmlInclude };
    DocInclude(DocNode *parent,const QString &file,
               const QString context, Type t,
               bool isExample,const QString exampleFile) : 
      m_parent(parent), m_file(file), m_context(context), m_type(t),
      m_isExample(isExample), m_exampleFile(exampleFile) {}
    Kind kind() const           { return Kind_Include; }
    QString file() const        { return m_file; }
    Type type() const           { return m_type; }
    QString text() const        { return m_text; }
    QString context() const     { return m_context; }
    DocNode *parent() const     { return m_parent; }
    bool isExample() const      { return m_isExample; }
    QString exampleFile() const { return m_exampleFile; }
    void accept(DocVisitor *v)  { v->visit(this); }
    void parse();

  private:
    DocNode *m_parent;
    QString  m_file;
    QString  m_context;
    QString  m_text;
    Type     m_type;
    bool     m_isExample;
    QString  m_exampleFile;
};

/*! @brief Node representing a include/dontinclude operator block */
class DocIncOperator : public DocNode
{
  public:
    enum Type { Line, SkipLine, Skip, Until };
    DocIncOperator(DocNode *parent,Type t,const QString &pat,
                   const QString &context,bool isExample,const QString &exampleFile) : 
      m_parent(parent), m_type(t), m_pattern(pat), m_context(context), 
      m_isFirst(FALSE), m_isLast(FALSE),
      m_isExample(isExample), m_exampleFile(exampleFile) {}
    Kind kind() const           { return Kind_IncOperator; }
    Type type() const           { return m_type; }
    QString text() const        { return m_text; }
    QString pattern() const     { return m_pattern; }
    QString context() const     { return m_context; }
    DocNode *parent() const     { return m_parent; }
    void accept(DocVisitor *v)  { v->visit(this); }
    bool isFirst() const        { return m_isFirst; }
    bool isLast() const         { return m_isLast; }
    void markFirst(bool v=TRUE) { m_isFirst = v; }
    void markLast(bool v=TRUE)  { m_isLast = v; }
    bool isExample() const      { return m_isExample; }
    QString exampleFile() const { return m_exampleFile; }
    void parse();

  private:
    DocNode *m_parent;
    Type     m_type;
    QString  m_text;
    QString  m_pattern;
    QString  m_context;
    bool     m_isFirst;
    bool     m_isLast;
    bool     m_isExample;
    QString  m_exampleFile;
};

/*! @brief Node representing an item of a cross-referenced list */
class DocFormula : public DocNode
{
  public:
    DocFormula(DocNode *parent,int id);
    Kind kind() const       { return Kind_Formula; }
    QString name() const   { return m_name; }
    QString text() const   { return m_text; }
    int id() const          { return m_id; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { v->visit(this); }

  private:
    DocNode *m_parent;
    QString  m_name;
    QString  m_text;
    int      m_id;
};

/*! @brief Node representing an entry in the index. */
class 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) { v->visit(this); }
    QString entry() { return m_entry; }

  private:
    DocNode *m_parent;
    QString  m_entry;
};

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

/*! @brief Node representing a entry in the index. */
class DocCopy : public CompAccept<DocCopy>, public DocNode
{
  public:
    DocCopy(DocNode *parent,const QString &link) 
      : m_parent(parent), m_link(link) { }
    Kind kind() const { return Kind_IndexEntry; }
    QString link() const { return m_link; }
    void parse();
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { CompAccept<DocCopy>::accept(this,v); }

  private:
    DocNode *m_parent;
    QString  m_link;
};

/*! @brief Node representing an 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;
};


/*! @brief Node representing a 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;
};

/*! @brief Node representing an item of a cross-referenced list */
class DocXRefItem : public CompAccept<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; }
    QString file() const { return m_file; }
    QString anchor() const { return m_anchor; }
    QString title() const { return m_title; }
    void parse();
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { CompAccept<DocXRefItem>::accept(this,v); }

  private:
    DocNode *m_parent;
    int      m_id;
    Type     m_type;
    QString  m_file;
    QString  m_anchor;
    QString  m_title;
};

/*! @brief Node representing an image */
class DocImage : public CompAccept<DocImage>, public DocNode
{
  public:
    enum Type { Html, Latex, Rtf };
    DocImage(DocNode *parent,const QString &name,Type t) : 
      m_parent(parent), m_name(name), m_type(t) {}
    Kind kind() const          { return Kind_Image; }
    Type type() const          { return m_type; }
    QString name() const      { return m_name; }
    DocNode *parent() const    { return m_parent; }
    bool hasCaption() const    { return !m_children.isEmpty(); }
    QString width() const     { return m_width; }
    QString height() const    { return m_height; }
    void accept(DocVisitor *v) { CompAccept<DocImage>::accept(this,v); }
    void parse();

  private:
    DocNode *m_parent;
    QString  m_name;
    Type     m_type;
    QString  m_width;
    QString  m_height;
};

/*! @brief Node representing a dot file */
class DocDotFile : public CompAccept<DocDotFile>, public DocNode
{
  public:
    DocDotFile(DocNode *parent,const QString &name) : 
      m_parent(parent), m_name(name) { }
    void parse();
    Kind kind() const          { return Kind_DotFile; }
    QString name() const      { return m_name; }
    QString file() const      { return m_file; }
    bool hasCaption() const    { return !m_children.isEmpty(); }
    QString width() const     { return m_width; }
    QString height() const    { return m_height; }
    DocNode *parent() const    { return m_parent; }
    void accept(DocVisitor *v) { CompAccept<DocDotFile>::accept(this,v); }

  private:
    DocNode *m_parent;
    QString  m_name;
    QString  m_file;
    QString  m_width;
    QString  m_height;
};

/*! @brief Node representing a link to some item */
class DocLink : public CompAccept<DocLink>, public DocNode
{
  public:
    DocLink(DocNode *parent,const QString &target);
    QString parse(bool);
    Kind kind() const { return Kind_Link; }
    QString file() const { return m_file; }
    QString ref() const { return m_ref; }
    QString anchor() const { return m_anchor; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { CompAccept<DocLink>::accept(this,v); }

  private:
    DocNode *m_parent;
    QString  m_file;
    QString  m_ref;
    QString  m_anchor;
};

/*! @brief Node representing a reference to some item */
class DocRef : public CompAccept<DocRef>, public DocNode
{
  public:
    DocRef(DocNode *parent,const QString &target);
    void parse();
    Kind kind() const            { return Kind_Ref; }
    QString file() const        { return m_file; }
    QString ref() const         { return m_ref; }
    QString anchor() const      { return m_anchor; }
    QString targetTitle() const { return m_text; }
    DocNode *parent() const      { return m_parent; }
    bool hasLinkText() const     { return !m_children.isEmpty(); }
    bool refToAnchor() const     { return m_refToAnchor; }
    bool refToSection() const    { return m_refToSection; }
    void accept(DocVisitor *v)   { CompAccept<DocRef>::accept(this,v); }

  private:
    DocNode * m_parent;
    bool      m_refToSection;
    bool      m_refToAnchor;
    QString   m_file;
    QString   m_ref;
    QString   m_anchor;
    QString   m_text;
};

/*! @brief Node representing an internal reference to some item */
class DocInternalRef : public CompAccept<DocInternalRef>, public DocNode
{
  public:
    DocInternalRef(DocNode *parent,const QString &target);
    void parse();
    Kind kind() const            { return Kind_Ref; }
    QString file() const        { return m_file; }
    QString anchor() const      { return m_anchor; }
    DocNode *parent() const      { return m_parent; }
    void accept(DocVisitor *v)   { CompAccept<DocInternalRef>::accept(this,v); }

  private:
    DocNode * m_parent;
    QString   m_file;
    QString   m_anchor;
};

/*! @brief Node representing a Language specific section */
class DocLanguage : public CompAccept<DocLanguage>, public DocNode
{
  public:
    DocLanguage(DocNode *parent,const QString &id) : 
      m_parent(parent), m_id(id) {}
    QString 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;
    QString   m_id;
};

/*! @brief Node representing a Hypertext reference */
class DocHRef : public CompAccept<DocHRef>, public DocNode
{
  public:
    DocHRef(DocNode *parent,const QString &url) : 
      m_parent(parent), m_url(url) {}
    int parse();
    QString 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;
    QString   m_url;
};

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

  private:
    DocNode *     m_parent;
    int           m_level;
    HtmlAttribList m_attribs;
};

/*! @brief Node representing a Html description item */
class DocHtmlDescTitle : public CompAccept<DocHtmlDescTitle>, public DocNode
{
  public:
    DocHtmlDescTitle(DocNode *parent,const HtmlAttribList &attribs) : 
      m_parent(parent), m_attribs(attribs) {}
    int parse();
    Kind kind() const { return Kind_HtmlDescTitle; }
    DocNode *parent() const { return m_parent; }
    const HtmlAttribList &attribs() const { return m_attribs; }
    void accept(DocVisitor *v) { CompAccept<DocHtmlDescTitle>::accept(this,v); }

  private:
    DocNode *     m_parent;
    HtmlAttribList m_attribs;
};

/*! @brief Node representing a Html description list */
class DocHtmlDescList : public CompAccept<DocHtmlDescList>, public DocNode
{
  public:
    DocHtmlDescList(DocNode *parent,const HtmlAttribList &attribs) 
      : m_parent(parent), m_attribs(attribs) {}
    int parse();
    Kind kind() const { return Kind_HtmlDescList; }
    DocNode *parent() const { return m_parent; }
    const HtmlAttribList &attribs() const { return m_attribs; }
    void accept(DocVisitor *v) { CompAccept<DocHtmlDescList>::accept(this,v); }

  private:
    DocNode *     m_parent;
    HtmlAttribList m_attribs;
};

/*! @brief Node representing a normal section */
class DocSection : public CompAccept<DocSection>, public DocNode
{
  public:
    DocSection(DocNode *parent,int level,const QString &id) :
      m_parent(parent), m_level(level), m_id(id) {} 
    Kind kind() const          { return Kind_Section; }
    int level() const          { return m_level; }
    QString title() const     { return m_title; }
    QString anchor() const    { return m_anchor; }
    QString id() const        { return m_id; }
    QString file() const      { return m_file; }
    DocNode *parent() const    { return m_parent; }
    void accept(DocVisitor *v) { CompAccept<DocSection>::accept(this,v); }
    int parse();

  private:
    DocNode *m_parent;
    int      m_level;
    QString  m_id;
    QString  m_title;
    QString  m_anchor;
    QString  m_file;
};

/*! @brief Node representing a reference to a section */
class DocSecRefItem : public CompAccept<DocSecRefItem>, public DocNode
{
  public:
    DocSecRefItem(DocNode *parent,const QString &target) : 
      m_parent(parent), m_target(target) {}
    Kind kind() const          { return Kind_SecRefItem; }
    QString target() const    { return m_target; }
    QString file() const      { return m_file; }
    QString anchor() const    { return m_anchor; }
    DocNode *parent() const    { return m_parent; }
    void accept(DocVisitor *v) { CompAccept<DocSecRefItem>::accept(this,v); }
    void parse();

  private:
    DocNode *m_parent;
    QString  m_target;
    QString  m_file;
    QString  m_anchor;
};

/*! @brief Node representing a 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;
};

/*! @brief Node representing an internal section of documentation */
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;
};

/*! @brief Node representing a 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;
};

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

  private:
    DocNode *     m_parent;
    Type          m_type;
    HtmlAttribList m_attribs;
};

/*! Node representing a simple section */
class DocSimpleSect : public CompAccept<DocSimpleSect>, public DocNode
{
  public:
    enum Type 
    {  
       Unknown, See, Return, Author, Authors, Version, Since, Date,
       Note, Warning, Pre, Post, Invar, Remark, Attention, User
    };
    DocSimpleSect(DocNode *parent,Type t);
    virtual ~DocSimpleSect();
    int parse(bool userTitle);
    Kind kind() const { return Kind_SimpleSect; }
    Type type() const { return m_type; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v);

  private:
    DocNode *       m_parent;
    Type            m_type;
    DocTitle *      m_title;
};

/*! Node representing a parameter section */
class DocParamSect : public CompAccept<DocParamSect>, public DocNode
{
  public:
    enum Type 
    {  
       Unknown, Param, RetVal, Exception 
    };
    DocParamSect(DocNode *parent,Type t) : m_parent(parent), m_type(t) {}
    int parse(const QString &cmdName);
    Kind kind() const { return Kind_ParamSect; }
    Type type() const { return m_type; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { CompAccept<DocParamSect>::accept(this,v); }

  private:
    DocNode *       m_parent;
    Type            m_type;
};

/*! Node representing a paragraph in the documentation tree */
class DocPara : public CompAccept<DocPara>, public DocNode
{
  public:
    DocPara(DocNode *parent) : m_parent(parent), 
             m_isFirst(FALSE), m_isLast(FALSE) {}
    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); }
    void markFirst(bool v=TRUE) { m_isFirst=v; }
    void markLast(bool v=TRUE)  { m_isLast=v; }
    bool isFirst() const { return m_isFirst; }
    bool isLast() const { return m_isLast; }

    int handleCommand(const QString &cmdName);
    int handleHtmlStartTag(const QString &tagName,const HtmlAttribList &tagHtmlAttribs);
    int handleHtmlEndTag(const QString &tagName);
    int handleSimpleSection(DocSimpleSect::Type t);
    int handleXRefItem(DocXRefItem::Type t);
    int handleParamSection(const QString &cmdName,DocParamSect::Type t);
    void handleIncludeOperator(const QString &cmdName,DocIncOperator::Type t);
    void handleImage(const QString &cmdName);
    void handleDotFile(const QString &cmdName);
    void handleInclude(const QString &cmdName,DocInclude::Type t);
    void handleLink(const QString &cmdName,bool isJavaLink);
    void handleRef(const QString &cmdName);
    int handleLanguageSwitch();

  private:
    DocNode *m_parent;
    QString  m_sectionId;
    bool     m_isFirst;
    bool     m_isLast;
};

/*! @brief Node representing a parameter list. */
class DocParamList : public DocNode
{
  public:
    DocParamList(DocNode *parent,DocParamSect::Type t) 
      : m_parent(parent) , m_type(t), m_isFirst(TRUE), m_isLast(TRUE)
    { m_paragraph=new DocPara(this); }
    virtual ~DocParamList()
    { delete m_paragraph; }
    int parse(const QString &cmdName);
    Kind kind() const { return Kind_ParamList; }
    DocNode *parent() const { return m_parent; }
    const QStrList &parameters() { return m_params; }
    DocParamSect::Type type() const { return m_type; }
    void markFirst(bool b=TRUE) { m_isFirst=b; }
    void markLast(bool b=TRUE) { m_isLast=b; }
    bool isFirst() const { return m_isFirst; }
    bool isLast() const { return m_isLast; }
    void accept(DocVisitor *v)
    { 
      v->visitPre(this); 
      m_paragraph->accept(v);
      v->visitPost(this); 
    }

  private:
    DocNode *          m_parent;
    DocPara *          m_paragraph;
    QStrList           m_params;
    DocParamSect::Type m_type;
    bool               m_isFirst;
    bool               m_isLast;
};

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

/*! @brief Node representing a 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;
};

/*! @brief Node representing a HTML list item */
class DocHtmlListItem : public CompAccept<DocHtmlListItem>, public DocNode
{
  public:
    DocHtmlListItem(DocNode *parent,const HtmlAttribList &attribs,int num) : 
      m_parent(parent), m_attribs(attribs), m_itemNum(num) {}
    int parse();
    Kind kind() const { return Kind_HtmlListItem; }
    int itemNumber() const { return m_itemNum; }
    const HtmlAttribList &attribs() const { return m_attribs; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { CompAccept<DocHtmlListItem>::accept(this,v); }

  private:
    DocNode *      m_parent;
    HtmlAttribList m_attribs;
    int            m_itemNum;
};

/*! @brief Node representing a 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; }
    const HtmlAttribList &attribs() const { return m_attribs; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { CompAccept<DocHtmlDescData>::accept(this,v); }

  private:
    DocNode *     m_parent;
    HtmlAttribList m_attribs;
};


/*! @brief Node representing a preformatted HTML section */
class DocHtmlPre : public CompAccept<DocHtmlPre>, public DocNode
{
  public:
    DocHtmlPre(DocNode *parent,const HtmlAttribList &attribs) 
      : m_parent(parent), m_attribs(attribs) {}
    int parse();
    Kind kind() const { return Kind_HtmlPre; }
    const HtmlAttribList &attribs() const { return m_attribs; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { CompAccept<DocHtmlPre>::accept(this,v); }

  private:
    DocNode *     m_parent;
    HtmlAttribList m_attribs;
};

/*! @brief Node representing a HTML table cell */
class DocHtmlCell : public CompAccept<DocHtmlCell>, public DocNode
{
  public:
    DocHtmlCell(DocNode *parent,const HtmlAttribList &attribs,bool isHeading) : 
       m_parent(parent), m_isHeading(isHeading), 
       m_isFirst(FALSE), m_isLast(FALSE), m_attribs(attribs) {}
    int parse();
    bool isHeading() const { return m_isHeading; }
    bool isFirst() const { return m_isFirst; }
    bool isLast() const { return m_isLast; }
    Kind kind() const { return Kind_HtmlCell; }
    const HtmlAttribList &attribs() const { return m_attribs; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { CompAccept<DocHtmlCell>::accept(this,v); }
    void markFirst(bool v=TRUE) { m_isFirst=v; }
    void markLast(bool v=TRUE) { m_isLast=v; }

  private:
    DocNode *      m_parent;
    bool           m_isHeading;
    bool           m_isFirst;
    bool           m_isLast;
    HtmlAttribList  m_attribs;
};

/*! @brief Node representing a HTML table caption */
class DocHtmlCaption : public CompAccept<DocHtmlCaption>, public DocNode
{
  public:
    DocHtmlCaption(DocNode *parent,const HtmlAttribList &attribs) : 
      m_parent(parent), m_attribs(attribs) {}
    int parse();
    Kind kind() const { return Kind_HtmlCaption; }
    const HtmlAttribList &attribs() const { return m_attribs; }
    DocNode *parent() const { return m_parent; }
    void accept(DocVisitor *v) { CompAccept<DocHtmlCaption>::accept(this,v); }

  private:
    DocNode *     m_parent;
    HtmlAttribList m_attribs;
};

/*! @brief Node representing a HTML table row */
class DocHtmlRow : public CompAccept<DocHtmlRow>, public DocNode
{
  public:
    DocHtmlRow(DocNode *parent,const HtmlAttribList &attribs) 
      : m_parent(parent), m_attribs(attribs) {}
    int parse();
    Kind kind() const { return Kind_HtmlRow; }
    const HtmlAttribList &attribs() const { return m_attribs; }
    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;
    HtmlAttribList m_attribs;
};

/*! @brief Node representing a HTML table */
class DocHtmlTable : public CompAccept<DocHtmlTable>, public DocNode
{
  public:
    DocHtmlTable(DocNode *parent,const HtmlAttribList &attribs) 
      : m_parent(parent), m_attribs(attribs) 
    { m_caption=0; }
    ~DocHtmlTable()         { delete m_caption; }
    Kind kind() const       { return Kind_HtmlTable; }
    DocNode *parent() const { return m_parent; }
    uint numRows() const    { return m_children.count(); }
    bool hasCaption()       { return m_caption!=0; }
    const HtmlAttribList &attribs() const { return m_attribs; }
    int parse();
    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) 
    { 
      v->visitPre(this); 
      QListIterator<DocNode> cli(m_children);
      DocNode *n;
      for (cli.toFirst();(n=cli.current());++cli) n->accept(v);
      if (m_caption) m_caption->accept(v);
      v->visitPost(this); 
    }

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

/*! @brief Root node of a text fragment */
class DocText : public CompAccept<DocText>, public DocNode
{
  public:
    DocText() {}
    void parse();
    Kind kind() const { return Kind_Text; }
    DocNode *parent() const { return 0; }
    void accept(DocVisitor *v) { CompAccept<DocText>::accept(this,v); }
};

/*! @brief 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