diff options
Diffstat (limited to 'addon/doxmlparser')
-rw-r--r-- | addon/doxmlparser/doxygen.dtd | 225 | ||||
-rw-r--r-- | addon/doxmlparser/include/doxmlintf.h | 52 | ||||
-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 | ||||
-rw-r--r-- | addon/doxmlparser/test/main.cpp | 198 |
8 files changed, 681 insertions, 159 deletions
diff --git a/addon/doxmlparser/doxygen.dtd b/addon/doxmlparser/doxygen.dtd index 5b293d0..319b776 100644 --- a/addon/doxmlparser/doxygen.dtd +++ b/addon/doxmlparser/doxygen.dtd @@ -1,37 +1,79 @@ -<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -<!-- NOTE: THIS DTD IS NOT UP TO DATE!!! DO NOT DEPEND ON IT --> -<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> - <?xml version="1.0" encoding="ISO-8859-1"?> <!-- DTD describing the grammar used in doxygen's XML output --> +<!-- Version 0.1 December 25, 2001 --> +<!-- Defined by Angelo Hulshout, based on works of Dimitri van Heesch --> <!-- standard character entities --> -<!ENTITY lt "&#60;"> -<!ENTITY gt ">"> -<!ENTITY amp "&#38;"> -<!ENTITY apos "'"> -<!ENTITY quot """> - -<!-- required attributes for compounds --> -<!ENTITY % compound-req.att +<!ENTITY lt "&#60;"> +<!ENTITY gt ">"> +<!ENTITY amp "&#38;"> +<!ENTITY apos "'"> +<!ENTITY quot """> + +<!-- + Document root +--> +<!ELEMENT doxygen (compounddef)*> + +<!-- + Compound related entities and elements +--> +<!ENTITY % compound-req.att 'id ID #REQUIRED - type (group|file|namespace| + kind (group|file|namespace| class|struct|union| interface|dispinterface| valuetype|library) #REQUIRED' > -<!-- required attributes for references --> <!ENTITY % ref-req.att 'idref IDREF #REQUIRED' > -<!-- required attributes for inheritance relations --> <!ENTITY % inheritcompref-req.att '%ref-req.att; prot (public|protected|private) #REQUIRED virt (non-virtual|virtual) #REQUIRED' > +<!ELEMENT compounddef (compoundname, + basecompoundref*, + derivedcompoundref*, + sectiondef*, + briefdescription, + detaileddescription, + inheritancegraph?, + collaborationgraph?, + programlisting?, + sourcecode?, + location? + ) +> +<!ATTLIST compounddef %compound-req.att;> + +<!ELEMENT compoundname (#PCDATA)> + +<!ELEMENT location (#PCDATA)> +<!ATTLIST location file CDATA #REQUIRED line CDATA #REQUIRED > + +<!ELEMENT compoundref EMPTY> +<!ATTLIST compoundref %ref-req.att;> + +<!ELEMENT basecompoundref EMPTY> +<!ATTLIST basecompoundref %inheritcompref-req.att;> + +<!ELEMENT derivedcompoundref EMPTY> +<!ATTLIST derivedcompoundref %inheritcompref-req.att;> + +<!ELEMENT memberdef (#PCDATA|type|name|briefdescription|detaileddescription|location|param|initializer|enumvalue)*> +<!ATTLIST memberdef kind (define|property|variable|typedef|enum|function|signal|prototype|friend|dcop|slot) #REQUIRED id CDATA #REQUIRED virt (normal|virtual|pure-virtual) #REQUIRED prot (public|protected|private) #REQUIRED> + +<!ELEMENT briefdescription (#PCDATA|para)*> + +<!ELEMENT detaileddescription (#PCDATA|para)*> + +<!-- + Compound attributes related entities and elements +--> <!-- required attributes for member sections --> -<!ENTITY % sec-req.att 'type (user +<!ENTITY % sec-req.att 'kind (user |public-type |public-func |public-attrib @@ -59,65 +101,148 @@ ) #REQUIRED ' > -<!-- required attributes for members --> <!ENTITY % mem-req.att 'id ID #REQUIRED'> <!-- optional attributes for function --> <!ENTITY % func-opt.att 'virt (virtual|pure-virtual) #IMPLIED'> -<!-- elements --> -<!ELEMENT doxygen (compounddef)*> -<!ELEMENT compounddef (compoundname, - basecompoundref*, - derivedcompoundref*, - sectiondef*, - briefdescription, - detaileddescription, - inheritancegraph?, - collaborationgraph?, - sourcecode? - ) -> -<!ATTLIST compounddef %compound-req.att;> -<!ELEMENT compoundref (#PCDATA)> -<!ATTLIST compoundref %ref-req.att;> <!ELEMENT memberref (#PCDATA)> <!ATTLIST memberref %ref-req.att;> -<!ELEMENT basecompoundref EMPTY> -<!ATTLIST basecompoundref %inheritcompref-req.att;> -<!ELEMENT derivedcompoundref EMPTY> -<!ATTLIST derivedcompoundref %inheritcompref-req.att;> + <!ELEMENT sectionlist (sectiondef)+> -<!ELEMENT sectiondef (memberlist)> + +<!ELEMENT sectiondef (memberdef|memberlist)*> <!ATTLIST sectiondef %sec-req.att;> + <!ELEMENT memberlist (functiondef|variabledef|typedef|definedef|enumdef)+> -<!ELEMENT functiondef (type?,name,paramlist)> + +<!ELEMENT functiondef (type?,name,parameterlist)> <!ATTLIST functiondef %mem-req.att; %func-opt.att;> + <!ELEMENT variabledef (type,name,array?,initializer?)> <!ATTLIST variabledef %mem-req.att;> + +<!ELEMENT parameterlist (title|parametername|parameterdescription)*> +<!ATTLIST parameterlist kind (param|retval|exception) #REQUIRED> + +<!ELEMENT param (attributes?,type?,declname?,defname?,array?,defval?)> + +<!ELEMENT parametername (#PCDATA)> + +<!ELEMENT parameterdescription (#PCDATA|para)*> + +<!ELEMENT defparameterlist (defarg)*> + +<!ELEMENT defarg (#PCDATA)> + +<!-- + Programming language declaration related entities and elements +--> +<!ELEMENT name (#PCDATA)> + <!ELEMENT typedef (type,name)> <!ATTLIST typedef %mem-req.att;> -<!ELEMENT definedef (name,defparamlist?,initializer?)> + +<!ELEMENT definedef (name,defparameterlist?,initializer?)> <!ATTLIST definedef %mem-req.att;> + <!ELEMENT enumdef (name,enumvaluelist)> <!ATTLIST enumdef %mem-req.att;> -<!ELEMENT slotdef (type,name,paramlist)> + +<!ELEMENT slotdef (type,name,parameterlist)> <!ATTLIST slotdef %mem-req.att;> -<!ELEMENT signaldef (type,name,paramlist)> + +<!ELEMENT signaldef (type,name,parameterlist)> <!ATTLIST signaldef %mem-req.att;> -<!ELEMENT paramlist (param)*> -<!ELEMENT param (attributes?,type,declname?,defname?,array?,defval?)> -<!ELEMENT defparamlist (defarg)*> -<!ELEMENT defarg (#PCDATA)> + <!ELEMENT enumvaluelist (enumvalue)*> + <!ELEMENT enumvalue (name,initializer?)> -<!ELEMENT name (#PCDATA)> -<!ELEMENT compoundname (#PCDATA)> + <!ELEMENT declname (#PCDATA)> + <!ELEMENT defname (#PCDATA)> -<!ELEMENT type (#PCDATA|memberref|compoundref|compounddef)*> + +<!ELEMENT type (#PCDATA|memberref|compoundref|compounddef|ref)*> + <!ELEMENT defval (#PCDATA|memberref|compoundref)*> -<!ELEMENT initializer (#PCDATA|memberref|compoundref)*> + +<!ELEMENT initializer (#PCDATA|memberref|compoundref|ref)*> + <!ELEMENT array (#PCDATA)> + <!ELEMENT attributes (#PCDATA)> +<!-- + Graph related entities and elements +--> +<!ELEMENT collaborationgraph (node)*> + +<!ELEMENT inheritancegraph (node)*> + +<!ELEMENT node (label|link|childnode)*> +<!ATTLIST node id CDATA #REQUIRED> + +<!ELEMENT childnode (edgelabel)*> +<!ATTLIST childnode id CDATA #REQUIRED relation CDATA #REQUIRED> + +<!ELEMENT label (#PCDATA)> + +<!ELEMENT link EMPTY> +<!ATTLIST link id CDATA #REQUIRED> + +<!ELEMENT edgelabel (#PCDATA)> + +<!-- + Source code listing related entities and elements +--> +<!ELEMENT codeline (#PCDATA|highlight|ref)*> + +<!ELEMENT linenumber (#PCDATA|anchor)*> +<!ATTLIST linenumber line CDATA #IMPLIED refid CDATA #IMPLIED> + +<!ELEMENT sourcecode (linenumber|codeline|highlight|ref)*> + +<!ELEMENT itemizedlist (listitem)*> + +<!ELEMENT listitem (#PCDATA|para)*> + +<!ELEMENT programlisting (#PCDATA|linenumber|codeline|linebreak|highlight)*> + +<!-- + Hypertext related entities and elements +--> +<!ELEMENT ulink (#PCDATA)> +<!ATTLIST ulink url CDATA #REQUIRED> + +<!ELEMENT anchor (ref)> +<!ATTLIST anchor id CDATA #REQUIRED> + +<!ELEMENT ref (#PCDATA)> +<!ATTLIST ref idref CDATA #REQUIRED anchor CDATA #IMPLIED> + +<!-- + Documentation layout entities and elements +--> +<!--ELEMENT highlight (#PCDATA|ref)*--> +<!ELEMENT highlight ANY> +<!ATTLIST highlight class (preprocessor|keyword|keywordtype|keywordflow|stringliteral|charliteral|comment) #REQUIRED> + +<!ELEMENT linebreak EMPTY> + +<!--ELEMENT simplesect (title|para)*--> +<!ELEMENT simplesect ANY> +<!ATTLIST simplesect kind (see|return|author|version|since|date|bug|note|warning|par|deprecated|pre|post|invariant|remark|attention|todo|test|rcs|enumvalues|examples) #REQUIRED> + +<!--ELEMENT computeroutput (#PCDATA)--> +<!ELEMENT computeroutput ANY> + +<!--ELEMENT emphasis (#PCDATA|ref)*--> +<!ELEMENT emphasis ANY> + +<!--ELEMENT title (#PCDATA|ref)*--> +<!ELEMENT title ANY> + +<!--ELEMENT para (#PCDATA|computeroutput|ref|emphasis|parameterlist|simplesect|ulink|programlisting|itemizedlist|linebreak)*--> +<!ELEMENT para ANY> + diff --git a/addon/doxmlparser/include/doxmlintf.h b/addon/doxmlparser/include/doxmlintf.h index ec2950c..390e9bb 100644 --- a/addon/doxmlparser/include/doxmlintf.h +++ b/addon/doxmlparser/include/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/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() diff --git a/addon/doxmlparser/test/main.cpp b/addon/doxmlparser/test/main.cpp index 9af575a..b94bc0a 100644 --- a/addon/doxmlparser/test/main.cpp +++ b/addon/doxmlparser/test/main.cpp @@ -60,6 +60,90 @@ void DumpDoc(IDoc *doc) printf(" --- text `%s' markup=%d --- \n",txt->text().data(),txt->markup()); } break; + case IDoc::MarkupModifier: + { + IDocMarkupModifier *md = dynamic_cast<IDocMarkupModifier*>(doc); + ASSERT(md!=0); + printf(" --- markup modifier enabled=%d markup=%d\n",md->enabled(),md->markup()); + } + break; + case IDoc::ItemizedList: + { + printf(" --- itemized list --- \n"); + IDocItemizedList *list = dynamic_cast<IDocItemizedList*>(doc); + ASSERT(list!=0); + IDocIterator *di = list->elements(); + IDoc *pdoc; + for (di->toFirst();(pdoc=di->current());di->toNext()) + { + DumpDoc(pdoc); + } + di->release(); + printf(" --- end itemized list --- \n"); + } + break; + case IDoc::OrderedList: + { + printf(" --- ordered list --- \n"); + IDocOrderedList *list = dynamic_cast<IDocOrderedList*>(doc); + ASSERT(list!=0); + IDocIterator *di = list->elements(); + IDoc *pdoc; + for (di->toFirst();(pdoc=di->current());di->toNext()) + { + DumpDoc(pdoc); + } + di->release(); + printf(" --- end ordered list --- \n"); + } + break; + case IDoc::ListItem: + { + printf(" --- list item --- \n"); + IDocListItem *li = dynamic_cast<IDocListItem*>(doc); + ASSERT(li!=0); + IDocIterator *di = li->contents(); + IDoc *pdoc; + for (di->toFirst();(pdoc=di->current());di->toNext()) + { + DumpDoc(pdoc); + } + di->release(); + printf(" --- end list item --- \n"); + } + break; + case IDoc::ParameterList: + { + IDocParameterList *list = dynamic_cast<IDocParameterList*>(doc); + printf(" --- parameter list type=%d --- \n",list->listType()); + IDocListItem *li = dynamic_cast<IDocListItem*>(doc); + ASSERT(li!=0); + IDocIterator *di = li->contents(); + IDoc *pdoc; + for (di->toFirst();(pdoc=di->current());di->toNext()) + { + DumpDoc(pdoc); + } + di->release(); + printf(" --- parameter list item --- \n"); + ASSERT(list!=0); + } + break; + case IDoc::Parameter: + { + IDocParameter *par = dynamic_cast<IDocParameter*>(doc); + ASSERT(par!=0); + printf(" --- parameter name=%s --- \n",par->name().data()); + DumpDoc(par->description()); + printf(" --- end parameter --- \n"); + } + break; + case IDoc::SimpleSect: + { + IDocSimpleSect *ss = dynamic_cast<IDocSimpleSect*>(ss); + ASSERT(ss!=0); + } + break; case IDoc::Title: { printf(" --- title --- \n"); @@ -74,6 +158,120 @@ void DumpDoc(IDoc *doc) printf(" --- end title --- \n"); } break; + case IDoc::Ref: + { + IDocRef *ref = dynamic_cast<IDocRef*>(ref); + ASSERT(ref!=0); + } + break; + case IDoc::VariableList: + { + IDocVariableList *vl = dynamic_cast<IDocVariableList*>(vl); + ASSERT(vl!=0); + } + break; + case IDoc::VariableListEntry: + { + IDocVariableListEntry *vle = dynamic_cast<IDocVariableListEntry*>(vle); + ASSERT(vle!=0); + } + break; + case IDoc::HRuler: + { + IDocHRuler *hr = dynamic_cast<IDocHRuler*>(hr); + ASSERT(hr!=0); + } + break; + case IDoc::LineBreak: + { + IDocLineBreak *lb = dynamic_cast<IDocLineBreak*>(lb); + ASSERT(lb!=0); + } + break; + case IDoc::ULink: + { + IDocULink *ul = dynamic_cast<IDocULink*>(ul); + ASSERT(ul!=0); + } + break; + case IDoc::EMail: + { + IDocEMail *em = dynamic_cast<IDocEMail*>(em); + ASSERT(em!=0); + } + break; + case IDoc::Link: + { + IDocLink *lk = dynamic_cast<IDocLink*>(lk); + ASSERT(lk!=0); + } + break; + case IDoc::ProgramListing: + { + IDocProgramListing *pl = dynamic_cast<IDocProgramListing*>(pl); + ASSERT(pl!=0); + } + break; + case IDoc::CodeLine: + { + IDocCodeLine *cl = dynamic_cast<IDocCodeLine*>(cl); + ASSERT(cl!=0); + } + break; + case IDoc::Highlight: + { + IDocHighlight *hl = dynamic_cast<IDocHighlight*>(hl); + ASSERT(hl!=0); + } + break; + case IDoc::Anchor: + { + IDocAnchor *anc = dynamic_cast<IDocAnchor*>(anc); + ASSERT(anc!=0); + } + break; + case IDoc::Formula: + { + IDocFormula *fm = dynamic_cast<IDocFormula*>(fm); + ASSERT(fm!=0); + } + break; + case IDoc::Image: + { + IDocImage *img = dynamic_cast<IDocImage*>(img); + ASSERT(img!=0); + } + break; + case IDoc::DotFile: + { + IDocDotFile *df = dynamic_cast<IDocDotFile*>(df); + ASSERT(df!=0); + } + break; + case IDoc::IndexEntry: + { + IDocIndexEntry *ie = dynamic_cast<IDocIndexEntry*>(ie); + ASSERT(ie!=0); + } + break; + case IDoc::Table: + { + IDocTable *tbl = dynamic_cast<IDocTable*>(tbl); + ASSERT(tbl!=0); + } + break; + case IDoc::Row: + { + IDocRow *row = dynamic_cast<IDocRow*>(row); + ASSERT(row!=0); + } + break; + case IDoc::Entry: + { + IDocEntry *ent = dynamic_cast<IDocEntry*>(ent); + ASSERT(ent!=0); + } + break; case IDoc::Section: { IDocSection *sec = dynamic_cast<IDocSection*>(doc); |