diff options
Diffstat (limited to 'addon/xmlparse')
-rw-r--r-- | addon/xmlparse/Doxyfile | 161 | ||||
-rw-r--r-- | addon/xmlparse/Makefile.in | 16 | ||||
-rw-r--r-- | addon/xmlparse/basehandler.h | 252 | ||||
-rw-r--r-- | addon/xmlparse/compoundhandler.cpp | 100 | ||||
-rw-r--r-- | addon/xmlparse/compoundhandler.h | 57 | ||||
-rw-r--r-- | addon/xmlparse/dochandler.cpp | 316 | ||||
-rw-r--r-- | addon/xmlparse/dochandler.h | 154 | ||||
-rw-r--r-- | addon/xmlparse/main.cpp | 54 | ||||
-rw-r--r-- | addon/xmlparse/mainhandler.cpp | 23 | ||||
-rw-r--r-- | addon/xmlparse/mainhandler.h | 18 | ||||
-rw-r--r-- | addon/xmlparse/memberhandler.cpp | 77 | ||||
-rw-r--r-- | addon/xmlparse/memberhandler.h | 39 | ||||
-rw-r--r-- | addon/xmlparse/paramhandler.cpp | 79 | ||||
-rw-r--r-- | addon/xmlparse/paramhandler.h | 34 | ||||
-rw-r--r-- | addon/xmlparse/sectionhandler.cpp | 34 | ||||
-rw-r--r-- | addon/xmlparse/sectionhandler.h | 26 | ||||
-rw-r--r-- | addon/xmlparse/xmlparse.pro.in | 26 |
17 files changed, 1466 insertions, 0 deletions
diff --git a/addon/xmlparse/Doxyfile b/addon/xmlparse/Doxyfile new file mode 100644 index 0000000..bec9537 --- /dev/null +++ b/addon/xmlparse/Doxyfile @@ -0,0 +1,161 @@ +# Doxyfile 1.2.8-20010715 + +#--------------------------------------------------------------------------- +# General configuration options +#--------------------------------------------------------------------------- +PROJECT_NAME = dox2html +PROJECT_NUMBER = +OUTPUT_DIRECTORY = doc +OUTPUT_LANGUAGE = English +EXTRACT_ALL = YES +EXTRACT_PRIVATE = YES +EXTRACT_STATIC = YES +HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_CLASSES = NO +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ALWAYS_DETAILED_SEC = NO +FULL_PATH_NAMES = NO +STRIP_FROM_PATH = +INTERNAL_DOCS = NO +CLASS_DIAGRAMS = YES +SOURCE_BROWSER = YES +INLINE_SOURCES = NO +STRIP_CODE_COMMENTS = YES +CASE_SENSE_NAMES = YES +SHORT_NAMES = NO +HIDE_SCOPE_NAMES = NO +VERBATIM_HEADERS = YES +SHOW_INCLUDE_FILES = YES +JAVADOC_AUTOBRIEF = NO +INHERIT_DOCS = YES +INLINE_INFO = YES +SORT_MEMBER_DOCS = YES +DISTRIBUTE_GROUP_DOC = NO +TAB_SIZE = 8 +ENABLED_SECTIONS = +GENERATE_TODOLIST = YES +GENERATE_TESTLIST = YES +GENERATE_BUGLIST = YES +ALIASES = +MAX_INITIALIZER_LINES = 30 +OPTIMIZE_OUTPUT_FOR_C = NO +SHOW_USED_FILES = YES +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- +QUIET = NO +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_FORMAT = +WARN_LOGFILE = +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- +INPUT = . +FILE_PATTERNS = *.h *.cpp +RECURSIVE = NO +EXCLUDE = +EXCLUDE_PATTERNS = +EXAMPLE_PATH = +EXAMPLE_PATTERNS = +IMAGE_PATH = +INPUT_FILTER = +FILTER_SOURCE_FILES = NO +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- +ALPHABETICAL_INDEX = NO +COLS_IN_ALPHA_INDEX = 5 +IGNORE_PREFIX = +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- +GENERATE_HTML = YES +HTML_OUTPUT = +HTML_HEADER = +HTML_FOOTER = +HTML_STYLESHEET = +HTML_ALIGN_MEMBERS = YES +GENERATE_HTMLHELP = NO +GENERATE_CHI = NO +BINARY_TOC = NO +TOC_EXPAND = NO +DISABLE_INDEX = NO +ENUM_VALUES_PER_LINE = 4 +GENERATE_TREEVIEW = NO +TREEVIEW_WIDTH = 250 +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- +GENERATE_LATEX = NO +LATEX_OUTPUT = +COMPACT_LATEX = NO +PAPER_TYPE = a4wide +EXTRA_PACKAGES = +LATEX_HEADER = +PDF_HYPERLINKS = NO +USE_PDFLATEX = NO +LATEX_BATCHMODE = NO +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- +GENERATE_RTF = NO +RTF_OUTPUT = +COMPACT_RTF = NO +RTF_HYPERLINKS = NO +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- +GENERATE_MAN = NO +MAN_OUTPUT = +MAN_EXTENSION = +MAN_LINKS = NO +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- +GENERATE_XML = YES +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = NO +EXPAND_ONLY_PREDEF = NO +SEARCH_INCLUDES = YES +INCLUDE_PATH = +INCLUDE_FILE_PATTERNS = +PREDEFINED = +EXPAND_AS_DEFINED = +#--------------------------------------------------------------------------- +# Configuration::addtions related to external references +#--------------------------------------------------------------------------- +TAGFILES = ../../qtools_docs/qtools.tag=../../../../qtools_docs/html +GENERATE_TAGFILE = +ALLEXTERNALS = NO +PERL_PATH = +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- +HAVE_DOT = YES +CLASS_GRAPH = YES +COLLABORATION_GRAPH = YES +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = YES +GRAPHICAL_HIERARCHY = YES +DOT_PATH = +MAX_DOT_GRAPH_WIDTH = 3024 +MAX_DOT_GRAPH_HEIGHT = 3024 +GENERATE_LEGEND = YES +DOT_CLEANUP = YES +#--------------------------------------------------------------------------- +# Configuration::addtions related to the search engine +#--------------------------------------------------------------------------- +SEARCHENGINE = NO +CGI_NAME = +CGI_URL = +DOC_URL = +DOC_ABSPATH = +BIN_ABSPATH = +EXT_DOC_PATHS = diff --git a/addon/xmlparse/Makefile.in b/addon/xmlparse/Makefile.in new file mode 100644 index 0000000..5fe8421 --- /dev/null +++ b/addon/xmlparse/Makefile.in @@ -0,0 +1,16 @@ +all clean depend: Makefile.xmlparse + $(MAKE) -f Makefile.xmlparse $@ + +distclean: clean + $(RM) -rf Makefile.xmlparse xmlparse.pro Makefile obj + +tmake: + $(ENV) $(PERL) $(TMAKE) xmlparse.pro >Makefile.xmlparse + +Makefile.xmlparse: xmlparse.pro + $(ENV) $(PERL) $(TMAKE) xmlparse.pro >Makefile.xmlparse + +install: + $(INSTTOOL) -d $(INSTALL)/bin + $(INSTTOOL) -m 755 ../../bin/xmlparse $(INSTALL)/bin + diff --git a/addon/xmlparse/basehandler.h b/addon/xmlparse/basehandler.h new file mode 100644 index 0000000..2d037e0 --- /dev/null +++ b/addon/xmlparse/basehandler.h @@ -0,0 +1,252 @@ +#ifndef _BASEHANDLER_H +#define _BASEHANDLER_H + +#include <qxml.h> +#include <qdict.h> +#include <qstring.h> + +class IBaseHandler +{ + public: + virtual void setDelegate(QXmlDefaultHandler *delegate) = 0; + virtual QXmlDefaultHandler *delegate() const = 0; +}; + +class IFallBackHandler +{ + public: + virtual bool handleStartElement(const QString & name, + const QXmlAttributes & attrib) = 0; + virtual bool handleEndElement(const QString &name) = 0; +}; + +template<class T> class ElementMapper +{ + class StartElementHandler + { + typedef void (T::*Handler)(const QXmlAttributes &attrib); + public: + StartElementHandler() : m_parent(0) {} + StartElementHandler(T *parent, Handler h) + : m_parent(parent), m_handler(h) {} + void operator()(const QXmlAttributes &attrib) + { if (m_parent) (m_parent->*m_handler)(attrib); } + private: + T *m_parent; + Handler m_handler; + }; + + class EndElementHandler + { + typedef void (T::*Handler)(); + public: + EndElementHandler() : m_parent(0) {} + EndElementHandler(T *parent, Handler h) + : m_parent(parent), m_handler(h) {} + void operator()() + { if (m_parent) (m_parent->*m_handler)(); } + private: + T *m_parent; + Handler m_handler; + }; + + typedef StartElementHandler<T> StartElementHandlerT; + typedef EndElementHandler<T> EndElementHandlerT; + + public: + ElementMapper() : m_startHandlers(67), m_endHandlers(67) + { + m_startHandlers.setAutoDelete(TRUE); + m_endHandlers.setAutoDelete(TRUE); + } + virtual ~ElementMapper() + { + } + + void addStartHandler(const char *key) + { + m_startHandlers.insert(key,new StartElementHandlerT); + } + + void addStartHandler(const char *key, T *obj, void (T::*handler)(const QXmlAttributes &)) + { + m_startHandlers.insert(key,new StartElementHandlerT(obj,handler)); + } + + void addEndHandler(const char *key) + { + m_endHandlers.insert(key,new EndElementHandlerT); + } + + void addEndHandler(const char *key, T *obj, void (T::*handler)()) + { + m_endHandlers.insert(key,new EndElementHandlerT(obj,handler)); + } + + + protected: + QDict<StartElementHandlerT> m_startHandlers; + QDict<EndElementHandlerT> m_endHandlers; +}; + +template<class T> class BaseHandler : public IBaseHandler, + public QXmlDefaultHandler, + public ElementMapper<T> +{ + public: + BaseHandler() : m_delegateHandler(0), m_fallBackHandler(0) + { + } + + virtual ~BaseHandler() + { + delete m_fallBackHandler; + } + + virtual bool startDocument() + { + return TRUE; + } + + virtual bool startElement( const QString & namespaceURI, + const QString & localName, + const QString & name, + const QXmlAttributes & attrib + ) + { + if (m_delegateHandler) + { + return m_delegateHandler->startElement(namespaceURI,localName,name,attrib); + } + if (!m_skipUntil.isEmpty()) // skip mode + { + if (m_skipUntil==name) m_skipCount++; + printf("skipping start tag %s count=%d\n",name.data(),m_skipCount); + return TRUE; + } + + StartElementHandlerT *handler = m_startHandlers[name]; + if (handler) + { + (*handler)(attrib); + //printf("found start tag %s\n",name.data()); + } + else if (m_fallBackHandler && + !m_fallBackHandler->handleStartElement(name,attrib) + ) + { + printf("found unexpected tag `%s', skipping until matching end tag\n",name.data()); + m_skipUntil = name; + m_skipCount=1; + } + return TRUE; + } + + virtual bool endElement( const QString& namespaceURI, const QString& localName, const QString& name ) + { + if (m_delegateHandler) + { + return m_delegateHandler->endElement(namespaceURI,localName,name); + } + + if (name==m_skipUntil) + { + m_skipCount--; + printf("skipping end tag %s count=%d\n",name.data(),m_skipCount); + if (m_skipCount==0) + { + m_skipUntil=""; + } + //printf("found end tag %s\n",name.data()); + } + else if (m_skipUntil.isEmpty()) + { + EndElementHandlerT *handler = m_endHandlers[name]; + if (handler) + { + (*handler)(); + //printf("found end tag %s\n",name.data()); + } + else if (m_fallBackHandler) + { + m_fallBackHandler->handleEndElement(name); + } + } + m_curString=""; + return TRUE; + } + + virtual bool characters ( const QString & ch ) + { + if (m_delegateHandler) + { + return m_delegateHandler->characters(ch); + } + + m_curString+=ch; + return TRUE; + } + + void setDelegate(QXmlDefaultHandler *delegate) + { + m_delegateHandler = delegate; + } + + QXmlDefaultHandler *delegate() const + { + return m_delegateHandler; + } + + void setFallBackHandler(IFallBackHandler *h) + { + m_fallBackHandler = h; + } + + IFallBackHandler *fallBackHandler() const + { + return m_fallBackHandler; + } + + protected: + QString m_curString; + QString m_skipUntil; + int m_skipCount; + QXmlDefaultHandler *m_delegateHandler; + IFallBackHandler *m_fallBackHandler; +}; + +template<class T> class BaseFallBackHandler : public ElementMapper<T>, + public IFallBackHandler +{ + public: + BaseFallBackHandler() + { + } + virtual ~BaseFallBackHandler() + { + } + bool handleStartElement(const QString & name, + const QXmlAttributes & attrib) + { + StartElementHandlerT *handler = m_startHandlers[name]; + if (handler) + { + (*handler)(attrib); + return TRUE; + } + return FALSE; + } + bool handleEndElement(const QString &name) + { + EndElementHandlerT *handler = m_endHandlers[name]; + if (handler) + { + (*handler)(); + return TRUE; + } + return FALSE; + } +}; + + +#endif diff --git a/addon/xmlparse/compoundhandler.cpp b/addon/xmlparse/compoundhandler.cpp new file mode 100644 index 0000000..4949f63 --- /dev/null +++ b/addon/xmlparse/compoundhandler.cpp @@ -0,0 +1,100 @@ +#include "mainhandler.h" +#include "compoundhandler.h" +#include "dochandler.h" + +CompoundHandler::CompoundHandler(IBaseHandler *parent) + : m_parent(parent), m_brief(0), m_detailed(0) +{ + m_superClasses.setAutoDelete(TRUE); + + addEndHandler("compounddef",this,&CompoundHandler::endCompound); + + addStartHandler("compoundname"); + addEndHandler("compoundname",this,&CompoundHandler::endCompoundName); + + addStartHandler("derivedcompoundref",this,&CompoundHandler::addSubClass); + addEndHandler("derivedcompoundref"); + + addStartHandler("basecompoundref",this,&CompoundHandler::addSuperClass); + addEndHandler("basecompoundref"); + + addStartHandler("briefdescription",this,&CompoundHandler::startBriefDesc); + + addStartHandler("detaileddescription",this,&CompoundHandler::startDetailedDesc); + + addStartHandler("sectiondef",this,&CompoundHandler::startSection); +} + +CompoundHandler::~CompoundHandler() +{ +} + +void CompoundHandler::startSection(const QXmlAttributes& attrib) +{ + SectionHandler *sectHandler = new SectionHandler(this); + sectHandler->startSection(attrib); + m_sections.append(sectHandler); +} + +void CompoundHandler::startBriefDesc(const QXmlAttributes& attrib) +{ + DocHandler *docHandler = new DocHandler(this); + docHandler->startDoc(attrib); + m_brief = docHandler; +} + +void CompoundHandler::startDetailedDesc(const QXmlAttributes& attrib) +{ + DocHandler *docHandler = new DocHandler(this); + docHandler->startDoc(attrib); + m_detailed = docHandler; +} + +void CompoundHandler::startCompound(const QXmlAttributes& attrib) +{ + m_parent->setDelegate(this); + m_id = attrib.value("id"); + m_kind = attrib.value("kind"); + printf("startCompound(id=`%s' type=`%s')\n",m_id.data(),m_kind.data()); +} + +void CompoundHandler::endCompound() +{ + printf("endCompound()\n"); + m_parent->setDelegate(0); +} + +void CompoundHandler::endCompoundName() +{ + m_name = m_curString.stripWhiteSpace(); + printf("Compound name `%s'\n",m_name.data()); +} + +void CompoundHandler::addSuperClass(const QXmlAttributes& attrib) +{ + SuperClass *sc=new SuperClass( + attrib.value("idref"), + attrib.value("prot"), + attrib.value("virt") + ); + printf("super class id=`%s' prot=`%s' virt=`%s'\n", + sc->m_id.data(), + sc->m_protection.data(), + sc->m_virtualness.data()); + m_superClasses.append(sc); +} + +void CompoundHandler::addSubClass(const QXmlAttributes& attrib) +{ + SubClass *sc = new SubClass( + attrib.value("idref"), + attrib.value("prot"), + attrib.value("virt") + ); + printf("sub class id=`%s' prot=`%s' virt=`%s'\n", + sc->m_id.data(), + sc->m_protection.data(), + sc->m_virtualness.data()); + m_subClasses.append(sc); +} + diff --git a/addon/xmlparse/compoundhandler.h b/addon/xmlparse/compoundhandler.h new file mode 100644 index 0000000..cd7da55 --- /dev/null +++ b/addon/xmlparse/compoundhandler.h @@ -0,0 +1,57 @@ +#ifndef _COMPOUNDHANDLER_H +#define _COMPOUNDHANDLER_H + +#include <qstring.h> +#include <qlist.h> +#include <qxml.h> + +#include "basehandler.h" +#include "sectionhandler.h" + +class DocHandler; + +class CompoundHandler : public BaseHandler<CompoundHandler> +{ + public: + virtual void startSection(const QXmlAttributes& attrib); + virtual void startCompound(const QXmlAttributes& attrib); + virtual void addSuperClass(const QXmlAttributes& attrib); + virtual void addSubClass(const QXmlAttributes& attrib); + virtual void endCompound(); + virtual void endCompoundName(); + virtual void startBriefDesc(const QXmlAttributes& attrib); + virtual void startDetailedDesc(const QXmlAttributes& attrib); + + CompoundHandler(IBaseHandler *parent); + virtual ~CompoundHandler(); + private: + struct SuperClass + { + SuperClass(const QString &id,const QString &prot,const QString &virt) : + m_id(id),m_protection(prot),m_virtualness(virt) {} + + QString m_id; + QString m_protection; + QString m_virtualness; + }; + struct SubClass + { + SubClass(const QString &id,const QString &prot,const QString &virt) : + m_id(id),m_protection(prot),m_virtualness(virt) {} + + QString m_id; + QString m_protection; + QString m_virtualness; + }; + QList<SuperClass> m_superClasses; + QList<SubClass> m_subClasses; + QList<SectionHandler> m_sections; + IBaseHandler *m_parent; + DocHandler *m_brief; + DocHandler *m_detailed; + QString m_id; + QString m_kind; + QString m_name; +}; + +#endif diff --git a/addon/xmlparse/dochandler.cpp b/addon/xmlparse/dochandler.cpp new file mode 100644 index 0000000..c9a96c4 --- /dev/null +++ b/addon/xmlparse/dochandler.cpp @@ -0,0 +1,316 @@ +#include "dochandler.h" + +//---------------------------------------------------------------------- +// MarkupHandler +//---------------------------------------------------------------------- + +MarkupHandler::MarkupHandler(QList<DocNode> &children,QString &curString) + : m_children(children), m_curString(curString), m_curMarkup(DocNode::Normal) +{ + addStartHandler("bold",this,&MarkupHandler::startBold); + addEndHandler("bold",this,&MarkupHandler::endBold); + + addStartHandler("emphasis",this,&MarkupHandler::startEmphasis); + addEndHandler("emphasis",this,&MarkupHandler::endEmphasis); + + addStartHandler("computeroutput",this,&MarkupHandler::startComputerOutput); + addEndHandler("computeroutput",this,&MarkupHandler::endComputerOutput); + + addStartHandler("center",this,&MarkupHandler::startCenter); + addEndHandler("center",this,&MarkupHandler::endCenter); + + addStartHandler("small",this,&MarkupHandler::startSmallFont); + addEndHandler("small",this,&MarkupHandler::endSmallFont); + + addStartHandler("subscript",this,&MarkupHandler::startSubscript); + addEndHandler("subscript",this,&MarkupHandler::endSubscript); + + addStartHandler("superscript",this,&MarkupHandler::startSuperscript); + addEndHandler("superscript",this,&MarkupHandler::endSuperscript); +} + +MarkupHandler::~MarkupHandler() +{ +} + +void MarkupHandler::addTextNode() +{ + if (!m_curString.isEmpty()) + { + m_children.append(new TextNode(m_curString,m_curMarkup)); + printf("addTextNode() text=%s markup=%x\n",m_curString.data(),m_curMarkup); + m_curString=""; + } +} + +void MarkupHandler::startBold(const QXmlAttributes & /*attrib*/) +{ + addTextNode(); + m_children.append(new MarkupModifierNode(DocNode::Bold,TRUE)); + m_curMarkup |= DocNode::Bold; +} + +void MarkupHandler::endBold() +{ + addTextNode(); + m_children.append(new MarkupModifierNode(DocNode::Bold,FALSE)); + m_curMarkup &= ~DocNode::Bold; +} + +void MarkupHandler::startEmphasis(const QXmlAttributes & /*attrib*/) +{ + addTextNode(); + m_children.append(new MarkupModifierNode(DocNode::Emphasis,TRUE)); + m_curMarkup |= DocNode::Emphasis; +} + +void MarkupHandler::endEmphasis() +{ + addTextNode(); + m_children.append(new MarkupModifierNode(DocNode::Emphasis,FALSE)); + m_curMarkup &= ~DocNode::Emphasis; +} + +void MarkupHandler::startComputerOutput(const QXmlAttributes & /*attrib*/) +{ + addTextNode(); + m_children.append(new MarkupModifierNode(DocNode::ComputerOutput,TRUE)); + m_curMarkup |= DocNode::ComputerOutput; +} + +void MarkupHandler::endComputerOutput() +{ + addTextNode(); + m_children.append(new MarkupModifierNode(DocNode::ComputerOutput,FALSE)); + m_curMarkup &= ~DocNode::ComputerOutput; +} + +void MarkupHandler::startCenter(const QXmlAttributes & /*attrib*/) +{ + addTextNode(); + m_children.append(new MarkupModifierNode(DocNode::Center,TRUE)); + m_curMarkup |= DocNode::Center; +} + +void MarkupHandler::endCenter() +{ + addTextNode(); + m_children.append(new MarkupModifierNode(DocNode::Center,FALSE)); + m_curMarkup &= ~DocNode::Center; +} + +void MarkupHandler::startSmallFont(const QXmlAttributes & /*attrib*/) +{ + addTextNode(); + m_children.append(new MarkupModifierNode(DocNode::SmallFont,TRUE)); + m_curMarkup |= DocNode::SmallFont; +} + +void MarkupHandler::endSmallFont() +{ + addTextNode(); + m_children.append(new MarkupModifierNode(DocNode::SmallFont,FALSE)); + m_curMarkup &= ~DocNode::SmallFont; +} + +void MarkupHandler::startSubscript(const QXmlAttributes & /*attrib*/) +{ + addTextNode(); + m_children.append(new MarkupModifierNode(DocNode::Subscript,TRUE)); + m_curMarkup |= DocNode::Subscript; +} + +void MarkupHandler::endSubscript() +{ + addTextNode(); + m_children.append(new MarkupModifierNode(DocNode::Subscript,FALSE)); + m_curMarkup &= ~DocNode::Subscript; +} + +void MarkupHandler::startSuperscript(const QXmlAttributes & /*attrib*/) +{ + addTextNode(); + m_children.append(new MarkupModifierNode(DocNode::Superscript,TRUE)); + m_curMarkup |= DocNode::Superscript; +} + +void MarkupHandler::endSuperscript() +{ + addTextNode(); + m_children.append(new MarkupModifierNode(DocNode::Superscript,FALSE)); + m_curMarkup &= ~DocNode::Superscript; +} + +//---------------------------------------------------------------------- +// ListItemHandler +//---------------------------------------------------------------------- + +ListItemHandler::ListItemHandler(IBaseHandler *parent) + : DocNode(ListItem), m_parent(parent) +{ + addEndHandler("listitem",this,&ListItemHandler::endListItem); + + addStartHandler("para",this,&ListItemHandler::startParagraph); +} + +ListItemHandler::~ListItemHandler() +{ +} + +void ListItemHandler::startListItem(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + printf("start list item handler\n"); +} + +void ListItemHandler::endListItem() +{ + printf("end list item handler\n"); + m_parent->setDelegate(0); +} + +void ListItemHandler::startParagraph(const QXmlAttributes& attrib) +{ + ParagraphHandler *parHandler = new ParagraphHandler(this); + parHandler->startParagraph(attrib); + m_children.append(parHandler); +} + +//---------------------------------------------------------------------- +// ListHandler +//---------------------------------------------------------------------- + +ListHandler::ListHandler(NodeKind k,IBaseHandler *parent) + : DocNode(k), 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); + + addStartHandler("listitem",this,&ListHandler::startListItem); +} + +ListHandler::~ListHandler() +{ +} + +void ListHandler::startList(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); +} + +void ListHandler::endList() +{ + m_parent->setDelegate(0); +} + +void ListHandler::startListItem(const QXmlAttributes& attrib) +{ + ListItemHandler *liHandler = new ListItemHandler(this); + liHandler->startListItem(attrib); + m_children.append(liHandler); +} + +//---------------------------------------------------------------------- +// ParagraphHandler +//---------------------------------------------------------------------- + +ParagraphHandler::ParagraphHandler(IBaseHandler *parent) + : DocNode(Para), m_parent(parent) +{ + m_children.setAutoDelete(TRUE); + + m_markupHandler = new MarkupHandler(m_children,m_curString); + setFallBackHandler(m_markupHandler); + + addEndHandler("para",this,&ParagraphHandler::endParagraph); + + addStartHandler("itemizedlist",this,&ParagraphHandler::startItemizedList); + addStartHandler("orderedlist",this,&ParagraphHandler::startOrderedList); +} + +ParagraphHandler::~ParagraphHandler() +{ +} + +void ParagraphHandler::startParagraph(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + printf("para\n"); +} + +void ParagraphHandler::endParagraph() +{ + addTextNode(); + printf("end para\n"); + m_parent->setDelegate(0); +} + +void ParagraphHandler::startItemizedList(const QXmlAttributes& attrib) +{ + addTextNode(); + ListHandler *listHandler = new ListHandler(ItemizedList,this); + listHandler->startList(attrib); + m_children.append(listHandler); +} + +void ParagraphHandler::startOrderedList(const QXmlAttributes& attrib) +{ + addTextNode(); + ListHandler *listHandler = new ListHandler(OrderedList,this); + listHandler->startList(attrib); + m_children.append(listHandler); +} + +void ParagraphHandler::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=""; + } +} + +//---------------------------------------------------------------------- +// DocHandler +//---------------------------------------------------------------------- + +DocHandler::DocHandler(IBaseHandler *parent) : m_parent(parent) +{ + addEndHandler("briefdescription",this,&DocHandler::endDoc); + addEndHandler("detaileddescription",this,&DocHandler::endDoc); + + addStartHandler("para",this,&DocHandler::startParagraph); +} + +DocHandler::~DocHandler() +{ +} + +void DocHandler::startDoc(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + printf("start dochandler\n"); +} + +void DocHandler::endDoc() +{ + printf("end dochandler\n"); + m_parent->setDelegate(0); +} + +void DocHandler::startParagraph(const QXmlAttributes& attrib) +{ + ParagraphHandler *parHandler = new ParagraphHandler(this); + parHandler->startParagraph(attrib); + m_children.append(parHandler); +} + diff --git a/addon/xmlparse/dochandler.h b/addon/xmlparse/dochandler.h new file mode 100644 index 0000000..761842f --- /dev/null +++ b/addon/xmlparse/dochandler.h @@ -0,0 +1,154 @@ +#ifndef _DOCHANDLER_H +#define _DOCHANDLER_H + +#include <qstring.h> +#include <qlist.h> +#include <qxml.h> + +#include "basehandler.h" + +class DocNode +{ + public: + enum Markup + { + Normal = 0x00, + Bold = 0x01, + Emphasis = 0x02, + ComputerOutput = 0x04, + Subscript = 0x08, + Superscript = 0x10, + SmallFont = 0x20, + Center = 0x40 + }; + enum NodeKind + { + Para, + Text, + MarkupModifier, + ItemizedList, + OrderedList, + ListItem + }; + DocNode(NodeKind k) : m_kind(k) {} + virtual ~DocNode() {} + + private: + NodeKind m_kind; +}; + +class TextNode : public DocNode +{ + public: + TextNode(const QString &t,int markup) + : DocNode(Text), m_text(t), m_markup(markup) {} + + private: + QString m_text; + int m_markup; +}; + +class MarkupModifierNode : public DocNode +{ + public: + MarkupModifierNode(int markup,bool enabled) + : DocNode(MarkupModifier), m_markup(markup), m_enabled(enabled) {} + + private: + int m_markup; + bool m_enabled; +}; + +class MarkupHandler : public BaseFallBackHandler<MarkupHandler> +{ + public: + MarkupHandler(QList<DocNode> &children,QString &curString); + virtual ~MarkupHandler(); + int markup() const { return m_curMarkup; } + + virtual void startBold(const QXmlAttributes &attrib); + virtual void endBold(); + virtual void startEmphasis(const QXmlAttributes &attrib); + virtual void endEmphasis(); + virtual void startComputerOutput(const QXmlAttributes &attrib); + virtual void endComputerOutput(); + virtual void startCenter(const QXmlAttributes &attrib); + virtual void endCenter(); + virtual void startSmallFont(const QXmlAttributes &attrib); + virtual void endSmallFont(); + virtual void startSubscript(const QXmlAttributes &attrib); + virtual void endSubscript(); + virtual void startSuperscript(const QXmlAttributes &attrib); + virtual void endSuperscript(); + + + private: + void addTextNode(); + + QList<DocNode> &m_children; + QString &m_curString; + int m_curMarkup; +}; + +class ListItemHandler : public DocNode, public BaseHandler<ListItemHandler> +{ + public: + ListItemHandler(IBaseHandler *parent); + virtual ~ListItemHandler(); + virtual void startListItem(const QXmlAttributes& attrib); + virtual void endListItem(); + virtual void startParagraph(const QXmlAttributes& attrib); + + private: + IBaseHandler *m_parent; + QList<DocNode> m_children; +}; + +class ListHandler : public DocNode, public BaseHandler<ListHandler> +{ + public: + ListHandler(NodeKind k,IBaseHandler *parent); + virtual ~ListHandler(); + virtual void startList(const QXmlAttributes& attrib); + virtual void endList(); + virtual void startListItem(const QXmlAttributes& attrib); + + private: + IBaseHandler *m_parent; + QList<DocNode> m_children; +}; + +class ParagraphHandler : public DocNode, public BaseHandler<ParagraphHandler> +{ + public: + virtual void startParagraph(const QXmlAttributes& attrib); + virtual void endParagraph(); + virtual void startItemizedList(const QXmlAttributes& attrib); + virtual void startOrderedList(const QXmlAttributes& attrib); + + ParagraphHandler(IBaseHandler *parent); + virtual ~ParagraphHandler(); + + private: + void addTextNode(); + IBaseHandler *m_parent; + QList<DocNode> m_children; + MarkupHandler *m_markupHandler; +}; + + +class DocHandler : public BaseHandler<DocHandler> +{ + public: + virtual void startDoc(const QXmlAttributes& attrib); + virtual void endDoc(); + virtual void startParagraph(const QXmlAttributes& attrib); + + DocHandler(IBaseHandler *parent); + virtual ~DocHandler(); + private: + IBaseHandler *m_parent; + QList<DocNode> m_children; +}; + +#endif diff --git a/addon/xmlparse/main.cpp b/addon/xmlparse/main.cpp new file mode 100644 index 0000000..82cc849 --- /dev/null +++ b/addon/xmlparse/main.cpp @@ -0,0 +1,54 @@ +#include "mainhandler.h" + +#include <qstring.h> +#include <qxml.h> +#include <qfile.h> +#include <qdict.h> +#include <qlist.h> + +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; +}; + + +int main(int argc,char **argv) +{ + if (argc==1) + { + printf("Usage: %s file.xml\n",argv[0]); + exit(1); + } + + QFile xmlFile(argv[1]); + MainHandler handler; + ErrorHandler errorHandler; + QXmlInputSource source( xmlFile ); + QXmlSimpleReader reader; + reader.setContentHandler( &handler ); + reader.setErrorHandler( &errorHandler ); + reader.parse( source ); + + return 0; +} + diff --git a/addon/xmlparse/mainhandler.cpp b/addon/xmlparse/mainhandler.cpp new file mode 100644 index 0000000..b062578 --- /dev/null +++ b/addon/xmlparse/mainhandler.cpp @@ -0,0 +1,23 @@ +#include "mainhandler.h" + +void MainHandler::startCompound(const QXmlAttributes& attrib) +{ + CompoundHandler *compHandler = new CompoundHandler(this); + compHandler->startCompound(attrib); + m_compounds.append(compHandler); +} + +MainHandler::MainHandler() +{ + m_compounds.setAutoDelete(TRUE); + addStartHandler("doxygen"); + addStartHandler("compounddef",this,&MainHandler::startCompound); + addEndHandler("doxygen"); + addEndHandler("compounddef"); +} + +MainHandler::~MainHandler() +{ +} + + diff --git a/addon/xmlparse/mainhandler.h b/addon/xmlparse/mainhandler.h new file mode 100644 index 0000000..20eedc3 --- /dev/null +++ b/addon/xmlparse/mainhandler.h @@ -0,0 +1,18 @@ +#ifndef _MAINHANDLER_H +#define _MAINHANDLER_H + +#include <qlist.h> +#include "basehandler.h" +#include "compoundhandler.h" + +class MainHandler : public BaseHandler<MainHandler> +{ + public: + virtual void startCompound(const QXmlAttributes& attrib); + MainHandler(); + virtual ~MainHandler(); + private: + QList<CompoundHandler> m_compounds; +}; + +#endif diff --git a/addon/xmlparse/memberhandler.cpp b/addon/xmlparse/memberhandler.cpp new file mode 100644 index 0000000..1130f8d --- /dev/null +++ b/addon/xmlparse/memberhandler.cpp @@ -0,0 +1,77 @@ +#include "memberhandler.h" +#include "sectionhandler.h" +#include "dochandler.h" + +MemberHandler::MemberHandler(IBaseHandler *parent) + : m_parent(parent), m_brief(0), m_detailed(0) +{ + addEndHandler("memberdef",this,&MemberHandler::endMember); + + addStartHandler("type"); + addEndHandler("type",this,&MemberHandler::endType); + + addStartHandler("name"); + addEndHandler("name",this,&MemberHandler::endName); + + addStartHandler("param",this,&MemberHandler::startParam); + + addStartHandler("briefdescription",this,&MemberHandler::startBriefDesc); + + addStartHandler("detaileddescription",this,&MemberHandler::startDetailedDesc); + +} + +MemberHandler::~MemberHandler() +{ +} + +void MemberHandler::startMember(const QXmlAttributes& attrib) +{ + m_parent->setDelegate(this); + m_kind = attrib.value("kind"); + m_id = attrib.value("id"); + m_protection = attrib.value("prot"); + m_virtualness = attrib.value("virtualness"); + printf("member kind=`%s' id=`%s' prot=`%s' virt=`%s'\n", + m_kind.data(),m_id.data(),m_protection.data(),m_virtualness.data()); +} + +void MemberHandler::startBriefDesc(const QXmlAttributes& attrib) +{ + DocHandler *docHandler = new DocHandler(this); + docHandler->startDoc(attrib); + m_brief = docHandler; +} + +void MemberHandler::startDetailedDesc(const QXmlAttributes& attrib) +{ + DocHandler *docHandler = new DocHandler(this); + docHandler->startDoc(attrib); + m_detailed = docHandler; +} + +void MemberHandler::endMember() +{ + m_parent->setDelegate(0); +} + +void MemberHandler::endType() +{ + m_type = m_curString.stripWhiteSpace(); + printf("member type=`%s'\n",m_type.data()); +} + +void MemberHandler::endName() +{ + m_name = m_curString.stripWhiteSpace(); + printf("member name=`%s'\n",m_name.data()); +} + +void MemberHandler::startParam(const QXmlAttributes& attrib) +{ + ParamHandler *paramHandler = new ParamHandler(this); + paramHandler->startParam(attrib); + m_params.append(paramHandler); +} + + diff --git a/addon/xmlparse/memberhandler.h b/addon/xmlparse/memberhandler.h new file mode 100644 index 0000000..5f19ee2 --- /dev/null +++ b/addon/xmlparse/memberhandler.h @@ -0,0 +1,39 @@ +#ifndef _MEMBERHANDLER_H +#define _MEMBERHANDLER_H + +#include <qstring.h> +#include <qlist.h> +#include <qxml.h> + +#include "basehandler.h" +#include "paramhandler.h" + +class DocHandler; + +class MemberHandler : public BaseHandler<MemberHandler> +{ + public: + virtual void startMember(const QXmlAttributes& attrib); + virtual void endMember(); + virtual void startParam(const QXmlAttributes& attrib); + virtual void endType(); + virtual void endName(); + virtual void startBriefDesc(const QXmlAttributes& attrib); + virtual void startDetailedDesc(const QXmlAttributes& attrib); + + MemberHandler(IBaseHandler *parent); + virtual ~MemberHandler(); + private: + IBaseHandler *m_parent; + QString m_kind; + QString m_id; + QString m_protection; + QString m_virtualness; + QString m_type; + QString m_name; + DocHandler *m_brief; + DocHandler *m_detailed; + QList<ParamHandler> m_params; +}; + +#endif diff --git a/addon/xmlparse/paramhandler.cpp b/addon/xmlparse/paramhandler.cpp new file mode 100644 index 0000000..3563ebd --- /dev/null +++ b/addon/xmlparse/paramhandler.cpp @@ -0,0 +1,79 @@ +#include "paramhandler.h" +#include "memberhandler.h" + +ParamHandler::ParamHandler(IBaseHandler *parent) : m_parent(parent) +{ + addEndHandler("param",this,&ParamHandler::endParam); + + addStartHandler("type"); + addEndHandler("type",this,&ParamHandler::endType); + + addStartHandler("declname"); + addEndHandler("declname",this,&ParamHandler::endDeclName); + + addStartHandler("defname"); + addEndHandler("defname",this,&ParamHandler::endDefName); + + addStartHandler("array"); + addEndHandler("array",this,&ParamHandler::endArray); + + addStartHandler("attrib"); + addEndHandler("attrib",this,&ParamHandler::endAttrib); + + addStartHandler("defval"); + addEndHandler("defval",this,&ParamHandler::endDefVal); +} + +ParamHandler::~ParamHandler() +{ +} + +void ParamHandler::startParam(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + printf("param\n"); +} + +void ParamHandler::endParam() +{ + m_parent->setDelegate(0); +} + +void ParamHandler::endType() +{ + m_type = m_curString.stripWhiteSpace(); + printf("param type=`%s'\n",m_type.data()); +} + +void ParamHandler::endDeclName() +{ + m_declName = m_curString.stripWhiteSpace(); + printf("member declName=`%s'\n",m_declName.data()); +} + +void ParamHandler::endDefName() +{ + m_defName = m_curString.stripWhiteSpace(); + printf("member defName=`%s'\n",m_defName.data()); +} + +void ParamHandler::endAttrib() +{ + m_attrib = m_curString.stripWhiteSpace(); + printf("member attrib=`%s'\n",m_attrib.data()); +} + +void ParamHandler::endArray() +{ + m_array = m_curString.stripWhiteSpace(); + printf("member array=`%s'\n",m_array.data()); +} + +void ParamHandler::endDefVal() +{ + m_defVal = m_curString.stripWhiteSpace(); + printf("member defVal=`%s'\n",m_defVal.data()); +} + + + diff --git a/addon/xmlparse/paramhandler.h b/addon/xmlparse/paramhandler.h new file mode 100644 index 0000000..062bab1 --- /dev/null +++ b/addon/xmlparse/paramhandler.h @@ -0,0 +1,34 @@ +#ifndef _PARAMHANDLER_H +#define _PARAMHANDLER_H + +#include <qstring.h> +#include <qlist.h> +#include <qxml.h> + +#include "basehandler.h" + +class ParamHandler : public BaseHandler<ParamHandler> +{ + public: + virtual void startParam(const QXmlAttributes& attrib); + virtual void endParam(); + virtual void endType(); + virtual void endDeclName(); + virtual void endDefName(); + virtual void endAttrib(); + virtual void endArray(); + virtual void endDefVal(); + + ParamHandler(IBaseHandler *parent); + virtual ~ParamHandler(); + private: + IBaseHandler *m_parent; + QString m_type; + QString m_declName; + QString m_defName; + QString m_attrib; + QString m_array; + QString m_defVal; +}; + +#endif diff --git a/addon/xmlparse/sectionhandler.cpp b/addon/xmlparse/sectionhandler.cpp new file mode 100644 index 0000000..0b63832 --- /dev/null +++ b/addon/xmlparse/sectionhandler.cpp @@ -0,0 +1,34 @@ +#include "compoundhandler.h" +#include "sectionhandler.h" + +SectionHandler::SectionHandler(IBaseHandler *parent) : m_parent(parent) +{ + m_members.setAutoDelete(TRUE); + addEndHandler("sectiondef",this,&SectionHandler::endSection); + addStartHandler("memberdef",this,&SectionHandler::startMember); +} + +SectionHandler::~SectionHandler() +{ +} + +void SectionHandler::startSection(const QXmlAttributes& attrib) +{ + m_parent->setDelegate(this); + m_kind = attrib.value("kind"); + printf("section kind=`%s'\n",m_kind.data()); +} + +void SectionHandler::endSection() +{ + m_parent->setDelegate(0); +} + +void SectionHandler::startMember(const QXmlAttributes& attrib) +{ + MemberHandler *memHandler = new MemberHandler(this); + memHandler->startMember(attrib); + m_members.append(memHandler); +} + + diff --git a/addon/xmlparse/sectionhandler.h b/addon/xmlparse/sectionhandler.h new file mode 100644 index 0000000..b2d1ce1 --- /dev/null +++ b/addon/xmlparse/sectionhandler.h @@ -0,0 +1,26 @@ +#ifndef _SECTIONHANDLER_H +#define _SECTIONHANDLER_H + +#include <qstring.h> +#include <qlist.h> +#include <qxml.h> + +#include "basehandler.h" +#include "memberhandler.h" + +class SectionHandler : public BaseHandler<SectionHandler> +{ + public: + virtual void startMember(const QXmlAttributes& attrib); + virtual void startSection(const QXmlAttributes& attrib); + virtual void endSection(); + + SectionHandler(IBaseHandler *parent); + virtual ~SectionHandler(); + private: + IBaseHandler *m_parent; + QString m_kind; + QList<MemberHandler> m_members; +}; + +#endif diff --git a/addon/xmlparse/xmlparse.pro.in b/addon/xmlparse/xmlparse.pro.in new file mode 100644 index 0000000..9e3b6aa --- /dev/null +++ b/addon/xmlparse/xmlparse.pro.in @@ -0,0 +1,26 @@ +TEMPLATE = app.t +CONFIG = console warn_on $extraopt +HEADERS = basehandler.h mainhandler.h \ + compoundhandler.h sectionhandler.h \ + memberhandler.h paramhandler.h \ + dochandler.h +SOURCES = main.cpp mainhandler.cpp \ + compoundhandler.cpp sectionhandler.cpp \ + memberhandler.cpp paramhandler.cpp \ + dochandler.cpp +DEPENDPATH = ../../src +unix:LIBS += -L../../lib -ldoxycfg -lqtools +win32:INCLUDEPATH += . +win32-mingw:LIBS += -L../../lib -ldoxycfg -lqtools +win32-msvc:LIBS += qtools.lib doxycfg.lib shell32.lib +win32-msvc:TMAKE_LFLAGS += /LIBPATH:..\..\lib +win32-borland:LIBS += qtools.lib doxycfg.lib shell32.lib +win32-borland:TMAKE_LFLAGS += -L..\..\lib +win32:TMAKE_CXXFLAGS += -DQT_NODLL +INCLUDEPATH += ../../qtools ../../src +DESTDIR = +TARGET = xmlparse +unix:TARGETDEPS = ../../lib/libdoxycfg.a +win32:TARGETDEPS = ../../lib/doxycfg.lib +OBJECTS_DIR = obj + |