Chameleon

Chameleon Svn Source Tree

Root/branches/xZenu/src/util/doxygen/addon/doxmlparser/src/dochandler.h

Source at commit 1322 created 9 years 5 months ago.
By meklort, Add doxygen to utils folder
1/******************************************************************************
2 *
3 * $Id:$
4 *
5 *
6 * Copyright (C) 1997-2006 by Dimitri van Heesch.
7 *
8 * Permission to use, copy, modify, and distribute this software and its
9 * documentation under the terms of the GNU General Public License is hereby
10 * granted. No representations are made about the suitability of this software
11 * for any purpose. It is provided "as is" without express or implied warranty.
12 * See the GNU General Public License for more details.
13 *
14 */
15
16#ifndef _DOCHANDLER_H
17#define _DOCHANDLER_H
18
19#include <qstring.h>
20#include <qlist.h>
21#include <qxml.h>
22
23#include <doxmlintf.h>
24#include "stringimpl.h"
25#include "basehandler.h"
26#include "baseiterator.h"
27
28class ParagraphHandler;
29class DocInternalHandler;
30class LinkedTextImpl;
31class LinkedTextHandler;
32
33//-----------------------------------------------------------------------------
34
35class DocImpl : public IDoc { public: virtual ~DocImpl() {} };
36
37#define DEFINE_CLS_IMPL(cls) \
38 class cls##Impl : public I##cls, public DocImpl { public: virtual ~cls##Impl() {} }
39
40DEFINE_CLS_IMPL(DocMarkup);
41DEFINE_CLS_IMPL(DocPara);
42DEFINE_CLS_IMPL(DocText);
43DEFINE_CLS_IMPL(DocMarkupModifier);
44DEFINE_CLS_IMPL(DocItemizedList);
45DEFINE_CLS_IMPL(DocOrderedList);
46DEFINE_CLS_IMPL(DocListItem);
47DEFINE_CLS_IMPL(DocParameterList);
48DEFINE_CLS_IMPL(DocParameterItem);
49DEFINE_CLS_IMPL(DocParameter);
50DEFINE_CLS_IMPL(DocTitle);
51DEFINE_CLS_IMPL(DocSimpleSect);
52DEFINE_CLS_IMPL(DocRef);
53DEFINE_CLS_IMPL(DocVariableList);
54DEFINE_CLS_IMPL(DocVariableListEntry);
55DEFINE_CLS_IMPL(DocHRuler);
56DEFINE_CLS_IMPL(DocLineBreak);
57DEFINE_CLS_IMPL(DocULink);
58DEFINE_CLS_IMPL(DocEMail);
59DEFINE_CLS_IMPL(DocLink);
60DEFINE_CLS_IMPL(DocProgramListing);
61DEFINE_CLS_IMPL(DocCodeLine);
62DEFINE_CLS_IMPL(DocHighlight);
63DEFINE_CLS_IMPL(DocFormula);
64DEFINE_CLS_IMPL(DocImage);
65DEFINE_CLS_IMPL(DocDotFile);
66DEFINE_CLS_IMPL(DocIndexEntry);
67DEFINE_CLS_IMPL(DocTable);
68DEFINE_CLS_IMPL(DocRow);
69DEFINE_CLS_IMPL(DocEntry);
70DEFINE_CLS_IMPL(DocSection);
71DEFINE_CLS_IMPL(DocVerbatim);
72DEFINE_CLS_IMPL(DocCopy);
73DEFINE_CLS_IMPL(DocTocList);
74DEFINE_CLS_IMPL(DocTocItem);
75DEFINE_CLS_IMPL(DocAnchor);
76DEFINE_CLS_IMPL(DocSymbol);
77DEFINE_CLS_IMPL(DocInternal);
78DEFINE_CLS_IMPL(DocRoot);
79
80//-----------------------------------------------------------------------------
81
82
83/*! \brief Node representing a piece of text.
84 *
85 */
86class TextNode : public DocTextImpl
87{
88 public:
89 TextNode(const QString &t,int markup,int level)
90 : m_text(t), m_markup(markup), m_headingLevel(level) {}
91 virtual ~TextNode() {}
92
93 // IDocText
94 virtual Kind kind() const { return DocImpl::Text; }
95 virtual const IString *text() const { return &m_text; }
96 virtual int markup() const { return m_markup; }
97 virtual int headingLevel() const { return m_headingLevel; }
98
99 private:
100 StringImpl m_text;
101 int m_markup;
102 int m_headingLevel;
103};
104
105//-----------------------------------------------------------------------------
106
107/*! \brief Node representing a change in the markup style.
108 *
109 */
110class MarkupModifierNode : public DocMarkupModifierImpl
111{
112 public:
113 MarkupModifierNode(int markup,bool enabled,int level=0)
114 : m_markup(markup), m_enabled(enabled), m_headingLevel(level) {}
115 virtual ~MarkupModifierNode() {}
116
117 // IDocMarkupModifier
118 virtual Kind kind() const { return DocImpl::MarkupModifier; }
119 virtual bool enabled() const { return m_enabled; }
120 virtual int markup() const { return m_markup; }
121 virtual int headingLevel() const { return m_headingLevel; }
122
123 private:
124 int m_markup;
125 bool m_enabled;
126 int m_headingLevel;
127};
128
129
130//-----------------------------------------------------------------------------
131
132/*! \brief Handles markup commands in the XML input.
133 *
134 */
135class MarkupHandler : public BaseFallBackHandler<MarkupHandler>
136{
137 public:
138 MarkupHandler(QList<DocImpl> &children,QString &curString);
139 virtual ~MarkupHandler();
140 int markup() const { return m_curMarkup; }
141 int headingLevel() const { return m_headingLevel; }
142
143 virtual void startBold(const QXmlAttributes &attrib);
144 virtual void endBold();
145 virtual void startEmphasis(const QXmlAttributes &attrib);
146 virtual void endEmphasis();
147 virtual void startComputerOutput(const QXmlAttributes &attrib);
148 virtual void endComputerOutput();
149 virtual void startCenter(const QXmlAttributes &attrib);
150 virtual void endCenter();
151 virtual void startSmallFont(const QXmlAttributes &attrib);
152 virtual void endSmallFont();
153 virtual void startSubscript(const QXmlAttributes &attrib);
154 virtual void endSubscript();
155 virtual void startSuperscript(const QXmlAttributes &attrib);
156 virtual void endSuperscript();
157 virtual void startPreformatted(const QXmlAttributes &attrib);
158 virtual void endPreformatted();
159 virtual void startHeading1(const QXmlAttributes &attrib);
160 virtual void endHeading1();
161 virtual void startHeading2(const QXmlAttributes &attrib);
162 virtual void endHeading2();
163 virtual void startHeading3(const QXmlAttributes &attrib);
164 virtual void endHeading3();
165 virtual void startHeading4(const QXmlAttributes &attrib);
166 virtual void endHeading4();
167 virtual void startHeading5(const QXmlAttributes &attrib);
168 virtual void endHeading5();
169 virtual void startHeading6(const QXmlAttributes &attrib);
170 virtual void endHeading6();
171
172
173 private:
174 void addTextNode();
175
176 QList<DocImpl> &m_children;
177 QString &m_curString;
178 int m_curMarkup;
179 int m_headingLevel;
180};
181
182//-----------------------------------------------------------------------------
183
184/*! \brief Node representing a paragraph of text and commands.
185 *
186 */
187// children: itemizedlist, orderedlist, parameterlist, simplesect, ref,
188// variablelist, hruler, linebreak, ulink, email, link
189// programlisting, formula, image, dotfile, indexentry,
190// table
191//
192// children handled by MarkupHandler:
193// bold, computeroutput, emphasis, center,
194// small, subscript, superscript.
195//
196class ParagraphHandler : public DocParaImpl,
197 public BaseHandler<ParagraphHandler>
198{
199 friend class ParagraphIterator;
200
201 public:
202 virtual void startParagraph(const QXmlAttributes& attrib);
203 virtual void endParagraph();
204 virtual void startItemizedList(const QXmlAttributes& attrib);
205 virtual void startOrderedList(const QXmlAttributes& attrib);
206 virtual void startParameterList(const QXmlAttributes& attrib);
207 virtual void startSimpleSect(const QXmlAttributes& attrib);
208 virtual void startRef(const QXmlAttributes& attrib);
209 virtual void startVariableList(const QXmlAttributes& attrib);
210 virtual void startHRuler(const QXmlAttributes& attrib);
211 virtual void startLineBreak(const QXmlAttributes& attrib);
212 virtual void startULink(const QXmlAttributes& attrib);
213 virtual void startEMail(const QXmlAttributes& attrib);
214 virtual void startLink(const QXmlAttributes& attrib);
215 virtual void startProgramListing(const QXmlAttributes& attrib);
216 virtual void startFormula(const QXmlAttributes& attrib);
217 virtual void startImage(const QXmlAttributes& attrib);
218 virtual void startDotFile(const QXmlAttributes& attrib);
219 virtual void startIndexEntry(const QXmlAttributes& attrib);
220 virtual void startTable(const QXmlAttributes& attrib);
221 virtual void startVerbatim(const QXmlAttributes& attrib);
222 virtual void startHtmlOnly(const QXmlAttributes& attrib);
223 virtual void startLatexOnly(const QXmlAttributes& attrib);
224 virtual void startUmlaut(const QXmlAttributes& attrib);
225 virtual void startAcute(const QXmlAttributes& attrib);
226 virtual void startGrave(const QXmlAttributes& attrib);
227 virtual void startCirc(const QXmlAttributes& attrib);
228 virtual void startTilde(const QXmlAttributes& attrib);
229 virtual void startSzlig(const QXmlAttributes& attrib);
230 virtual void startCedil(const QXmlAttributes& attrib);
231 virtual void startRing(const QXmlAttributes& attrib);
232 virtual void startNbsp(const QXmlAttributes& attrib);
233 virtual void startCopy(const QXmlAttributes& attrib);
234 virtual void startAnchor(const QXmlAttributes& attrib);
235 virtual void startCopyDoc(const QXmlAttributes& attrib);
236 virtual void startTocList(const QXmlAttributes& attrib);
237
238 ParagraphHandler(IBaseHandler *parent);
239 virtual ~ParagraphHandler();
240
241 // IDocPara
242 virtual Kind kind() const { return DocImpl::Para; }
243 virtual IDocIterator *contents() const;
244
245 private:
246 void addTextNode();
247 IBaseHandler *m_parent;
248 QList<DocImpl> m_children;
249 MarkupHandler *m_markupHandler;
250};
251
252class ParagraphIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>
253{
254 public:
255 ParagraphIterator(const ParagraphHandler &handler) :
256 BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {}
257};
258
259//-----------------------------------------------------------------------------
260
261/*! \brief Node representing a list item.
262 *
263 */
264class ListItemHandler : public DocListItemImpl, public BaseHandler<ListItemHandler>
265{
266 friend class ListItemIterator;
267 public:
268 ListItemHandler(IBaseHandler *parent);
269 virtual ~ListItemHandler();
270 virtual void startListItem(const QXmlAttributes& attrib);
271 virtual void endListItem();
272 virtual void startParagraph(const QXmlAttributes& attrib);
273
274 // IDocItem
275 virtual Kind kind() const { return DocImpl::ListItem; }
276 virtual IDocIterator *contents() const;
277
278 private:
279 IBaseHandler *m_parent;
280 QList<DocImpl> m_children;
281};
282
283class ListItemIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>
284{
285 public:
286 ListItemIterator(const ListItemHandler &handler) :
287 BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {}
288};
289
290
291//-----------------------------------------------------------------------------
292
293/*! \brief Node representing list of items.
294 *
295 */
296class OrderedListHandler : public DocOrderedListImpl, public BaseHandler<OrderedListHandler>
297{
298 friend class OrderedListIterator;
299 public:
300 OrderedListHandler(IBaseHandler *parent);
301 virtual ~OrderedListHandler();
302 virtual void startOrderedList(const QXmlAttributes& attrib);
303 virtual void endOrderedList();
304 virtual void startOrderedListItem(const QXmlAttributes& attrib);
305
306 // IDocOrderedList
307 virtual Kind kind() const { return DocImpl::OrderedList; }
308 virtual IDocIterator *elements() const;
309
310 private:
311 IBaseHandler *m_parent;
312 QList<DocImpl> m_children;
313};
314
315class OrderedListIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>
316{
317 public:
318 OrderedListIterator(const OrderedListHandler &handler) :
319 BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {}
320};
321
322//-----------------------------------------------------------------------------
323
324/*! \brief Node representing table of contents list.
325 *
326 */
327class TocListHandler : public DocTocListImpl, public BaseHandler<TocListHandler>
328{
329 friend class TocListIterator;
330 public:
331 TocListHandler(IBaseHandler *parent);
332 virtual ~TocListHandler();
333 virtual void startTocList(const QXmlAttributes& attrib);
334 virtual void endTocList();
335 virtual void startTocItem(const QXmlAttributes& attrib);
336
337 // IDocTocList
338 virtual Kind kind() const { return DocImpl::TocList; }
339 virtual IDocIterator *elements() const;
340
341 private:
342 IBaseHandler *m_parent;
343 QList<DocImpl> m_children;
344};
345
346class TocListIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>
347{
348 public:
349 TocListIterator(const TocListHandler &handler) :
350 BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {}
351};
352
353//-----------------------------------------------------------------------------
354
355/*! \brief Node representing a table of contents item.
356 *
357 */
358class TocItemHandler : public DocTocItemImpl, public BaseHandler<TocItemHandler>
359{
360 friend class TocItemIterator;
361 public:
362 TocItemHandler(IBaseHandler *parent);
363 virtual ~TocItemHandler();
364 virtual void startTocItem(const QXmlAttributes& attrib);
365 virtual void endTocItem();
366
367 // IDocItem
368 virtual Kind kind() const { return DocImpl::TocItem; }
369 virtual const IString *id() const { return &m_id; }
370 virtual const IString *title() const { return &m_title; }
371
372 private:
373 IBaseHandler *m_parent;
374 StringImpl m_id;
375 StringImpl m_title;
376};
377
378//-----------------------------------------------------------------------------
379
380/*! \brief Node representing list of items.
381 *
382 */
383class ItemizedListHandler : public DocItemizedListImpl, public BaseHandler<ItemizedListHandler>
384{
385 friend class ItemizedListIterator;
386 public:
387 ItemizedListHandler(IBaseHandler *parent);
388 virtual ~ItemizedListHandler();
389 virtual void startItemizedList(const QXmlAttributes& attrib);
390 virtual void endItemizedList();
391 virtual void startItemizedListItem(const QXmlAttributes& attrib);
392
393 // IDocItemizedList
394 virtual Kind kind() const { return DocImpl::ItemizedList; }
395 virtual IDocIterator *elements() const;
396
397 private:
398 IBaseHandler *m_parent;
399 QList<DocImpl> m_children;
400};
401
402class ItemizedListIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>
403{
404 public:
405 ItemizedListIterator(const ItemizedListHandler &handler) :
406 BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {}
407};
408
409
410//-----------------------------------------------------------------------------
411/*! \brief Node representing a parameter.
412 *
413 */
414class ParameterHandler : public DocParameterImpl,
415 public BaseHandler<ParameterHandler>
416{
417 public:
418 ParameterHandler(IBaseHandler *parent);
419 virtual ~ParameterHandler();
420 virtual void startParameterName(const QXmlAttributes& attrib);
421 virtual void endParameterName();
422
423 // IDocParameter
424 virtual Kind kind() const { return DocImpl::Parameter; }
425 virtual const IString *name() const { return &m_name; }
426
427 private:
428 IBaseHandler *m_parent;
429 StringImpl m_name;
430};
431
432//-----------------------------------------------------------------------------
433
434/* \brief Node representing a list of param names with a single description.
435 *
436 */
437class ParameterItemHandler : public DocParameterItemImpl,
438 public BaseHandler<ParameterItemHandler>
439{
440 friend class ParameterItemIterator;
441 public:
442 ParameterItemHandler(IBaseHandler *parent);
443 virtual ~ParameterItemHandler();
444 virtual void startParameterItem(const QXmlAttributes& attrib);
445 virtual void endParameterItem();
446 virtual void startParameterName(const QXmlAttributes& attrib);
447 virtual void startParagraph(const QXmlAttributes& attrib);
448
449 // IDocParameterItem
450 virtual Kind kind() const { return DocImpl::ParameterItem; }
451 virtual IDocIterator *paramNames() const;
452 virtual IDocPara *description() const { return m_description; }
453
454 private:
455 IBaseHandler *m_parent;
456 QList<ParameterHandler> m_parameters;
457 ParagraphHandler *m_description;
458};
459
460class ParameterItemIterator : public BaseIteratorVia<IDocIterator,IDoc,ParameterHandler,DocImpl>
461{
462 public:
463 ParameterItemIterator(const ParameterItemHandler &handler) :
464 BaseIteratorVia<IDocIterator,IDoc,ParameterHandler,DocImpl>(handler.m_parameters) {}
465};
466
467//-----------------------------------------------------------------------------
468
469/* \brief Node representing a parameter section.
470 *
471 */
472class ParameterListHandler : public DocParameterListImpl,
473 public BaseHandler<ParameterListHandler>
474{
475 friend class ParameterListIterator;
476 public:
477 ParameterListHandler(IBaseHandler *parent);
478 virtual ~ParameterListHandler();
479 virtual void startParameterList(const QXmlAttributes& attrib);
480 virtual void endParameterList();
481 virtual void startParameterItem(const QXmlAttributes& attrib);
482
483 // IDocParameterList
484 virtual Kind kind() const { return DocImpl::ParameterList; }
485 virtual Types sectType() const { return m_type; }
486 virtual IDocIterator *params() const;
487
488 private:
489 IBaseHandler *m_parent;
490 QList<ParameterItemHandler> m_paramItems;
491 Types m_type;
492};
493
494class ParameterListIterator : public BaseIteratorVia<IDocIterator,IDoc,ParameterItemHandler,DocImpl>
495{
496 public:
497 ParameterListIterator(const ParameterListHandler &handler) :
498 BaseIteratorVia<IDocIterator,IDoc,ParameterItemHandler,DocImpl>(handler.m_paramItems) {}
499};
500
501//-----------------------------------------------------------------------------
502
503/* \brief Node representing a horizontal ruler
504 *
505 */
506class LineBreakHandler : public DocLineBreakImpl, public BaseHandler<LineBreakHandler>
507{
508 public:
509 LineBreakHandler(IBaseHandler *parent);
510 virtual ~LineBreakHandler();
511
512 void startLineBreak(const QXmlAttributes& attrib);
513 void endLineBreak();
514
515 // IDocLineBreak
516 virtual Kind kind() const { return DocImpl::LineBreak; }
517
518 private:
519 IBaseHandler *m_parent;
520};
521
522//-----------------------------------------------------------------------------
523
524/* \brief Node representing a link to section
525 *
526 */
527class LinkHandler : public DocLinkImpl, public BaseHandler<LinkHandler>
528{
529 public:
530 LinkHandler(IBaseHandler *parent);
531 virtual ~LinkHandler();
532
533 void startLink(const QXmlAttributes& attrib);
534 void endLink();
535
536 // IDocLink
537 virtual Kind kind() const { return DocImpl::Link; }
538 virtual const IString *refId() const { return &m_ref; }
539 virtual const IString *text() const { return &m_text; }
540
541 private:
542 IBaseHandler *m_parent;
543 StringImpl m_ref;
544 StringImpl m_text;
545};
546
547
548//-----------------------------------------------------------------------------
549
550/* \brief Node representing a link to an email address
551 *
552 */
553class EMailHandler : public DocEMailImpl, public BaseHandler<EMailHandler>
554{
555 public:
556 EMailHandler(IBaseHandler *parent);
557 virtual ~EMailHandler();
558
559 void startEMail(const QXmlAttributes& attrib);
560 void endEMail();
561
562 // IDocEMail
563 virtual Kind kind() const { return DocImpl::EMail; }
564 virtual const IString *address() const { return &m_address; }
565
566 private:
567 IBaseHandler *m_parent;
568 StringImpl m_address;
569};
570
571
572//-----------------------------------------------------------------------------
573
574/* \brief Node representing a link to an URL
575 *
576 */
577class ULinkHandler : public DocULinkImpl, public BaseHandler<ULinkHandler>
578{
579 public:
580 ULinkHandler(IBaseHandler *parent);
581 virtual ~ULinkHandler();
582
583 void startULink(const QXmlAttributes& attrib);
584 void endULink();
585
586 // IDocULink
587 virtual Kind kind() const { return DocImpl::ULink; }
588 virtual const IString * url() const { return &m_url; }
589 virtual const IString * text() const { return &m_text; }
590
591 private:
592 IBaseHandler *m_parent;
593 StringImpl m_url;
594 StringImpl m_text;
595};
596
597//-----------------------------------------------------------------------------
598
599/* \brief Node representing a horizontal ruler
600 *
601 */
602class HRulerHandler : public DocHRulerImpl, public BaseHandler<HRulerHandler>
603{
604 public:
605 HRulerHandler(IBaseHandler *parent);
606 virtual ~HRulerHandler();
607
608 void startHRuler(const QXmlAttributes& attrib);
609 void endHRuler();
610
611 // IDocHRuler
612 virtual Kind kind() const { return DocImpl::HRuler; }
613
614 private:
615 IBaseHandler *m_parent;
616};
617
618//-----------------------------------------------------------------------------
619
620/* \brief Node representing a reference to another item
621 *
622 */
623class RefHandler : public DocRefImpl, public BaseHandler<RefHandler>
624{
625 public:
626 RefHandler(IBaseHandler *parent);
627 virtual ~RefHandler();
628 void startRef(const QXmlAttributes& attrib);
629 void endRef();
630
631 // IDocRef
632 virtual Kind kind() const { return DocImpl::Ref; }
633 virtual const IString *refId() const { return &m_refId; }
634 virtual TargetKind targetKind() const { return m_targetKind; }
635 virtual const IString *external() const { return &m_extId; }
636 virtual const IString *text() const { return &m_linkText; }
637
638 private:
639 IBaseHandler *m_parent;
640 StringImpl m_refId;
641 StringImpl m_extId;
642 StringImpl m_linkText;
643 TargetKind m_targetKind;
644};
645
646//-----------------------------------------------------------------------------
647
648/* \brief Node representing the title of a section
649 *
650 */
651// children: text, ref
652// children handled by MarkupHandler:
653// bold, computeroutput, emphasis, center,
654// small, subscript, superscript.
655class TitleHandler : public DocTitleImpl, public BaseHandler<TitleHandler>
656{
657 friend class TitleIterator;
658 public:
659 TitleHandler(IBaseHandler *parent);
660 virtual ~TitleHandler();
661 virtual void startTitle(const QXmlAttributes& attrib);
662 virtual void endTitle();
663 virtual void startRef(const QXmlAttributes& attrib);
664 void addTextNode();
665
666 // IDocTitle
667 virtual Kind kind() const { return DocImpl::Title; }
668 virtual IDocIterator *title() const;
669
670 private:
671 IBaseHandler *m_parent;
672 QList<DocImpl> m_children;
673 MarkupHandler *m_markupHandler;
674};
675
676class TitleIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>
677{
678 public:
679 TitleIterator(const TitleHandler &handler) :
680 BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {}
681};
682
683//-----------------------------------------------------------------------------
684
685/* \brief Node representing a simple section with an unnumbered header.
686 *
687 */
688// children: title, para
689class SimpleSectHandler : public DocSimpleSectImpl,
690 public BaseHandler<SimpleSectHandler>
691{
692 public:
693 SimpleSectHandler(IBaseHandler *parent);
694 virtual ~SimpleSectHandler();
695 virtual void startSimpleSect(const QXmlAttributes& attrib);
696 virtual void endSimpleSect();
697 virtual void startTitle(const QXmlAttributes& attrib);
698 virtual void startParagraph(const QXmlAttributes& attrib);
699
700 // IDocSimpleSect
701 virtual Kind kind() const { return DocImpl::SimpleSect; }
702 virtual Types type() const { return m_type; }
703 virtual const IString *typeString() const { return &m_typeString; }
704 virtual IDocTitle *title() const { return m_title; }
705 virtual IDocPara *description() const { return m_paragraph; }
706
707 private:
708 IBaseHandler *m_parent;
709 ParagraphHandler *m_paragraph;
710 Types m_type;
711 StringImpl m_typeString;
712 TitleHandler *m_title;
713};
714
715//-----------------------------------------------------------------------------
716
717/* \brief Node representing an named item of a VariableList.
718 *
719 */
720class VariableListEntryHandler : public DocVariableListEntryImpl,
721 public BaseHandler<VariableListEntryHandler>
722{
723 public:
724 virtual void startVarListEntry(const QXmlAttributes& attrib);
725 virtual void endVarListEntry();
726 virtual void startListItem(const QXmlAttributes& attrib);
727 virtual void endListItem();
728 virtual void startTerm(const QXmlAttributes& attrib);
729 virtual void endTerm();
730 virtual void startParagraph(const QXmlAttributes& attrib);
731
732 VariableListEntryHandler(IBaseHandler *parent);
733 virtual ~VariableListEntryHandler();
734
735 // IDocVariableListEntry
736 virtual Kind kind() const { return DocImpl::VariableListEntry; }
737 virtual ILinkedTextIterator *term() const;
738 virtual IDocPara *description() const { return m_description; }
739
740 private:
741 IBaseHandler* m_parent;
742 QList<LinkedTextImpl> m_term;
743 ParagraphHandler* m_description;
744 LinkedTextHandler* m_linkedTextHandler;
745};
746
747//-----------------------------------------------------------------------------
748
749/*! \brief Node representing a list of named items.
750 *
751 */
752// children: varlistentry, listitem
753class VariableListHandler : public DocVariableListImpl,
754 public BaseHandler<VariableListHandler>
755{
756 friend class VariableListIterator;
757
758 public:
759 virtual void startVariableList(const QXmlAttributes& attrib);
760 virtual void endVariableList();
761 virtual void startVarListEntry(const QXmlAttributes& attrib);
762 virtual void startListItem(const QXmlAttributes& attrib);
763
764 VariableListHandler(IBaseHandler *parent);
765 virtual ~VariableListHandler();
766
767 // IDocVariableList
768 virtual Kind kind() const { return DocImpl::VariableList; }
769 virtual IDocIterator *entries() const;
770
771 private:
772 IBaseHandler *m_parent;
773 QList<VariableListEntryHandler> m_entries;
774 VariableListEntryHandler *m_curEntry;
775};
776
777class VariableListIterator : public BaseIteratorVia<IDocIterator,IDoc,VariableListEntryHandler,DocImpl>
778{
779 public:
780 VariableListIterator(const VariableListHandler &handler) :
781 BaseIteratorVia<IDocIterator,IDoc,VariableListEntryHandler,DocImpl>(handler.m_entries) {}
782};
783
784//-----------------------------------------------------------------------------
785
786/*! \brief Node representing a highlighted text fragment.
787 *
788 */
789// children: ref
790class HighlightHandler : public DocHighlightImpl, public BaseHandler<HighlightHandler>
791{
792 friend class HighlightIterator;
793 public:
794 HighlightHandler(IBaseHandler *parent);
795 virtual ~HighlightHandler();
796 void startHighlight(const QXmlAttributes& attrib);
797 void endHighlight();
798 virtual void startRef(const QXmlAttributes&);
799 virtual void startSpace(const QXmlAttributes&);
800
801 // IDocHighlight
802 virtual Kind kind() const { return DocImpl::Highlight; }
803 virtual HighlightKind highlightKind() const { return m_hl; }
804 virtual IDocIterator *codeElements() const;
805
806 private:
807 void addTextNode();
808
809 IBaseHandler *m_parent;
810 HighlightKind m_hl;
811 QString m_hlString;
812 QList<DocImpl> m_children;
813};
814
815class HighlightIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>
816{
817 public:
818 HighlightIterator(const HighlightHandler &handler) :
819 BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {}
820};
821
822//-----------------------------------------------------------------------------
823
824/*! \brief Node representing a line of code.
825 *
826 */
827// children: linenumber, highlight, anchor, ref
828class CodeLineHandler : public DocCodeLineImpl, public BaseHandler<CodeLineHandler>
829{
830 friend class CodeLineIterator;
831 public:
832
833 virtual void startCodeLine(const QXmlAttributes&);
834 virtual void endCodeLine();
835 virtual void startLineNumber(const QXmlAttributes&);
836 virtual void endLineNumber();
837 virtual void startHighlight(const QXmlAttributes&);
838 virtual void startRef(const QXmlAttributes&);
839
840 CodeLineHandler(IBaseHandler *parent);
841 virtual ~CodeLineHandler();
842
843 // IDocCodeLine
844 virtual Kind kind() const { return DocImpl::CodeLine; }
845 virtual int lineNumber() const { return m_lineNumber; }
846 virtual const IString *refId() const { return &m_refId; }
847 virtual IDocIterator *codeElements() const;
848
849 private:
850 void addTextNode();
851
852 IBaseHandler *m_parent;
853 int m_lineNumber;
854 StringImpl m_refId;
855 QList<DocImpl> m_children;
856};
857
858class CodeLineIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>
859{
860 public:
861 CodeLineIterator(const CodeLineHandler &handler) :
862 BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {}
863};
864
865//-----------------------------------------------------------------------------
866
867/*! \brief Node representing a program listing
868 *
869 */
870// children: codeline, linenumber
871class ProgramListingHandler : public DocProgramListingImpl, public BaseHandler<ProgramListingHandler>
872{
873 friend class ProgramListingIterator;
874 public:
875 virtual void startProgramListing(const QXmlAttributes& attrib);
876 virtual void endProgramListing();
877 virtual void startCodeLine(const QXmlAttributes&);
878 virtual void startLineNumber(const QXmlAttributes&);
879
880 ProgramListingHandler(IBaseHandler *parent);
881 virtual ~ProgramListingHandler();
882
883 // IDocProgramListing
884 virtual Kind kind() const { return DocImpl::ProgramListing; }
885 virtual IDocIterator *codeLines() const;
886
887 private:
888 IBaseHandler *m_parent;
889 QList<CodeLineHandler> m_children;
890 bool m_hasLineNumber;
891};
892
893//-----------------------------------------------------------------------------
894
895class ProgramListingIterator : public BaseIteratorVia<IDocIterator,IDoc,CodeLineHandler,DocImpl>
896{
897 public:
898 ProgramListingIterator(const ProgramListingHandler &handler) :
899 BaseIteratorVia<IDocIterator,IDoc,CodeLineHandler,DocImpl>(handler.m_children) {}
900};
901
902//-----------------------------------------------------------------------------
903
904/*! \brief Node representing a formula.
905 *
906 */
907// children: -
908class FormulaHandler : public DocFormulaImpl, public BaseHandler<FormulaHandler>
909{
910 public:
911 FormulaHandler(IBaseHandler *parent);
912 virtual ~FormulaHandler();
913 void startFormula(const QXmlAttributes& attrib);
914 void endFormula();
915
916 // IDocFormula
917 virtual Kind kind() const { return DocImpl::Formula; }
918 virtual const IString *id() const { return &m_id; }
919 virtual const IString *text() const { return &m_text; }
920
921 private:
922 IBaseHandler *m_parent;
923 StringImpl m_id;
924 StringImpl m_text;
925};
926
927//-----------------------------------------------------------------------------
928
929/*! \brief Node representing an image.
930 *
931 */
932// children: -
933class ImageHandler : public DocImageImpl, public BaseHandler<ImageHandler>
934{
935 public:
936 ImageHandler(IBaseHandler *parent);
937 virtual ~ImageHandler();
938 void startImage(const QXmlAttributes& attrib);
939 void endImage();
940
941 // IDocImage
942 virtual Kind kind() const { return DocImpl::Image; }
943 virtual const IString *name() const { return &m_name; }
944 virtual const IString *caption() const { return &m_caption; }
945
946 private:
947 IBaseHandler *m_parent;
948 StringImpl m_name;
949 StringImpl m_caption;
950};
951
952
953//-----------------------------------------------------------------------------
954/*! \brief Node representing an anchor.
955 *
956 */
957// children: -
958class AnchorHandler : public DocAnchorImpl, public BaseHandler<AnchorHandler>
959{
960 public:
961 AnchorHandler(IBaseHandler *parent);
962 virtual ~AnchorHandler();
963 void startAnchor(const QXmlAttributes& attrib);
964 void endAnchor();
965
966 // IDocAnchor
967 virtual Kind kind() const { return DocImpl::Anchor; }
968 virtual const IString *id() const { return &m_id; }
969
970 private:
971 IBaseHandler *m_parent;
972 StringImpl m_id;
973};
974
975//-----------------------------------------------------------------------------
976
977/*! \brief Node representing a dot file.
978 *
979 */
980// children: -
981class DotFileHandler : public DocDotFileImpl, public BaseHandler<DotFileHandler>
982{
983 public:
984 DotFileHandler(IBaseHandler *parent);
985 virtual ~DotFileHandler();
986 void startDotFile(const QXmlAttributes& attrib);
987 void endDotFile();
988
989 // IDocDotFile
990 virtual Kind kind() const { return DocImpl::DotFile; }
991 virtual const IString *name() const { return &m_name; }
992 virtual const IString *caption() const { return &m_caption; }
993
994 private:
995 IBaseHandler *m_parent;
996 StringImpl m_name;
997 StringImpl m_caption;
998};
999
1000//-----------------------------------------------------------------------------
1001
1002/*! \brief Node representing an entry in the index.
1003 *
1004 */
1005// children: -
1006class IndexEntryHandler : public DocIndexEntryImpl, public BaseHandler<IndexEntryHandler>
1007{
1008 public:
1009 IndexEntryHandler(IBaseHandler *parent);
1010 virtual ~IndexEntryHandler();
1011 void startIndexEntry(const QXmlAttributes& attrib);
1012 void endIndexEntry();
1013 void startPrimaryIE(const QXmlAttributes& attrib);
1014 void endPrimaryIE();
1015 void startSecondaryIE(const QXmlAttributes& attrib);
1016 void endSecondaryIE();
1017
1018 // IDocIndexEntry
1019 virtual Kind kind() const { return DocImpl::IndexEntry; }
1020 virtual const IString *primary() const { return &m_primary; }
1021 virtual const IString *secondary() const { return &m_secondary; }
1022
1023 private:
1024 IBaseHandler *m_parent;
1025 StringImpl m_primary;
1026 StringImpl m_secondary;
1027};
1028
1029//-----------------------------------------------------------------------------
1030
1031/*! \brief Node representing an entry in the table entry.
1032 *
1033 */
1034// children: para
1035class EntryHandler : public DocEntryImpl, public BaseHandler<EntryHandler>
1036{
1037 friend class EntryIterator;
1038 public:
1039 EntryHandler(IBaseHandler *parent);
1040 virtual ~EntryHandler();
1041 void startEntry(const QXmlAttributes& attrib);
1042 void endEntry();
1043 void startParagraph(const QXmlAttributes& attrib);
1044
1045 // IDocEntry
1046 virtual Kind kind() const { return DocImpl::Entry; }
1047 virtual IDocIterator *contents() const;
1048
1049 private:
1050 IBaseHandler *m_parent;
1051 QList<DocImpl> m_children;
1052};
1053
1054class EntryIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>
1055{
1056 public:
1057 EntryIterator(const EntryHandler &handler) :
1058 BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {}
1059};
1060
1061//-----------------------------------------------------------------------------
1062
1063/*! \brief Node representing an entry in the table row.
1064 *
1065 */
1066// children: entry
1067class RowHandler : public DocRowImpl, public BaseHandler<RowHandler>
1068{
1069 friend class RowIterator;
1070 public:
1071 RowHandler(IBaseHandler *parent);
1072 virtual ~RowHandler();
1073 void startRow(const QXmlAttributes& attrib);
1074 void endRow();
1075 void startEntry(const QXmlAttributes& attrib);
1076
1077 // IDocRow
1078 virtual Kind kind() const { return DocImpl::Row; }
1079 virtual IDocIterator *entries() const;
1080
1081 private:
1082 IBaseHandler *m_parent;
1083 QList<EntryHandler> m_children;
1084};
1085
1086class RowIterator : public BaseIteratorVia<IDocIterator,IDoc,EntryHandler,DocImpl>
1087{
1088 public:
1089 RowIterator(const RowHandler &handler) :
1090 BaseIteratorVia<IDocIterator,IDoc,EntryHandler,DocImpl>(handler.m_children) {}
1091};
1092
1093//-----------------------------------------------------------------------------
1094
1095/*! \brief Node representing an entry in the table.
1096 *
1097 */
1098// children: row, caption
1099class TableHandler : public DocTableImpl, public BaseHandler<TableHandler>
1100{
1101 friend class TableIterator;
1102 public:
1103 TableHandler(IBaseHandler *parent);
1104 virtual ~TableHandler();
1105 void startTable(const QXmlAttributes& attrib);
1106 void endTable();
1107 void startRow(const QXmlAttributes& attrib);
1108 void startCaption(const QXmlAttributes& attrib);
1109 void endCaption();
1110
1111 // IDocTable
1112 virtual Kind kind() const { return DocImpl::Table; }
1113 virtual IDocIterator *rows() const;
1114 virtual int numColumns() const { return m_numColumns; }
1115 virtual const IString *caption() const { return &m_caption; }
1116
1117 private:
1118 IBaseHandler *m_parent;
1119 QList<RowHandler> m_children;
1120 int m_numColumns;
1121 StringImpl m_caption;
1122};
1123
1124class TableIterator : public BaseIteratorVia<IDocIterator,IDoc,RowHandler,DocImpl>
1125{
1126 public:
1127 TableIterator(const TableHandler &handler) :
1128 BaseIteratorVia<IDocIterator,IDoc,RowHandler,DocImpl>(handler.m_children) {}
1129};
1130
1131//-----------------------------------------------------------------------------
1132
1133/*! \brief Node representing a copied piece of documentation.
1134 *
1135 */
1136class CopyHandler : public DocCopyImpl, public BaseHandler<CopyHandler>
1137{
1138 friend class CopyIterator;
1139 public:
1140 CopyHandler(IBaseHandler *parent);
1141 virtual ~CopyHandler();
1142 virtual void startCopy(const QXmlAttributes& attrib);
1143 virtual void endCopy();
1144 virtual void startParagraph(const QXmlAttributes& attrib);
1145
1146 // IDocCopy
1147 virtual Kind kind() const { return DocImpl::Copy; }
1148 virtual IDocIterator *contents() const;
1149
1150 private:
1151 IBaseHandler *m_parent;
1152 QList<DocImpl> m_children;
1153};
1154
1155class CopyIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>
1156{
1157 public:
1158 CopyIterator(const CopyHandler &handler) :
1159 BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {}
1160};
1161
1162//-----------------------------------------------------------------------------
1163
1164/*! \brief Node representing an preformatted section
1165 */
1166class VerbatimHandler : public DocVerbatimImpl,
1167 public BaseHandler<VerbatimHandler>
1168{
1169 public:
1170 VerbatimHandler(IBaseHandler *parent);
1171 virtual ~VerbatimHandler();
1172 void startVerbatim(const QXmlAttributes& attrib,Types type);
1173 void endVerbatim();
1174
1175 // IDocVerbatim
1176 virtual Kind kind() const { return DocImpl::Verbatim; }
1177 virtual const IString *text() const { return &m_text; }
1178 virtual Types type() const { return m_type; }
1179
1180 private:
1181 IBaseHandler *m_parent;
1182 StringImpl m_text;
1183 Types m_type;
1184};
1185
1186
1187//-----------------------------------------------------------------------------
1188
1189/*! \brief Node representing an special symbol.
1190 *
1191 */
1192// children: -
1193class SymbolHandler : public DocSymbolImpl, public BaseHandler<SymbolHandler>
1194{
1195 public:
1196 SymbolHandler(IBaseHandler *parent,Types type);
1197 virtual ~SymbolHandler();
1198 void startSymbol(const QXmlAttributes& attrib);
1199 void endSymbol();
1200
1201 // IDocSymbol
1202 virtual Kind kind() const { return DocImpl::Symbol; }
1203 virtual Types type() const { return m_type; }
1204 virtual const IString *typeString() const { return &m_typeString; }
1205 virtual char letter() const { return m_letter; }
1206
1207 private:
1208 IBaseHandler *m_parent;
1209 char m_letter;
1210 Types m_type;
1211 StringImpl m_typeString;
1212};
1213
1214
1215//-----------------------------------------------------------------------------
1216
1217/*! \brief Node representing a section.
1218 *
1219 */
1220// children: title, para, sect(n+1)
1221class DocSectionHandler : public DocSectionImpl, public BaseHandler<DocSectionHandler>
1222{
1223 friend class DocSectionParaIterator;
1224 friend class DocSectionSubIterator;
1225 public:
1226 DocSectionHandler(IBaseHandler *parent,int level);
1227 virtual ~DocSectionHandler();
1228 virtual void startDocSection(const QXmlAttributes& attrib);
1229 virtual void endDocSection();
1230 virtual void startTitle(const QXmlAttributes& attrib);
1231 virtual void startSubSection(const QXmlAttributes& attrib);
1232 virtual void startParagraph(const QXmlAttributes& attrib);
1233 virtual void startInternal(const QXmlAttributes& attrib);
1234
1235 // IDocSection
1236 virtual Kind kind() const { return DocImpl::Section; }
1237 virtual const IString *id() const { return &m_id; }
1238 virtual int level() const { return m_level; }
1239 virtual IDocTitle *title() const { return m_title; }
1240 virtual IDocIterator *paragraphs() const;
1241 virtual IDocIterator *subSections() const;
1242 virtual IDocInternal *internal() const;
1243
1244 private:
1245 IBaseHandler *m_parent;
1246 QList<DocImpl> m_paragraphs;
1247 QList<DocImpl> m_subsections;
1248 DocInternalHandler *m_internal;
1249 StringImpl m_id;
1250 int m_level;
1251 TitleHandler *m_title;
1252};
1253
1254class DocSectionParaIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>
1255{
1256 public:
1257 DocSectionParaIterator(const DocSectionHandler &handler) :
1258 BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_paragraphs) {}
1259};
1260
1261class DocSectionSubIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>
1262{
1263 public:
1264 DocSectionSubIterator(const DocSectionHandler &handler) :
1265 BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_subsections) {}
1266};
1267
1268//-----------------------------------------------------------------------------
1269
1270class DocInternalHandler : public DocInternalImpl, public BaseHandler<DocInternalHandler>
1271{
1272 public:
1273 friend class DocInternalParaIterator;
1274 friend class DocInternalSubIterator;
1275 DocInternalHandler(IBaseHandler *parent,int level);
1276 virtual ~DocInternalHandler();
1277 virtual void startInternal(const QXmlAttributes& attrib);
1278 virtual void endInternal();
1279 virtual void startSubSection(const QXmlAttributes& attrib);
1280 virtual void startParagraph(const QXmlAttributes& attrib);
1281
1282 // IDocInternal
1283 virtual Kind kind() const { return DocImpl::Internal; }
1284 virtual IDocIterator *paragraphs() const;
1285 virtual IDocIterator *subSections() const;
1286
1287 private:
1288 IBaseHandler *m_parent;
1289 QList<DocImpl> m_paragraphs;
1290 QList<DocImpl> m_subsections;
1291 int m_level;
1292};
1293
1294class DocInternalParaIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>
1295{
1296 public:
1297 DocInternalParaIterator(const DocInternalHandler &handler) :
1298 BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_paragraphs) {}
1299};
1300
1301class DocInternalSubIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>
1302{
1303 public:
1304 DocInternalSubIterator(const DocInternalHandler &handler) :
1305 BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_subsections) {}
1306};
1307
1308
1309//-----------------------------------------------------------------------------
1310
1311/*! \brief Node representing a documentation block.
1312 *
1313 */
1314// children: para, title, sect1, internal
1315class DocHandler : public DocRootImpl, public BaseHandler<DocHandler>
1316{
1317 friend class DocIterator;
1318 public:
1319 virtual void startDoc(const QXmlAttributes& attrib);
1320 virtual void endDoc();
1321 virtual void startParagraph(const QXmlAttributes& attrib);
1322 virtual void startSect1(const QXmlAttributes& attrib);
1323 virtual void startTitle(const QXmlAttributes& attrib);
1324 virtual void startInternal(const QXmlAttributes& attrib);
1325
1326 DocHandler(IBaseHandler *parent);
1327 virtual ~DocHandler();
1328
1329 // IDocRoot
1330 virtual Kind kind() const { return DocImpl::Root; }
1331 virtual IDocIterator *contents() const;
1332 virtual IDocInternal *internal() const;
1333
1334 private:
1335 IBaseHandler *m_parent;
1336 QList<DocImpl> m_children;
1337 DocInternalHandler *m_internal;
1338};
1339
1340class DocIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>
1341{
1342 public:
1343 DocIterator(const DocHandler &handler) :
1344 BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {}
1345};
1346
1347//-----------------------------------------------------------------------------
1348
1349void dochandler_init();
1350void dochandler_exit();
1351
1352#endif
1353

Archive Download this file

Revision: 1322