summaryrefslogtreecommitdiffstats
path: root/src/H5Sdeprec.c
Commit message (Expand)AuthorAgeFilesLines
* HDFFV-10365: Changes as described in the RFC: H5Sencode/H5Sdecode Format Change.Vailin Choi2019-04-061-0/+121
pHandler = new MarkupHandler(m_children,m_curString); + setFallBackHandler(m_markupHandler); + addStartHandler("ref",this,&TitleHandler::startRef); +} + +TitleHandler::~TitleHandler() +{ + delete m_markupHandler; +} + +void TitleHandler::startTitle(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + addEndHandler("title",this,&TitleHandler::endTitle); + printf("Start title\n"); + m_curString=""; +} + +void TitleHandler::endTitle() +{ + addTextNode(); + m_parent->setDelegate(0); + printf("End title\n"); +} + +void TitleHandler::addTextNode() +{ + if (!m_curString.isEmpty()) + { + m_children.append(new TextNode(m_curString,m_markupHandler->markup())); + printf("addTextNode() text=\"%s\" markup=%x\n", + m_curString.data(),m_markupHandler->markup()); + m_curString=""; + } +} + +void TitleHandler::startRef(const QXmlAttributes& attrib) +{ + RefHandler *ref = new RefHandler(this); + ref->startRef(attrib); + m_children.append(ref); +} + +//---------------------------------------------------------------------- // SimpleSectHandler //---------------------------------------------------------------------- SimpleSectHandler::SimpleSectHandler(IBaseHandler *parent) - : DocNode(Para), m_parent(parent), m_paragraph(0) + : DocNode(Para), m_parent(parent), m_paragraph(0), m_title(0) { addStartHandler("title",this,&SimpleSectHandler::startTitle); - addEndHandler("title",this,&SimpleSectHandler::endTitle); addStartHandler("para",this,&SimpleSectHandler::startParagraph); } @@ -402,24 +535,124 @@ void SimpleSectHandler::endSimpleSect() m_parent->setDelegate(0); } -void SimpleSectHandler::startTitle(const QXmlAttributes& /*attrib*/) +void SimpleSectHandler::startTitle(const QXmlAttributes& attrib) { - m_curString=""; + ASSERT(m_title==0); + m_title = new TitleHandler(this); + m_title->startTitle(attrib); +} + +void SimpleSectHandler::startParagraph(const QXmlAttributes& attrib) +{ + ASSERT(m_paragraph==0); + m_paragraph = new ParagraphHandler(this); + m_paragraph->startParagraph(attrib); +} + +//---------------------------------------------------------------------- +// VariableListEntryHandler +//---------------------------------------------------------------------- + +VariableListEntryHandler::VariableListEntryHandler(IBaseHandler *parent) + : DocNode(VariableListEntry), m_parent(parent), m_description(0) +{ + addStartHandler("term",this,&VariableListEntryHandler::startTerm); + addEndHandler("term",this,&VariableListEntryHandler::endTerm); + addStartHandler("para",this,&VariableListEntryHandler::startParagraph); +} + +VariableListEntryHandler::~VariableListEntryHandler() +{ + delete m_description; +} + +void VariableListEntryHandler::startVarListEntry(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + printf("start varlistentry\n"); + addEndHandler("varlistentry",this,&VariableListEntryHandler::endVarListEntry); } -void SimpleSectHandler::endTitle() +void VariableListEntryHandler::endVarListEntry() +{ + m_parent->setDelegate(0); + printf("end varlistentry\n"); +} + +void VariableListEntryHandler::startListItem(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + printf("start listitem\n"); + addEndHandler("listitem",this,&VariableListEntryHandler::endListItem); +} + +void VariableListEntryHandler::endListItem() +{ + m_parent->setDelegate(0); + printf("end listitem\n"); +} + +void VariableListEntryHandler::startTerm(const QXmlAttributes& /*attrib*/) { - printf("simpleSect title=\"%s\"\n",m_curString.data()); - m_title = m_curString; m_curString=""; } +void VariableListEntryHandler::endTerm() +{ + m_term = m_curString; + printf("term=%s\n",m_term.data()); +} -void SimpleSectHandler::startParagraph(const QXmlAttributes& attrib) +void VariableListEntryHandler::startParagraph(const QXmlAttributes& attrib) { - ASSERT(m_paragraph==0); - m_paragraph = new ParagraphHandler(this); - m_paragraph->startParagraph(attrib); + ASSERT(m_description==0); + m_description = new ParagraphHandler(this); + m_description->startParagraph(attrib); +} + + + +//---------------------------------------------------------------------- +// VariableListHandler +//---------------------------------------------------------------------- + +VariableListHandler::VariableListHandler(IBaseHandler *parent) + : DocNode(VariableList), m_parent(parent) +{ + m_entries.setAutoDelete(TRUE); + addStartHandler("varlistentry",this,&VariableListHandler::startVarListEntry); + addStartHandler("listitem",this,&VariableListHandler::startListItem); +} + +VariableListHandler::~VariableListHandler() +{ +} + +void VariableListHandler::startVariableList(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + printf("start variablelist\n"); + addEndHandler("variablelist",this,&VariableListHandler::endVariableList); +} + +void VariableListHandler::endVariableList() +{ + printf("end variablelist\n"); + m_parent->setDelegate(0); +} + +void VariableListHandler::startVarListEntry(const QXmlAttributes& attrib) +{ + VariableListEntryHandler *vle = new VariableListEntryHandler(this); + vle->startVarListEntry(attrib); + m_curEntry = vle; + m_entries.append(vle); +} + +void VariableListHandler::startListItem(const QXmlAttributes& attrib) +{ + ASSERT(m_curEntry!=0); + m_curEntry->startListItem(attrib); } //---------------------------------------------------------------------- @@ -440,6 +673,10 @@ ParagraphHandler::ParagraphHandler(IBaseHandler *parent) addStartHandler("orderedlist",this,&ParagraphHandler::startOrderedList); addStartHandler("parameterlist",this,&ParagraphHandler::startParameterList); addStartHandler("simplesect",this,&ParagraphHandler::startSimpleSect); + addStartHandler("ref",this,&ParagraphHandler::startRef); + addStartHandler("variablelist",this,&ParagraphHandler::startVariableList); + addStartHandler("hruler",this,&ParagraphHandler::startHRuler); + addStartHandler("linebreak",this,&ParagraphHandler::startLineBreak); } ParagraphHandler::~ParagraphHandler() @@ -492,12 +729,40 @@ void ParagraphHandler::startSimpleSect(const QXmlAttributes& attrib) m_children.append(sectHandler); } +void ParagraphHandler::startRef(const QXmlAttributes& attrib) +{ + RefHandler *ref = new RefHandler(this); + ref->startRef(attrib); + m_children.append(ref); +} + +void ParagraphHandler::startVariableList(const QXmlAttributes& attrib) +{ + VariableListHandler *vl = new VariableListHandler(this); + vl->startVariableList(attrib); + m_children.append(vl); +} + +void ParagraphHandler::startHRuler(const QXmlAttributes& attrib) +{ + HRulerHandler *hr = new HRulerHandler(this); + hr->startHRuler(attrib); + m_children.append(hr); +} + +void ParagraphHandler::startLineBreak(const QXmlAttributes& attrib) +{ + LineBreakHandler *lb = new LineBreakHandler(this); + lb->startLineBreak(attrib); + m_children.append(lb); +} + void ParagraphHandler::addTextNode() { if (!m_curString.isEmpty()) { m_children.append(new TextNode(m_curString,m_markupHandler->markup())); - printf("addTextNode() text=%s markup=%x\n", + printf("addTextNode() text=\"%s\" markup=%x\n", m_curString.data(),m_markupHandler->markup()); m_curString=""; } diff --git a/addon/xmlparse/dochandler.h b/addon/xmlparse/dochandler.h index 4dc50c5..c805371 100644 --- a/addon/xmlparse/dochandler.h +++ b/addon/xmlparse/dochandler.h @@ -53,7 +53,13 @@ class DocNode ListItem, ParameterList, Parameter, - SimpleSect + SimpleSect, + Title, + Ref, + VariableList, + VariableListEntry, + HRuler, + LineBreak }; DocNode(NodeKind k) : m_kind(k) {} virtual ~DocNode() {} @@ -223,6 +229,85 @@ class ParameterListHandler : public DocNode, //----------------------------------------------------------------------------- +/* \brief Node representing a horizontal ruler + * + */ +class LineBreakHandler : public DocNode, public BaseHandler +{ + public: + LineBreakHandler(IBaseHandler *parent); + virtual ~LineBreakHandler(); + + void startLineBreak(const QXmlAttributes& attrib); + void endLineBreak(); + + private: + IBaseHandler *m_parent; +}; + +//----------------------------------------------------------------------------- + +/* \brief Node representing a horizontal ruler + * + */ +class HRulerHandler : public DocNode, public BaseHandler +{ + public: + HRulerHandler(IBaseHandler *parent); + virtual ~HRulerHandler(); + + void startHRuler(const QXmlAttributes& attrib); + void endHRuler(); + + private: + IBaseHandler *m_parent; +}; + +//----------------------------------------------------------------------------- + +/* \brief Node representing a reference to another item + * + */ +class RefHandler : public DocNode, public BaseHandler +{ + public: + RefHandler(IBaseHandler *parent); + virtual ~RefHandler(); + void startRef(const QXmlAttributes& attrib); + void endRef(); + private: + IBaseHandler *m_parent; + QCString m_refId; + QCString m_anchor; + QCString m_linkText; +}; + +//----------------------------------------------------------------------------- + +/* \brief Node representing the title of a section + * + */ +// children: text, ref +// children handled by MarkupHandler: +// bold, computeroutput, emphasis, center, +// small, subscript, superscript. +class TitleHandler : public DocNode, public BaseHandler +{ + public: + TitleHandler(IBaseHandler *parent); + virtual ~TitleHandler(); + virtual void startTitle(const QXmlAttributes& attrib); + virtual void endTitle(); + virtual void startRef(const QXmlAttributes& attrib); + void addTextNode(); + private: + IBaseHandler *m_parent; + QList m_children; + MarkupHandler *m_markupHandler; +}; + +//----------------------------------------------------------------------------- + /* \brief Node representing a simple section with an unnumbered header. * */ @@ -244,15 +329,58 @@ class SimpleSectHandler : public DocNode, virtual void startSimpleSect(const QXmlAttributes& attrib); virtual void endSimpleSect(); virtual void startTitle(const QXmlAttributes& attrib); - virtual void endTitle(); virtual void startParagraph(const QXmlAttributes& attrib); private: IBaseHandler *m_parent; ParagraphHandler *m_paragraph; Types m_type; - // TODO: a title can also contain links (for todo sections for instance!) - QString m_title; + TitleHandler *m_title; +}; + +//----------------------------------------------------------------------------- + +class VariableListEntryHandler : public DocNode, public BaseHandler +{ + public: + virtual void startVarListEntry(const QXmlAttributes& attrib); + virtual void endVarListEntry(); + virtual void startListItem(const QXmlAttributes& attrib); + virtual void endListItem(); + virtual void startTerm(const QXmlAttributes& attrib); + virtual void endTerm(); + virtual void startParagraph(const QXmlAttributes& attrib); + + VariableListEntryHandler(IBaseHandler *parent); + virtual ~VariableListEntryHandler(); + + private: + IBaseHandler *m_parent; + QString m_term; + ParagraphHandler *m_description; +}; + +//----------------------------------------------------------------------------- + +/*! \brief Node representing a list of named items. + * + */ +// children: varlistentry, listitem +class VariableListHandler : public DocNode, public BaseHandler +{ + public: + virtual void startVariableList(const QXmlAttributes& attrib); + virtual void endVariableList(); + virtual void startVarListEntry(const QXmlAttributes& attrib); + virtual void startListItem(const QXmlAttributes& attrib); + + VariableListHandler(IBaseHandler *parent); + virtual ~VariableListHandler(); + + private: + IBaseHandler *m_parent; + QList m_entries; + VariableListEntryHandler *m_curEntry; }; //----------------------------------------------------------------------------- @@ -260,10 +388,13 @@ class SimpleSectHandler : public DocNode, /*! \brief Node representing a paragraph of text and commands. * */ -// children: itemizedlist, orderedlist, parameterlist, simplesect, -// programlisting, hruler, variablelist, -// linebreak, nonbreakablespace, ref, ulink, email, -// table, link, indexentry, formula, image, dotfile, ref +// children: itemizedlist, orderedlist, parameterlist, simplesect, ref, +// variablelist, hruler, linebreak, +// TODO: +// ulink, email, link +// table, +// programlisting, +// indexentry, formula, image, dotfile // children handled by MarkupHandler: // bold, computeroutput, emphasis, center, // small, subscript, superscript. @@ -276,6 +407,10 @@ class ParagraphHandler : public DocNode, public BaseHandler 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); ParagraphHandler(IBaseHandler *parent); virtual ~ParagraphHandler(); diff --git a/addon/xmlparse/doxmlintf.h b/addon/xmlparse/doxmlintf.h new file mode 100644 index 0000000..50acb79 --- /dev/null +++ b/addon/xmlparse/doxmlintf.h @@ -0,0 +1,63 @@ +#ifndef _DOXMLINTF_H +#define _DOXMLINTF_H + +#include +#include + +class IParam +{ + public: + virtual QString type() const = 0; + virtual QString declarationName() const = 0; + virtual QString definitionName() const = 0; + virtual QString attrib() const = 0; + virtual QString arraySpecifier() const = 0; + virtual QString defaultValue() const = 0; +}; + +class IMember +{ + public: + virtual QString kind() const = 0; + virtual QString id() const = 0; + virtual QString protection() const = 0; + virtual QString virtualness() const = 0; + virtual QString type() const = 0; + virtual QString name() const = 0; + virtual QListIterator getParamIterator() const = 0; +}; + +class ISection +{ + public: + virtual QString kind() const = 0; + virtual QListIterator getMemberIterator() const = 0; +}; + +class ICompound +{ + public: + virtual QString name() const = 0; + virtual QString id() const = 0; + virtual QString kind() const = 0; + virtual QListIterator getSectionIterator() const = 0; +}; + +/*! Root node of the object model. */ +class IDoxygen +{ + public: + /*! Returns an iterator that can be used to iterate over the list + * of compounds found in the project. + */ + virtual QListIterator getCompoundIterator() const = 0; +}; + +/*! Factory method that creates an object model given an XML file generated + * by doxygen. + * @param xmlFileName The name of the XML to parse. + * @returns An iterface to the object model. + */ +IDoxygen *createObjectModelFromXML(const char *xmlFileName); + +#endif diff --git a/addon/xmlparse/main.cpp b/addon/xmlparse/main.cpp index 44c5e36..081b0d7 100644 --- a/addon/xmlparse/main.cpp +++ b/addon/xmlparse/main.cpp @@ -13,95 +13,53 @@ * */ -#include "mainhandler.h" - -#include -#include -#include -#include -#include - -//#define USE_DOM -#define USE_SAX - -#ifdef USE_DOM -#include -#endif - -class ErrorHandler : public QXmlErrorHandler -{ - public: - virtual ~ErrorHandler() {} - bool warning( const QXmlParseException & ) - { - return FALSE; - } - bool error( const QXmlParseException & ) - { - return FALSE; - } - bool fatalError( const QXmlParseException &exception ) - { - fprintf(stderr,"Fatal error at line %d column %d: %s\n", - exception.lineNumber(),exception.columnNumber(), - exception.message().data()); - return FALSE; - } - QString errorString() { return ""; } - - private: - QString errorMsg; -}; +#include +#include "doxmlintf.h" int main(int argc,char **argv) { - if (argc==1) + if (argc!=2) { printf("Usage: %s file.xml\n",argv[0]); exit(1); } - QFile xmlFile(argv[1]); - -#ifdef USE_SAX - MainHandler handler; - ErrorHandler errorHandler; - QXmlInputSource source( xmlFile ); - QXmlSimpleReader reader; - reader.setContentHandler( &handler ); - reader.setErrorHandler( &errorHandler ); - reader.parse( source ); -#endif - -#ifdef USE_DOM - if (!xmlFile.open( IO_ReadOnly )) - { - qFatal("Could not read %s",argv[1] ); - } - QDomDocument doc; - doc.setContent( &xmlFile ); - - QDomElement de = doc.documentElement(); - - printf("docElem=%s\n",de.tagName().data()); + IDoxygen *dox = createObjectModelFromXML(argv[1]); - QDomNode n = de.firstChild(); - while( !n.isNull() ) { - QDomElement e = n.toElement(); // try to convert the node to an element. - if( !e.isNull() ) - { // the node was really an element. - printf("direct child %s id=%s kind=%s\n", - e.tagName().data(), - e.attribute("id").data(), - e.attribute("kind").data() - ); + QListIterator cli(dox->getCompoundIterator()); + ICompound *comp; + printf("--- compound list ---------\n"); + for (cli.toFirst();(comp=cli.current());++cli) + { + printf("Compound name=%s id=%s kind=%s\n", + comp->name().data(),comp->id().data(),comp->kind().data()); + QListIterator sli(comp->getSectionIterator()); + ISection *sec; + for (sli.toFirst();(sec=sli.current());++sli) + { + printf(" Section kind=%s\n",sec->kind().data()); + QListIterator mli(sec->getMemberIterator()); + IMember *mem; + for (mli.toFirst();(mem=mli.current());++mli) + { + printf(" Member type=%s name=%s\n",mem->type().data(),mem->name().data()); + QListIterator pli(mem->getParamIterator()); + IParam *par; + for (pli.toFirst();(par=pli.current());++pli) + { + printf(" Param type=%s name=%s defvalue=%s\n", + par->type().data(),par->definitionName().data(),par->defaultValue().data()); + } + } + } } - n = n.nextSibling(); + printf("---------------------------\n"); + } -#endif + delete dox; return 0; } diff --git a/addon/xmlparse/mainhandler.cpp b/addon/xmlparse/mainhandler.cpp index 8a5d449..21185e6 100644 --- a/addon/xmlparse/mainhandler.cpp +++ b/addon/xmlparse/mainhandler.cpp @@ -13,6 +13,7 @@ * */ +#include #include "mainhandler.h" void MainHandler::startCompound(const QXmlAttributes& attrib) @@ -20,9 +21,10 @@ void MainHandler::startCompound(const QXmlAttributes& attrib) CompoundHand