diff options
Diffstat (limited to 'addon/doxmlparser/src')
-rw-r--r-- | addon/doxmlparser/src/compoundhandler.cpp | 4 | ||||
-rw-r--r-- | addon/doxmlparser/src/dochandler.cpp | 95 | ||||
-rw-r--r-- | addon/doxmlparser/src/dochandler.h | 207 | ||||
-rw-r--r-- | addon/doxmlparser/src/doxmlintf.h | 52 | ||||
-rw-r--r-- | addon/doxmlparser/src/linkedtexthandler.cpp | 7 |
5 files changed, 262 insertions, 103 deletions
diff --git a/addon/doxmlparser/src/compoundhandler.cpp b/addon/doxmlparser/src/compoundhandler.cpp index 0b420bf..1ce6c6b 100644 --- a/addon/doxmlparser/src/compoundhandler.cpp +++ b/addon/doxmlparser/src/compoundhandler.cpp @@ -111,7 +111,7 @@ void CompoundHandler::endCompoundName() void CompoundHandler::addSuperClass(const QXmlAttributes& attrib) { SuperClass *sc=new SuperClass( - attrib.value("idref"), + attrib.value("refid"), attrib.value("prot"), attrib.value("virt") ); @@ -125,7 +125,7 @@ void CompoundHandler::addSuperClass(const QXmlAttributes& attrib) void CompoundHandler::addSubClass(const QXmlAttributes& attrib) { SubClass *sc = new SubClass( - attrib.value("idref"), + attrib.value("refid"), attrib.value("prot"), attrib.value("virt") ); diff --git a/addon/doxmlparser/src/dochandler.cpp b/addon/doxmlparser/src/dochandler.cpp index 3350cf4..b670de2 100644 --- a/addon/doxmlparser/src/dochandler.cpp +++ b/addon/doxmlparser/src/dochandler.cpp @@ -232,47 +232,85 @@ void ListItemHandler::startParagraph(const QXmlAttributes& attrib) m_children.append(parHandler); } +IDocIterator *ListItemHandler::contents() const +{ + return new ListItemIterator(*this); +} + //---------------------------------------------------------------------- -// ListHandler +// OrderedListHandler //---------------------------------------------------------------------- -ListHandler::ListHandler(Kind k,IBaseHandler *parent) - : m_parent(parent), m_kind(k) +OrderedListHandler::OrderedListHandler(IBaseHandler *parent) : m_parent(parent) { m_children.setAutoDelete(TRUE); - const char *endListName=0; - switch(k) - { - case ItemizedList : endListName="itemizedlist"; break; - case OrderedList : endListName="orderedlist"; break; - default: ASSERT(0); - } - addEndHandler(endListName,this,&ListHandler::endList); + addEndHandler("orderedlist",this,&OrderedListHandler::endOrderedList); + addStartHandler("listitem",this,&OrderedListHandler::startOrderedListItem); +} - addStartHandler("listitem",this,&ListHandler::startListItem); +OrderedListHandler::~OrderedListHandler() +{ +} + +void OrderedListHandler::startOrderedList(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); } -ListHandler::~ListHandler() +void OrderedListHandler::endOrderedList() { + m_parent->setDelegate(0); } -void ListHandler::startList(const QXmlAttributes& /*attrib*/) +void OrderedListHandler::startOrderedListItem(const QXmlAttributes& attrib) +{ + ListItemHandler *liHandler = new ListItemHandler(this); + liHandler->startListItem(attrib); + m_children.append(liHandler); +} + +IDocIterator *OrderedListHandler::elements() const +{ + return new OrderedListIterator(*this); +} + +//---------------------------------------------------------------------- +// ItemizedListHandler +//---------------------------------------------------------------------- + +ItemizedListHandler::ItemizedListHandler(IBaseHandler *parent) : m_parent(parent) +{ + m_children.setAutoDelete(TRUE); + addEndHandler("itemizedlist",this,&ItemizedListHandler::endItemizedList); + addStartHandler("listitem",this,&ItemizedListHandler::startItemizedListItem); +} + +ItemizedListHandler::~ItemizedListHandler() +{ +} + +void ItemizedListHandler::startItemizedList(const QXmlAttributes& /*attrib*/) { m_parent->setDelegate(this); } -void ListHandler::endList() +void ItemizedListHandler::endItemizedList() { m_parent->setDelegate(0); } -void ListHandler::startListItem(const QXmlAttributes& attrib) +void ItemizedListHandler::startItemizedListItem(const QXmlAttributes& attrib) { ListItemHandler *liHandler = new ListItemHandler(this); liHandler->startListItem(attrib); m_children.append(liHandler); } +IDocIterator *ItemizedListHandler::elements() const +{ + return new ItemizedListIterator(*this); +} + //---------------------------------------------------------------------- // ParameterHandler //---------------------------------------------------------------------- @@ -372,6 +410,11 @@ void ParameterListHandler::startParameterDescription(const QXmlAttributes& attri m_curParam->startParameterDescription(attrib); } +IDocIterator *ParameterListHandler::params() const +{ + return new ParameterListIterator(*this); +} + //---------------------------------------------------------------------- // LinkHandler //---------------------------------------------------------------------- @@ -1116,6 +1159,8 @@ TableHandler::TableHandler(IBaseHandler *parent) m_children.setAutoDelete(TRUE); addEndHandler("table",this,&TableHandler::endTable); addStartHandler("row",this,&TableHandler::startRow); + addStartHandler("caption",this,&TableHandler::startCaption); + addEndHandler("caption",this,&TableHandler::endCaption); } TableHandler::~TableHandler() @@ -1141,6 +1186,16 @@ void TableHandler::startRow(const QXmlAttributes& attrib) m_children.append(rh); } +void TableHandler::startCaption(const QXmlAttributes& /*attrib*/) +{ + m_curString=""; +} + +void TableHandler::endCaption() +{ + m_caption = m_curString; +} + //---------------------------------------------------------------------- // ParagraphHandler //---------------------------------------------------------------------- @@ -1195,16 +1250,16 @@ void ParagraphHandler::endParagraph() void ParagraphHandler::startItemizedList(const QXmlAttributes& attrib) { addTextNode(); - ListHandler *listHandler = new ListHandler(ItemizedList,this); - listHandler->startList(attrib); + ItemizedListHandler *listHandler = new ItemizedListHandler(this); + listHandler->startItemizedList(attrib); m_children.append(listHandler); } void ParagraphHandler::startOrderedList(const QXmlAttributes& attrib) { addTextNode(); - ListHandler *listHandler = new ListHandler(OrderedList,this); - listHandler->startList(attrib); + OrderedListHandler *listHandler = new OrderedListHandler(this); + listHandler->startOrderedList(attrib); m_children.append(listHandler); } diff --git a/addon/doxmlparser/src/dochandler.h b/addon/doxmlparser/src/dochandler.h index 3425288..e72ad41 100644 --- a/addon/doxmlparser/src/dochandler.h +++ b/addon/doxmlparser/src/dochandler.h @@ -63,6 +63,8 @@ class MarkupModifierNode : public IDocMarkupModifier // IDocMarkupModifier virtual Kind kind() const { return MarkupModifier; } + virtual bool enabled() const { return m_enabled; } + virtual int markup() const { return m_markup; } private: int m_markup; @@ -106,6 +108,59 @@ class MarkupHandler : public BaseFallBackHandler<MarkupHandler> int m_curMarkup; }; +//----------------------------------------------------------------------------- + +/*! \brief Node representing a paragraph of text and commands. + * + */ +// children: itemizedlist, orderedlist, parameterlist, simplesect, ref, +// variablelist, hruler, linebreak, ulink, email, link +// programlisting, formula, image, dotfile, indexentry, +// table +// +// children handled by MarkupHandler: +// bold, computeroutput, emphasis, center, +// small, subscript, superscript. +// +class ParagraphHandler : public IDocPara, + public BaseHandler<ParagraphHandler> +{ + friend class ParagraphIterator; + + public: + virtual void startParagraph(const QXmlAttributes& attrib); + virtual void endParagraph(); + virtual void startItemizedList(const QXmlAttributes& attrib); + virtual void startOrderedList(const QXmlAttributes& attrib); + virtual void startParameterList(const QXmlAttributes& attrib); + virtual void startSimpleSect(const QXmlAttributes& attrib); + virtual void startRef(const QXmlAttributes& attrib); + virtual void startVariableList(const QXmlAttributes& attrib); + virtual void startHRuler(const QXmlAttributes& attrib); + virtual void startLineBreak(const QXmlAttributes& attrib); + virtual void startULink(const QXmlAttributes& attrib); + virtual void startEMail(const QXmlAttributes& attrib); + virtual void startLink(const QXmlAttributes& attrib); + virtual void startProgramListing(const QXmlAttributes& attrib); + virtual void startFormula(const QXmlAttributes& attrib); + virtual void startImage(const QXmlAttributes& attrib); + virtual void startDotFile(const QXmlAttributes& attrib); + virtual void startIndexEntry(const QXmlAttributes& attrib); + virtual void startTable(const QXmlAttributes& attrib); + + ParagraphHandler(IBaseHandler *parent); + virtual ~ParagraphHandler(); + + // IDocPara + virtual Kind kind() const { return Para; } + virtual IDocIterator *contents() const; + + private: + void addTextNode(); + IBaseHandler *m_parent; + QList<IDoc> m_children; + MarkupHandler *m_markupHandler; +}; //----------------------------------------------------------------------------- @@ -114,6 +169,7 @@ class MarkupHandler : public BaseFallBackHandler<MarkupHandler> */ class ListItemHandler : public IDocListItem, public BaseHandler<ListItemHandler> { + friend class ListItemIterator; public: ListItemHandler(IBaseHandler *parent); virtual ~ListItemHandler(); @@ -123,39 +179,86 @@ class ListItemHandler : public IDocListItem, public BaseHandler<ListItemHandler> // IDocItem virtual Kind kind() const { return ListItem; } + virtual IDocIterator *contents() const; private: IBaseHandler *m_parent; QList<IDoc> m_children; }; +class ListItemIterator : public BaseIterator<IDocIterator,IDoc,IDoc> +{ + public: + ListItemIterator(const ListItemHandler &handler) : + BaseIterator<IDocIterator,IDoc,IDoc>(handler.m_children) {} +}; + //----------------------------------------------------------------------------- /*! \brief Node representing list of items. * */ -class ListHandler : public IDocList, public BaseHandler<ListHandler> +class OrderedListHandler : public IDocOrderedList, public BaseHandler<OrderedListHandler> { + friend class OrderedListIterator; public: - ListHandler(Kind k,IBaseHandler *parent); - virtual ~ListHandler(); - virtual void startList(const QXmlAttributes& attrib); - virtual void endList(); - virtual void startListItem(const QXmlAttributes& attrib); + OrderedListHandler(IBaseHandler *parent); + virtual ~OrderedListHandler(); + virtual void startOrderedList(const QXmlAttributes& attrib); + virtual void endOrderedList(); + virtual void startOrderedListItem(const QXmlAttributes& attrib); - // IDocList - virtual Kind kind() const { return m_kind; } + // IDocOrderedList + virtual Kind kind() const { return OrderedList; } + virtual IDocIterator *elements() const; private: IBaseHandler *m_parent; QList<IDoc> m_children; - Kind m_kind; +}; + +class OrderedListIterator : public BaseIterator<IDocIterator,IDoc,IDoc> +{ + public: + OrderedListIterator(const OrderedListHandler &handler) : + BaseIterator<IDocIterator,IDoc,IDoc>(handler.m_children) {} }; //----------------------------------------------------------------------------- +/*! \brief Node representing list of items. + * + */ +class ItemizedListHandler : public IDocItemizedList, public BaseHandler<ItemizedListHandler> +{ + friend class ItemizedListIterator; + public: + ItemizedListHandler(IBaseHandler *parent); + virtual ~ItemizedListHandler(); + virtual void startItemizedList(const QXmlAttributes& attrib); + virtual void endItemizedList(); + virtual void startItemizedListItem(const QXmlAttributes& attrib); + + // IDocItemizedList + virtual Kind kind() const { return ItemizedList; } + virtual IDocIterator *elements() const; + + private: + IBaseHandler *m_parent; + QList<IDoc> m_children; +}; + +class ItemizedListIterator : public BaseIterator<IDocIterator,IDoc,IDoc> +{ + public: + ItemizedListIterator(const ItemizedListHandler &handler) : + BaseIterator<IDocIterator,IDoc,IDoc>(handler.m_children) {} +}; + + +//----------------------------------------------------------------------------- /*! \brief Node representing a parameter. * */ @@ -173,6 +276,8 @@ class ParameterHandler : public IDocParameter, // IDocParameter virtual Kind kind() const { return Parameter; } + virtual QString name() const { return m_name; } + virtual IDocPara *description() const { return m_description; } private: IBaseHandler *m_parent; @@ -180,17 +285,16 @@ class ParameterHandler : public IDocParameter, ParagraphHandler *m_description; }; - //----------------------------------------------------------------------------- /* \brief Node representing a parameter list. * */ -class ParameterListHandler : public IDocParameter, +class ParameterListHandler : public IDocParameterList, public BaseHandler<ParameterListHandler> { + friend class ParameterListIterator; public: - enum Types { Param, RetVal, Exception }; ParameterListHandler(IBaseHandler *parent); virtual ~ParameterListHandler(); virtual void startParameterList(const QXmlAttributes& attrib); @@ -200,6 +304,8 @@ class ParameterListHandler : public IDocParameter, // IDocParameterList virtual Kind kind() const { return ParameterList; } + virtual Types listType() const { return m_type; } + virtual IDocIterator *params() const; private: IBaseHandler *m_parent; @@ -208,6 +314,13 @@ class ParameterListHandler : public IDocParameter, Types m_type; }; +class ParameterListIterator : public BaseIterator<IDocIterator,IDoc,ParameterHandler> +{ + public: + ParameterListIterator(const ParameterListHandler &handler) : + BaseIterator<IDocIterator,IDoc,ParameterHandler>(handler.m_parameters) {} +}; + //----------------------------------------------------------------------------- /* \brief Node representing a horizontal ruler @@ -335,11 +448,11 @@ class RefHandler : public IDocRef, public BaseHandler<RefHandler> // IDocRef virtual Kind kind() const { return Ref; } + virtual QString refId() const { return m_refId; } private: IBaseHandler *m_parent; QString m_refId; - QString m_anchor; QString m_linkText; }; @@ -390,14 +503,6 @@ class SimpleSectHandler : public IDocSimpleSect, public BaseHandler<SimpleSectHandler> { public: - enum Types { Invalid = 0, - See, Return, Author, Version, - Since, Date, Bug, Note, - Warning, Par, Deprecated, Pre, - Post, Invar, Remark, Attention, - Todo, Test, RCS, EnumValues, - Examples - }; SimpleSectHandler(IBaseHandler *parent); virtual ~SimpleSectHandler(); virtual void startSimpleSect(const QXmlAttributes& attrib); @@ -407,6 +512,9 @@ class SimpleSectHandler : public IDocSimpleSect, // IDocSimpleSect virtual Kind kind() const { return SimpleSect; } + virtual Types sectionType() const { return m_type; } + virtual IDocTitle *title() const { return m_title; } + virtual IDocPara *description() const { return m_paragraph; } private: IBaseHandler *m_parent; @@ -697,7 +805,7 @@ class RowHandler : public IDocRow, public BaseHandler<RowHandler> /*! \brief Node representing an entry in the table. * */ -// children: row +// children: row, caption class TableHandler : public IDocTable, public BaseHandler<TableHandler> { public: @@ -706,6 +814,8 @@ class TableHandler : public IDocTable, public BaseHandler<TableHandler> void startTable(const QXmlAttributes& attrib); void endTable(); void startRow(const QXmlAttributes& attrib); + void startCaption(const QXmlAttributes& attrib); + void endCaption(); // IDocTable virtual Kind kind() const { return Table; } @@ -714,62 +824,11 @@ class TableHandler : public IDocTable, public BaseHandler<TableHandler> IBaseHandler *m_parent; QList<RowHandler> m_children; int m_numColumns; + QString m_caption; }; //----------------------------------------------------------------------------- -/*! \brief Node representing a paragraph of text and commands. - * - */ -// children: itemizedlist, orderedlist, parameterlist, simplesect, ref, -// variablelist, hruler, linebreak, ulink, email, link -// programlisting, formula, image, dotfile, indexentry, -// table -// -// children handled by MarkupHandler: -// bold, computeroutput, emphasis, center, -// small, subscript, superscript. -// -class ParagraphHandler : public IDocPara, - public BaseHandler<ParagraphHandler> -{ - friend class ParagraphIterator; - - public: - virtual void startParagraph(const QXmlAttributes& attrib); - virtual void endParagraph(); - virtual void startItemizedList(const QXmlAttributes& attrib); - virtual void startOrderedList(const QXmlAttributes& attrib); - virtual void startParameterList(const QXmlAttributes& attrib); - virtual void startSimpleSect(const QXmlAttributes& attrib); - virtual void startRef(const QXmlAttributes& attrib); - virtual void startVariableList(const QXmlAttributes& attrib); - virtual void startHRuler(const QXmlAttributes& attrib); - virtual void startLineBreak(const QXmlAttributes& attrib); - virtual void startULink(const QXmlAttributes& attrib); - virtual void startEMail(const QXmlAttributes& attrib); - virtual void startLink(const QXmlAttributes& attrib); - virtual void startProgramListing(const QXmlAttributes& attrib); - virtual void startFormula(const QXmlAttributes& attrib); - virtual void startImage(const QXmlAttributes& attrib); - virtual void startDotFile(const QXmlAttributes& attrib); - virtual void startIndexEntry(const QXmlAttributes& attrib); - virtual void startTable(const QXmlAttributes& attrib); - - ParagraphHandler(IBaseHandler *parent); - virtual ~ParagraphHandler(); - - // IDocPara - virtual Kind kind() const { return Para; } - virtual IDocIterator *contents() const; - - private: - void addTextNode(); - IBaseHandler *m_parent; - QList<IDoc> m_children; - MarkupHandler *m_markupHandler; -}; - class ParagraphIterator : public BaseIterator<IDocIterator,IDoc,IDoc> { public: diff --git a/addon/doxmlparser/src/doxmlintf.h b/addon/doxmlparser/src/doxmlintf.h index ec2950c..390e9bb 100644 --- a/addon/doxmlparser/src/doxmlintf.h +++ b/addon/doxmlparser/src/doxmlintf.h @@ -22,7 +22,9 @@ class ILT_Text : public ILinkedText class ILT_Ref : public ILinkedText { public: + enum TargetKind { Member, Compound }; virtual QString id() const = 0; + virtual TargetKind targetKind() const = 0; virtual QString external() const = 0; virtual QString text() const = 0; }; @@ -104,8 +106,8 @@ class IDoc Para, // 0 -> IDocPara Text, // 1 -> IDocText MarkupModifier, // 2 -> IDocMarkupModifier - ItemizedList, // 3 -> IDocList - OrderedList, // 4 -> IDocList + ItemizedList, // 3 -> IDocItemizedList + OrderedList, // 4 -> IDocOrderedList ListItem, // 5 -> IDocListItem ParameterList, // 6 -> IDocParameterList Parameter, // 7 -> IDocParameter @@ -168,36 +170,74 @@ class IDocText : public IDocMarkup class IDocMarkupModifier : public IDoc { + public: + virtual bool enabled() const = 0; + virtual int markup() const = 0; +}; + +class IDocItemizedList : public IDoc +{ + public: + virtual IDocIterator *elements() const = 0; }; -class IDocList : public IDoc +class IDocOrderedList : public IDoc { + public: + virtual IDocIterator *elements() const = 0; }; class IDocListItem : public IDoc { + public: + virtual IDocIterator *contents() const = 0; }; class IDocParameterList : public IDoc { + public: + enum Types { Param, RetVal, Exception }; + virtual Types listType() const = 0; + virtual IDocIterator *params() const = 0; }; class IDocParameter : public IDoc { + public: + virtual QString name() const = 0; + virtual IDocPara *description() const = 0; }; -class IDocSimpleSect : public IDoc +class IDocTitle : public IDoc { + public: + virtual IDocIterator *title() const = 0; }; -class IDocTitle : public IDoc +class IDocSimpleSect : public IDoc { public: - virtual IDocIterator *title() const = 0; + enum Types { Invalid = 0, + See, Return, Author, Version, + Since, Date, Bug, Note, + Warning, Par, Deprecated, Pre, + Post, Invar, Remark, Attention, + Todo, Test, RCS, EnumValues, + Examples + }; + virtual Types sectionType() const = 0; + virtual IDocTitle *title() const = 0; + virtual IDocPara *description() const = 0; }; class IDocRef : public IDoc { + public: + enum TargetKind { Member, Compound }; + virtual QString id() const = 0; + virtual TargetKind targetKind() const = 0; + virtual QString external() const = 0; + virtual QString text() const = 0; }; class IDocVariableList : public IDoc diff --git a/addon/doxmlparser/src/linkedtexthandler.cpp b/addon/doxmlparser/src/linkedtexthandler.cpp index b142188..fabd0c1 100644 --- a/addon/doxmlparser/src/linkedtexthandler.cpp +++ b/addon/doxmlparser/src/linkedtexthandler.cpp @@ -36,10 +36,12 @@ class LT_Ref : public ILT_Ref void setRefId(const QString &refId) { m_refId=refId; } void setText(const QString &text) { m_text=text; } void setExtId(const QString &extId) { m_extId=extId; } + void setTargetKind(TargetKind k) { m_targetKind=k; } // ILT_Ref virtual QString text() const { return m_text; } virtual QString id() const { return m_refId; } + virtual TargetKind targetKind() const { return m_targetKind; } virtual QString external() const { return m_extId; } virtual Kind kind() const { return Kind_Ref; } @@ -47,6 +49,7 @@ class LT_Ref : public ILT_Ref QString m_refId; QString m_extId; QString m_text; + TargetKind m_targetKind; }; LinkedTextHandler::LinkedTextHandler(IBaseHandler *parent, @@ -92,8 +95,10 @@ void LinkedTextHandler::startRef(const QXmlAttributes& attrib) } ASSERT(m_ref==0); m_ref = new LT_Ref; - m_ref->setRefId(attrib.value("idref")); + m_ref->setRefId(attrib.value("refid")); m_ref->setExtId(attrib.value("external")); + ASSERT(attrib.value("kindref")=="compound" || attrib.value("kindref")=="member"); + m_ref->setTargetKind(attrib.value("kindref")=="compound" ? Compound : Member); } void LinkedTextHandler::endRef() |