00001 /****************************************************************************** 00002 * 00003 * $Id: $ 00004 * 00005 * 00006 * Copyright (C) 1997-2008 by Dimitri van Heesch. 00007 * 00008 * Permission to use, copy, modify, and distribute this software and its 00009 * documentation under the terms of the GNU General Public License is hereby 00010 * granted. No representations are made about the suitability of this software 00011 * for any purpose. It is provided "as is" without express or implied warranty. 00012 * See the GNU General Public License for more details. 00013 * 00014 * Documents produced by Doxygen are derivative works derived from the 00015 * input used in their production; they are not affected by this license. 00016 * 00017 */ 00018 00019 #ifndef _DOCPARSER_H 00020 #define _DOCPARSER_H 00021 00022 #include <stdio.h> 00023 00024 #include <qlist.h> 00025 #include <qstrlist.h> 00026 #include <qstring.h> 00027 00028 #include "docvisitor.h" 00029 #include "htmlattrib.h" 00030 00031 class DocNode; 00032 class MemberDef; 00033 class Definition; 00034 class MemberGroup; 00035 class SectionDict; 00036 00037 //--------------------------------------------------------------------------- 00038 00040 void initDocParser(); 00042 void finializeDocParser(); 00043 00064 DocNode *validatingParseDoc(const char *fileName,int startLine, 00065 Definition *context, MemberDef *md, 00066 const char *input,bool indexWords, 00067 bool isExample,const char *exampleName=0, 00068 bool singleLine=FALSE,bool linkFromIndex=FALSE); 00069 00073 DocNode *validatingParseText(const char *input); 00074 00076 void docFindSections(const char *input, 00077 Definition *d, 00078 MemberGroup *m, 00079 const char *fileName); 00080 00081 //--------------------------------------------------------------------------- 00082 00084 class DocNode 00085 { 00086 public: 00088 enum Kind { Kind_Root = 0, 00089 Kind_Word = 1, 00090 Kind_WhiteSpace = 2, 00091 Kind_Para = 3, 00092 Kind_AutoList = 4, 00093 Kind_AutoListItem = 5, 00094 Kind_Symbol = 6, 00095 Kind_URL = 7, 00096 Kind_StyleChange = 8, 00097 Kind_SimpleSect = 9, 00098 Kind_Title = 10, 00099 Kind_SimpleList = 11, 00100 Kind_SimpleListItem = 12, 00101 Kind_Section = 13, 00102 Kind_Verbatim = 14, 00103 Kind_XRefItem = 15, 00104 Kind_HtmlList = 16, 00105 Kind_HtmlListItem = 17, 00106 Kind_HtmlDescList = 18, 00107 Kind_HtmlDescData = 19, 00108 Kind_HtmlDescTitle = 20, 00109 Kind_HtmlTable = 21, 00110 Kind_HtmlRow = 22, 00111 Kind_HtmlCell = 23, 00112 Kind_HtmlCaption = 24, 00113 Kind_LineBreak = 25, 00114 Kind_HorRuler = 26, 00115 Kind_Anchor = 27, 00116 Kind_IndexEntry = 28, 00117 Kind_Internal = 29, 00118 Kind_HRef = 30, 00119 Kind_Include = 31, 00120 Kind_IncOperator = 32, 00121 Kind_HtmlHeader = 33, 00122 Kind_Image = 34, 00123 Kind_DotFile = 35, 00124 Kind_Link = 36, 00125 Kind_Ref = 37, 00126 Kind_Formula = 38, 00127 Kind_SecRefItem = 39, 00128 Kind_SecRefList = 40, 00129 //Kind_Language = 41, 00130 Kind_LinkedWord = 42, 00131 Kind_ParamSect = 43, 00132 Kind_ParamList = 44, 00133 Kind_InternalRef = 45, 00134 Kind_Copy = 46, 00135 Kind_Text = 47 00136 }; 00138 DocNode() : m_insidePre(FALSE) {} 00139 00141 virtual ~DocNode() {} 00142 00144 virtual Kind kind() const = 0; 00145 00147 virtual DocNode *parent() const = 0; 00148 00152 virtual void accept(DocVisitor *v) = 0; 00153 00155 bool isPreformatted() const { return m_insidePre; } 00156 00157 protected: 00159 void setInsidePreformatted(bool p) { m_insidePre = p; } 00160 private: 00161 00162 bool m_insidePre; 00163 }; 00164 00168 template<class T> class CompAccept 00169 { 00170 public: 00171 CompAccept() { m_children.setAutoDelete(TRUE); } 00172 void accept(T *obj, DocVisitor *v) 00173 { 00174 v->visitPre(obj); 00175 QListIterator<DocNode> cli(m_children); 00176 DocNode *n; 00177 for (cli.toFirst();(n=cli.current());++cli) n->accept(v); 00178 v->visitPost(obj); 00179 } 00180 00181 protected: 00182 QList<DocNode> m_children; 00183 }; 00184 00185 00188 class DocWord : public DocNode 00189 { 00190 public: 00191 DocWord(DocNode *parent,const QString &word); 00192 QString word() const { return m_word; } 00193 Kind kind() const { return Kind_Word; } 00194 DocNode *parent() const { return m_parent; } 00195 void accept(DocVisitor *v) { v->visit(this); } 00196 00197 private: 00198 DocNode *m_parent; 00199 QString m_word; 00200 }; 00201 00204 class DocLinkedWord : public DocNode 00205 { 00206 public: 00207 DocLinkedWord(DocNode *parent,const QString &word, 00208 const QString &ref,const QString &file, 00209 const QString &anchor,const QString &tooltip); 00210 QString word() const { return m_word; } 00211 Kind kind() const { return Kind_LinkedWord; } 00212 DocNode *parent() const { return m_parent; } 00213 QString file() const { return m_file; } 00214 QString relPath() const { return m_relPath; } 00215 QString ref() const { return m_ref; } 00216 QString anchor() const { return m_anchor; } 00217 QString tooltip() const { return m_tooltip; } 00218 void accept(DocVisitor *v) { v->visit(this); } 00219 00220 private: 00221 DocNode *m_parent; 00222 QString m_word; 00223 QString m_ref; 00224 QString m_file; 00225 QString m_relPath; 00226 QString m_anchor; 00227 QString m_tooltip; 00228 }; 00229 00231 class DocURL : public DocNode 00232 { 00233 public: 00234 DocURL(DocNode *parent,const QString &url,bool isEmail) : 00235 m_parent(parent), m_url(url), m_isEmail(isEmail) {} 00236 QString url() const { return m_url; } 00237 Kind kind() const { return Kind_URL; } 00238 DocNode *parent() const { return m_parent; } 00239 void accept(DocVisitor *v) { v->visit(this); } 00240 bool isEmail() const { return m_isEmail; } 00241 00242 private: 00243 DocNode *m_parent; 00244 QString m_url; 00245 bool m_isEmail; 00246 }; 00247 00249 class DocLineBreak : public DocNode 00250 { 00251 public: 00252 DocLineBreak(DocNode *parent) : 00253 m_parent(parent) {} 00254 Kind kind() const { return Kind_LineBreak; } 00255 DocNode *parent() const { return m_parent; } 00256 void accept(DocVisitor *v) { v->visit(this); } 00257 00258 private: 00259 DocNode *m_parent; 00260 }; 00261 00263 class DocHorRuler : public DocNode 00264 { 00265 public: 00266 DocHorRuler(DocNode *parent) : 00267 m_parent(parent) {} 00268 Kind kind() const { return Kind_HorRuler; } 00269 DocNode *parent() const { return m_parent; } 00270 void accept(DocVisitor *v) { v->visit(this); } 00271 00272 private: 00273 DocNode *m_parent; 00274 }; 00275 00277 class DocAnchor : public DocNode 00278 { 00279 public: 00280 DocAnchor(DocNode *parent,const QString &id,bool newAnchor); 00281 Kind kind() const { return Kind_Anchor; } 00282 DocNode *parent() const { return m_parent; } 00283 QString anchor() const { return m_anchor; } 00284 QString file() const { return m_file; } 00285 void accept(DocVisitor *v) { v->visit(this); } 00286 00287 private: 00288 DocNode *m_parent; 00289 QString m_anchor; 00290 QString m_file; 00291 }; 00292 00294 class DocStyleChange : public DocNode 00295 { 00296 public: 00297 enum Style { Bold, Italic, Code, Center, Small, 00298 Subscript, Superscript, Preformatted, 00299 Span, Div 00300 }; 00301 DocStyleChange(DocNode *parent,uint position,Style s,bool enable, 00302 const HtmlAttribList *attribs=0) : 00303 m_parent(parent), m_position(position), m_style(s), m_enable(enable) 00304 { if (attribs) m_attribs=*attribs; } 00305 Kind kind() const { return Kind_StyleChange; } 00306 Style style() const { return m_style; } 00307 const char *styleString() const; 00308 bool enable() const { return m_enable; } 00309 uint position() const { return m_position; } 00310 DocNode *parent() const { return m_parent; } 00311 void accept(DocVisitor *v) { v->visit(this); } 00312 const HtmlAttribList &attribs() const { return m_attribs; } 00313 00314 private: 00315 DocNode *m_parent; 00316 uint m_position; 00317 Style m_style; 00318 bool m_enable; 00319 HtmlAttribList m_attribs; 00320 }; 00321 00323 class DocSymbol : public DocNode 00324 { 00325 public: 00326 enum SymType { Unknown=0, BSlash,At,Less,Greater,Amp,Dollar,Hash,Percent, 00327 Copy, Tm, Reg, Apos, Quot, Uml, Acute, Grave, Circ, Tilde, 00328 Szlig, Cedil, Ring, Nbsp, Slash, Lsquo, Rsquo, Ldquo, Rdquo, 00329 Ndash, Mdash 00330 }; 00331 DocSymbol(DocNode *parent,SymType s,char letter='\0') : 00332 m_parent(parent), m_symbol(s), m_letter(letter) {} 00333 SymType symbol() const { return m_symbol; } 00334 char letter() const { return m_letter; } 00335 Kind kind() const { return Kind_Symbol; } 00336 DocNode *parent() const { return m_parent; } 00337 void accept(DocVisitor *v) { v->visit(this); } 00338 static SymType decodeSymbol(const QString &symName,char *letter); 00339 00340 private: 00341 DocNode *m_parent; 00342 SymType m_symbol; 00343 char m_letter; 00344 }; 00345 00347 class DocWhiteSpace : public DocNode 00348 { 00349 public: 00350 DocWhiteSpace(DocNode *parent,const QString &chars) : 00351 m_parent(parent), m_chars(chars) {} 00352 Kind kind() const { return Kind_WhiteSpace; } 00353 QString chars() const { return m_chars; } 00354 DocNode *parent() const { return m_parent; } 00355 void accept(DocVisitor *v) { v->visit(this); } 00356 private: 00357 DocNode *m_parent; 00358 QString m_chars; 00359 }; 00360 00362 class DocVerbatim : public DocNode 00363 { 00364 public: 00365 enum Type { Code, HtmlOnly, ManOnly, LatexOnly, XmlOnly, Verbatim, Dot, Msc }; 00366 DocVerbatim(DocNode *parent,const QString &context, 00367 const QString &text, Type t,bool isExample, 00368 const QString &exampleFile); 00369 Kind kind() const { return Kind_Verbatim; } 00370 Type type() const { return m_type; } 00371 QString text() const { return m_text; } 00372 QString context() const { return m_context; } 00373 DocNode *parent() const { return m_parent; } 00374 void accept(DocVisitor *v) { v->visit(this); } 00375 bool isExample() const { return m_isExample; } 00376 QString exampleFile() const { return m_exampleFile; } 00377 QString relPath() const { return m_relPath; } 00378 00379 private: 00380 DocNode *m_parent; 00381 QString m_context; 00382 QString m_text; 00383 Type m_type; 00384 bool m_isExample; 00385 QString m_exampleFile; 00386 QString m_relPath; 00387 }; 00388 00389 00391 class DocInclude : public DocNode 00392 { 00393 public: 00394 enum Type { Include, DontInclude, VerbInclude, HtmlInclude, IncWithLines }; 00395 DocInclude(DocNode *parent,const QString &file, 00396 const QString context, Type t, 00397 bool isExample,const QString exampleFile) : 00398 m_parent(parent), m_file(file), m_context(context), m_type(t), 00399 m_isExample(isExample), m_exampleFile(exampleFile) {} 00400 Kind kind() const { return Kind_Include; } 00401 QString file() const { return m_file; } 00402 QString extension() const { int i=m_file.findRev('.'); 00403 if (i!=-1) 00404 return m_file.right(m_file.length()-i); 00405 else 00406 return ""; 00407 } 00408 Type type() const { return m_type; } 00409 QString text() const { return m_text; } 00410 QString context() const { return m_context; } 00411 DocNode *parent() const { return m_parent; } 00412 bool isExample() const { return m_isExample; } 00413 QString exampleFile() const { return m_exampleFile; } 00414 void accept(DocVisitor *v) { v->visit(this); } 00415 void parse(); 00416 00417 private: 00418 DocNode *m_parent; 00419 QString m_file; 00420 QString m_context; 00421 QString m_text; 00422 Type m_type; 00423 bool m_isExample; 00424 QString m_exampleFile; 00425 }; 00426 00428 class DocIncOperator : public DocNode 00429 { 00430 public: 00431 enum Type { Line, SkipLine, Skip, Until }; 00432 DocIncOperator(DocNode *parent,Type t,const QString &pat, 00433 const QString &context,bool isExample,const QString &exampleFile) : 00434 m_parent(parent), m_type(t), m_pattern(pat), m_context(context), 00435 m_isFirst(FALSE), m_isLast(FALSE), 00436 m_isExample(isExample), m_exampleFile(exampleFile) {} 00437 Kind kind() const { return Kind_IncOperator; } 00438 Type type() const { return m_type; } 00439 QString text() const { return m_text; } 00440 QString pattern() const { return m_pattern; } 00441 QString context() const { return m_context; } 00442 DocNode *parent() const { return m_parent; } 00443 void accept(DocVisitor *v) { v->visit(this); } 00444 bool isFirst() const { return m_isFirst; } 00445 bool isLast() const { return m_isLast; } 00446 void markFirst(bool v=TRUE) { m_isFirst = v; } 00447 void markLast(bool v=TRUE) { m_isLast = v; } 00448 bool isExample() const { return m_isExample; } 00449 QString exampleFile() const { return m_exampleFile; } 00450 void parse(); 00451 00452 private: 00453 DocNode *m_parent; 00454 Type m_type; 00455 QString m_text; 00456 QString m_pattern; 00457 QString m_context; 00458 bool m_isFirst; 00459 bool m_isLast; 00460 bool m_isExample; 00461 QString m_exampleFile; 00462 }; 00463 00465 class DocFormula : public DocNode 00466 { 00467 public: 00468 DocFormula(DocNode *parent,int id); 00469 Kind kind() const { return Kind_Formula; } 00470 QString name() const { return m_name; } 00471 QString text() const { return m_text; } 00472 QString relPath() const { return m_relPath; } 00473 int id() const { return m_id; } 00474 DocNode *parent() const { return m_parent; } 00475 void accept(DocVisitor *v) { v->visit(this); } 00476 00477 private: 00478 DocNode *m_parent; 00479 QString m_name; 00480 QString m_text; 00481 QString m_relPath; 00482 int m_id; 00483 }; 00484 00486 class DocIndexEntry : public DocNode 00487 { 00488 public: 00489 DocIndexEntry(DocNode *parent) : m_parent(parent) { } 00490 Kind kind() const { return Kind_IndexEntry; } 00491 int parse(); 00492 DocNode *parent() const { return m_parent; } 00493 void accept(DocVisitor *v) { v->visit(this); } 00494 QString entry() { return m_entry; } 00495 00496 private: 00497 DocNode *m_parent; 00498 QString m_entry; 00499 }; 00500 00501 //----------------------------------------------------------------------- 00502 00504 class DocCopy : public CompAccept<DocCopy>, public DocNode 00505 { 00506 public: 00507 DocCopy(DocNode *parent,const QString &link) 00508 : m_parent(parent), m_link(link) { } 00509 Kind kind() const { return Kind_IndexEntry; } 00510 QString link() const { return m_link; } 00511 DocNode *parent() const { return m_parent; } 00512 void accept(DocVisitor *v) { CompAccept<DocCopy>::accept(this,v); } 00513 void parse(); 00514 00515 private: 00516 DocNode *m_parent; 00517 QString m_link; 00518 }; 00519 00521 class DocAutoList : public CompAccept<DocAutoList>, public DocNode 00522 { 00523 public: 00524 DocAutoList(DocNode *parent,int indent,bool isEnumList, 00525 int depth) : 00526 m_parent(parent), m_indent(indent), m_isEnumList(isEnumList), 00527 m_depth(depth) {} 00528 Kind kind() const { return Kind_AutoList; } 00529 bool isEnumList() const { return m_isEnumList; } 00530 int indent() const { return m_indent; } 00531 DocNode *parent() const { return m_parent; } 00532 int depth() const { return m_depth; } 00533 void accept(DocVisitor *v) { CompAccept<DocAutoList>::accept(this,v); } 00534 int parse(); 00535 00536 private: 00537 DocNode *m_parent; 00538 int m_indent; 00539 bool m_isEnumList; 00540 int m_depth; 00541 }; 00542 00543 00545 class DocTitle : public CompAccept<DocTitle>, public DocNode 00546 { 00547 public: 00548 DocTitle(DocNode *parent) : m_parent(parent) {} 00549 void parse(); 00550 void parseFromString(const QString &title); 00551 Kind kind() const { return Kind_Title; } 00552 DocNode *parent() const { return m_parent; } 00553 void accept(DocVisitor *v) { CompAccept<DocTitle>::accept(this,v); } 00554 00555 private: 00556 DocNode *m_parent; 00557 }; 00558 00560 class DocXRefItem : public CompAccept<DocXRefItem>, public DocNode 00561 { 00562 public: 00563 //enum Type { Bug, Test, Todo, Deprecated }; 00564 DocXRefItem(DocNode *parent,int id,const char *key); 00565 Kind kind() const { return Kind_XRefItem; } 00566 QString file() const { return m_file; } 00567 QString anchor() const { return m_anchor; } 00568 QString title() const { return m_title; } 00569 DocNode *parent() const { return m_parent; } 00570 QString relPath() const { return m_relPath; } 00571 QString key() const { return m_key; } 00572 void accept(DocVisitor *v) { CompAccept<DocXRefItem>::accept(this,v); } 00573 bool parse(); 00574 00575 private: 00576 DocNode *m_parent; 00577 int m_id; 00578 QString m_key; 00579 QString m_file; 00580 QString m_anchor; 00581 QString m_title; 00582 QString m_relPath; 00583 }; 00584 00586 class DocImage : public CompAccept<DocImage>, public DocNode 00587 { 00588 public: 00589 enum Type { Html, Latex, Rtf }; 00590 DocImage(DocNode *parent,const HtmlAttribList &attribs,const QString &name,Type t); 00591 Kind kind() const { return Kind_Image; } 00592 Type type() const { return m_type; } 00593 QString name() const { return m_name; } 00594 DocNode *parent() const { return m_parent; } 00595 bool hasCaption() const { return !m_children.isEmpty(); } 00596 QString width() const { return m_width; } 00597 QString height() const { return m_height; } 00598 QString relPath() const { return m_relPath; } 00599 const HtmlAttribList &attribs() const { return m_attribs; } 00600 void accept(DocVisitor *v) { CompAccept<DocImage>::accept(this,v); } 00601 void parse(); 00602 00603 private: 00604 DocNode *m_parent; 00605 HtmlAttribList m_attribs; 00606 QString m_name; 00607 Type m_type; 00608 QString m_width; 00609 QString m_height; 00610 QString m_relPath; 00611 }; 00612 00614 class DocDotFile : public CompAccept<DocDotFile>, public DocNode 00615 { 00616 public: 00617 DocDotFile(DocNode *parent,const QString &name,const QString &context); 00618 void parse(); 00619 Kind kind() const { return Kind_DotFile; } 00620 QString name() const { return m_name; } 00621 QString file() const { return m_file; } 00622 QString relPath() const { return m_relPath; } 00623 bool hasCaption() const { return !m_children.isEmpty(); } 00624 QString width() const { return m_width; } 00625 QString height() const { return m_height; } 00626 DocNode *parent() const { return m_parent; } 00627 QString context() const { return m_context; } 00628 void accept(DocVisitor *v) { CompAccept<DocDotFile>::accept(this,v); } 00629 private: 00630 DocNode *m_parent; 00631 QString m_name; 00632 QString m_file; 00633 QString m_relPath; 00634 QString m_width; 00635 QString m_height; 00636 QString m_context; 00637 }; 00638 00640 class DocLink : public CompAccept<DocLink>, public DocNode 00641 { 00642 public: 00643 DocLink(DocNode *parent,const QString &target); 00644 QString parse(bool,bool isXmlLink=FALSE); 00645 Kind kind() const { return Kind_Link; } 00646 QString file() const { return m_file; } 00647 QString relPath() const { return m_relPath; } 00648 QString ref() const { return m_ref; } 00649 QString anchor() const { return m_anchor; } 00650 DocNode *parent() const { return m_parent; } 00651 void accept(DocVisitor *v) { CompAccept<DocLink>::accept(this,v); } 00652 00653 private: 00654 DocNode *m_parent; 00655 QString m_file; 00656 QString m_relPath; 00657 QString m_ref; 00658 QString m_anchor; 00659 QString m_refText; 00660 }; 00661 00663 class DocRef : public CompAccept<DocRef>, public DocNode 00664 { 00665 public: 00666 DocRef(DocNode *parent,const QString &target,const QString &context); 00667 void parse(); 00668 Kind kind() const { return Kind_Ref; } 00669 QString file() const { return m_file; } 00670 QString relPath() const { return m_relPath; } 00671 QString ref() const { return m_ref; } 00672 QString anchor() const { return m_anchor; } 00673 QString targetTitle() const { return m_text; } 00674 DocNode *parent() const { return m_parent; } 00675 bool hasLinkText() const { return !m_children.isEmpty(); } 00676 bool refToAnchor() const { return m_refToAnchor; } 00677 bool refToSection() const { return m_refToSection; } 00678 void accept(DocVisitor *v) { CompAccept<DocRef>::accept(this,v); } 00679 00680 private: 00681 DocNode * m_parent; 00682 bool m_refToSection; 00683 bool m_refToAnchor; 00684 QString m_file; 00685 QString m_relPath; 00686 QString m_ref; 00687 QString m_anchor; 00688 QString m_text; 00689 }; 00690 00692 class DocInternalRef : public CompAccept<DocInternalRef>, public DocNode 00693 { 00694 public: 00695 DocInternalRef(DocNode *parent,const QString &target); 00696 void parse(); 00697 Kind kind() const { return Kind_Ref; } 00698 QString file() const { return m_file; } 00699 QString relPath() const { return m_relPath; } 00700 QString anchor() const { return m_anchor; } 00701 DocNode *parent() const { return m_parent; } 00702 void accept(DocVisitor *v) { CompAccept<DocInternalRef>::accept(this,v); } 00703 00704 private: 00705 DocNode * m_parent; 00706 QString m_file; 00707 QString m_relPath; 00708 QString m_anchor; 00709 }; 00710 00712 //class DocLanguage : public CompAccept<DocLanguage>, public DocNode 00713 //{ 00714 // public: 00715 // DocLanguage(DocNode *parent,const QString &id) : 00716 // m_parent(parent), m_id(id) {} 00717 // QString id() const { return m_id; } 00718 // Kind kind() const { return Kind_Language; } 00719 // DocNode *parent() const { return m_parent; } 00720 // void accept(DocVisitor *v) { CompAccept<DocLanguage>::accept(this,v); } 00721 // int parse(); 00722 // 00723 // private: 00724 // DocNode * m_parent; 00725 // QString m_id; 00726 //}; 00727 00729 class DocHRef : public CompAccept<DocHRef>, public DocNode 00730 { 00731 public: 00732 DocHRef(DocNode *parent,const HtmlAttribList &attribs,const QString &url) : 00733 m_parent(parent), m_attribs(attribs), m_url(url) {} 00734 int parse(); 00735 QString url() const { return m_url; } 00736 Kind kind() const { return Kind_HRef; } 00737 DocNode *parent() const { return m_parent; } 00738 void accept(DocVisitor *v) { CompAccept<DocHRef>::accept(this,v); } 00739 const HtmlAttribList &attribs() const { return m_attribs; } 00740 00741 private: 00742 DocNode * m_parent; 00743 HtmlAttribList m_attribs; 00744 QString m_url; 00745 }; 00746 00748 class DocHtmlHeader : public CompAccept<DocHtmlHeader>, public DocNode 00749 { 00750 public: 00751 DocHtmlHeader(DocNode *parent,const HtmlAttribList &attribs,int level) : 00752 m_parent(parent), m_level(level), m_attribs(attribs) {} 00753 int level() const { return m_level; } 00754 Kind kind() const { return Kind_HtmlHeader; } 00755 const HtmlAttribList &attribs() const { return m_attribs; } 00756 DocNode *parent() const { return m_parent; } 00757 void accept(DocVisitor *v) { CompAccept<DocHtmlHeader>::accept(this,v); } 00758 int parse(); 00759 00760 private: 00761 DocNode * m_parent; 00762 int m_level; 00763 HtmlAttribList m_attribs; 00764 }; 00765 00767 class DocHtmlDescTitle : public CompAccept<DocHtmlDescTitle>, public DocNode 00768 { 00769 public: 00770 DocHtmlDescTitle(DocNode *parent,const HtmlAttribList &attribs) : 00771 m_parent(parent), m_attribs(attribs) {} 00772 Kind kind() const { return Kind_HtmlDescTitle; } 00773 DocNode *parent() const { return m_parent; } 00774 const HtmlAttribList &attribs() const { return m_attribs; } 00775 void accept(DocVisitor *v) { CompAccept<DocHtmlDescTitle>::accept(this,v); } 00776 int parse(); 00777 00778 private: 00779 DocNode * m_parent; 00780 HtmlAttribList m_attribs; 00781 }; 00782 00784 class DocHtmlDescList : public CompAccept<DocHtmlDescList>, public DocNode 00785 { 00786 public: 00787 DocHtmlDescList(DocNode *parent,const HtmlAttribList &attribs) 00788 : m_parent(parent), m_attribs(attribs) {} 00789 Kind kind() const { return Kind_HtmlDescList; } 00790 DocNode *parent() const { return m_parent; } 00791 const HtmlAttribList &attribs() const { return m_attribs; } 00792 void accept(DocVisitor *v) { CompAccept<DocHtmlDescList>::accept(this,v); } 00793 int parse(); 00794 00795 private: 00796 DocNode * m_parent; 00797 HtmlAttribList m_attribs; 00798 }; 00799 00801 class DocSection : public CompAccept<DocSection>, public DocNode 00802 { 00803 public: 00804 DocSection(DocNode *parent,int level,const QString &id) : 00805 m_parent(parent), m_level(level), m_id(id) {} 00806 Kind kind() const { return Kind_Section; } 00807 int level() const { return m_level; } 00808 QString title() const { return m_title; } 00809 QString anchor() const { return m_anchor; } 00810 QString id() const { return m_id; } 00811 QString file() const { return m_file; } 00812 DocNode *parent() const { return m_parent; } 00813 void accept(DocVisitor *v) { CompAccept<DocSection>::accept(this,v); } 00814 int parse(); 00815 00816 private: 00817 DocNode *m_parent; 00818 int m_level; 00819 QString m_id; 00820 QString m_title; 00821 QString m_anchor; 00822 QString m_file; 00823 }; 00824 00826 class DocSecRefItem : public CompAccept<DocSecRefItem>, public DocNode 00827 { 00828 public: 00829 DocSecRefItem(DocNode *parent,const QString &target) : 00830 m_parent(parent), m_target(target) {} 00831 Kind kind() const { return Kind_SecRefItem; } 00832 QString target() const { return m_target; } 00833 QString file() const { return m_file; } 00834 QString anchor() const { return m_anchor; } 00835 DocNode *parent() const { return m_parent; } 00836 void accept(DocVisitor *v) { CompAccept<DocSecRefItem>::accept(this,v); } 00837 void parse(); 00838 00839 private: 00840 DocNode *m_parent; 00841 QString m_target; 00842 QString m_file; 00843 QString m_anchor; 00844 }; 00845 00847 class DocSecRefList : public CompAccept<DocSecRefList>, public DocNode 00848 { 00849 public: 00850 DocSecRefList(DocNode *parent) : m_parent(parent) {} 00851 void parse(); 00852 Kind kind() const { return Kind_SecRefList; } 00853 DocNode *parent() const { return m_parent; } 00854 void accept(DocVisitor *v) { CompAccept<DocSecRefList>::accept(this,v); } 00855 00856 private: 00857 DocNode *m_parent; 00858 }; 00859 00861 class DocInternal : public CompAccept<DocInternal>, public DocNode 00862 { 00863 public: 00864 DocInternal(DocNode *parent) : m_parent(parent) {} 00865 int parse(int); 00866 Kind kind() const { return Kind_Internal; } 00867 DocNode *parent() const { return m_parent; } 00868 void accept(DocVisitor *v) { CompAccept<DocInternal>::accept(this,v); } 00869 00870 private: 00871 DocNode *m_parent; 00872 }; 00873 00875 class DocSimpleList : public CompAccept<DocSimpleList>, public DocNode 00876 { 00877 public: 00878 DocSimpleList(DocNode *parent) : m_parent(parent) {} 00879 Kind kind() const { return Kind_SimpleList; } 00880 DocNode *parent() const { return m_parent; } 00881 void accept(DocVisitor *v) { CompAccept<DocSimpleList>::accept(this,v); } 00882 int parse(); 00883 00884 private: 00885 DocNode *m_parent; 00886 }; 00887 00889 class DocHtmlList : public CompAccept<DocHtmlList>, public DocNode 00890 { 00891 public: 00892 enum Type { Unordered, Ordered }; 00893 DocHtmlList(DocNode *parent,const HtmlAttribList &attribs,Type t) : 00894 m_parent(parent), m_type(t), m_attribs(attribs) {} 00895 Kind kind() const { return Kind_HtmlList; } 00896 Type type() const { return m_type; } 00897 DocNode *parent() const { return m_parent; } 00898 void accept(DocVisitor *v) { CompAccept<DocHtmlList>::accept(this,v); } 00899 const HtmlAttribList &attribs() const { return m_attribs; } 00900 int parse(); 00901 int parseXml(); 00902 00903 private: 00904 DocNode * m_parent; 00905 Type m_type; 00906 HtmlAttribList m_attribs; 00907 }; 00908 00910 class DocSimpleSect : public CompAccept<DocSimpleSect>, public DocNode 00911 { 00912 public: 00913 enum Type 00914 { 00915 Unknown, See, Return, Author, Authors, Version, Since, Date, 00916 Note, Warning, Pre, Post, Invar, Remark, Attention, User, Rcs 00917 }; 00918 DocSimpleSect(DocNode *parent,Type t); 00919 virtual ~DocSimpleSect(); 00920 Kind kind() const { return Kind_SimpleSect; } 00921 Type type() const { return m_type; } 00922 QCString typeString() const; 00923 DocNode *parent() const { return m_parent; } 00924 void accept(DocVisitor *v); 00925 int parse(bool userTitle); 00926 int parseRcs(); 00927 int parseXml(); 00928 void appendLinkWord(const QString &word); 00929 00930 private: 00931 DocNode * m_parent; 00932 Type m_type; 00933 DocTitle * m_title; 00934 }; 00935 00937 class DocParamSect : public CompAccept<DocParamSect>, public DocNode 00938 { 00939 public: 00940 enum Type 00941 { 00942 Unknown, Param, RetVal, Exception, TemplateParam 00943 }; 00944 enum Direction 00945 { 00946 In=1, Out=2, InOut=3, Unspecified=0 00947 }; 00948 DocParamSect(DocNode *parent,Type t) 00949 : m_parent(parent), m_type(t) {} 00950 int parse(const QString &cmdName,bool xmlContext,Direction d); 00951 Kind kind() const { return Kind_ParamSect; } 00952 Type type() const { return m_type; } 00953 DocNode *parent() const { return m_parent; } 00954 void accept(DocVisitor *v) { CompAccept<DocParamSect>::accept(this,v); } 00955 00956 private: 00957 DocNode * m_parent; 00958 Type m_type; 00959 Direction m_dir; 00960 }; 00961 00963 class DocPara : public CompAccept<DocPara>, public DocNode 00964 { 00965 public: 00966 DocPara(DocNode *parent) : m_parent(parent), 00967 m_isFirst(FALSE), m_isLast(FALSE) {} 00968 int parse(); 00969 Kind kind() const { return Kind_Para; } 00970 DocNode *parent() const { return m_parent; } 00971 bool isEmpty() const { return m_children.isEmpty(); } 00972 void accept(DocVisitor *v) { CompAccept<DocPara>::accept(this,v); } 00973 void markFirst(bool v=TRUE) { m_isFirst=v; } 00974 void markLast(bool v=TRUE) { m_isLast=v; } 00975 bool isFirst() const { return m_isFirst; } 00976 bool isLast() const { return m_isLast; } 00977 const QList<DocNode> &children() const { return m_children; } 00978 QList<DocNode> &children() { return m_children; } 00979 00980 int handleCommand(const QString &cmdName); 00981 int handleHtmlStartTag(const QString &tagName,const HtmlAttribList &tagHtmlAttribs); 00982 int handleHtmlEndTag(const QString &tagName); 00983 int handleSimpleSection(DocSimpleSect::Type t,bool xmlContext=FALSE); 00984 int handleXRefItem(); 00985 int handleParamSection(const QString &cmdName,DocParamSect::Type t, 00986 bool xmlContext, 00987 int direction); 00988 void handleIncludeOperator(const QString &cmdName,DocIncOperator::Type t); 00989 void handleImage(const QString &cmdName); 00990 void handleDotFile(const QString &cmdName); 00991 void handleInclude(const QString &cmdName,DocInclude::Type t); 00992 void handleLink(const QString &cmdName,bool isJavaLink); 00993 void handleRef(const QString &cmdName); 00994 void handleSection(const QString &cmdName); 00995 void handleInheritDoc(); 00996 int handleStartCode(); 00997 int handleHtmlHeader(const HtmlAttribList &tagHtmlAttribs,int level); 00998 bool injectToken(int tok,const QString &tokText); 00999 01000 private: 01001 DocNode *m_parent; 01002 QString m_sectionId; 01003 bool m_isFirst; 01004 bool m_isLast; 01005 }; 01006 01008 class DocParamList : public DocNode 01009 { 01010 public: 01011 DocParamList(DocNode *parent,DocParamSect::Type t,DocParamSect::Direction d) 01012 : m_parent(parent) , m_type(t), m_dir(d), m_isFirst(TRUE), m_isLast(TRUE) 01013 { m_paragraphs.setAutoDelete(TRUE); } 01014 virtual ~DocParamList() { } 01015 Kind kind() const { return Kind_ParamList; } 01016 DocNode *parent() const { return m_parent; } 01017 const QList<DocNode> ¶meters() { return m_params; } 01018 DocParamSect::Type type() const { return m_type; } 01019 DocParamSect::Direction direction() const { return m_dir; } 01020 void markFirst(bool b=TRUE) { m_isFirst=b; } 01021 void markLast(bool b=TRUE) { m_isLast=b; } 01022 bool isFirst() const { return m_isFirst; } 01023 bool isLast() const { return m_isLast; } 01024 void accept(DocVisitor *v) 01025 { 01026 v->visitPre(this); 01027 QListIterator<DocPara> cli(m_paragraphs); 01028 DocNode *n; 01029 for (cli.toFirst();(n=cli.current());++cli) n->accept(v); 01030 v->visitPost(this); 01031 } 01032 int parse(const QString &cmdName); 01033 int parseXml(const QString ¶mName); 01034 01035 private: 01036 DocNode * m_parent; 01037 QList<DocPara> m_paragraphs; 01038 QList<DocNode> m_params; 01039 DocParamSect::Type m_type; 01040 DocParamSect::Direction m_dir; 01041 bool m_isFirst; 01042 bool m_isLast; 01043 }; 01044 01046 class DocAutoListItem : public DocNode 01047 { 01048 public: 01049 DocAutoListItem(DocNode *parent,int num) : m_parent(parent), m_itemNum(num) 01050 { m_paragraph=new DocPara(this); } 01051 virtual ~DocAutoListItem() { delete m_paragraph; } 01052 Kind kind() const { return Kind_AutoListItem; } 01053 DocNode *parent() const { return m_parent; } 01054 int itemNumber() const { return m_itemNum; } 01055 void accept(DocVisitor *v) 01056 { 01057 v->visitPre(this); 01058 m_paragraph->accept(v); 01059 v->visitPost(this); 01060 } 01061 int parse(); 01062 01063 private: 01064 DocNode *m_parent; 01065 DocPara *m_paragraph; 01066 int m_itemNum; 01067 }; 01068 01070 class DocSimpleListItem : public DocNode 01071 { 01072 public: 01073 DocSimpleListItem(DocNode *parent) : m_parent(parent) 01074 { m_paragraph=new DocPara(this); } 01075 int parse(); 01076 virtual ~DocSimpleListItem() { delete m_paragraph; } 01077 Kind kind() const { return Kind_SimpleListItem; } 01078 DocNode *parent() const { return m_parent; } 01079 void accept(DocVisitor *v) 01080 { 01081 v->visitPre(this); 01082 m_paragraph->accept(v); 01083 v->visitPost(this); 01084 } 01085 01086 private: 01087 DocNode *m_parent; 01088 DocPara *m_paragraph; 01089 }; 01090 01092 class DocHtmlListItem : public CompAccept<DocHtmlListItem>, public DocNode 01093 { 01094 public: 01095 DocHtmlListItem(DocNode *parent,const HtmlAttribList &attribs,int num) : 01096 m_parent(parent), m_attribs(attribs), m_itemNum(num) {} 01097 Kind kind() const { return Kind_HtmlListItem; } 01098 int itemNumber() const { return m_itemNum; } 01099 const HtmlAttribList &attribs() const { return m_attribs; } 01100 DocNode *parent() const { return m_parent; } 01101 void accept(DocVisitor *v) { CompAccept<DocHtmlListItem>::accept(this,v); } 01102 int parse(); 01103 int parseXml(); 01104 01105 private: 01106 DocNode * m_parent; 01107 HtmlAttribList m_attribs; 01108 int m_itemNum; 01109 }; 01110 01112 class DocHtmlDescData : public CompAccept<DocHtmlDescData>, public DocNode 01113 { 01114 public: 01115 DocHtmlDescData(DocNode *parent) : 01116 m_parent(parent) {} 01117 Kind kind() const { return Kind_HtmlDescData; } 01118 const HtmlAttribList &attribs() const { return m_attribs; } 01119 DocNode *parent() const { return m_parent; } 01120 void accept(DocVisitor *v) { CompAccept<DocHtmlDescData>::accept(this,v); } 01121 int parse(); 01122 01123 private: 01124 DocNode * m_parent; 01125 HtmlAttribList m_attribs; 01126 }; 01127 01129 class DocHtmlCell : public CompAccept<DocHtmlCell>, public DocNode 01130 { 01131 public: 01132 DocHtmlCell(DocNode *parent,const HtmlAttribList &attribs,bool isHeading) : 01133 m_parent(parent), m_isHeading(isHeading), 01134 m_isFirst(FALSE), m_isLast(FALSE), m_attribs(attribs) {} 01135 bool isHeading() const { return m_isHeading; } 01136 bool isFirst() const { return m_isFirst; } 01137 bool isLast() const { return m_isLast; } 01138 Kind kind() const { return Kind_HtmlCell; } 01139 DocNode *parent() const { return m_parent; } 01140 void accept(DocVisitor *v) { CompAccept<DocHtmlCell>::accept(this,v); } 01141 void markFirst(bool v=TRUE) { m_isFirst=v; } 01142 void markLast(bool v=TRUE) { m_isLast=v; } 01143 const HtmlAttribList &attribs() const { return m_attribs; } 01144 int parse(); 01145 int parseXml(); 01146 01147 private: 01148 DocNode * m_parent; 01149 bool m_isHeading; 01150 bool m_isFirst; 01151 bool m_isLast; 01152 HtmlAttribList m_attribs; 01153 }; 01154 01156 class DocHtmlCaption : public CompAccept<DocHtmlCaption>, public DocNode 01157 { 01158 public: 01159 DocHtmlCaption(DocNode *parent,const HtmlAttribList &attribs) : 01160 m_parent(parent), m_attribs(attribs) {} 01161 Kind kind() const { return Kind_HtmlCaption; } 01162 DocNode *parent() const { return m_parent; } 01163 void accept(DocVisitor *v) { CompAccept<DocHtmlCaption>::accept(this,v); } 01164 const HtmlAttribList &attribs() const { return m_attribs; } 01165 int parse(); 01166 01167 private: 01168 DocNode * m_parent; 01169 HtmlAttribList m_attribs; 01170 bool m_atTop; 01171 }; 01172 01174 class DocHtmlRow : public CompAccept<DocHtmlRow>, public DocNode 01175 { 01176 public: 01177 DocHtmlRow(DocNode *parent,const HtmlAttribList &attribs) 01178 : m_parent(parent), m_attribs(attribs) {} 01179 Kind kind() const { return Kind_HtmlRow; } 01180 DocNode *parent() const { return m_parent; } 01181 uint numCells() const { return m_children.count(); } 01182 void accept(DocVisitor *v) { CompAccept<DocHtmlRow>::accept(this,v); } 01183 const HtmlAttribList &attribs() const { return m_attribs; } 01184 int parse(); 01185 int parseXml(bool header); 01186 01187 private: 01188 DocNode * m_parent; 01189 HtmlAttribList m_attribs; 01190 }; 01191 01193 class DocHtmlTable : public CompAccept<DocHtmlTable>, public DocNode 01194 { 01195 public: 01196 DocHtmlTable(DocNode *parent,const HtmlAttribList &attribs) 01197 : m_parent(parent), m_attribs(attribs) 01198 { m_caption=0; } 01199 ~DocHtmlTable() { delete m_caption; } 01200 Kind kind() const { return Kind_HtmlTable; } 01201 DocNode *parent() const { return m_parent; } 01202 uint numRows() const { return m_children.count(); } 01203 bool hasCaption() { return m_caption!=0; } 01204 const HtmlAttribList &attribs() const { return m_attribs; } 01205 int parse(); 01206 int parseXml(); 01207 uint numCols() const; 01208 void accept(DocVisitor *v); 01209 01210 private: 01211 DocNode * m_parent; 01212 DocHtmlCaption *m_caption; 01213 HtmlAttribList m_attribs; 01214 }; 01215 01217 class DocText : public CompAccept<DocText>, public DocNode 01218 { 01219 public: 01220 DocText() {} 01221 Kind kind() const { return Kind_Text; } 01222 DocNode *parent() const { return 0; } 01223 void accept(DocVisitor *v) { CompAccept<DocText>::accept(this,v); } 01224 void parse(); 01225 }; 01226 01228 class DocRoot : public CompAccept<DocRoot>, public DocNode 01229 { 01230 public: 01231 DocRoot(bool indent,bool sl) : m_indent(indent), m_singleLine(sl) {} 01232 Kind kind() const { return Kind_Root; } 01233 DocNode *parent() const { return 0; } 01234 void accept(DocVisitor *v) { CompAccept<DocRoot>::accept(this,v); } 01235 void parse(); 01236 bool indent() const { return m_indent; } 01237 bool singleLine() const { return m_singleLine; } 01238 01239 private: 01240 bool m_indent; 01241 bool m_singleLine; 01242 }; 01243 01244 01245 #endif