diff options
Diffstat (limited to 'addon/doxmlparser/src')
30 files changed, 7700 insertions, 0 deletions
diff --git a/addon/doxmlparser/src/Makefile b/addon/doxmlparser/src/Makefile new file mode 100644 index 0000000..85b3aac --- /dev/null +++ b/addon/doxmlparser/src/Makefile @@ -0,0 +1,33 @@ +# +# This file was generated from Makefile.in on Sat Aug 11 14:29:47 CEST 2012 +# + +DOXYGEN = /Users/dimitri/doxygen +TMAKEPATH = /Users/dimitri/doxygen/tmake/lib/macosx-c++ +ENV = env TMAKEPATH=$(TMAKEPATH) +TMAKE = /Users/dimitri/doxygen/tmake/bin/tmake +MAKE = /opt/local/bin/gmake +PERL = /opt/local/bin/perl +RM = rm -f +CP = cp +VERSION = 1.8.1.2 +INSTALL = /usr/local +INSTTOOL = /opt/local/bin/ginstall +DOXYDOCS = .. +DOCDIR = $(INSTALL)/share/doc/packages/doxygen +QTDIR = /usr +HAVE_DOT = /usr/local/bin/dot +MKSPECS = -spec macx-g++ +all clean depend: Makefile.doxmlparser + $(MAKE) -f Makefile.doxmlparser $@ + +distclean: clean + $(RM) -rf Makefile.doxmlparser doxmlparser.pro Makefile obj + +tmake: + $(ENV) $(PERL) $(TMAKE) doxmlparser.pro >Makefile.doxmlparser + +Makefile.doxmlparser: doxmlparser.pro + $(ENV) $(PERL) $(TMAKE) doxmlparser.pro >Makefile.doxmlparser + +install: diff --git a/addon/doxmlparser/src/Makefile.doxmlparser b/addon/doxmlparser/src/Makefile.doxmlparser new file mode 100644 index 0000000..e74929a --- /dev/null +++ b/addon/doxmlparser/src/Makefile.doxmlparser @@ -0,0 +1,224 @@ +############################################################################# +# Makefile for building ../lib/libdoxmlparser.a +# Generated by tmake at 16:24, 2012/08/12 +# Project: doxmlparser +# Template: lib.t +############################################################################# + +####### Compiler, tools and options + +CC = cc +CXX = c++ +CFLAGS = -pipe -Wall -W -Wno-deprecated-declarations -Wno-invalid-source-encoding -g -fstack-protector +CXXFLAGS= -pipe -D__FreeBSD__=6 -DYY_TYPEDEF_YY_SIZE_T -Dyy_size_t=int -Wall -W -Wno-deprecated-declarations -Wno-invalid-source-encoding -g -fstack-protector +INCPATH = -I../../../qtools -I../include +AR = ar cq +RANLIB = ranlib +MOC = /usr/bin/moc + +TAR = tar -cf +GZIP = gzip -9f + +####### Files + +HEADERS = basehandler.h \ + mainhandler.h \ + compoundhandler.h \ + sectionhandler.h \ + memberhandler.h \ + paramhandler.h \ + dochandler.h \ + linkedtexthandler.h \ + debug.h \ + graphhandler.h \ + stringimpl.h \ + loamhandler.h +SOURCES = mainhandler.cpp \ + compoundhandler.cpp \ + sectionhandler.cpp \ + memberhandler.cpp \ + paramhandler.cpp \ + dochandler.cpp \ + linkedtexthandler.cpp \ + basehandler.cpp \ + debug.cpp \ + graphhandler.cpp \ + loamhandler.cpp +OBJECTS = ../objects/mainhandler.o \ + ../objects/compoundhandler.o \ + ../objects/sectionhandler.o \ + ../objects/memberhandler.o \ + ../objects/paramhandler.o \ + ../objects/dochandler.o \ + ../objects/linkedtexthandler.o \ + ../objects/basehandler.o \ + ../objects/debug.o \ + ../objects/graphhandler.o \ + ../objects/loamhandler.o +SRCMOC = +OBJMOC = +DIST = +TARGET = ../lib/libdoxmlparser.a + +####### Implicit rules + +.SUFFIXES: .cpp .cxx .cc .C .c + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< + +####### Build rules + +all: $(TARGET) + +staticlib: $(TARGET) + +$(TARGET): $(OBJECTS) $(OBJMOC) + -rm -f $(TARGET) + $(AR) $(TARGET) $(OBJECTS) $(OBJMOC) + ranlib $(TARGET) + +moc: $(SRCMOC) + +tmake: + tmake doxmlparser.pro + +dist: + $(TAR) doxmlparser.tar doxmlparser.pro $(SOURCES) $(HEADERS) $(DIST) + $(GZIP) doxmlparser.tar + +clean: + -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(TARGET) + -rm -f *~ core + +####### Compile + +../objects/mainhandler.o: mainhandler.cpp \ + mainhandler.h \ + doxmlintf.h \ + basehandler.h \ + debug.h \ + compoundhandler.h \ + stringimpl.h \ + baseiterator.h \ + sectionhandler.h \ + graphhandler.h \ + dochandler.h \ + memberhandler.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o ../objects/mainhandler.o mainhandler.cpp + +../objects/compoundhandler.o: compoundhandler.cpp \ + mainhandler.h \ + doxmlintf.h \ + basehandler.h \ + debug.h \ + compoundhandler.h \ + stringimpl.h \ + baseiterator.h \ + dochandler.h \ + graphhandler.h \ + sectionhandler.h \ + paramhandler.h \ + loamhandler.h \ + memberhandler.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o ../objects/compoundhandler.o compoundhandler.cpp + +../objects/sectionhandler.o: sectionhandler.cpp \ + mainhandler.h \ + doxmlintf.h \ + basehandler.h \ + debug.h \ + compoundhandler.h \ + stringimpl.h \ + baseiterator.h \ + sectionhandler.h \ + memberhandler.h \ + dochandler.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o ../objects/sectionhandler.o sectionhandler.cpp + +../objects/memberhandler.o: memberhandler.cpp \ + memberhandler.h \ + doxmlintf.h \ + basehandler.h \ + debug.h \ + baseiterator.h \ + stringimpl.h \ + sectionhandler.h \ + dochandler.h \ + mainhandler.h \ + linkedtexthandler.h \ + paramhandler.h \ + compoundhandler.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o ../objects/memberhandler.o memberhandler.cpp + +../objects/paramhandler.o: paramhandler.cpp \ + paramhandler.h \ + doxmlintf.h \ + stringimpl.h \ + basehandler.h \ + debug.h \ + baseiterator.h \ + memberhandler.h \ + linkedtexthandler.h \ + dochandler.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o ../objects/paramhandler.o paramhandler.cpp + +../objects/dochandler.o: dochandler.cpp \ + dochandler.h \ + doxmlintf.h \ + stringimpl.h \ + basehandler.h \ + debug.h \ + baseiterator.h \ + linkedtexthandler.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o ../objects/dochandler.o dochandler.cpp + +../objects/linkedtexthandler.o: linkedtexthandler.cpp \ + linkedtexthandler.h \ + baseiterator.h \ + doxmlintf.h \ + basehandler.h \ + debug.h \ + stringimpl.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o ../objects/linkedtexthandler.o linkedtexthandler.cpp + +../objects/basehandler.o: basehandler.cpp \ + basehandler.h \ + debug.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o ../objects/basehandler.o basehandler.cpp + +../objects/debug.o: debug.cpp \ + debug.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o ../objects/debug.o debug.cpp + +../objects/graphhandler.o: graphhandler.cpp \ + graphhandler.h \ + stringimpl.h \ + doxmlintf.h \ + basehandler.h \ + debug.h \ + baseiterator.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o ../objects/graphhandler.o graphhandler.cpp + +../objects/loamhandler.o: loamhandler.cpp \ + loamhandler.h \ + doxmlintf.h \ + basehandler.h \ + debug.h \ + memberhandler.h \ + baseiterator.h \ + stringimpl.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o ../objects/loamhandler.o loamhandler.cpp + diff --git a/addon/doxmlparser/src/Makefile.in b/addon/doxmlparser/src/Makefile.in new file mode 100644 index 0000000..049f969 --- /dev/null +++ b/addon/doxmlparser/src/Makefile.in @@ -0,0 +1,13 @@ +all clean depend: Makefile.doxmlparser + $(MAKE) -f Makefile.doxmlparser $@ + +distclean: clean + $(RM) -rf Makefile.doxmlparser doxmlparser.pro Makefile obj + +tmake: + $(ENV) $(PERL) $(TMAKE) doxmlparser.pro >Makefile.doxmlparser + +Makefile.doxmlparser: doxmlparser.pro + $(ENV) $(PERL) $(TMAKE) doxmlparser.pro >Makefile.doxmlparser + +install: diff --git a/addon/doxmlparser/src/basehandler.cpp b/addon/doxmlparser/src/basehandler.cpp new file mode 100644 index 0000000..02d98c2 --- /dev/null +++ b/addon/doxmlparser/src/basehandler.cpp @@ -0,0 +1,3 @@ +#include "basehandler.h" + +QXmlLocator * LocatorContainer::s_theLocator=0; diff --git a/addon/doxmlparser/src/basehandler.h b/addon/doxmlparser/src/basehandler.h new file mode 100644 index 0000000..9432504 --- /dev/null +++ b/addon/doxmlparser/src/basehandler.h @@ -0,0 +1,325 @@ +/****************************************************************************** + * + * $Id: basehandler.h,v 1.33 2002/10/13 21:01:58 dimitri Exp $ + * + * + * Copyright (C) 1997-2012 by Dimitri van Heesch. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#ifndef _BASEHANDLER_H +#define _BASEHANDLER_H + +#include <qxml.h> +#include <qdict.h> +#include <qstring.h> + +#include "debug.h" + +//----------------------------------------------------------------------------- + +class IBaseHandler +{ + public: + virtual void setDelegate(QXmlDefaultHandler *delegate) = 0; + virtual QXmlDefaultHandler *delegate() const = 0; + virtual ~IBaseHandler() {} +}; + +//----------------------------------------------------------------------------- + +class IFallBackHandler +{ + public: + virtual bool handleStartElement(const QString & name, + const QXmlAttributes & attrib) = 0; + virtual bool handleEndElement(const QString &name) = 0; + virtual ~IFallBackHandler() {} +}; + +//----------------------------------------------------------------------------- + +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; + }; + + public: + typedef StartElementHandler StartElementHandlerT; + typedef EndElementHandler EndElementHandlerT; + + 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; +}; + +//----------------------------------------------------------------------------- + +struct LocatorContainer +{ + static QXmlLocator *s_theLocator; +}; + +//----------------------------------------------------------------------------- + +template<class T> class BaseHandler : public QXmlDefaultHandler, + public ElementMapper<T>, + public LocatorContainer, + public IBaseHandler +{ + public: + typedef typename ElementMapper<T>::StartElementHandlerT StartElementHandlerT; + typedef typename ElementMapper<T>::EndElementHandlerT EndElementHandlerT; + + BaseHandler() : m_skipCount(0), m_delegateHandler(0), m_fallBackHandler(0) + { + } + + virtual ~BaseHandler() + { + ASSERT(m_delegateHandler==0); + } + + 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++; + debug(1,"line %d, col %d: skipping start tag %s count=%d\n", + s_theLocator->lineNumber(),s_theLocator->columnNumber(), + name.data(),m_skipCount); + return TRUE; + } + + StartElementHandlerT *handler = ElementMapper<T>::m_startHandlers[name.utf8()]; + if (handler) + { + (*handler)(attrib); + //printf("found start tag %s\n",name.data()); + } + else if (!m_fallBackHandler || + !m_fallBackHandler->handleStartElement(name,attrib) + ) + { + debug(1,"line %d, col %d: found unexpected tag `%s', skipping until matching end tag\n", + s_theLocator->lineNumber(),s_theLocator->columnNumber(), + 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--; + debug(1,"line %d, col %d: skipping end tag %s count=%d\n", + s_theLocator->lineNumber(),s_theLocator->columnNumber(), + 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 = ElementMapper<T>::m_endHandlers[name.utf8()]; + if (handler) + { + (*handler)(); + //printf("found end tag %s\n",name.data()); + } + else if (m_fallBackHandler) + { + m_fallBackHandler->handleEndElement(name); + } + } + m_curString=""; + return TRUE; + } + + bool skippedEntity ( const QString &s ) + { + if (m_delegateHandler) + { + return m_delegateHandler->skippedEntity(s); + } + + debug(1,"line %d, col %d: Skipped unhandled entity %s\n", + s_theLocator->lineNumber(),s_theLocator->columnNumber(), + s.data()); + return TRUE; + } + + /*! called when a number of characters are received by the parser. + * \param ch the characters. + */ + virtual bool characters ( const QString & ch ) + { + if (m_delegateHandler) + { + return m_delegateHandler->characters(ch); + } + + //printf("Found characters \"%s\"\n",ch.data()); + 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; + } + + void setDocumentLocator( QXmlLocator * locator ) + { + debug(2,"setDocumentLocator(%p)\n",locator); + s_theLocator = locator; + } + + 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: + typedef typename ElementMapper<T>::StartElementHandlerT StartElementHandlerT; + typedef typename ElementMapper<T>::EndElementHandlerT EndElementHandlerT; + + BaseFallBackHandler() + { + } + virtual ~BaseFallBackHandler() + { + } + + bool handleStartElement(const QString & name, + const QXmlAttributes & attrib) + { + StartElementHandlerT *handler = ElementMapper<T>::m_startHandlers[name.utf8()]; + if (handler) + { + (*handler)(attrib); + return TRUE; + } + return FALSE; + } + bool handleEndElement(const QString &name) + { + EndElementHandlerT *handler = ElementMapper<T>::m_endHandlers[name.utf8()]; + if (handler) + { + (*handler)(); + return TRUE; + } + return FALSE; + } +}; + + +#endif diff --git a/addon/doxmlparser/src/baseiterator.h b/addon/doxmlparser/src/baseiterator.h new file mode 100644 index 0000000..4010cb2 --- /dev/null +++ b/addon/doxmlparser/src/baseiterator.h @@ -0,0 +1,50 @@ +/****************************************************************************** + * + * $Id: doxygen.cpp,v 1.87 2001/03/19 19:27:40 root Exp $ + * + * + * Copyright (C) 1997-2012 by Dimitri van Heesch. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ +#ifndef BASEITERATOR_H +#define BASEITERATOR_H + +#include <qlist.h> +#include <doxmlintf.h> + +template<class Intf,class ElemIntf,class ElemImpl> class BaseIterator : + public Intf, public QListIterator<ElemImpl> +{ + public: + BaseIterator(const QList<ElemImpl> &list) : QListIterator<ElemImpl>(list) {} + virtual ~BaseIterator() {} + virtual ElemIntf *toFirst() { return QListIterator<ElemImpl>::toFirst(); } + virtual ElemIntf *toLast() { return QListIterator<ElemImpl>::toLast(); } + virtual ElemIntf *toNext() { return QListIterator<ElemImpl>::operator++(); } + virtual ElemIntf *toPrev() { return QListIterator<ElemImpl>::operator--(); } + virtual ElemIntf *current() const { return QListIterator<ElemImpl>::current(); } + virtual void release() { delete this; } +}; + +template<class Intf,class ElemIntf,class ElemImpl,class Intermediate> + class BaseIteratorVia : + public Intf, public QListIterator<ElemImpl> +{ + public: + BaseIteratorVia(const QList<ElemImpl> &list) : QListIterator<ElemImpl>(list) {} + virtual ~BaseIteratorVia() {} + virtual ElemIntf *toFirst() { return static_cast<Intermediate *>(QListIterator<ElemImpl>::toFirst()); } + virtual ElemIntf *toLast() { return static_cast<Intermediate *>(QListIterator<ElemImpl>::toLast()); } + virtual ElemIntf *toNext() { return static_cast<Intermediate *>(QListIterator<ElemImpl>::operator++()); } + virtual ElemIntf *toPrev() { return static_cast<Intermediate *>(QListIterator<ElemImpl>::operator--()); } + virtual ElemIntf *current() const { return static_cast<Intermediate *>(QListIterator<ElemImpl>::current()); } + virtual void release() { delete this; } +}; + +#endif diff --git a/addon/doxmlparser/src/compoundhandler.cpp b/addon/doxmlparser/src/compoundhandler.cpp new file mode 100644 index 0000000..e955b6b --- /dev/null +++ b/addon/doxmlparser/src/compoundhandler.cpp @@ -0,0 +1,654 @@ +/****************************************************************************** + * + * $Id: compoundhandler.cpp,v 1.33 2002/10/13 21:01:58 dimitri Exp $ + * + * + * Copyright (C) 1997-2012 by Dimitri van Heesch. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#include "mainhandler.h" +#include "compoundhandler.h" +#include "dochandler.h" +#include "debug.h" +#include "graphhandler.h" +#include "sectionhandler.h" +#include "paramhandler.h" +#include "loamhandler.h" +#include "memberhandler.h" + +//---------------------------------------------------------------------------- + +IncludeHandler::IncludeHandler(IBaseHandler *parent,const char *endtag) : + m_parent(parent) +{ + addEndHandler(endtag,this,&IncludeHandler::endInclude); +} + +IncludeHandler::~IncludeHandler() +{ +} + +void IncludeHandler::startInclude(const QXmlAttributes &attrib) +{ + m_curString = ""; + m_refId = attrib.value("refid"); + m_isLocal = attrib.value("local")=="yes"; + m_parent->setDelegate(this); +} + +void IncludeHandler::endInclude() +{ + m_name = m_curString; + m_parent->setDelegate(0); + debug(2,"Found include %s\n",m_name.data()); +} + +//---------------------------------------------------------------------------- + +class CompoundIdIterator : public ICompoundIterator, + public QListIterator<QString> +{ + public: + CompoundIdIterator(const MainHandler *m,const QList<QString> &list) : + QListIterator<QString>(list), m_mainHandler(m) {} + virtual ~CompoundIdIterator() {} + + virtual void toFirst() + { + QListIterator<QString>::toFirst(); + } + virtual void toLast() + { + QListIterator<QString>::toLast(); + } + virtual void toNext() + { + QListIterator<QString>::operator++(); + } + virtual void toPrev() + { + QListIterator<QString>::operator--(); + } + virtual ICompound *current() const + { + QString *id = QListIterator<QString>::current(); + return id ? m_mainHandler->compoundById(id->utf8()) : 0; + } + virtual void release() + { delete this; } + + private: + const MainHandler *m_mainHandler; +}; + +//---------------------------------------------------------------------------- + +ICompound *RelatedCompound::compound() const +{ + return m_parent->m_mainHandler->compoundById(m_id.utf8()); +} + +//---------------------------------------------------------------------------- + +class CompoundErrorHandler : public QXmlErrorHandler +{ + public: + virtual ~CompoundErrorHandler() {} + bool warning( const QXmlParseException & ) + { + return FALSE; + } + bool error( const QXmlParseException & ) + { + return FALSE; + } + bool fatalError( const QXmlParseException &exception ) + { + debug(1,"Fatal error at line %d column %d: %s\n", + exception.lineNumber(),exception.columnNumber(), + exception.message().data()); + return FALSE; + } + QString errorString() { return ""; } + + private: + QString errorMsg; +}; + +//---------------------------------------------------------------------------- + +class CompoundTypeMap +{ + public: + CompoundTypeMap() + { + m_map.setAutoDelete(TRUE); + m_map.insert("class", new int(ICompound::Class)); + m_map.insert("struct", new int(ICompound::Struct)); + m_map.insert("union", new int(ICompound::Union)); + m_map.insert("interface",new int(ICompound::Interface)); + m_map.insert("protocol", new int(ICompound::Protocol)); + m_map.insert("category", new int(ICompound::Category)); + m_map.insert("exception",new int(ICompound::Exception)); + m_map.insert("file", new int(ICompound::File)); + m_map.insert("namespace",new int(ICompound::Namespace)); + m_map.insert("group", new int(ICompound::Group)); + m_map.insert("page", new int(ICompound::Page)); + m_map.insert("example", new int(ICompound::Example)); + m_map.insert("dir", new int(ICompound::Dir)); + } + virtual ~CompoundTypeMap() + { + } + ICompound::CompoundKind map(const QString &s) + { + int *val = m_map.find(s.utf8()); + if (val==0) + { + debug(1,"Warning: `%s' is an invalid compound type\n",s.data()); + return ICompound::Invalid; + } + else return (ICompound::CompoundKind)*val; + } + private: + QDict<int> m_map; +}; + +static CompoundTypeMap *s_typeMap; + +void compoundhandler_init() +{ + s_typeMap = new CompoundTypeMap; +} + +void compoundhandler_exit() +{ + delete s_typeMap; +} + +//---------------------------------------------------------------------------- + +CompoundHandler::CompoundHandler(const QString &xmlDir) + : m_titleHandler(0), + m_includeDependencyGraph(0), + m_includedByDependencyGraph(0), + m_templateParamList(0), + m_brief(0), + m_detailed(0), + m_inheritanceGraph(0), + m_collaborationGraph(0), + m_programListing(0), + m_members(0), + m_xmlDir(xmlDir), + m_refCount(1), + m_memberDict(257), + m_memberNameDict(257), + m_mainHandler(0) +{ + m_superClasses.setAutoDelete(TRUE); + m_subClasses.setAutoDelete(TRUE); + m_sections.setAutoDelete(TRUE); + m_memberNameDict.setAutoDelete(TRUE); + m_innerCompounds.setAutoDelete(TRUE); + m_includes.setAutoDelete(TRUE); + m_includedBy.setAutoDelete(TRUE); + + addStartHandler("doxygen"); + addEndHandler("doxygen"); + + addStartHandler("compounddef",this,&CompoundHandler::startCompound); + addEndHandler("compounddef",this,&CompoundHandler::endCompound); + + addStartHandler("compoundname"); + addEndHandler("compoundname",this,&CompoundHandler::endCompoundName); + + addStartHandler("title",this,&CompoundHandler::startTitle); + + addStartHandler("basecompoundref",this,&CompoundHandler::startSuperClass); + addEndHandler("basecompoundref",this,&CompoundHandler::endSuperClass); + + addStartHandler("derivedcompoundref",this,&CompoundHandler::startSubClass); + addEndHandler("derivedcompoundref",this,&CompoundHandler::endSubClass); + + addStartHandler("includes",this,&CompoundHandler::startIncludes); + addStartHandler("includedby",this,&CompoundHandler::startIncludedBy); + + addStartHandler("incdepgraph",this,&CompoundHandler::startIncludeDependencyGraph); + + addStartHandler("invincdepgraph",this,&CompoundHandler::startIncludedByDependencyGraph); + + addStartHandler("innerdir",this,&CompoundHandler::startInnerDir); + addEndHandler("innerdir"); + + addStartHandler("innerfile",this,&CompoundHandler::startInnerFile); + addEndHandler("innerfile"); + + addStartHandler("innerclass",this,&CompoundHandler::startInnerClass); + addEndHandler("innerclass"); + + addStartHandler("innernamespace",this,&CompoundHandler::startInnerNamespace); + addEndHandler("innernamespace"); + + addStartHandler("innerpage",this,&CompoundHandler::startInnerPage); + addEndHandler("innerpage"); + + addStartHandler("innergroup",this,&CompoundHandler::startInnerGroup); + addEndHandler("innergroup"); + + addStartHandler("templateparamlist",this,&CompoundHandler::startTemplateParamList); + + addStartHandler("sectiondef",this,&CompoundHandler::startSection); + + addStartHandler("briefdescription",this,&CompoundHandler::startBriefDesc); + + addStartHandler("detaileddescription",this,&CompoundHandler::startDetailedDesc); + + addStartHandler("inheritancegraph",this,&CompoundHandler::startInheritanceGraph); + + addStartHandler("collaborationgraph",this,&CompoundHandler::startCollaborationGraph); + + addStartHandler("programlisting",this,&CompoundHandler::startProgramListing); + + addStartHandler("location",this,&CompoundHandler::startLocation); + addEndHandler("location"); + + addStartHandler("listofallmembers",this,&CompoundHandler::startListOfAllMembers); +} + +CompoundHandler::~CompoundHandler() +{ + debug(2,"CompoundHandler::~CompoundHandler()\n"); + delete m_titleHandler; + delete m_brief; + delete m_detailed; + delete m_programListing; + delete m_inheritanceGraph; + delete m_collaborationGraph; + delete m_includeDependencyGraph; + delete m_includedByDependencyGraph; + delete m_templateParamList; + delete m_members; +} + +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::startProgramListing(const QXmlAttributes& attrib) +{ + ProgramListingHandler *plHandler = new ProgramListingHandler(this); + plHandler->startProgramListing(attrib); + m_programListing = plHandler; +} + +void CompoundHandler::startIncludes(const QXmlAttributes& attrib) +{ + IncludeHandler *inc = new IncludeHandler(this,"includes"); + m_includes.append(inc); + inc->startInclude(attrib); +} + +void CompoundHandler::startIncludedBy(const QXmlAttributes& attrib) +{ + IncludeHandler *inc = new IncludeHandler(this,"includedby"); + m_includedBy.append(inc); + inc->startInclude(attrib); +} + +void CompoundHandler::startCompound(const QXmlAttributes& attrib) +{ + m_id = attrib.value("id"); + m_kindString = attrib.value("kind"); + m_kind = s_typeMap->map(m_kindString); + m_protection = attrib.value("prot"); + debug(2,"startCompound(id=`%s' type=`%s')\n",m_id.data(),m_kindString.data()); +} + +void CompoundHandler::endCompound() +{ + debug(2,"endCompound()\n"); +} + +void CompoundHandler::startLocation(const QXmlAttributes& attrib) +{ + m_defFile = attrib.value("file"); + m_defLine = attrib.value("line").toInt(); + m_defBodyFile = attrib.value("bodyfile"); + m_defBodyStart = attrib.value("bodystart").toInt(); + m_defBodyEnd = attrib.value("bodyend").toInt(); +} + +void CompoundHandler::endCompoundName() +{ + m_name = m_curString.stripWhiteSpace(); + debug(2,"Compound name `%s'\n",m_name.data()); +} + +void CompoundHandler::startInnerClass(const QXmlAttributes& attrib) +{ + m_innerCompounds.append(new QString(attrib.value("refid"))); +} + +void CompoundHandler::startInnerNamespace(const QXmlAttributes& attrib) +{ + m_innerCompounds.append(new QString(attrib.value("refid"))); +} + +void CompoundHandler::startInnerFile(const QXmlAttributes& attrib) +{ + m_innerCompounds.append(new QString(attrib.value("refid"))); +} + +void CompoundHandler::startInnerGroup(const QXmlAttributes& attrib) +{ + m_innerCompounds.append(new QString(attrib.value("refid"))); +} + +void CompoundHandler::startInnerPage(const QXmlAttributes& attrib) +{ + m_innerCompounds.append(new QString(attrib.value("refid"))); +} + +void CompoundHandler::startInnerDir(const QXmlAttributes& attrib) +{ + m_innerCompounds.append(new QString(attrib.value("refid"))); +} + +void CompoundHandler::startTemplateParamList(const QXmlAttributes& attrib) +{ + m_templateParamList = new TemplateParamListHandler(this); + m_templateParamList->startTemplateParamList(attrib); +} + +void CompoundHandler::startListOfAllMembers(const QXmlAttributes& attrib) +{ + m_members = new ListOfAllMembersHandler(this); + m_members->startListOfAllMembers(attrib); +} + +void CompoundHandler::startSuperClass(const QXmlAttributes& attrib) +{ + IRelatedCompound::Protection prot = IRelatedCompound::Public; + QString protString = attrib.value("prot"); + if (protString=="protected") + { + prot = IRelatedCompound::Protected; + } + else if (protString=="private") + { + prot = IRelatedCompound::Private; + } + IRelatedCompound::Kind kind = IRelatedCompound::Normal; + QString kindString = attrib.value("virt"); + if (kindString=="virtual") kind = IRelatedCompound::Virtual; + + RelatedCompound *sc=new RelatedCompound( + this, + attrib.value("refid"), + prot, + kind + ); + debug(2,"super class id=`%s' prot=`%s' virt=`%s'\n", + attrib.value("refid").data(), + protString.data(), + kindString.data()); + m_superClasses.append(sc); + m_curString = ""; +} + +void CompoundHandler::endSuperClass() +{ + m_superClasses.getLast()->setName(m_curString); +} + +void CompoundHandler::startSubClass(const QXmlAttributes& attrib) +{ + IRelatedCompound::Protection prot = IRelatedCompound::Public; + QString protString = attrib.value("prot"); + if (protString=="protected") prot = IRelatedCompound::Protected; + else if (protString=="private") prot = IRelatedCompound::Private; + + IRelatedCompound::Kind kind = IRelatedCompound::Normal; + QString kindString = attrib.value("virt"); + if (kindString=="virtual") kind = IRelatedCompound::Virtual; + + RelatedCompound *sc = new RelatedCompound( + this, + attrib.value("refid"), + prot, + kind + ); + debug(2,"sub class id=`%s' prot=`%s' virt=`%s'\n", + attrib.value("refid").data(), + protString.data(), + kindString.data()); + m_subClasses.append(sc); + m_curString = ""; +} + +void CompoundHandler::endSubClass() +{ + m_subClasses.getLast()->setName(m_curString); +} + +void CompoundHandler::startTitle(const QXmlAttributes& attrib) +{ + ASSERT(m_titleHandler==0); + m_titleHandler = new TitleHandler(this); + m_titleHandler->startTitle(attrib); +} + +bool CompoundHandler::parseXML(const char *compId) +{ + QFile xmlFile(m_xmlDir+"/"+compId+".xml"); + if (!xmlFile.exists()) return FALSE; + CompoundErrorHandler errorHandler; + QXmlInputSource source( xmlFile ); + QXmlSimpleReader reader; + reader.setContentHandler( this ); + reader.setErrorHandler( &errorHandler ); + reader.parse( source ); + return TRUE; +} + +void CompoundHandler::initialize(MainHandler *mh) +{ + m_mainHandler = mh; + QListIterator<SectionHandler> msi(m_sections); + SectionHandler *sec; + for (;(sec=msi.current());++msi) + { + sec->initialize(this); + } + if (m_members) + { + m_members->initialize(mh); + } +} + +void CompoundHandler::insertMember(MemberHandler *mh) +{ + m_memberDict.insert(mh->id()->latin1(),mh); + mh->initialize(m_mainHandler); + QList<MemberHandler> *mhl = m_memberNameDict.find(mh->id()->latin1()); + if (mhl==0) + { + mhl = new QList<MemberHandler>; + m_memberNameDict.insert(mh->name()->latin1(),mhl); + } + mhl->append(mh); +} + +ICompound *CompoundHandler::toICompound() const +{ + switch (m_kind) + { + case ICompound::Class: return (IClass *)this; + case ICompound::Struct: return (IStruct *)this; + case ICompound::Union: return (IUnion *)this; + case ICompound::Interface: return (IInterface *)this; + case ICompound::Protocol: return (IClass *)this; + case ICompound::Category: return (IClass *)this; + case ICompound::Exception: return (IException *)this; + case ICompound::File: return (IFile *)this; + case ICompound::Namespace: return (INamespace *)this; + case ICompound::Group: return (IGroup *)this; + case ICompound::Page: return (IPage *)this; + case ICompound::Example: return (IPage *)this; + case ICompound::Dir: return (IDir *)this; + default: return 0; + } + return 0; +} + +void CompoundHandler::release() +{ + debug(2,"CompoundHandler::release() %d->%d\n",m_refCount,m_refCount-1); + if (--m_refCount<=0) + { + m_mainHandler->unloadCompound(this); + delete this; + } +} + +ISectionIterator *CompoundHandler::sections() const +{ + return new SectionIterator(m_sections); +} + +IMemberIterator *CompoundHandler::memberByName(const char *name) const +{ + QList<MemberHandler> *ml = m_memberNameDict[name]; + if (ml==0) return 0; + return new MemberIterator(*ml); +} + +void CompoundHandler::startInheritanceGraph(const QXmlAttributes &attrib) +{ + m_inheritanceGraph = new GraphHandler(this,"inheritancegraph"); + m_inheritanceGraph->startGraph(attrib); +} + +void CompoundHandler::startCollaborationGraph(const QXmlAttributes &attrib) +{ + m_collaborationGraph = new GraphHandler(this,"collaborationgraph"); + m_collaborationGraph->startGraph(attrib); +} + +void CompoundHandler::startIncludeDependencyGraph(const QXmlAttributes &attrib) +{ + m_includeDependencyGraph = new GraphHandler(this,"incdepgraph"); + m_includeDependencyGraph->startGraph(attrib); +} + +void CompoundHandler::startIncludedByDependencyGraph(const QXmlAttributes &attrib) +{ + m_includedByDependencyGraph = new GraphHandler(this,"invincdepgraph"); + m_includedByDependencyGraph->startGraph(attrib); +} + +IDocRoot *CompoundHandler::briefDescription() const +{ + return m_brief; +} + +IDocRoot *CompoundHandler::detailedDescription() const +{ + return m_detailed; +} + +IMember *CompoundHandler::memberById(const char *id) const +{ + return (IFunction*)m_memberDict[id]; +} + +IGraph *CompoundHandler::inheritanceGraph() const +{ + return m_inheritanceGraph; +} + +IGraph *CompoundHandler::collaborationGraph() const +{ + return m_collaborationGraph; +} + +IGraph *CompoundHandler::includeDependencyGraph() const +{ + return m_includeDependencyGraph; +} + +IGraph *CompoundHandler::includedByDependencyGraph() const +{ + return m_includedByDependencyGraph; +} + +IRelatedCompoundIterator *CompoundHandler::baseCompounds() const +{ + return new RelatedCompoundIterator(m_superClasses); +} + +IRelatedCompoundIterator *CompoundHandler::derivedCompounds() const +{ + return new RelatedCompoundIterator(m_subClasses); +} + +ICompoundIterator *CompoundHandler::nestedCompounds() const +{ + return new CompoundIdIterator(m_mainHandler,m_innerCompounds); +} + +IDocProgramListing *CompoundHandler::source() const +{ + return m_programListing; +} + +IIncludeIterator *CompoundHandler::includes() const +{ + return new IncludeIterator(m_includes); +} + +IIncludeIterator *CompoundHandler::includedBy() const +{ + return new IncludeIterator(m_includedBy); +} + +IParamIterator *CompoundHandler::templateParameters() const +{ + return m_templateParamList ? m_templateParamList->templateParams() : 0; +} + +const IDocTitle *CompoundHandler::title() const +{ + return m_titleHandler; +} + +IMemberReferenceIterator *CompoundHandler::members() const +{ + return m_members ? m_members->members() : 0; +} + + diff --git a/addon/doxmlparser/src/compoundhandler.h b/addon/doxmlparser/src/compoundhandler.h new file mode 100644 index 0000000..6ec2ffc --- /dev/null +++ b/addon/doxmlparser/src/compoundhandler.h @@ -0,0 +1,237 @@ +/****************************************************************************** + * + * $Id: compoundhandler.h,v 1.33 2002/10/13 21:01:58 dimitri Exp $ + * + * + * Copyright (C) 1997-2012 by Dimitri van Heesch. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ +#ifndef _COMPOUNDHANDLER_H +#define _COMPOUNDHANDLER_H + +#include <qstring.h> +#include <qlist.h> +#include <qxml.h> +#include <doxmlintf.h> + +#include "stringimpl.h" +#include "basehandler.h" +#include "baseiterator.h" + +class MainHandler; +class DocHandler; +class ProgramListingHandler; +class GraphHandler; +class MemberHandler; +class CompoundHandler; +class SectionHandler; +class ParamHandler; +class TemplateParamListHandler; +class TitleHandler; +class ListOfAllMembersHandler; + +class IncludeHandler : public IInclude, public BaseHandler<IncludeHandler> +{ + public: + IncludeHandler(IBaseHandler *parent,const char *endtag); + virtual ~IncludeHandler(); + + void startInclude(const QXmlAttributes &attrib); + void endInclude(); + + // IInclude + virtual const IString * name() const + { return &m_name; } + virtual const IString * refId() const + { return &m_refId; } + virtual bool isLocal() const + { return &m_isLocal; } + + private: + IBaseHandler *m_parent; + StringImpl m_name; // element's content + StringImpl m_refId; // refid + bool m_isLocal; // local +}; + +class IncludeIterator : public BaseIterator<IIncludeIterator,IInclude,IncludeHandler> +{ + public: + IncludeIterator(const QList<IncludeHandler> &list) : + BaseIterator<IIncludeIterator,IInclude,IncludeHandler>(list) {} +}; + + +class RelatedCompound : public IRelatedCompound +{ + public: + RelatedCompound(CompoundHandler *parent, + const QString &id, + Protection prot, + Kind kind + ) : + m_parent(parent), m_id(id), m_protection(prot), m_kind(kind) {} + virtual ~RelatedCompound() {} + void setName(const QString &str) { m_name = str; } + + virtual ICompound *compound() const; + virtual Protection protection() const { return m_protection; } + virtual Kind kind() const { return m_kind; } + virtual const IString *name() const { return &m_name; } + + private: + CompoundHandler *m_parent; + QString m_id; // refid + Protection m_protection; // prot + Kind m_kind; // virt + StringImpl m_name; // element's content +}; + +class RelatedCompoundIterator : public BaseIterator<IRelatedCompoundIterator,IRelatedCompound,RelatedCompound> +{ + public: + RelatedCompoundIterator(const QList<RelatedCompound> &list) : + BaseIterator<IRelatedCompoundIterator,IRelatedCompound,RelatedCompound>(list) {} +}; + + +class CompoundHandler : public IClass, + public IStruct, + public IUnion, + public IException, + public IInterface, + public INamespace, + public IFile, + public IGroup, + public IPage, + public IDir, + public BaseHandler<CompoundHandler> +{ + friend class RelatedCompound; + + public: + virtual void startSection(const QXmlAttributes& attrib); + virtual void startCompound(const QXmlAttributes& attrib); + virtual void startSuperClass(const QXmlAttributes& attrib); + virtual void endSuperClass(); + virtual void startSubClass(const QXmlAttributes& attrib); + virtual void endSubClass(); + virtual void endCompound(); + virtual void endCompoundName(); + virtual void startBriefDesc(const QXmlAttributes& attrib); + virtual void startDetailedDesc(const QXmlAttributes& attrib); + virtual void startLocation(const QXmlAttributes& attrib); + virtual void startProgramListing(const QXmlAttributes& attrib); + virtual void startInheritanceGraph(const QXmlAttributes& attrib); + virtual void startCollaborationGraph(const QXmlAttributes& attrib); + virtual void startIncludeDependencyGraph(const QXmlAttributes& attrib); + virtual void startIncludedByDependencyGraph(const QXmlAttributes& attrib); + virtual void startIncludes(const QXmlAttributes& attrib); + virtual void startIncludedBy(const QXmlAttributes& attrib); + virtual void startInnerDir(const QXmlAttributes& attrib); + virtual void startInnerClass(const QXmlAttributes& attrib); + virtual void startInnerNamespace(const QXmlAttributes& attrib); + virtual void startInnerFile(const QXmlAttributes& attrib); + virtual void startInnerGroup(const QXmlAttributes& attrib); + virtual void startInnerPage(const QXmlAttributes& attrib); + virtual void startTitle(const QXmlAttributes& attrib); + virtual void startTemplateParamList(const QXmlAttributes& attrib); + virtual void startListOfAllMembers(const QXmlAttributes& attrib); + virtual void addref() { m_refCount++; } + + CompoundHandler(const QString &dirName); + virtual ~CompoundHandler(); + bool parseXML(const char *compId); + void initialize(MainHandler *mh); + void insertMember(MemberHandler *mh); + ICompound *toICompound() const; + + // ICompound implementation + const IString *name() const { return &m_name; } + const IString *id() const { return &m_id; } + CompoundKind kind() const { return m_kind; } + const IString *kindString() const { return &m_kindString; } + ISectionIterator *sections() const; + IDocRoot *briefDescription() const; + IDocRoot *detailedDescription() const; + IMember *memberById(const char *id) const; + IMemberIterator *memberByName(const char *name) const; + IParamIterator *templateParameters() const; + void release(); + + // IClass implementation + IGraph *inheritanceGraph() const; + IGraph *collaborationGraph() const; + IRelatedCompoundIterator *baseCompounds() const; + IRelatedCompoundIterator *derivedCompounds() const; + ICompoundIterator *nestedCompounds() const; + ICompoundIterator *nestedGroup() const; + const IString *locationFile() const { return &m_defFile; } + int locationLine() const { return m_defLine; } + const IString *locationBodyFile() const { return &m_defBodyFile; } + int locationBodyStartLine() const { return m_defBodyStart; } + int locationBodyEndLine() const { return m_defBodyEnd; } + IMemberReferenceIterator *members() const; + + // IFile implementation + IGraph *includeDependencyGraph() const; + IGraph *includedByDependencyGraph() const; + IDocProgramListing *source() const; + IIncludeIterator *includes() const; + IIncludeIterator *includedBy() const; + + // IPage implementation + const IDocTitle *title() const; + + private: + // XML elements: + // ------------- + StringImpl m_name; // compoundname + TitleHandler* m_titleHandler; // title + QList<RelatedCompound> m_subClasses; // basecompoundref + QList<RelatedCompound> m_superClasses; // derivedcompoundref + QList<IncludeHandler> m_includes; // includes + QList<IncludeHandler> m_includedBy; // includedBy + GraphHandler* m_includeDependencyGraph; // incdepgraph + GraphHandler* m_includedByDependencyGraph; // invincdepgraph + QList<QString> m_innerCompounds; // innerdir/innerfile/innerclass/innernamespace/innergroup + TemplateParamListHandler* m_templateParamList; // templateparamlist + QList<SectionHandler> m_sections; // sectiondef + DocHandler* m_brief; // briefdescription + DocHandler* m_detailed; // detaileddescription + GraphHandler* m_inheritanceGraph; // inheritancegraph + GraphHandler* m_collaborationGraph; // collaborationgraph + ProgramListingHandler* m_programListing; // programlisting + // location + StringImpl m_defFile; // - file + int m_defLine; // - line + StringImpl m_defBodyFile; // - bodyfile + int m_defBodyStart; // - bodystart + int m_defBodyEnd; // - bodyend + ListOfAllMembersHandler* m_members; // listofallmember + + // XML attributes: + // --------------- + StringImpl m_id; // id + CompoundKind m_kind; // kind + StringImpl m_kindString; // kind as a string + StringImpl m_protection; // prot + + // local variables + QString m_xmlDir; // directory where the info is found + int m_refCount; // object reference counter + QDict<MemberHandler> m_memberDict; // id->member lookup + QDict<QList<MemberHandler> > m_memberNameDict; // name->memberlist lookup + MainHandler* m_mainHandler; // parent object +}; + +void compoundhandler_init(); +void compoundhandler_exit(); + +#endif diff --git a/addon/doxmlparser/src/debug.cpp b/addon/doxmlparser/src/debug.cpp new file mode 100644 index 0000000..a8be32c --- /dev/null +++ b/addon/doxmlparser/src/debug.cpp @@ -0,0 +1,24 @@ +#include <stdio.h> +#include <stdlib.h> +#include <stdarg.h> + +#include "debug.h" + +static int s_debugLevel = 0; + +void debug(int level,const char *msg,...) +{ + if (level<=s_debugLevel) + { + va_list args; + va_start(args, msg); + vfprintf(stderr, msg, args); + va_end(args); + } +} + +void setDebugLevel(int level) +{ + s_debugLevel = level; +} + diff --git a/addon/doxmlparser/src/debug.h b/addon/doxmlparser/src/debug.h new file mode 100644 index 0000000..c77f7fe --- /dev/null +++ b/addon/doxmlparser/src/debug.h @@ -0,0 +1,7 @@ +#ifndef _DEBUG_H +#define _DEBUG_H + +void debug(int level,const char *msg,...); +void setDebugLevel(int level); + +#endif diff --git a/addon/doxmlparser/src/dochandler.cpp b/addon/doxmlparser/src/dochandler.cpp new file mode 100644 index 0000000..30698f4 --- /dev/null +++ b/addon/doxmlparser/src/dochandler.cpp @@ -0,0 +1,2240 @@ +/****************************************************************************** + * + * $Id: dochandler.cpp,v 1.33 2002/10/13 21:01:58 dimitri Exp $ + * + * + * Copyright (C) 1997-2012 by Dimitri van Heesch. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#include <qmap.h> + +#include "dochandler.h" +#include "debug.h" +#include "linkedtexthandler.h" + + +//---------------------------------------------------------------------- + +class TypeNameMapper +{ + public: + TypeNameMapper() + { + m_map.insert("see", SimpleSectHandler::See); + m_map.insert("return", SimpleSectHandler::Return); + m_map.insert("author", SimpleSectHandler::Author); + m_map.insert("version", SimpleSectHandler::Version); + m_map.insert("since", SimpleSectHandler::Since); + m_map.insert("date", SimpleSectHandler::Date); + m_map.insert("bug", SimpleSectHandler::Bug); + m_map.insert("note", SimpleSectHandler::Note); + m_map.insert("warning", SimpleSectHandler::Warning); + m_map.insert("par", SimpleSectHandler::Par); + m_map.insert("deprecated",SimpleSectHandler::Deprecated); + m_map.insert("pre", SimpleSectHandler::Pre); + m_map.insert("post", SimpleSectHandler::Post); + m_map.insert("invariant", SimpleSectHandler::Invar); + m_map.insert("remark", SimpleSectHandler::Remark); + m_map.insert("attention", SimpleSectHandler::Attention); + m_map.insert("todo", SimpleSectHandler::Todo); + m_map.insert("test", SimpleSectHandler::Test); + m_map.insert("rcs", SimpleSectHandler::RCS); + m_map.insert("enumvalues",SimpleSectHandler::EnumValues); + m_map.insert("examples", SimpleSectHandler::Examples); + } + SimpleSectHandler::Types stringToType(const QString &typeStr) + { + return m_map[typeStr]; + } + private: + QMap<QString,SimpleSectHandler::Types> m_map; +}; + +class HighlightMapper +{ + public: + HighlightMapper() + { + m_map.insert("comment", HighlightHandler::Comment); + m_map.insert("keyword", HighlightHandler::Keyword); + m_map.insert("keywordtype", HighlightHandler::KeywordType); + m_map.insert("keywordflow", HighlightHandler::KeywordFlow); + m_map.insert("charliteral", HighlightHandler::CharLiteral); + m_map.insert("stringliteral", HighlightHandler::StringLiteral); + m_map.insert("preprocessor", HighlightHandler::Preprocessor); + } + HighlightHandler::HighlightKind stringToKind(const QString &kindStr) + { + return m_map[kindStr]; + } + private: + QMap<QString,HighlightHandler::HighlightKind> m_map; +}; + +static TypeNameMapper *s_typeMapper; +static HighlightMapper *s_highlightMapper; + +void dochandler_init() +{ + s_typeMapper = new TypeNameMapper; + s_highlightMapper = new HighlightMapper; +} + +void dochandler_exit() +{ + delete s_typeMapper; + delete s_highlightMapper; +} + +//---------------------------------------------------------------------- +// MarkupHandler +//---------------------------------------------------------------------- + +MarkupHandler::MarkupHandler(QList<DocImpl> &children,QString &curString) + : m_children(children), m_curString(curString), + m_curMarkup(IDocMarkup::Normal), m_headingLevel(0) +{ + 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); + + addStartHandler("preformatted",this,&MarkupHandler::startPreformatted); + addEndHandler("preformatted",this,&MarkupHandler::endPreformatted); + + addStartHandler("heading1",this,&MarkupHandler::startHeading1); + addEndHandler("heading1",this,&MarkupHandler::endHeading1); + + addStartHandler("heading2",this,&MarkupHandler::startHeading2); + addEndHandler("heading2",this,&MarkupHandler::endHeading2); + + addStartHandler("heading3",this,&MarkupHandler::startHeading3); + addEndHandler("heading3",this,&MarkupHandler::endHeading3); + + addStartHandler("heading4",this,&MarkupHandler::startHeading4); + addEndHandler("heading4",this,&MarkupHandler::endHeading4); + + addStartHandler("heading5",this,&MarkupHandler::startHeading5); + addEndHandler("heading5",this,&MarkupHandler::endHeading5); + + addStartHandler("heading6",this,&MarkupHandler::startHeading6); + addEndHandler("heading6",this,&MarkupHandler::endHeading6); +} + +MarkupHandler::~MarkupHandler() +{ +} + +void MarkupHandler::addTextNode() +{ + if (!m_curString.isEmpty()) + { + m_children.append(new TextNode(m_curString,m_curMarkup,m_headingLevel)); + debug(2,"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(IDocMarkup::Bold,TRUE)); + m_curMarkup |= IDocMarkup::Bold; +} + +void MarkupHandler::endBold() +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Bold,FALSE)); + m_curMarkup &= ~IDocMarkup::Bold; +} + +void MarkupHandler::startEmphasis(const QXmlAttributes & /*attrib*/) +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Emphasis,TRUE)); + m_curMarkup |= IDocMarkup::Emphasis; +} + +void MarkupHandler::endEmphasis() +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Emphasis,FALSE)); + m_curMarkup &= ~IDocMarkup::Emphasis; +} + +void MarkupHandler::startComputerOutput(const QXmlAttributes & /*attrib*/) +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::ComputerOutput,TRUE)); + m_curMarkup |= IDocMarkup::ComputerOutput; +} + +void MarkupHandler::endComputerOutput() +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::ComputerOutput,FALSE)); + m_curMarkup &= ~IDocMarkup::ComputerOutput; +} + +void MarkupHandler::startCenter(const QXmlAttributes & /*attrib*/) +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Center,TRUE)); + m_curMarkup |= IDocMarkup::Center; +} + +void MarkupHandler::endCenter() +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Center,FALSE)); + m_curMarkup &= ~IDocMarkup::Center; +} + +void MarkupHandler::startSmallFont(const QXmlAttributes & /*attrib*/) +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::SmallFont,TRUE)); + m_curMarkup |= IDocMarkup::SmallFont; +} + +void MarkupHandler::endSmallFont() +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::SmallFont,FALSE)); + m_curMarkup &= ~IDocMarkup::SmallFont; +} + +void MarkupHandler::startSubscript(const QXmlAttributes & /*attrib*/) +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Subscript,TRUE)); + m_curMarkup |= IDocMarkup::Subscript; +} + +void MarkupHandler::endSubscript() +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Subscript,FALSE)); + m_curMarkup &= ~IDocMarkup::Subscript; +} + +void MarkupHandler::startSuperscript(const QXmlAttributes & /*attrib*/) +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Superscript,TRUE)); + m_curMarkup |= IDocMarkup::Superscript; +} + +void MarkupHandler::endSuperscript() +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Superscript,FALSE)); + m_curMarkup &= ~IDocMarkup::Superscript; +} + +void MarkupHandler::startPreformatted(const QXmlAttributes & /*attrib*/) +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Preformatted,TRUE)); + m_curMarkup |= IDocMarkup::Preformatted; +} + +void MarkupHandler::endPreformatted() +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Preformatted,FALSE)); + m_curMarkup &= ~IDocMarkup::Preformatted; +} + +void MarkupHandler::startHeading1(const QXmlAttributes & /*attrib*/) +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Heading,TRUE,1)); + m_curMarkup |= IDocMarkup::Heading; + m_headingLevel=1; +} + +void MarkupHandler::endHeading1() +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Heading,FALSE,1)); + m_curMarkup &= ~IDocMarkup::Heading; + m_headingLevel=0; +} + +void MarkupHandler::startHeading2(const QXmlAttributes & /*attrib*/) +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Heading,TRUE,2)); + m_curMarkup |= IDocMarkup::Heading; + m_headingLevel=2; +} + +void MarkupHandler::endHeading2() +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Heading,FALSE,2)); + m_curMarkup &= ~IDocMarkup::Heading; + m_headingLevel=0; +} + +void MarkupHandler::startHeading3(const QXmlAttributes & /*attrib*/) +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Heading,TRUE,3)); + m_curMarkup |= IDocMarkup::Heading; + m_headingLevel=3; +} + +void MarkupHandler::endHeading3() +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Heading,FALSE,3)); + m_curMarkup &= ~IDocMarkup::Heading; + m_headingLevel=0; +} + +void MarkupHandler::startHeading4(const QXmlAttributes & /*attrib*/) +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Heading,TRUE,4)); + m_curMarkup |= IDocMarkup::Heading; + m_headingLevel=4; +} + +void MarkupHandler::endHeading4() +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Heading,FALSE,4)); + m_curMarkup &= ~IDocMarkup::Heading; + m_headingLevel=0; +} + +void MarkupHandler::startHeading5(const QXmlAttributes & /*attrib*/) +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Heading,TRUE,5)); + m_curMarkup |= IDocMarkup::Heading; + m_headingLevel=5; +} + +void MarkupHandler::endHeading5() +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Heading,FALSE,5)); + m_curMarkup &= ~IDocMarkup::Heading; + m_headingLevel=0; +} + +void MarkupHandler::startHeading6(const QXmlAttributes & /*attrib*/) +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Heading,TRUE,6)); + m_curMarkup |= IDocMarkup::Heading; + m_headingLevel=6; +} + +void MarkupHandler::endHeading6() +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Heading,FALSE,6)); + m_curMarkup &= ~IDocMarkup::Heading; + m_headingLevel=0; +} + + +//---------------------------------------------------------------------- +// ListItemHandler +//---------------------------------------------------------------------- + +ListItemHandler::ListItemHandler(IBaseHandler *parent) + : m_parent(parent) +{ + m_children.setAutoDelete(TRUE); + + addEndHandler("listitem",this,&ListItemHandler::endListItem); + + addStartHandler("para",this,&ListItemHandler::startParagraph); +} + +ListItemHandler::~ListItemHandler() +{ +} + +void ListItemHandler::startListItem(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + debug(2,"start list item handler\n"); +} + +void ListItemHandler::endListItem() +{ + debug(2,"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); +} + +IDocIterator *ListItemHandler::contents() const +{ + return new ListItemIterator(*this); +} + +//---------------------------------------------------------------------- +// OrderedListHandler +//---------------------------------------------------------------------- + +OrderedListHandler::OrderedListHandler(IBaseHandler *parent) : m_parent(parent) +{ + m_children.setAutoDelete(TRUE); + addEndHandler("orderedlist",this,&OrderedListHandler::endOrderedList); + addStartHandler("listitem",this,&OrderedListHandler::startOrderedListItem); +} + +OrderedListHandler::~OrderedListHandler() +{ +} + +void OrderedListHandler::startOrderedList(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); +} + +void OrderedListHandler::endOrderedList() +{ + m_parent->setDelegate(0); +} + +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 ItemizedListHandler::endItemizedList() +{ + m_parent->setDelegate(0); +} + +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); +} + +//---------------------------------------------------------------------- +// TocListHandler +//---------------------------------------------------------------------- + +TocListHandler::TocListHandler(IBaseHandler *parent) : m_parent(parent) +{ + m_children.setAutoDelete(TRUE); + addEndHandler("toclist",this,&TocListHandler::endTocList); + addStartHandler("tocitem",this,&TocListHandler::startTocItem); +} + +TocListHandler::~TocListHandler() +{ +} + +void TocListHandler::startTocList(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); +} + +void TocListHandler::endTocList() +{ + m_parent->setDelegate(0); +} + +void TocListHandler::startTocItem(const QXmlAttributes& attrib) +{ + TocItemHandler *tiHandler = new TocItemHandler(this); + tiHandler->startTocItem(attrib); + m_children.append(tiHandler); +} + +IDocIterator *TocListHandler::elements() const +{ + return new TocListIterator(*this); +} + +//---------------------------------------------------------------------- +// TocItemHandler +//---------------------------------------------------------------------- + +TocItemHandler::TocItemHandler(IBaseHandler *parent) : m_parent(parent) +{ + addEndHandler("tocitem",this,&TocItemHandler::endTocItem); +} + +TocItemHandler::~TocItemHandler() +{ +} + +void TocItemHandler::startTocItem(const QXmlAttributes& attrib) +{ + m_parent->setDelegate(this); + m_id = attrib.value("id"); + m_curString=""; +} + +void TocItemHandler::endTocItem() +{ + m_title = m_curString; + m_parent->setDelegate(0); +} + +//---------------------------------------------------------------------- +// ParameterHandler +//---------------------------------------------------------------------- + +ParameterHandler::ParameterHandler(IBaseHandler *parent) : + m_parent(parent) +{ + addEndHandler("parametername",this,&ParameterHandler::endParameterName); +} + +ParameterHandler::~ParameterHandler() +{ +} + +void ParameterHandler::startParameterName(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); +} + +void ParameterHandler::endParameterName() +{ + m_name = m_curString; + debug(2,"parameter %s\n",m_name.data()); + m_curString=""; + m_parent->setDelegate(0); +} + +//---------------------------------------------------------------------- +// ParameterListHandler +//---------------------------------------------------------------------- + +ParameterItemHandler::ParameterItemHandler(IBaseHandler *parent) + : m_parent(parent) +{ + addEndHandler("parameteritem",this,&ParameterItemHandler::endParameterItem); + addStartHandler("parameternamelist"); + addEndHandler("parameternamelist"); + addStartHandler("parametername",this,&ParameterItemHandler::startParameterName); + addStartHandler("parameterdescription"); + addEndHandler("parameterdescription"); + addStartHandler("para",this,&ParameterItemHandler::startParagraph); + m_parameters.setAutoDelete(TRUE); + m_description = 0; +} + +ParameterItemHandler::~ParameterItemHandler() +{ + delete m_description; +} + +void ParameterItemHandler::startParameterItem(const QXmlAttributes&) +{ + m_parent->setDelegate(this); +} + +void ParameterItemHandler::endParameterItem() +{ + m_parent->setDelegate(0); +} + +void ParameterItemHandler::startParameterName(const QXmlAttributes& attrib) +{ + ParameterHandler *param = new ParameterHandler(this); + m_parameters.append(param); + param->startParameterName(attrib); +} + +void ParameterItemHandler::startParagraph(const QXmlAttributes& attrib) +{ + m_description = new ParagraphHandler(this); + m_description->startParagraph(attrib); +} + +IDocIterator *ParameterItemHandler::paramNames() const +{ + return new ParameterItemIterator(*this); +} + +//---------------------------------------------------------------------- +// ParameterListHandler +//---------------------------------------------------------------------- + +ParameterListHandler::ParameterListHandler(IBaseHandler *parent) + : m_parent(parent) +{ + addEndHandler("parameterlist",this,&ParameterListHandler::endParameterList); + addStartHandler("parameteritem",this,&ParameterListHandler::startParameterItem); + m_paramItems.setAutoDelete(TRUE); +} + +ParameterListHandler::~ParameterListHandler() +{ +} + +void ParameterListHandler::startParameterList(const QXmlAttributes& attrib) +{ + QString kind = attrib.value("kind"); + if (kind=="retval") m_type=RetVal; + else if (kind=="exception") m_type=Exception; + else if (kind=="param") m_type=Param; + else + { + debug(1,"Error: invalid parameterlist type: %s\n",kind.data()); + } + debug(2,"parameterlist kind=%s\n",kind.data()); + m_parent->setDelegate(this); +} + +void ParameterListHandler::endParameterList() +{ + m_parent->setDelegate(0); +} + +void ParameterListHandler::startParameterItem(const QXmlAttributes& attrib) +{ + ParameterItemHandler *paramItem = new ParameterItemHandler(this); + m_paramItems.append(paramItem); + paramItem->startParameterItem(attrib); +} + +IDocIterator *ParameterListHandler::params() const +{ + return new ParameterListIterator(*this); +} + +//---------------------------------------------------------------------- +// LinkHandler +//---------------------------------------------------------------------- + +LinkHandler::LinkHandler(IBaseHandler *parent) + : m_parent(parent) +{ + addEndHandler("link",this,&LinkHandler::endLink); +} + +LinkHandler::~LinkHandler() +{ +} + +void LinkHandler::startLink(const QXmlAttributes& attrib) +{ + m_parent->setDelegate(this); + debug(2,"Start link\n"); + m_ref = attrib.value("linkend"); + m_curString=""; +} + +void LinkHandler::endLink() +{ + m_text = m_curString; + m_curString=""; + m_parent->setDelegate(0); + debug(2,"End link\n"); +} + +//---------------------------------------------------------------------- +// EMailHandler +//---------------------------------------------------------------------- + +EMailHandler::EMailHandler(IBaseHandler *parent) + : m_parent(parent) +{ + addEndHandler("email",this,&EMailHandler::endEMail); +} + +EMailHandler::~EMailHandler() +{ +} + +void EMailHandler::startEMail(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + debug(2,"Start email\n"); + m_curString=""; +} + +void EMailHandler::endEMail() +{ + m_address = m_curString; + m_curString=""; + m_parent->setDelegate(0); + debug(2,"End email\n"); +} + +//---------------------------------------------------------------------- +// ULinkHandler +//---------------------------------------------------------------------- + +ULinkHandler::ULinkHandler(IBaseHandler *parent) + : m_parent(parent) +{ + addEndHandler("ulink",this,&ULinkHandler::endULink); +} + +ULinkHandler::~ULinkHandler() +{ +} + +void ULinkHandler::startULink(const QXmlAttributes& attrib) +{ + m_parent->setDelegate(this); + debug(2,"Start ulink\n"); + m_url = attrib.value("url"); + m_curString=""; +} + +void ULinkHandler::endULink() +{ + m_text = m_curString; + m_curString=""; + m_parent->setDelegate(0); + debug(2,"End ulink\n"); +} + +//---------------------------------------------------------------------- +// LineBreakHandler +//---------------------------------------------------------------------- + +LineBreakHandler::LineBreakHandler(IBaseHandler *parent) + : m_parent(parent) +{ + addEndHandler("linebreak",this,&LineBreakHandler::endLineBreak); +} + +LineBreakHandler::~LineBreakHandler() +{ +} + +void LineBreakHandler::startLineBreak(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + debug(2,"Start linebreak\n"); +} + +void LineBreakHandler::endLineBreak() +{ + m_parent->setDelegate(0); + debug(2,"End linebreak\n"); +} + +//---------------------------------------------------------------------- +// HRulerHandler +//---------------------------------------------------------------------- + +HRulerHandler::HRulerHandler(IBaseHandler *parent) + : m_parent(parent) +{ + addEndHandler("hruler",this,&HRulerHandler::endHRuler); +} + +HRulerHandler::~HRulerHandler() +{ +} + +void HRulerHandler::startHRuler(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + debug(2,"Start hruler\n"); +} + +void HRulerHandler::endHRuler() +{ + m_parent->setDelegate(0); + debug(2,"End hruler\n"); +} + +//---------------------------------------------------------------------- +// RefHandler +//---------------------------------------------------------------------- + +RefHandler::RefHandler(IBaseHandler *parent) + : m_parent(parent) +{ + addEndHandler("ref",this,&RefHandler::endRef); +} + +RefHandler::~RefHandler() +{ +} + +void RefHandler::startRef(const QXmlAttributes& attrib) +{ + m_parent->setDelegate(this); + m_refId = attrib.value("refid"); + m_extId = attrib.value("external"); + ASSERT(attrib.value("kindref")=="compound" || + attrib.value("kindref")=="member"); + m_targetKind = attrib.value("kindref")=="compound" ? Compound : Member; + debug(2,"Start ref refId=%s\n",m_refId.data()); + m_curString=""; +} + +void RefHandler::endRef() +{ + m_linkText = m_curString; + m_parent->setDelegate(0); + debug(2,"End ref: text=`%s'\n",m_linkText.data()); +} + + +//---------------------------------------------------------------------- +// TitleHandler +//---------------------------------------------------------------------- + +TitleHandler::TitleHandler(IBaseHandler *parent) + : m_parent(parent) +{ + m_children.setAutoDelete(TRUE); + m_markupHandler = new MarkupHandler(m_children,m_curString); + setFallBackHandler(m_markupHandler); + addStartHandler("ref",this,&TitleHandler::startRef); + addEndHandler("title",this,&TitleHandler::endTitle); +} + +TitleHandler::~TitleHandler() +{ + delete m_markupHandler; +} + +void TitleHandler::startTitle(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + debug(2,"Start title\n"); + m_curString=""; +} + +void TitleHandler::endTitle() +{ + addTextNode(); + m_parent->setDelegate(0); + debug(2,"End title\n"); +} + +void TitleHandler::addTextNode() +{ + if (!m_curString.isEmpty()) + { + m_children.append( + new TextNode( + m_curString, + m_markupHandler->markup(), + m_markupHandler->headingLevel() + ) + ); + debug(2,"addTextNode() text=\"%s\" markup=%x headingLevel=%d\n", + m_curString.data(),m_markupHandler->markup(),m_markupHandler->headingLevel()); + m_curString=""; + } +} + +void TitleHandler::startRef(const QXmlAttributes& attrib) +{ + RefHandler *ref = new RefHandler(this); + ref->startRef(attrib); + m_children.append(ref); +} + +IDocIterator *TitleHandler::title() const +{ + return new TitleIterator(*this); +} + +//---------------------------------------------------------------------- +// SimpleSectHandler +//---------------------------------------------------------------------- + +SimpleSectHandler::SimpleSectHandler(IBaseHandler *parent) + : m_parent(parent), m_paragraph(0), m_title(0) +{ + addStartHandler("title",this,&SimpleSectHandler::startTitle); + addStartHandler("para",this,&SimpleSectHandler::startParagraph); + addEndHandler("simplesect",this,&SimpleSectHandler::endSimpleSect); +} + +SimpleSectHandler::~SimpleSectHandler() +{ +} + +void SimpleSectHandler::startSimpleSect(const QXmlAttributes& attrib) +{ + m_typeString = attrib.value("kind"); + m_type = s_typeMapper->stringToType(m_typeString); + debug(2,"start simple section %s\n",m_typeString.data()); + m_parent->setDelegate(this); +} + +void SimpleSectHandler::endSimpleSect() +{ + debug(2,"end simple section\n"); + m_parent->setDelegate(0); +} + +void SimpleSectHandler::startTitle(const QXmlAttributes& attrib) +{ + 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) + : m_parent(parent), m_description(0), m_linkedTextHandler(0) +{ + addStartHandler("term",this,&VariableListEntryHandler::startTerm); + addEndHandler("term",this,&VariableListEntryHandler::endTerm); + addStartHandler("para",this,&VariableListEntryHandler::startParagraph); + addEndHandler("varlistentry",this,&VariableListEntryHandler::endVarListEntry); + addEndHandler("listitem",this,&VariableListEntryHandler::endListItem); +} + +VariableListEntryHandler::~VariableListEntryHandler() +{ + delete m_description; +} + +void VariableListEntryHandler::startVarListEntry(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + debug(2,"start varlistentry\n"); +} + +void VariableListEntryHandler::endVarListEntry() +{ + m_parent->setDelegate(0); + debug(2,"end varlistentry\n"); +} + +void VariableListEntryHandler::startListItem(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + debug(2,"start listitem\n"); +} + +void VariableListEntryHandler::endListItem() +{ + m_parent->setDelegate(0); + debug(2,"end listitem\n"); +} + +void VariableListEntryHandler::startTerm(const QXmlAttributes& /*attrib*/) +{ + m_curString=""; + m_linkedTextHandler = new LinkedTextHandler(this,m_term); + m_linkedTextHandler->start("term"); +} + +void VariableListEntryHandler::endTerm() +{ + delete m_linkedTextHandler; +} + +void VariableListEntryHandler::startParagraph(const QXmlAttributes& attrib) +{ + ASSERT(m_description==0); + m_description = new ParagraphHandler(this); + m_description->startParagraph(attrib); +} + +ILinkedTextIterator *VariableListEntryHandler::term() const +{ + return new LinkedTextIterator(m_term); +} + + +//---------------------------------------------------------------------- +// VariableListHandler +//---------------------------------------------------------------------- + +VariableListHandler::VariableListHandler(IBaseHandler *parent) + : m_parent(parent) +{ + m_entries.setAutoDelete(TRUE); + addStartHandler("varlistentry",this,&VariableListHandler::startVarListEntry); + addStartHandler("listitem",this,&VariableListHandler::startListItem); + addEndHandler("variablelist",this,&VariableListHandler::endVariableList); +} + +VariableListHandler::~VariableListHandler() +{ +} + +void VariableListHandler::startVariableList(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + debug(2,"start variablelist\n"); +} + +void VariableListHandler::endVariableList() +{ + debug(2,"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); +} + +IDocIterator *VariableListHandler::entries() const +{ + return new VariableListIterator(*this); +} + +//---------------------------------------------------------------------- +// HighlightHandler +//---------------------------------------------------------------------- + +HighlightHandler::HighlightHandler(IBaseHandler *parent) + : m_parent(parent) +{ + m_children.setAutoDelete(TRUE); + addEndHandler("highlight",this,&HighlightHandler::endHighlight); + addStartHandler("ref",this,&HighlightHandler::startRef); + addStartHandler("sp",this,&HighlightHandler::startSpace); + m_hl = IDocHighlight::Invalid; +} + +HighlightHandler::~HighlightHandler() +{ +} + +void HighlightHandler::startHighlight(const QXmlAttributes& attrib) +{ + m_hlString = attrib.value("class"); + m_hl = s_highlightMapper->stringToKind(m_hlString); + m_curString=""; + m_parent->setDelegate(this); + debug(2,"start highlight\n"); +} + +void HighlightHandler::endHighlight() +{ + addTextNode(); + debug(2,"end highlight class=`%s'\n",m_hlString.data()); + m_parent->setDelegate(0); +} + +void HighlightHandler::startRef(const QXmlAttributes& attrib) +{ + addTextNode(); + RefHandler *rh = new RefHandler(this); + m_children.append(rh); + rh->startRef(attrib); +} + +void HighlightHandler::startSpace(const QXmlAttributes&) +{ + m_curString=" "; + addTextNode(); +} + +void HighlightHandler::addTextNode() +{ + if (!m_curString.isEmpty()) + { + m_children.append(new TextNode(m_curString,IDocMarkup::Normal,0)); + debug(2,"addTextNode() text=\"%s\"\n", + m_curString.data()); + m_curString=""; + } +} + +IDocIterator *HighlightHandler::codeElements() const +{ + return new HighlightIterator(*this); +} + +//---------------------------------------------------------------------- +// CodeLineHandler +//---------------------------------------------------------------------- + +CodeLineHandler::CodeLineHandler(IBaseHandler *parent) + : m_parent(parent) +{ + m_children.setAutoDelete(TRUE); + addEndHandler("codeline",this,&CodeLineHandler::endCodeLine); + addEndHandler("linenumber",this,&CodeLineHandler::endLineNumber); + addStartHandler("highlight",this,&CodeLineHandler::startHighlight); + addStartHandler("ref",this,&CodeLineHandler::startRef); + m_lineNumber = 0; +} + +CodeLineHandler::~CodeLineHandler() +{ +} + +void CodeLineHandler::startCodeLine(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + debug(2,"start codeline\n"); +} + +void CodeLineHandler::endCodeLine() +{ + addTextNode(); + debug(2,"end codeline\n"); + m_parent->setDelegate(0); +} + +void CodeLineHandler::startLineNumber(const QXmlAttributes& attrib) +{ + m_parent->setDelegate(this); + debug(2,"start linenumber\n"); + m_lineNumber = attrib.value("line").toInt(); + m_refId = attrib.value("refid"); +} + +void CodeLineHandler::endLineNumber() +{ + m_parent->setDelegate(0); +} + +void CodeLineHandler::startHighlight(const QXmlAttributes& attrib) +{ + addTextNode(); + HighlightHandler *hlh = new HighlightHandler(this); + m_children.append(hlh); + hlh->startHighlight(attrib); +} + +void CodeLineHandler::startRef(const QXmlAttributes& attrib) +{ + addTextNode(); + RefHandler *rh = new RefHandler(this); + m_children.append(rh); + rh->startRef(attrib); +} + +void CodeLineHandler::addTextNode() +{ + if (!m_curString.isEmpty()) + { + m_children.append(new TextNode(m_curString,IDocMarkup::Normal,0)); + debug(2,"addTextNode() text=\"%s\"\n", + m_curString.data()); + m_curString=""; + } +} + +IDocIterator *CodeLineHandler::codeElements() const +{ + return new CodeLineIterator(*this); +} + + +//---------------------------------------------------------------------- +// ProgramListingHandler +//---------------------------------------------------------------------- + +ProgramListingHandler::ProgramListingHandler(IBaseHandler *parent) + : m_parent(parent) +{ + m_children.setAutoDelete(TRUE); + m_hasLineNumber=FALSE; + addEndHandler("programlisting",this,&ProgramListingHandler::endProgramListing); + + addStartHandler("linenumber",this,&ProgramListingHandler::startLineNumber); + addStartHandler("codeline",this,&ProgramListingHandler::startCodeLine); +} + +ProgramListingHandler::~ProgramListingHandler() +{ +} + +void ProgramListingHandler::startProgramListing(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + debug(2,"start programlisting\n"); +} + +void ProgramListingHandler::endProgramListing() +{ + debug(2,"end programlisting\n"); + m_parent->setDelegate(0); +} + +void ProgramListingHandler::startLineNumber(const QXmlAttributes& attrib) +{ + CodeLineHandler *clh = new CodeLineHandler(this); + m_children.append(clh); + m_hasLineNumber=TRUE; + clh->startLineNumber(attrib); +} + +void ProgramListingHandler::startCodeLine(const QXmlAttributes& attrib) +{ + CodeLineHandler *clh = 0; + if (!m_hasLineNumber) + { + clh = new CodeLineHandler(this); + m_children.append(clh); + } + else + { + clh = m_children.getLast(); + } + ASSERT(clh!=0); + clh->startCodeLine(attrib); + m_hasLineNumber=FALSE; +} + +IDocIterator *ProgramListingHandler::codeLines() const +{ + return new ProgramListingIterator(*this); +} + + + +//---------------------------------------------------------------------- +// FormulaHandler +//---------------------------------------------------------------------- + +FormulaHandler::FormulaHandler(IBaseHandler *parent) + : m_parent(parent) +{ + addEndHandler("formula",this,&FormulaHandler::endFormula); +} + +FormulaHandler::~FormulaHandler() +{ +} + +void FormulaHandler::startFormula(const QXmlAttributes& attrib) +{ + m_id = attrib.value("id"); + m_curString=""; + m_parent->setDelegate(this); +} + +void FormulaHandler::endFormula() +{ + m_text = m_curString; + debug(2,"formula id=`%s' text=`%s'\n",m_id.data(),m_text.data()); + m_parent->setDelegate(0); +} + +//---------------------------------------------------------------------- +// AnchorHandler +//---------------------------------------------------------------------- + +AnchorHandler::AnchorHandler(IBaseHandler *parent) + : m_parent(parent) +{ + addEndHandler("anchor",this,&AnchorHandler::endAnchor); +} + +AnchorHandler::~AnchorHandler() +{ +} + +void AnchorHandler::startAnchor(const QXmlAttributes& attrib) +{ + m_id = attrib.value("id"); + m_parent->setDelegate(this); +} + +void AnchorHandler::endAnchor() +{ + debug(2,"anchor id=`%s'\n",m_id.data()); + m_parent->setDelegate(0); +} + +//---------------------------------------------------------------------- +// ImageHandler +//---------------------------------------------------------------------- + +ImageHandler::ImageHandler(IBaseHandler *parent) + : m_parent(parent) +{ + addEndHandler("image",this,&ImageHandler::endImage); +} + +ImageHandler::~ImageHandler() +{ +} + +void ImageHandler::startImage(const QXmlAttributes& attrib) +{ + m_name = attrib.value("name"); + m_curString=""; + m_parent->setDelegate(this); +} + +void ImageHandler::endImage() +{ + m_caption = m_curString; + debug(2,"image name=`%s' caption=`%s'\n",m_name.data(),m_caption.data()); + m_parent->setDelegate(0); +} + +//---------------------------------------------------------------------- +// DotFileHandler +//---------------------------------------------------------------------- + +DotFileHandler::DotFileHandler(IBaseHandler *parent) + : m_parent(parent) +{ + addEndHandler("dotfile",this,&DotFileHandler::endDotFile); +} + +DotFileHandler::~DotFileHandler() +{ +} + +void DotFileHandler::startDotFile(const QXmlAttributes& attrib) +{ + m_name = attrib.value("name"); + m_curString=""; + m_parent->setDelegate(this); +} + +void DotFileHandler::endDotFile() +{ + m_caption = m_curString; + debug(2,"image name=`%s' caption=`%s'\n",m_name.data(),m_caption.data()); + m_parent->setDelegate(0); +} + +//---------------------------------------------------------------------- +// IndexEntryHandler +//---------------------------------------------------------------------- + +IndexEntryHandler::IndexEntryHandler(IBaseHandler *parent) + : m_parent(parent) +{ + addEndHandler("indexentry",this,&IndexEntryHandler::endIndexEntry); + addStartHandler("primaryie",this,&IndexEntryHandler::startPrimaryIE); + addEndHandler("primaryie",this,&IndexEntryHandler::endPrimaryIE); + addStartHandler("secondaryie",this,&IndexEntryHandler::startSecondaryIE); + addEndHandler("secondaryie",this,&IndexEntryHandler::endSecondaryIE); +} + +IndexEntryHandler::~IndexEntryHandler() +{ +} + +void IndexEntryHandler::startIndexEntry(const QXmlAttributes& /*attrib*/) +{ + debug(2,"start index entry\n"); + m_parent->setDelegate(this); +} + +void IndexEntryHandler::endIndexEntry() +{ + debug(2,"index entry primary=`%s' secondary=`%s'\n", + m_primary.data(),m_secondary.data()); + m_parent->setDelegate(0); +} + +void IndexEntryHandler::startPrimaryIE(const QXmlAttributes& /*attrib*/) +{ + m_curString=""; +} + +void IndexEntryHandler::endPrimaryIE() +{ + m_primary = m_curString; +} + +void IndexEntryHandler::startSecondaryIE(const QXmlAttributes& /*attrib*/) +{ + m_curString=""; +} + +void IndexEntryHandler::endSecondaryIE() +{ + m_secondary = m_curString; +} + +//---------------------------------------------------------------------- +// EntryHandler +//---------------------------------------------------------------------- + +EntryHandler::EntryHandler(IBaseHandler *parent) + : m_parent(parent) +{ + m_children.setAutoDelete(TRUE); + addEndHandler("entry",this,&EntryHandler::endEntry); + addStartHandler("para",this,&EntryHandler::startParagraph); +} + +EntryHandler::~EntryHandler() +{ +} + +void EntryHandler::startEntry(const QXmlAttributes&) +{ + m_parent->setDelegate(this); +} + +void EntryHandler::endEntry() +{ + m_parent->setDelegate(0); +} + +void EntryHandler::startParagraph(const QXmlAttributes& attrib) +{ + ParagraphHandler *ph = new ParagraphHandler(this); + ph->startParagraph(attrib); + m_children.append(ph); +} + +IDocIterator *EntryHandler::contents() const +{ + return new EntryIterator(*this); +} + +//---------------------------------------------------------------------- +// RowHandler +//---------------------------------------------------------------------- + +RowHandler::RowHandler(IBaseHandler *parent) + : m_parent(parent) +{ + m_children.setAutoDelete(TRUE); + addEndHandler("row",this,&RowHandler::endRow); + addStartHandler("entry",this,&RowHandler::startEntry); +} + +RowHandler::~RowHandler() +{ +} + +void RowHandler::startRow(const QXmlAttributes&) +{ + m_parent->setDelegate(this); +} + +void RowHandler::endRow() +{ + m_parent->setDelegate(0); +} + +void RowHandler::startEntry(const QXmlAttributes& attrib) +{ + EntryHandler *eh = new EntryHandler(this); + eh->startEntry(attrib); + m_children.append(eh); +} + +IDocIterator *RowHandler::entries() const +{ + return new RowIterator(*this); +} + +//---------------------------------------------------------------------- +// TableHandler +//---------------------------------------------------------------------- + +TableHandler::TableHandler(IBaseHandler *parent) + : m_parent(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() +{ +} + +void TableHandler::startTable(const QXmlAttributes& attrib) +{ + m_parent->setDelegate(this); + m_numColumns = attrib.value("cols").toInt(); + debug(2,"table cols=%d\n",m_numColumns); +} + +void TableHandler::endTable() +{ + m_parent->setDelegate(0); +} + +void TableHandler::startRow(const QXmlAttributes& attrib) +{ + RowHandler *rh = new RowHandler(this); + rh->startRow(attrib); + m_children.append(rh); +} + +void TableHandler::startCaption(const QXmlAttributes& /*attrib*/) +{ + m_curString=""; +} + +void TableHandler::endCaption() +{ + m_caption = m_curString; +} + +IDocIterator *TableHandler::rows() const +{ + return new TableIterator(*this); +} + +//---------------------------------------------------------------------- +// CopyHandler +//---------------------------------------------------------------------- + +CopyHandler::CopyHandler(IBaseHandler *parent) + : m_parent(parent) +{ + m_children.setAutoDelete(TRUE); + + addEndHandler("copydoc",this,&CopyHandler::endCopy); + + addStartHandler("para",this,&CopyHandler::startParagraph); +} + +CopyHandler::~CopyHandler() +{ +} + +void CopyHandler::startCopy(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + debug(2,"start copy handler\n"); +} + +void CopyHandler::endCopy() +{ + debug(2,"end copy handler\n"); + m_parent->setDelegate(0); +} + +void CopyHandler::startParagraph(const QXmlAttributes& attrib) +{ + ParagraphHandler *parHandler = new ParagraphHandler(this); + parHandler->startParagraph(attrib); + m_children.append(parHandler); +} + +IDocIterator *CopyHandler::contents() const +{ + return new CopyIterator(*this); +} + +//---------------------------------------------------------------------- +// VerbatimHandler +//---------------------------------------------------------------------- + +VerbatimHandler::VerbatimHandler(IBaseHandler *parent) + : m_parent(parent), m_type(IDocVerbatim::Invalid) +{ + addEndHandler("verbatim",this,&VerbatimHandler::endVerbatim); + addEndHandler("latexonly",this,&VerbatimHandler::endVerbatim); + addEndHandler("htmlonly",this,&VerbatimHandler::endVerbatim); +} + +VerbatimHandler::~VerbatimHandler() +{ +} + +void VerbatimHandler::startVerbatim(const QXmlAttributes&,Types type) +{ + m_type = type; + m_parent->setDelegate(this); + m_curString=""; +} + +void VerbatimHandler::endVerbatim() +{ + m_text = m_curString; + m_parent->setDelegate(0); +} + + +//---------------------------------------------------------------------- +// SymbolHandler +//---------------------------------------------------------------------- + +SymbolHandler::SymbolHandler(IBaseHandler *parent,Types type) + : m_parent(parent), m_letter('\0'), m_type(type) +{ + addEndHandler("symbol"); + switch (type) + { + case IDocSymbol::Invalid: m_typeString="invalid"; break; + case IDocSymbol::Umlaut: m_typeString="umlaut"; break; + case IDocSymbol::Acute: m_typeString="acute"; break; + case IDocSymbol::Grave: m_typeString="grave"; break; + case IDocSymbol::Circ: m_typeString="circ"; break; + case IDocSymbol::Tilde: m_typeString="tilde"; break; + case IDocSymbol::Szlig: m_typeString="szlig"; break; + case IDocSymbol::Cedil: m_typeString="cedil"; break; + case IDocSymbol::Ring: m_typeString="ring"; break; + case IDocSymbol::Nbsp: m_typeString="nbsp"; break; + case IDocSymbol::Copy: m_typeString="copy"; break; + } +} + +SymbolHandler::~SymbolHandler() +{ +} + +void SymbolHandler::startSymbol(const QXmlAttributes& attrib) +{ + QString ls = attrib.value("char"); + if (!ls.isEmpty()) m_letter = ls.latin1()[0]; +} + +//---------------------------------------------------------------------- +// ParagraphHandler +//---------------------------------------------------------------------- + +ParagraphHandler::ParagraphHandler(IBaseHandler *parent) + : m_parent(parent) +{ + m_children.setAutoDelete(TRUE); + + m_markupHandler = new MarkupHandler(m_children,m_curString); + + // preformatted + setFallBackHandler(m_markupHandler); + + addEndHandler("para",this,&ParagraphHandler::endParagraph); + + addStartHandler("linebreak",this,&ParagraphHandler::startLineBreak); + addStartHandler("hruler",this,&ParagraphHandler::startHRuler); + addStartHandler("programlisting",this,&ParagraphHandler::startProgramListing); + addStartHandler("verbatim",this,&ParagraphHandler::startVerbatim); + addStartHandler("indexentry",this,&ParagraphHandler::startIndexEntry); + addStartHandler("orderedlist",this,&ParagraphHandler::startOrderedList); + addStartHandler("itemizedlist",this,&ParagraphHandler::startItemizedList); + addStartHandler("simplesect",this,&ParagraphHandler::startSimpleSect); + // TODO: title + addStartHandler("variablelist",this,&ParagraphHandler::startVariableList); + addStartHandler("table",this,&ParagraphHandler::startTable); + // TODO: heading + addStartHandler("image",this,&ParagraphHandler::startImage); + addStartHandler("dotfile",this,&ParagraphHandler::startDotFile); + addStartHandler("toclist",this,&ParagraphHandler::startTocList); + // TODO: language??? + addStartHandler("parameterlist",this,&ParagraphHandler::startParameterList); + // TODO: xrefsect + addStartHandler("copydoc",this,&ParagraphHandler::startCopyDoc); + + addStartHandler("ref",this,&ParagraphHandler::startRef); + addStartHandler("ulink",this,&ParagraphHandler::startULink); + addStartHandler("email",this,&ParagraphHandler::startEMail); + addStartHandler("link",this,&ParagraphHandler::startLink); + addStartHandler("formula",this,&ParagraphHandler::startFormula); + addStartHandler("latexonly",this,&ParagraphHandler::startHtmlOnly); + addStartHandler("htmlonly",this,&ParagraphHandler::startLatexOnly); + addStartHandler("umlaut",this,&ParagraphHandler::startUmlaut); + addStartHandler("acute",this,&ParagraphHandler::startAcute); + addStartHandler("grave",this,&ParagraphHandler::startGrave); + addStartHandler("circ",this,&ParagraphHandler::startCirc); + addStartHandler("tilde",this,&ParagraphHandler::startTilde); + addStartHandler("szlig",this,&ParagraphHandler::startSzlig); + addStartHandler("cedil",this,&ParagraphHandler::startCedil); + addStartHandler("ring",this,&ParagraphHandler::startRing); + addStartHandler("nbsp",this,&ParagraphHandler::startNbsp); + addStartHandler("copy",this,&ParagraphHandler::startCopy); + addStartHandler("anchor",this,&ParagraphHandler::startAnchor); +} + +ParagraphHandler::~ParagraphHandler() +{ + delete m_markupHandler; +} + +void ParagraphHandler::startParagraph(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + debug(2,"para\n"); +} + +void ParagraphHandler::endParagraph() +{ + addTextNode(); + debug(2,"end para\n"); + m_parent->setDelegate(0); +} + +void ParagraphHandler::startItemizedList(const QXmlAttributes& attrib) +{ + addTextNode(); + ItemizedListHandler *listHandler = new ItemizedListHandler(this); + listHandler->startItemizedList(attrib); + m_children.append(listHandler); +} + +void ParagraphHandler::startOrderedList(const QXmlAttributes& attrib) +{ + addTextNode(); + OrderedListHandler *listHandler = new OrderedListHandler(this); + listHandler->startOrderedList(attrib); + m_children.append(listHandler); +} + +void ParagraphHandler::startParameterList(const QXmlAttributes& attrib) +{ + addTextNode(); + ParameterListHandler *listHandler = new ParameterListHandler(this); + listHandler->startParameterList(attrib); + m_children.append(listHandler); +} + +void ParagraphHandler::startSimpleSect(const QXmlAttributes& attrib) +{ + addTextNode(); + SimpleSectHandler *sectHandler = new SimpleSectHandler(this); + sectHandler->startSimpleSect(attrib); + m_children.append(sectHandler); +} + +void ParagraphHandler::startRef(const QXmlAttributes& attrib) +{ + addTextNode(); + RefHandler *ref = new RefHandler(this); + ref->startRef(attrib); + m_children.append(ref); +} + +void ParagraphHandler::startVariableList(const QXmlAttributes& attrib) +{ + addTextNode(); + VariableListHandler *vl = new VariableListHandler(this); + vl->startVariableList(attrib); + m_children.append(vl); +} + +void ParagraphHandler::startHRuler(const QXmlAttributes& attrib) +{ + addTextNode(); + HRulerHandler *hr = new HRulerHandler(this); + hr->startHRuler(attrib); + m_children.append(hr); +} + +void ParagraphHandler::startLineBreak(const QXmlAttributes& attrib) +{ + addTextNode(); + LineBreakHandler *lb = new LineBreakHandler(this); + lb->startLineBreak(attrib); + m_children.append(lb); +} + +void ParagraphHandler::startULink(const QXmlAttributes& attrib) +{ + addTextNode(); + ULinkHandler *uh = new ULinkHandler(this); + uh->startULink(attrib); + m_children.append(uh); +} + +void ParagraphHandler::startEMail(const QXmlAttributes& attrib) +{ + addTextNode(); + EMailHandler *eh = new EMailHandler(this); + eh->startEMail(attrib); + m_children.append(eh); +} + +void ParagraphHandler::startLink(const QXmlAttributes& attrib) +{ + addTextNode(); + LinkHandler *lh = new LinkHandler(this); + lh->startLink(attrib); + m_children.append(lh); +} + +void ParagraphHandler::startProgramListing(const QXmlAttributes& attrib) +{ + addTextNode(); + ProgramListingHandler *pl = new ProgramListingHandler(this); + pl->startProgramListing(attrib); + m_children.append(pl); +} + +void ParagraphHandler::startFormula(const QXmlAttributes& attrib) +{ + addTextNode(); + FormulaHandler *fh = new FormulaHandler(this); + fh->startFormula(attrib); + m_children.append(fh); +} + +void ParagraphHandler::startImage(const QXmlAttributes& attrib) +{ + addTextNode(); + ImageHandler *ih = new ImageHandler(this); + ih->startImage(attrib); + m_children.append(ih); +} + +void ParagraphHandler::startDotFile(const QXmlAttributes& attrib) +{ + addTextNode(); + DotFileHandler *df = new DotFileHandler(this); + df->startDotFile(attrib); + m_children.append(df); +} + +void ParagraphHandler::startIndexEntry(const QXmlAttributes& attrib) +{ + addTextNode(); + IndexEntryHandler *df = new IndexEntryHandler(this); + df->startIndexEntry(attrib); + m_children.append(df); +} + +void ParagraphHandler::startTable(const QXmlAttributes& attrib) +{ + addTextNode(); + TableHandler *th = new TableHandler(this); + th->startTable(attrib); + m_children.append(th); +} + +void ParagraphHandler::startVerbatim(const QXmlAttributes& attrib) +{ + addTextNode(); + VerbatimHandler *vh = new VerbatimHandler(this); + vh->startVerbatim(attrib,IDocVerbatim::Verbatim); + m_children.append(vh); +} + +void ParagraphHandler::startHtmlOnly(const QXmlAttributes& attrib) +{ + addTextNode(); + VerbatimHandler *vh = new VerbatimHandler(this); + vh->startVerbatim(attrib,IDocVerbatim::HtmlOnly); + m_children.append(vh); +} + +void ParagraphHandler::startLatexOnly(const QXmlAttributes& attrib) +{ + addTextNode(); + VerbatimHandler *vh = new VerbatimHandler(this); + vh->startVerbatim(attrib,IDocVerbatim::LatexOnly); + m_children.append(vh); +} + +void ParagraphHandler::startUmlaut(const QXmlAttributes& attrib) +{ + addTextNode(); + SymbolHandler *sh = new SymbolHandler(this,IDocSymbol::Umlaut); + sh->startSymbol(attrib); + m_children.append(sh); +} + +void ParagraphHandler::startAcute(const QXmlAttributes& attrib) +{ + addTextNode(); + SymbolHandler *sh = new SymbolHandler(this,IDocSymbol::Acute); + sh->startSymbol(attrib); + m_children.append(sh); +} + +void ParagraphHandler::startGrave(const QXmlAttributes& attrib) +{ + addTextNode(); + SymbolHandler *sh = new SymbolHandler(this,IDocSymbol::Grave); + sh->startSymbol(attrib); + m_children.append(sh); +} + +void ParagraphHandler::startCirc(const QXmlAttributes& attrib) +{ + addTextNode(); + SymbolHandler *sh = new SymbolHandler(this,IDocSymbol::Circ); + sh->startSymbol(attrib); + m_children.append(sh); +} + +void ParagraphHandler::startTilde(const QXmlAttributes& attrib) +{ + addTextNode(); + SymbolHandler *sh = new SymbolHandler(this,IDocSymbol::Tilde); + sh->startSymbol(attrib); + m_children.append(sh); +} + +void ParagraphHandler::startSzlig(const QXmlAttributes& attrib) +{ + addTextNode(); + SymbolHandler *sh = new SymbolHandler(this,IDocSymbol::Szlig); + sh->startSymbol(attrib); + m_children.append(sh); +} + +void ParagraphHandler::startCedil(const QXmlAttributes& attrib) +{ + addTextNode(); + SymbolHandler *sh = new SymbolHandler(this,IDocSymbol::Cedil); + sh->startSymbol(attrib); + m_children.append(sh); +} + +void ParagraphHandler::startRing(const QXmlAttributes& attrib) +{ + addTextNode(); + SymbolHandler *sh = new SymbolHandler(this,IDocSymbol::Ring); + sh->startSymbol(attrib); + m_children.append(sh); +} + +void ParagraphHandler::startNbsp(const QXmlAttributes& attrib) +{ + addTextNode(); + SymbolHandler *sh = new SymbolHandler(this,IDocSymbol::Nbsp); + sh->startSymbol(attrib); + m_children.append(sh); +} + +void ParagraphHandler::startCopy(const QXmlAttributes& attrib) +{ + addTextNode(); + SymbolHandler *sh = new SymbolHandler(this,IDocSymbol::Copy); + sh->startSymbol(attrib); + m_children.append(sh); +} + +void ParagraphHandler::startAnchor(const QXmlAttributes& attrib) +{ + addTextNode(); + AnchorHandler *ah = new AnchorHandler(this); + ah->startAnchor(attrib); + m_children.append(ah); +} + +void ParagraphHandler::startCopyDoc(const QXmlAttributes& attrib) +{ + addTextNode(); + CopyHandler *ch = new CopyHandler(this); + ch->startCopy(attrib); + m_children.append(ch); +} + +void ParagraphHandler::startTocList(const QXmlAttributes& attrib) +{ + addTextNode(); + TocListHandler *th = new TocListHandler(this); + th->startTocList(attrib); + m_children.append(th); +} + +void ParagraphHandler::addTextNode() +{ + if (!m_curString.isEmpty()) + { + m_children.append( + new TextNode( + m_curString, + m_markupHandler->markup(), + m_markupHandler->headingLevel() + ) + ); + debug(2,"addTextNode() text=\"%s\" markup=%x headingLevel=%d\n", + m_curString.data(),m_markupHandler->markup(),m_markupHandler->headingLevel()); + m_curString=""; + } +} + +IDocIterator *ParagraphHandler::contents() const +{ + return new ParagraphIterator(*this); +} + +//---------------------------------------------------------------------- +// DocSectionHandler +//---------------------------------------------------------------------- + +DocSectionHandler::DocSectionHandler(IBaseHandler *parent,int level) + : m_parent(parent), m_internal(0), m_level(level), m_title(0) +{ + QString sectionKey; + m_paragraphs.setAutoDelete(TRUE); + m_subsections.setAutoDelete(TRUE); + addStartHandler("title",this,&DocSectionHandler::startTitle); + addStartHandler("para",this,&DocSectionHandler::startParagraph); + if (level<6) + { + sectionKey.sprintf("sect%d",level+1); + addStartHandler(sectionKey.utf8(),this,&DocSectionHandler::startSubSection); + } + addStartHandler("internal",this,&DocSectionHandler::startInternal); + sectionKey.sprintf("sect%d",level); + addEndHandler(sectionKey.utf8(),this,&DocSectionHandler::endDocSection); +} + +DocSectionHandler::~DocSectionHandler() +{ +} + +void DocSectionHandler::startDocSection(const QXmlAttributes& attrib) +{ + m_parent->setDelegate(this); + debug(2,"Start docsection\n"); + m_id = attrib.value("id"); +} + +void DocSectionHandler::endDocSection() +{ + m_parent->setDelegate(0); + debug(2,"End docsection\n"); +} + +void DocSectionHandler::startSubSection(const QXmlAttributes& attrib) +{ + DocSectionHandler *secHandler = new DocSectionHandler(this,m_level+1); + secHandler->startDocSection(attrib); + m_subsections.append(secHandler); +} + +void DocSectionHandler::startParagraph(const QXmlAttributes& attrib) +{ + ParagraphHandler *parHandler = new ParagraphHandler(this); + parHandler->startParagraph(attrib); + m_paragraphs.append(parHandler); +} + +void DocSectionHandler::startInternal(const QXmlAttributes& attrib) +{ + m_internal = new DocInternalHandler(this,m_level); + m_internal->startInternal(attrib); +} + +void DocSectionHandler::startTitle(const QXmlAttributes& attrib) +{ + m_title = new TitleHandler(this); + m_title->startTitle(attrib); +} + +IDocIterator *DocSectionHandler::paragraphs() const +{ + return new DocSectionParaIterator(*this); +} + +IDocIterator *DocSectionHandler::subSections() const +{ + return new DocSectionSubIterator(*this); +} + +IDocInternal *DocSectionHandler::internal() const +{ + return m_internal; +} + +//---------------------------------------------------------------------- +// DocInternal +//---------------------------------------------------------------------- + +DocInternalHandler::DocInternalHandler(IBaseHandler *parent,int level) + : m_parent(parent), m_level(level) +{ + m_paragraphs.setAutoDelete(TRUE); + m_subsections.setAutoDelete(TRUE); + addStartHandler("para",this,&DocInternalHandler::startParagraph); + QString sectionKey; + sectionKey.sprintf("sect%d",level+1); + addStartHandler(sectionKey.utf8(),this,&DocInternalHandler::startSubSection); + addEndHandler("internal",this,&DocInternalHandler::endInternal); +} + +DocInternalHandler::~DocInternalHandler() +{ +} + +void DocInternalHandler::startInternal(const QXmlAttributes&) +{ + m_parent->setDelegate(this); + debug(2,"Start internal\n"); +} + +void DocInternalHandler::endInternal() +{ + m_parent->setDelegate(0); + debug(2,"End internal\n"); +} + +void DocInternalHandler::startSubSection(const QXmlAttributes& attrib) +{ + DocSectionHandler *secHandler = new DocSectionHandler(this,m_level+1); + secHandler->startDocSection(attrib); + m_subsections.append(secHandler); +} + +void DocInternalHandler::startParagraph(const QXmlAttributes& attrib) +{ + ParagraphHandler *parHandler = new ParagraphHandler(this); + parHandler->startParagraph(attrib); + m_paragraphs.append(parHandler); +} + +IDocIterator *DocInternalHandler::paragraphs() const +{ + return new DocInternalParaIterator(*this); +} + +IDocIterator *DocInternalHandler::subSections() const +{ + return new DocInternalSubIterator(*this); +} + + +//---------------------------------------------------------------------- +// DocHandler +//---------------------------------------------------------------------- + +DocHandler::DocHandler(IBaseHandler *parent) : m_parent(parent) +{ + m_children.setAutoDelete(TRUE); + + addEndHandler("briefdescription",this,&DocHandler::endDoc); + addEndHandler("detaileddescription",this,&DocHandler::endDoc); + addEndHandler("inbodydescription",this,&DocHandler::endDoc); + //addEndHandler("internal"); // TODO: implement this as a section + addStartHandler("internal",this,&DocHandler::startInternal); + + addStartHandler("para",this,&DocHandler::startParagraph); + addStartHandler("sect1",this,&DocHandler::startSect1); + addStartHandler("title",this,&DocHandler::startTitle); + //addStartHandler("internal"); +} + +DocHandler::~DocHandler() +{ +} + +void DocHandler::startDoc(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + debug(2,"start dochandler\n"); +} + +void DocHandler::endDoc() +{ + debug(2,"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); +} + +void DocHandler::startSect1(const QXmlAttributes& attrib) +{ + DocSectionHandler *secHandler = new DocSectionHandler(this,1); + secHandler->startDocSection(attrib); + m_children.append(secHandler); +} + +void DocHandler::startTitle(const QXmlAttributes& attrib) +{ + TitleHandler *titleHandler = new TitleHandler(this); + titleHandler->startTitle(attrib); + m_children.append(titleHandler); +} + +void DocHandler::startInternal(const QXmlAttributes& attrib) +{ + m_internal = new DocInternalHandler(this,1); + m_internal->startInternal(attrib); +} + +IDocIterator *DocHandler::contents() const +{ + return new DocIterator(*this); +} + +IDocInternal *DocHandler::internal() const +{ + return m_internal; +} + diff --git a/addon/doxmlparser/src/dochandler.h b/addon/doxmlparser/src/dochandler.h new file mode 100644 index 0000000..b1466fe --- /dev/null +++ b/addon/doxmlparser/src/dochandler.h @@ -0,0 +1,1352 @@ +/****************************************************************************** + * + * $Id:$ + * + * + * Copyright (C) 1997-2012 by Dimitri van Heesch. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#ifndef _DOCHANDLER_H +#define _DOCHANDLER_H + +#include <qstring.h> +#include <qlist.h> +#include <qxml.h> + +#include <doxmlintf.h> +#include "stringimpl.h" +#include "basehandler.h" +#include "baseiterator.h" + +class ParagraphHandler; +class DocInternalHandler; +class LinkedTextImpl; +class LinkedTextHandler; + +//----------------------------------------------------------------------------- + +class DocImpl : public IDoc { public: virtual ~DocImpl() {} }; + +#define DEFINE_CLS_IMPL(cls) \ + class cls##Impl : public I##cls, public DocImpl { public: virtual ~cls##Impl() {} } + +DEFINE_CLS_IMPL(DocMarkup); +DEFINE_CLS_IMPL(DocPara); +DEFINE_CLS_IMPL(DocText); +DEFINE_CLS_IMPL(DocMarkupModifier); +DEFINE_CLS_IMPL(DocItemizedList); +DEFINE_CLS_IMPL(DocOrderedList); +DEFINE_CLS_IMPL(DocListItem); +DEFINE_CLS_IMPL(DocParameterList); +DEFINE_CLS_IMPL(DocParameterItem); +DEFINE_CLS_IMPL(DocParameter); +DEFINE_CLS_IMPL(DocTitle); +DEFINE_CLS_IMPL(DocSimpleSect); +DEFINE_CLS_IMPL(DocRef); +DEFINE_CLS_IMPL(DocVariableList); +DEFINE_CLS_IMPL(DocVariableListEntry); +DEFINE_CLS_IMPL(DocHRuler); +DEFINE_CLS_IMPL(DocLineBreak); +DEFINE_CLS_IMPL(DocULink); +DEFINE_CLS_IMPL(DocEMail); +DEFINE_CLS_IMPL(DocLink); +DEFINE_CLS_IMPL(DocProgramListing); +DEFINE_CLS_IMPL(DocCodeLine); +DEFINE_CLS_IMPL(DocHighlight); +DEFINE_CLS_IMPL(DocFormula); +DEFINE_CLS_IMPL(DocImage); +DEFINE_CLS_IMPL(DocDotFile); +DEFINE_CLS_IMPL(DocIndexEntry); +DEFINE_CLS_IMPL(DocTable); +DEFINE_CLS_IMPL(DocRow); +DEFINE_CLS_IMPL(DocEntry); +DEFINE_CLS_IMPL(DocSection); +DEFINE_CLS_IMPL(DocVerbatim); +DEFINE_CLS_IMPL(DocCopy); +DEFINE_CLS_IMPL(DocTocList); +DEFINE_CLS_IMPL(DocTocItem); +DEFINE_CLS_IMPL(DocAnchor); +DEFINE_CLS_IMPL(DocSymbol); +DEFINE_CLS_IMPL(DocInternal); +DEFINE_CLS_IMPL(DocRoot); + +//----------------------------------------------------------------------------- + + +/*! \brief Node representing a piece of text. + * + */ +class TextNode : public DocTextImpl +{ + public: + TextNode(const QString &t,int markup,int level) + : m_text(t), m_markup(markup), m_headingLevel(level) {} + virtual ~TextNode() {} + + // IDocText + virtual Kind kind() const { return DocImpl::Text; } + virtual const IString *text() const { return &m_text; } + virtual int markup() const { return m_markup; } + virtual int headingLevel() const { return m_headingLevel; } + + private: + StringImpl m_text; + int m_markup; + int m_headingLevel; +}; + +//----------------------------------------------------------------------------- + +/*! \brief Node representing a change in the markup style. + * + */ +class MarkupModifierNode : public DocMarkupModifierImpl +{ + public: + MarkupModifierNode(int markup,bool enabled,int level=0) + : m_markup(markup), m_enabled(enabled), m_headingLevel(level) {} + virtual ~MarkupModifierNode() {} + + // IDocMarkupModifier + virtual Kind kind() const { return DocImpl::MarkupModifier; } + virtual bool enabled() const { return m_enabled; } + virtual int markup() const { return m_markup; } + virtual int headingLevel() const { return m_headingLevel; } + + private: + int m_markup; + bool m_enabled; + int m_headingLevel; +}; + + +//----------------------------------------------------------------------------- + +/*! \brief Handles markup commands in the XML input. + * + */ +class MarkupHandler : public BaseFallBackHandler<MarkupHandler> +{ + public: + MarkupHandler(QList<DocImpl> &children,QString &curString); + virtual ~MarkupHandler(); + int markup() const { return m_curMarkup; } + int headingLevel() const { return m_headingLevel; } + + 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(); + virtual void startPreformatted(const QXmlAttributes &attrib); + virtual void endPreformatted(); + virtual void startHeading1(const QXmlAttributes &attrib); + virtual void endHeading1(); + virtual void startHeading2(const QXmlAttributes &attrib); + virtual void endHeading2(); + virtual void startHeading3(const QXmlAttributes &attrib); + virtual void endHeading3(); + virtual void startHeading4(const QXmlAttributes &attrib); + virtual void endHeading4(); + virtual void startHeading5(const QXmlAttributes &attrib); + virtual void endHeading5(); + virtual void startHeading6(const QXmlAttributes &attrib); + virtual void endHeading6(); + + + private: + void addTextNode(); + + QList<DocImpl> &m_children; + QString &m_curString; + int m_curMarkup; + int m_headingLevel; +}; + +//----------------------------------------------------------------------------- + +/*! \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 DocParaImpl, + 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); + virtual void startVerbatim(const QXmlAttributes& attrib); + virtual void startHtmlOnly(const QXmlAttributes& attrib); + virtual void startLatexOnly(const QXmlAttributes& attrib); + virtual void startUmlaut(const QXmlAttributes& attrib); + virtual void startAcute(const QXmlAttributes& attrib); + virtual void startGrave(const QXmlAttributes& attrib); + virtual void startCirc(const QXmlAttributes& attrib); + virtual void startTilde(const QXmlAttributes& attrib); + virtual void startSzlig(const QXmlAttributes& attrib); + virtual void startCedil(const QXmlAttributes& attrib); + virtual void startRing(const QXmlAttributes& attrib); + virtual void startNbsp(const QXmlAttributes& attrib); + virtual void startCopy(const QXmlAttributes& attrib); + virtual void startAnchor(const QXmlAttributes& attrib); + virtual void startCopyDoc(const QXmlAttributes& attrib); + virtual void startTocList(const QXmlAttributes& attrib); + + ParagraphHandler(IBaseHandler *parent); + virtual ~ParagraphHandler(); + + // IDocPara + virtual Kind kind() const { return DocImpl::Para; } + virtual IDocIterator *contents() const; + + private: + void addTextNode(); + IBaseHandler *m_parent; + QList<DocImpl> m_children; + MarkupHandler *m_markupHandler; +}; + +class ParagraphIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl> +{ + public: + ParagraphIterator(const ParagraphHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {} +}; + +//----------------------------------------------------------------------------- + +/*! \brief Node representing a list item. + * + */ +class ListItemHandler : public DocListItemImpl, public BaseHandler<ListItemHandler> +{ + friend class ListItemIterator; + public: + ListItemHandler(IBaseHandler *parent); + virtual ~ListItemHandler(); + virtual void startListItem(const QXmlAttributes& attrib); + virtual void endListItem(); + virtual void startParagraph(const QXmlAttributes& attrib); + + // IDocItem + virtual Kind kind() const { return DocImpl::ListItem; } + virtual IDocIterator *contents() const; + + private: + IBaseHandler *m_parent; + QList<DocImpl> m_children; +}; + +class ListItemIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl> +{ + public: + ListItemIterator(const ListItemHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {} +}; + + +//----------------------------------------------------------------------------- + +/*! \brief Node representing list of items. + * + */ +class OrderedListHandler : public DocOrderedListImpl, public BaseHandler<OrderedListHandler> +{ + friend class OrderedListIterator; + public: + OrderedListHandler(IBaseHandler *parent); + virtual ~OrderedListHandler(); + virtual void startOrderedList(const QXmlAttributes& attrib); + virtual void endOrderedList(); + virtual void startOrderedListItem(const QXmlAttributes& attrib); + + // IDocOrderedList + virtual Kind kind() const { return DocImpl::OrderedList; } + virtual IDocIterator *elements() const; + + private: + IBaseHandler *m_parent; + QList<DocImpl> m_children; +}; + +class OrderedListIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl> +{ + public: + OrderedListIterator(const OrderedListHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {} +}; + +//----------------------------------------------------------------------------- + +/*! \brief Node representing table of contents list. + * + */ +class TocListHandler : public DocTocListImpl, public BaseHandler<TocListHandler> +{ + friend class TocListIterator; + public: + TocListHandler(IBaseHandler *parent); + virtual ~TocListHandler(); + virtual void startTocList(const QXmlAttributes& attrib); + virtual void endTocList(); + virtual void startTocItem(const QXmlAttributes& attrib); + + // IDocTocList + virtual Kind kind() const { return DocImpl::TocList; } + virtual IDocIterator *elements() const; + + private: + IBaseHandler *m_parent; + QList<DocImpl> m_children; +}; + +class TocListIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl> +{ + public: + TocListIterator(const TocListHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {} +}; + +//----------------------------------------------------------------------------- + +/*! \brief Node representing a table of contents item. + * + */ +class TocItemHandler : public DocTocItemImpl, public BaseHandler<TocItemHandler> +{ + friend class TocItemIterator; + public: + TocItemHandler(IBaseHandler *parent); + virtual ~TocItemHandler(); + virtual void startTocItem(const QXmlAttributes& attrib); + virtual void endTocItem(); + + // IDocItem + virtual Kind kind() const { return DocImpl::TocItem; } + virtual const IString *id() const { return &m_id; } + virtual const IString *title() const { return &m_title; } + + private: + IBaseHandler *m_parent; + StringImpl m_id; + StringImpl m_title; +}; + +//----------------------------------------------------------------------------- + +/*! \brief Node representing list of items. + * + */ +class ItemizedListHandler : public DocItemizedListImpl, 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 DocImpl::ItemizedList; } + virtual IDocIterator *elements() const; + + private: + IBaseHandler *m_parent; + QList<DocImpl> m_children; +}; + +class ItemizedListIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl> +{ + public: + ItemizedListIterator(const ItemizedListHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {} +}; + + +//----------------------------------------------------------------------------- +/*! \brief Node representing a parameter. + * + */ +class ParameterHandler : public DocParameterImpl, + public BaseHandler<ParameterHandler> +{ + public: + ParameterHandler(IBaseHandler *parent); + virtual ~ParameterHandler(); + virtual void startParameterName(const QXmlAttributes& attrib); + virtual void endParameterName(); + + // IDocParameter + virtual Kind kind() const { return DocImpl::Parameter; } + virtual const IString *name() const { return &m_name; } + + private: + IBaseHandler *m_parent; + StringImpl m_name; +}; + +//----------------------------------------------------------------------------- + +/* \brief Node representing a list of param names with a single description. + * + */ +class ParameterItemHandler : public DocParameterItemImpl, + public BaseHandler<ParameterItemHandler> +{ + friend class ParameterItemIterator; + public: + ParameterItemHandler(IBaseHandler *parent); + virtual ~ParameterItemHandler(); + virtual void startParameterItem(const QXmlAttributes& attrib); + virtual void endParameterItem(); + virtual void startParameterName(const QXmlAttributes& attrib); + virtual void startParagraph(const QXmlAttributes& attrib); + + // IDocParameterItem + virtual Kind kind() const { return DocImpl::ParameterItem; } + virtual IDocIterator *paramNames() const; + virtual IDocPara *description() const { return m_description; } + + private: + IBaseHandler *m_parent; + QList<ParameterHandler> m_parameters; + ParagraphHandler *m_description; +}; + +class ParameterItemIterator : public BaseIteratorVia<IDocIterator,IDoc,ParameterHandler,DocImpl> +{ + public: + ParameterItemIterator(const ParameterItemHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,ParameterHandler,DocImpl>(handler.m_parameters) {} +}; + +//----------------------------------------------------------------------------- + +/* \brief Node representing a parameter section. + * + */ +class ParameterListHandler : public DocParameterListImpl, + public BaseHandler<ParameterListHandler> +{ + friend class ParameterListIterator; + public: + ParameterListHandler(IBaseHandler *parent); + virtual ~ParameterListHandler(); + virtual void startParameterList(const QXmlAttributes& attrib); + virtual void endParameterList(); + virtual void startParameterItem(const QXmlAttributes& attrib); + + // IDocParameterList + virtual Kind kind() const { return DocImpl::ParameterList; } + virtual Types sectType() const { return m_type; } + virtual IDocIterator *params() const; + + private: + IBaseHandler *m_parent; + QList<ParameterItemHandler> m_paramItems; + Types m_type; +}; + +class ParameterListIterator : public BaseIteratorVia<IDocIterator,IDoc,ParameterItemHandler,DocImpl> +{ + public: + ParameterListIterator(const ParameterListHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,ParameterItemHandler,DocImpl>(handler.m_paramItems) {} +}; + +//----------------------------------------------------------------------------- + +/* \brief Node representing a horizontal ruler + * + */ +class LineBreakHandler : public DocLineBreakImpl, public BaseHandler<LineBreakHandler> +{ + public: + LineBreakHandler(IBaseHandler *parent); + virtual ~LineBreakHandler(); + + void startLineBreak(const QXmlAttributes& attrib); + void endLineBreak(); + + // IDocLineBreak + virtual Kind kind() const { return DocImpl::LineBreak; } + + private: + IBaseHandler *m_parent; +}; + +//----------------------------------------------------------------------------- + +/* \brief Node representing a link to section + * + */ +class LinkHandler : public DocLinkImpl, public BaseHandler<LinkHandler> +{ + public: + LinkHandler(IBaseHandler *parent); + virtual ~LinkHandler(); + + void startLink(const QXmlAttributes& attrib); + void endLink(); + + // IDocLink + virtual Kind kind() const { return DocImpl::Link; } + virtual const IString *refId() const { return &m_ref; } + virtual const IString *text() const { return &m_text; } + + private: + IBaseHandler *m_parent; + StringImpl m_ref; + StringImpl m_text; +}; + + +//----------------------------------------------------------------------------- + +/* \brief Node representing a link to an email address + * + */ +class EMailHandler : public DocEMailImpl, public BaseHandler<EMailHandler> +{ + public: + EMailHandler(IBaseHandler *parent); + virtual ~EMailHandler(); + + void startEMail(const QXmlAttributes& attrib); + void endEMail(); + + // IDocEMail + virtual Kind kind() const { return DocImpl::EMail; } + virtual const IString *address() const { return &m_address; } + + private: + IBaseHandler *m_parent; + StringImpl m_address; +}; + + +//----------------------------------------------------------------------------- + +/* \brief Node representing a link to an URL + * + */ +class ULinkHandler : public DocULinkImpl, public BaseHandler<ULinkHandler> +{ + public: + ULinkHandler(IBaseHandler *parent); + virtual ~ULinkHandler(); + + void startULink(const QXmlAttributes& attrib); + void endULink(); + + // IDocULink + virtual Kind kind() const { return DocImpl::ULink; } + virtual const IString * url() const { return &m_url; } + virtual const IString * text() const { return &m_text; } + + private: + IBaseHandler *m_parent; + StringImpl m_url; + StringImpl m_text; +}; + +//----------------------------------------------------------------------------- + +/* \brief Node representing a horizontal ruler + * + */ +class HRulerHandler : public DocHRulerImpl, public BaseHandler<HRulerHandler> +{ + public: + HRulerHandler(IBaseHandler *parent); + virtual ~HRulerHandler(); + + void startHRuler(const QXmlAttributes& attrib); + void endHRuler(); + + // IDocHRuler + virtual Kind kind() const { return DocImpl::HRuler; } + + private: + IBaseHandler *m_parent; +}; + +//----------------------------------------------------------------------------- + +/* \brief Node representing a reference to another item + * + */ +class RefHandler : public DocRefImpl, public BaseHandler<RefHandler> +{ + public: + RefHandler(IBaseHandler *parent); + virtual ~RefHandler(); + void startRef(const QXmlAttributes& attrib); + void endRef(); + + // IDocRef + virtual Kind kind() const { return DocImpl::Ref; } + virtual const IString *refId() const { return &m_refId; } + virtual TargetKind targetKind() const { return m_targetKind; } + virtual const IString *external() const { return &m_extId; } + virtual const IString *text() const { return &m_linkText; } + + private: + IBaseHandler *m_parent; + StringImpl m_refId; + StringImpl m_extId; + StringImpl m_linkText; + TargetKind m_targetKind; +}; + +//----------------------------------------------------------------------------- + +/* \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 DocTitleImpl, public BaseHandler<TitleHandler> +{ + friend class TitleIterator; + public: + TitleHandler(IBaseHandler *parent); + virtual ~TitleHandler(); + virtual void startTitle(const QXmlAttributes& attrib); + virtual void endTitle(); + virtual void startRef(const QXmlAttributes& attrib); + void addTextNode(); + + // IDocTitle + virtual Kind kind() const { return DocImpl::Title; } + virtual IDocIterator *title() const; + + private: + IBaseHandler *m_parent; + QList<DocImpl> m_children; + MarkupHandler *m_markupHandler; +}; + +class TitleIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl> +{ + public: + TitleIterator(const TitleHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {} +}; + +//----------------------------------------------------------------------------- + +/* \brief Node representing a simple section with an unnumbered header. + * + */ +// children: title, para +class SimpleSectHandler : public DocSimpleSectImpl, + public BaseHandler<SimpleSectHandler> +{ + public: + SimpleSectHandler(IBaseHandler *parent); + virtual ~SimpleSectHandler(); + virtual void startSimpleSect(const QXmlAttributes& attrib); + virtual void endSimpleSect(); + virtual void startTitle(const QXmlAttributes& attrib); + virtual void startParagraph(const QXmlAttributes& attrib); + + // IDocSimpleSect + virtual Kind kind() const { return DocImpl::SimpleSect; } + virtual Types type() const { return m_type; } + virtual const IString *typeString() const { return &m_typeString; } + virtual IDocTitle *title() const { return m_title; } + virtual IDocPara *description() const { return m_paragraph; } + + private: + IBaseHandler *m_parent; + ParagraphHandler *m_paragraph; + Types m_type; + StringImpl m_typeString; + TitleHandler *m_title; +}; + +//----------------------------------------------------------------------------- + +/* \brief Node representing an named item of a VariableList. + * + */ +class VariableListEntryHandler : public DocVariableListEntryImpl, + public BaseHandler<VariableListEntryHandler> +{ + 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(); + + // IDocVariableListEntry + virtual Kind kind() const { return DocImpl::VariableListEntry; } + virtual ILinkedTextIterator *term() const; + virtual IDocPara *description() const { return m_description; } + + private: + IBaseHandler* m_parent; + QList<LinkedTextImpl> m_term; + ParagraphHandler* m_description; + LinkedTextHandler* m_linkedTextHandler; +}; + +//----------------------------------------------------------------------------- + +/*! \brief Node representing a list of named items. + * + */ +// children: varlistentry, listitem +class VariableListHandler : public DocVariableListImpl, + public BaseHandler<VariableListHandler> +{ + friend class VariableListIterator; + + 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(); + + // IDocVariableList + virtual Kind kind() const { return DocImpl::VariableList; } + virtual IDocIterator *entries() const; + + private: + IBaseHandler *m_parent; + QList<VariableListEntryHandler> m_entries; + VariableListEntryHandler *m_curEntry; +}; + +class VariableListIterator : public BaseIteratorVia<IDocIterator,IDoc,VariableListEntryHandler,DocImpl> +{ + public: + VariableListIterator(const VariableListHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,VariableListEntryHandler,DocImpl>(handler.m_entries) {} +}; + +//----------------------------------------------------------------------------- + +/*! \brief Node representing a highlighted text fragment. + * + */ +// children: ref +class HighlightHandler : public DocHighlightImpl, public BaseHandler<HighlightHandler> +{ + friend class HighlightIterator; + public: + HighlightHandler(IBaseHandler *parent); + virtual ~HighlightHandler(); + void startHighlight(const QXmlAttributes& attrib); + void endHighlight(); + virtual void startRef(const QXmlAttributes&); + virtual void startSpace(const QXmlAttributes&); + + // IDocHighlight + virtual Kind kind() const { return DocImpl::Highlight; } + virtual HighlightKind highlightKind() const { return m_hl; } + virtual IDocIterator *codeElements() const; + + private: + void addTextNode(); + + IBaseHandler *m_parent; + HighlightKind m_hl; + QString m_hlString; + QList<DocImpl> m_children; +}; + +class HighlightIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl> +{ + public: + HighlightIterator(const HighlightHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {} +}; + +//----------------------------------------------------------------------------- + +/*! \brief Node representing a line of code. + * + */ +// children: linenumber, highlight, anchor, ref +class CodeLineHandler : public DocCodeLineImpl, public BaseHandler<CodeLineHandler> +{ + friend class CodeLineIterator; + public: + + virtual void startCodeLine(const QXmlAttributes&); + virtual void endCodeLine(); + virtual void startLineNumber(const QXmlAttributes&); + virtual void endLineNumber(); + virtual void startHighlight(const QXmlAttributes&); + virtual void startRef(const QXmlAttributes&); + + CodeLineHandler(IBaseHandler *parent); + virtual ~CodeLineHandler(); + + // IDocCodeLine + virtual Kind kind() const { return DocImpl::CodeLine; } + virtual int lineNumber() const { return m_lineNumber; } + virtual const IString *refId() const { return &m_refId; } + virtual IDocIterator *codeElements() const; + + private: + void addTextNode(); + + IBaseHandler *m_parent; + int m_lineNumber; + StringImpl m_refId; + QList<DocImpl> m_children; +}; + +class CodeLineIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl> +{ + public: + CodeLineIterator(const CodeLineHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {} +}; + +//----------------------------------------------------------------------------- + +/*! \brief Node representing a program listing + * + */ +// children: codeline, linenumber +class ProgramListingHandler : public DocProgramListingImpl, public BaseHandler<ProgramListingHandler> +{ + friend class ProgramListingIterator; + public: + virtual void startProgramListing(const QXmlAttributes& attrib); + virtual void endProgramListing(); + virtual void startCodeLine(const QXmlAttributes&); + virtual void startLineNumber(const QXmlAttributes&); + + ProgramListingHandler(IBaseHandler *parent); + virtual ~ProgramListingHandler(); + + // IDocProgramListing + virtual Kind kind() const { return DocImpl::ProgramListing; } + virtual IDocIterator *codeLines() const; + + private: + IBaseHandler *m_parent; + QList<CodeLineHandler> m_children; + bool m_hasLineNumber; +}; + +//----------------------------------------------------------------------------- + +class ProgramListingIterator : public BaseIteratorVia<IDocIterator,IDoc,CodeLineHandler,DocImpl> +{ + public: + ProgramListingIterator(const ProgramListingHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,CodeLineHandler,DocImpl>(handler.m_children) {} +}; + +//----------------------------------------------------------------------------- + +/*! \brief Node representing a formula. + * + */ +// children: - +class FormulaHandler : public DocFormulaImpl, public BaseHandler<FormulaHandler> +{ + public: + FormulaHandler(IBaseHandler *parent); + virtual ~FormulaHandler(); + void startFormula(const QXmlAttributes& attrib); + void endFormula(); + + // IDocFormula + virtual Kind kind() const { return DocImpl::Formula; } + virtual const IString *id() const { return &m_id; } + virtual const IString *text() const { return &m_text; } + + private: + IBaseHandler *m_parent; + StringImpl m_id; + StringImpl m_text; +}; + +//----------------------------------------------------------------------------- + +/*! \brief Node representing an image. + * + */ +// children: - +class ImageHandler : public DocImageImpl, public BaseHandler<ImageHandler> +{ + public: + ImageHandler(IBaseHandler *parent); + virtual ~ImageHandler(); + void startImage(const QXmlAttributes& attrib); + void endImage(); + + // IDocImage + virtual Kind kind() const { return DocImpl::Image; } + virtual const IString *name() const { return &m_name; } + virtual const IString *caption() const { return &m_caption; } + + private: + IBaseHandler *m_parent; + StringImpl m_name; + StringImpl m_caption; +}; + + +//----------------------------------------------------------------------------- +/*! \brief Node representing an anchor. + * + */ +// children: - +class AnchorHandler : public DocAnchorImpl, public BaseHandler<AnchorHandler> +{ + public: + AnchorHandler(IBaseHandler *parent); + virtual ~AnchorHandler(); + void startAnchor(const QXmlAttributes& attrib); + void endAnchor(); + + // IDocAnchor + virtual Kind kind() const { return DocImpl::Anchor; } + virtual const IString *id() const { return &m_id; } + + private: + IBaseHandler *m_parent; + StringImpl m_id; +}; + +//----------------------------------------------------------------------------- + +/*! \brief Node representing a dot file. + * + */ +// children: - +class DotFileHandler : public DocDotFileImpl, public BaseHandler<DotFileHandler> +{ + public: + DotFileHandler(IBaseHandler *parent); + virtual ~DotFileHandler(); + void startDotFile(const QXmlAttributes& attrib); + void endDotFile(); + + // IDocDotFile + virtual Kind kind() const { return DocImpl::DotFile; } + virtual const IString *name() const { return &m_name; } + virtual const IString *caption() const { return &m_caption; } + + private: + IBaseHandler *m_parent; + StringImpl m_name; + StringImpl m_caption; +}; + +//----------------------------------------------------------------------------- + +/*! \brief Node representing an entry in the index. + * + */ +// children: - +class IndexEntryHandler : public DocIndexEntryImpl, public BaseHandler<IndexEntryHandler> +{ + public: + IndexEntryHandler(IBaseHandler *parent); + virtual ~IndexEntryHandler(); + void startIndexEntry(const QXmlAttributes& attrib); + void endIndexEntry(); + void startPrimaryIE(const QXmlAttributes& attrib); + void endPrimaryIE(); + void startSecondaryIE(const QXmlAttributes& attrib); + void endSecondaryIE(); + + // IDocIndexEntry + virtual Kind kind() const { return DocImpl::IndexEntry; } + virtual const IString *primary() const { return &m_primary; } + virtual const IString *secondary() const { return &m_secondary; } + + private: + IBaseHandler *m_parent; + StringImpl m_primary; + StringImpl m_secondary; +}; + +//----------------------------------------------------------------------------- + +/*! \brief Node representing an entry in the table entry. + * + */ +// children: para +class EntryHandler : public DocEntryImpl, public BaseHandler<EntryHandler> +{ + friend class EntryIterator; + public: + EntryHandler(IBaseHandler *parent); + virtual ~EntryHandler(); + void startEntry(const QXmlAttributes& attrib); + void endEntry(); + void startParagraph(const QXmlAttributes& attrib); + + // IDocEntry + virtual Kind kind() const { return DocImpl::Entry; } + virtual IDocIterator *contents() const; + + private: + IBaseHandler *m_parent; + QList<DocImpl> m_children; +}; + +class EntryIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl> +{ + public: + EntryIterator(const EntryHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {} +}; + +//----------------------------------------------------------------------------- + +/*! \brief Node representing an entry in the table row. + * + */ +// children: entry +class RowHandler : public DocRowImpl, public BaseHandler<RowHandler> +{ + friend class RowIterator; + public: + RowHandler(IBaseHandler *parent); + virtual ~RowHandler(); + void startRow(const QXmlAttributes& attrib); + void endRow(); + void startEntry(const QXmlAttributes& attrib); + + // IDocRow + virtual Kind kind() const { return DocImpl::Row; } + virtual IDocIterator *entries() const; + + private: + IBaseHandler *m_parent; + QList<EntryHandler> m_children; +}; + +class RowIterator : public BaseIteratorVia<IDocIterator,IDoc,EntryHandler,DocImpl> +{ + public: + RowIterator(const RowHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,EntryHandler,DocImpl>(handler.m_children) {} +}; + +//----------------------------------------------------------------------------- + +/*! \brief Node representing an entry in the table. + * + */ +// children: row, caption +class TableHandler : public DocTableImpl, public BaseHandler<TableHandler> +{ + friend class TableIterator; + public: + TableHandler(IBaseHandler *parent); + virtual ~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 DocImpl::Table; } + virtual IDocIterator *rows() const; + virtual int numColumns() const { return m_numColumns; } + virtual const IString *caption() const { return &m_caption; } + + private: + IBaseHandler *m_parent; + QList<RowHandler> m_children; + int m_numColumns; + StringImpl m_caption; +}; + +class TableIterator : public BaseIteratorVia<IDocIterator,IDoc,RowHandler,DocImpl> +{ + public: + TableIterator(const TableHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,RowHandler,DocImpl>(handler.m_children) {} +}; + +//----------------------------------------------------------------------------- + +/*! \brief Node representing a copied piece of documentation. + * + */ +class CopyHandler : public DocCopyImpl, public BaseHandler<CopyHandler> +{ + friend class CopyIterator; + public: + CopyHandler(IBaseHandler *parent); + virtual ~CopyHandler(); + virtual void startCopy(const QXmlAttributes& attrib); + virtual void endCopy(); + virtual void startParagraph(const QXmlAttributes& attrib); + + // IDocCopy + virtual Kind kind() const { return DocImpl::Copy; } + virtual IDocIterator *contents() const; + + private: + IBaseHandler *m_parent; + QList<DocImpl> m_children; +}; + +class CopyIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl> +{ + public: + CopyIterator(const CopyHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {} +}; + +//----------------------------------------------------------------------------- + +/*! \brief Node representing an preformatted section + */ +class VerbatimHandler : public DocVerbatimImpl, + public BaseHandler<VerbatimHandler> +{ + public: + VerbatimHandler(IBaseHandler *parent); + virtual ~VerbatimHandler(); + void startVerbatim(const QXmlAttributes& attrib,Types type); + void endVerbatim(); + + // IDocVerbatim + virtual Kind kind() const { return DocImpl::Verbatim; } + virtual const IString *text() const { return &m_text; } + virtual Types type() const { return m_type; } + + private: + IBaseHandler *m_parent; + StringImpl m_text; + Types m_type; +}; + + +//----------------------------------------------------------------------------- + +/*! \brief Node representing an special symbol. + * + */ +// children: - +class SymbolHandler : public DocSymbolImpl, public BaseHandler<SymbolHandler> +{ + public: + SymbolHandler(IBaseHandler *parent,Types type); + virtual ~SymbolHandler(); + void startSymbol(const QXmlAttributes& attrib); + void endSymbol(); + + // IDocSymbol + virtual Kind kind() const { return DocImpl::Symbol; } + virtual Types type() const { return m_type; } + virtual const IString *typeString() const { return &m_typeString; } + virtual char letter() const { return m_letter; } + + private: + IBaseHandler *m_parent; + char m_letter; + Types m_type; + StringImpl m_typeString; +}; + + +//----------------------------------------------------------------------------- + +/*! \brief Node representing a section. + * + */ +// children: title, para, sect(n+1) +class DocSectionHandler : public DocSectionImpl, public BaseHandler<DocSectionHandler> +{ + friend class DocSectionParaIterator; + friend class DocSectionSubIterator; + public: + DocSectionHandler(IBaseHandler *parent,int level); + virtual ~DocSectionHandler(); + virtual void startDocSection(const QXmlAttributes& attrib); + virtual void endDocSection(); + virtual void startTitle(const QXmlAttributes& attrib); + virtual void startSubSection(const QXmlAttributes& attrib); + virtual void startParagraph(const QXmlAttributes& attrib); + virtual void startInternal(const QXmlAttributes& attrib); + + // IDocSection + virtual Kind kind() const { return DocImpl::Section; } + virtual const IString *id() const { return &m_id; } + virtual int level() const { return m_level; } + virtual IDocTitle *title() const { return m_title; } + virtual IDocIterator *paragraphs() const; + virtual IDocIterator *subSections() const; + virtual IDocInternal *internal() const; + + private: + IBaseHandler *m_parent; + QList<DocImpl> m_paragraphs; + QList<DocImpl> m_subsections; + DocInternalHandler *m_internal; + StringImpl m_id; + int m_level; + TitleHandler *m_title; +}; + +class DocSectionParaIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl> +{ + public: + DocSectionParaIterator(const DocSectionHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_paragraphs) {} +}; + +class DocSectionSubIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl> +{ + public: + DocSectionSubIterator(const DocSectionHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_subsections) {} +}; + +//----------------------------------------------------------------------------- + +class DocInternalHandler : public DocInternalImpl, public BaseHandler<DocInternalHandler> +{ + public: + friend class DocInternalParaIterator; + friend class DocInternalSubIterator; + DocInternalHandler(IBaseHandler *parent,int level); + virtual ~DocInternalHandler(); + virtual void startInternal(const QXmlAttributes& attrib); + virtual void endInternal(); + virtual void startSubSection(const QXmlAttributes& attrib); + virtual void startParagraph(const QXmlAttributes& attrib); + + // IDocInternal + virtual Kind kind() const { return DocImpl::Internal; } + virtual IDocIterator *paragraphs() const; + virtual IDocIterator *subSections() const; + + private: + IBaseHandler *m_parent; + QList<DocImpl> m_paragraphs; + QList<DocImpl> m_subsections; + int m_level; +}; + +class DocInternalParaIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl> +{ + public: + DocInternalParaIterator(const DocInternalHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_paragraphs) {} +}; + +class DocInternalSubIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl> +{ + public: + DocInternalSubIterator(const DocInternalHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_subsections) {} +}; + + +//----------------------------------------------------------------------------- + +/*! \brief Node representing a documentation block. + * + */ +// children: para, title, sect1, internal +class DocHandler : public DocRootImpl, public BaseHandler<DocHandler> +{ + friend class DocIterator; + public: + virtual void startDoc(const QXmlAttributes& attrib); + virtual void endDoc(); + virtual void startParagraph(const QXmlAttributes& attrib); + virtual void startSect1(const QXmlAttributes& attrib); + virtual void startTitle(const QXmlAttributes& attrib); + virtual void startInternal(const QXmlAttributes& attrib); + + DocHandler(IBaseHandler *parent); + virtual ~DocHandler(); + + // IDocRoot + virtual Kind kind() const { return DocImpl::Root; } + virtual IDocIterator *contents() const; + virtual IDocInternal *internal() const; + + private: + IBaseHandler *m_parent; + QList<DocImpl> m_children; + DocInternalHandler *m_internal; +}; + +class DocIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl> +{ + public: + DocIterator(const DocHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {} +}; + +//----------------------------------------------------------------------------- + +void dochandler_init(); +void dochandler_exit(); + +#endif diff --git a/addon/doxmlparser/src/doxmlintf.h b/addon/doxmlparser/src/doxmlintf.h new file mode 120000 index 0000000..1b1e847 --- /dev/null +++ b/addon/doxmlparser/src/doxmlintf.h @@ -0,0 +1 @@ +../include/doxmlintf.h
\ No newline at end of file diff --git a/addon/doxmlparser/src/doxmlparser.pro b/addon/doxmlparser/src/doxmlparser.pro new file mode 100644 index 0000000..ea67b87 --- /dev/null +++ b/addon/doxmlparser/src/doxmlparser.pro @@ -0,0 +1,32 @@ +# +# This file was generated from doxmlparser.pro.in on Sat Aug 11 14:29:47 CEST 2012 +# + +TEMPLATE = lib.t +CONFIG = console staticlib warn_on debug +HEADERS = basehandler.h mainhandler.h \ + compoundhandler.h sectionhandler.h \ + memberhandler.h paramhandler.h \ + dochandler.h linkedtexthandler.h \ + debug.h graphhandler.h stringimpl.h \ + loamhandler.h +SOURCES = mainhandler.cpp \ + compoundhandler.cpp sectionhandler.cpp \ + memberhandler.cpp paramhandler.cpp \ + dochandler.cpp linkedtexthandler.cpp \ + basehandler.cpp debug.cpp graphhandler.cpp \ + loamhandler.cpp +unix:LIBS += -L../../../lib -lqtools +win32:INCLUDEPATH += . +win32-mingw:LIBS += -L../../../lib -lqtools +win32-msvc:LIBS += qtools.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 +DESTDIR = ../lib +OBJECTS_DIR = ../objects +TARGET = doxmlparser +INCLUDEPATH += ../../../qtools ../include + +TMAKE_MOC = /usr/bin/moc diff --git a/addon/doxmlparser/src/doxmlparser.pro.in b/addon/doxmlparser/src/doxmlparser.pro.in new file mode 100644 index 0000000..841a46c --- /dev/null +++ b/addon/doxmlparser/src/doxmlparser.pro.in @@ -0,0 +1,27 @@ +TEMPLATE = lib.t +CONFIG = console staticlib warn_on $extraopts +HEADERS = basehandler.h mainhandler.h \ + compoundhandler.h sectionhandler.h \ + memberhandler.h paramhandler.h \ + dochandler.h linkedtexthandler.h \ + debug.h graphhandler.h stringimpl.h \ + loamhandler.h +SOURCES = mainhandler.cpp \ + compoundhandler.cpp sectionhandler.cpp \ + memberhandler.cpp paramhandler.cpp \ + dochandler.cpp linkedtexthandler.cpp \ + basehandler.cpp debug.cpp graphhandler.cpp \ + loamhandler.cpp +unix:LIBS += -L../../../lib -lqtools +win32:INCLUDEPATH += . +win32-mingw:LIBS += -L../../../lib -lqtools +win32-msvc:LIBS += qtools.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 +DESTDIR = ../lib +OBJECTS_DIR = ../objects +TARGET = doxmlparser +INCLUDEPATH += ../../../qtools ../include + diff --git a/addon/doxmlparser/src/graphhandler.cpp b/addon/doxmlparser/src/graphhandler.cpp new file mode 100644 index 0000000..de30923 --- /dev/null +++ b/addon/doxmlparser/src/graphhandler.cpp @@ -0,0 +1,216 @@ +#include "graphhandler.h" + +class EdgeRelationMapper +{ + public: + EdgeRelationMapper() + { + m_map.insert("public-inheritance", IChildNode::PublicInheritance); + m_map.insert("protected-inheritance", IChildNode::ProtectedInheritance); + m_map.insert("private-inheritance", IChildNode::PrivateInheritance); + m_map.insert("usage", IChildNode::Usage); + m_map.insert("template-instance", IChildNode::TemplateInstance); + } + IChildNode::NodeRelation stringToNodeRelation(const QString &nrStr) + { + return m_map[nrStr]; + } + private: + QMap<QString,IChildNode::NodeRelation> m_map; +}; + +static EdgeRelationMapper *s_edgeRelationMapper; + +void graphhandler_init() +{ + s_edgeRelationMapper = new EdgeRelationMapper; +} + +void graphhandler_exit() +{ + delete s_edgeRelationMapper; +} + +//------------------------------------------------------------------------ + +GraphHandler::GraphHandler(IBaseHandler *parent,const char *endTag) + : m_parent(parent) +{ + addEndHandler(endTag,this,&GraphHandler::endGraph); + addStartHandler("node",this,&GraphHandler::startNode); + m_nodes.setAutoDelete(TRUE); + m_nodeDict = new QDict<NodeHandler>(1009); +} + +GraphHandler::~GraphHandler() +{ + delete m_nodeDict; +} + +void GraphHandler::startGraph(const QXmlAttributes &) +{ + debug(2,"startGraph\n"); + m_parent->setDelegate(this); +} + +void GraphHandler::endGraph() +{ + debug(2,"endGraph\n"); + m_parent->setDelegate(0); +} + +void GraphHandler::startNode(const QXmlAttributes &attrib) +{ + NodeHandler *n = new NodeHandler(this); + n->startNode(attrib); + m_nodes.append(n); + m_nodeDict->insert(attrib.value("id").utf8(),n); +} + +INodeIterator *GraphHandler::nodes() const +{ + return new NodeIterator(*this); +} + +NodeHandler *GraphHandler::getNodeById(const QString &id) const +{ + return m_nodeDict->find(id.utf8()); +} + +//------------------------------------------------------------------------ + +NodeHandler::NodeHandler(GraphHandler *gh) + : m_parent(gh), m_graph(gh) +{ + addEndHandler("node",this,&NodeHandler::endNode); + addStartHandler("link",this,&NodeHandler::startLink); + addEndHandler("link",this,&NodeHandler::endLink); + addStartHandler("label",this,&NodeHandler::startLabel); + addEndHandler("label",this,&NodeHandler::endLabel); + addStartHandler("childnode",this,&NodeHandler::startChildNode); + m_children.setAutoDelete(TRUE); +} + +NodeHandler::~NodeHandler() +{ +} + +void NodeHandler::startNode(const QXmlAttributes &attrib) +{ + debug(2,"startNode\n"); + m_parent->setDelegate(this); + m_id = attrib.value("id"); +} + +void NodeHandler::endNode() +{ + debug(2,"endNode\n"); + m_parent->setDelegate(0); +} + +void NodeHandler::startLink(const QXmlAttributes &attrib) +{ + m_link = attrib.value("refid"); +} + +void NodeHandler::endLink() +{ +} + +void NodeHandler::startLabel(const QXmlAttributes &/*attrib*/) +{ + m_curString=""; +} + +void NodeHandler::endLabel() +{ + m_label = m_curString; +} + +void NodeHandler::startChildNode(const QXmlAttributes &attrib) +{ + ChildNodeHandler *cnh = new ChildNodeHandler(this,m_graph); + cnh->startChildNode(attrib); + m_children.append(cnh); +} + +IChildNodeIterator *NodeHandler::children() const +{ + return new ChildNodeIterator(*this); +} + +//------------------------------------------------------------------------ + +ChildNodeHandler::ChildNodeHandler(IBaseHandler *parent,GraphHandler *gh) + : m_parent(parent), m_graph(gh) +{ + addEndHandler("childnode",this,&ChildNodeHandler::endChildNode); + addStartHandler("edgelabel",this,&ChildNodeHandler::startEdgeLabel); + m_edgeLabels.setAutoDelete(TRUE); +} + +ChildNodeHandler::~ChildNodeHandler() +{ +} + +void ChildNodeHandler::startChildNode(const QXmlAttributes &attrib) +{ + debug(2,"startChildNode\n"); + m_id = attrib.value("refid"); + m_relationString = attrib.value("relation"); + m_relation = s_edgeRelationMapper->stringToNodeRelation(m_relationString); + m_parent->setDelegate(this); +} + +void ChildNodeHandler::endChildNode() +{ + debug(2,"endChildNode\n"); + m_parent->setDelegate(0); +} + + +void ChildNodeHandler::startEdgeLabel(const QXmlAttributes &attrib) +{ + EdgeLabelHandler *elh = new EdgeLabelHandler(this); + elh->startEdgeLabel(attrib); + m_edgeLabels.append(elh); +} + +IEdgeLabelIterator *ChildNodeHandler::edgeLabels() const +{ + return new EdgeLabelIterator(*this); +} + +INode *ChildNodeHandler::node() const +{ + return m_graph->getNodeById(m_id); +} + +//----------------------------------------------------------------------- + +EdgeLabelHandler::EdgeLabelHandler(IBaseHandler *parent) + : m_parent(parent) +{ + addEndHandler("edgelabel",this,&EdgeLabelHandler::endEdgeLabel); +} + +EdgeLabelHandler::~EdgeLabelHandler() +{ +} + +void EdgeLabelHandler::startEdgeLabel(const QXmlAttributes &) +{ + m_parent->setDelegate(this); + m_curString=""; +} + +void EdgeLabelHandler::endEdgeLabel() +{ + m_label=m_curString; + m_parent->setDelegate(0); +} + + + + + diff --git a/addon/doxmlparser/src/graphhandler.h b/addon/doxmlparser/src/graphhandler.h new file mode 100644 index 0000000..e121992 --- /dev/null +++ b/addon/doxmlparser/src/graphhandler.h @@ -0,0 +1,154 @@ +/****************************************************************************** + * + * $Id:$ + * + * + * Copyright (C) 1997-2012 by Dimitri van Heesch. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#ifndef _GRAPHHANDLER_H +#define _GRAPHHANDLER_H + +#include "stringimpl.h" +#include "doxmlintf.h" +#include "basehandler.h" +#include "baseiterator.h" + +class NodeHandler; +class ChildNodeHandler; +class EdgeLabelHandler; + +class GraphHandler : public IGraph, public BaseHandler<GraphHandler> +{ + friend class NodeIterator; + public: + GraphHandler(IBaseHandler *parent,const char *endTag); + virtual ~GraphHandler(); + + void startGraph(const QXmlAttributes &attrib); + void endGraph(); + void startNode(const QXmlAttributes &attrib); + NodeHandler *getNodeById(const QString &id) const; + + // IGraph + virtual INodeIterator *nodes() const; + + private: + IBaseHandler *m_parent; + QList<NodeHandler> m_nodes; + QDict<NodeHandler> *m_nodeDict; +}; + +//---------------------------------------------------------------------- + +class NodeHandler : public INode, public BaseHandler<NodeHandler> +{ + friend class ChildNodeIterator; + public: + NodeHandler(GraphHandler *gh); + virtual ~NodeHandler(); + + void startNode(const QXmlAttributes &attrib); + void endNode(); + void startLabel(const QXmlAttributes &attrib); + void endLabel(); + void startLink(const QXmlAttributes &attrib); + void endLink(); + void startChildNode(const QXmlAttributes &attrib); + + // INode + virtual const IString *id() const { return &m_id; } + virtual const IString *label() const { return &m_label; } + virtual const IString *linkId() const { return &m_link; } + virtual IChildNodeIterator *children() const; + + private: + IBaseHandler *m_parent; + StringImpl m_id; + StringImpl m_label; + StringImpl m_link; + QList<ChildNodeHandler> m_children; + GraphHandler *m_graph; +}; + +class NodeIterator : public BaseIterator<INodeIterator,INode,NodeHandler> +{ + public: + NodeIterator(const GraphHandler &handler) : + BaseIterator<INodeIterator,INode,NodeHandler>(handler.m_nodes) {} +}; + +//---------------------------------------------------------------------- + +class ChildNodeHandler : public IChildNode, public BaseHandler<ChildNodeHandler> +{ + friend class EdgeLabelIterator; + public: + ChildNodeHandler(IBaseHandler *parent,GraphHandler *gh); + virtual ~ChildNodeHandler(); + + void startChildNode(const QXmlAttributes &attrib); + void endChildNode(); + void startEdgeLabel(const QXmlAttributes &attrib); + + // IChildNode + virtual INode *node() const; + virtual NodeRelation relation() const { return m_relation; } + virtual const IString * relationString() const { return &m_relationString; } + virtual IEdgeLabelIterator *edgeLabels() const; + + private: + IBaseHandler *m_parent; + QString m_id; + NodeRelation m_relation; + StringImpl m_relationString; + QList<EdgeLabelHandler> m_edgeLabels; + GraphHandler *m_graph; +}; + +class ChildNodeIterator : public BaseIterator<IChildNodeIterator,IChildNode,ChildNodeHandler> +{ + public: + ChildNodeIterator(const NodeHandler &handler) : + BaseIterator<IChildNodeIterator,IChildNode,ChildNodeHandler>(handler.m_children) {} +}; + +//---------------------------------------------------------------------- + +class EdgeLabelHandler : public IEdgeLabel, public BaseHandler<EdgeLabelHandler> +{ + friend class EdgeLabelIterator; + public: + EdgeLabelHandler(IBaseHandler *parent); + virtual ~EdgeLabelHandler(); + + void startEdgeLabel(const QXmlAttributes &attrib); + void endEdgeLabel(); + + // IEdgeLabel + virtual const IString *label() const { return &m_label; } + + private: + IBaseHandler *m_parent; + StringImpl m_label; +}; + +class EdgeLabelIterator : public BaseIterator<IEdgeLabelIterator,IEdgeLabel,EdgeLabelHandler> +{ + public: + EdgeLabelIterator(const ChildNodeHandler &handler) : + BaseIterator<IEdgeLabelIterator,IEdgeLabel,EdgeLabelHandler>(handler.m_edgeLabels) {} +}; + +void graphhandler_init(); +void graphhandler_exit(); + +#endif + diff --git a/addon/doxmlparser/src/linkedtexthandler.cpp b/addon/doxmlparser/src/linkedtexthandler.cpp new file mode 100644 index 0000000..433465a --- /dev/null +++ b/addon/doxmlparser/src/linkedtexthandler.cpp @@ -0,0 +1,133 @@ +/****************************************************************************** + * + * $Id: doxygen.cpp,v 1.87 2001/03/19 19:27:40 root Exp $ + * + * + * Copyright (C) 1997-2012 by Dimitri van Heesch. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ +#include "linkedtexthandler.h" +#include "debug.h" +#include <doxmlintf.h> +#include "stringimpl.h" + +class LT_Text : public LinkedTextImpl, public ILT_Text +{ + public: + LT_Text(const QString &text) : m_text(text) {} + virtual ~LT_Text() {} + + // ILT_Text + virtual const IString *text() const { return &m_text; } + virtual Kind kind() const { return LinkedTextImpl::Kind_Text; } + private: + StringImpl m_text; +}; + +class LT_Ref : public LinkedTextImpl, public ILT_Ref +{ + public: + LT_Ref() {} + virtual ~LT_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 const IString *text() const { return &m_text; } + virtual const IString * id() const { return &m_refId; } + virtual TargetKind targetKind() const { return m_targetKind; } + virtual const IString *external() const { return &m_extId; } + virtual Kind kind() const { return LinkedTextImpl::Kind_Ref; } + + private: + StringImpl m_refId; + StringImpl m_extId; + StringImpl m_text; + TargetKind m_targetKind; +}; + +LinkedTextHandler::LinkedTextHandler(IBaseHandler *parent, + QList<LinkedTextImpl> &children + ) + : m_parent(parent), m_children(children) +{ + addStartHandler("ref",this,&LinkedTextHandler::startRef); + addEndHandler("ref",this,&LinkedTextHandler::endRef); + m_children.setAutoDelete(TRUE); + m_ref=0; +} + +LinkedTextHandler::~LinkedTextHandler() +{ +} + +void LinkedTextHandler::start(const char *endTag) +{ + addEndHandler(endTag,this,&LinkedTextHandler::end); + m_parent->setDelegate(this); + m_curString=""; +} + +void LinkedTextHandler::end() +{ + if (!m_curString.isEmpty()) + { + m_children.append(new LT_Text(m_curString)); + debug(2,"LinkedTextHandler: add text `%s'\n",m_curString.data()); + m_curString=""; + } + m_parent->setDelegate(0); +} + +void LinkedTextHandler::startRef(const QXmlAttributes& attrib) +{ + if (!m_curString.isEmpty()) + { + m_children.append(new LT_Text(m_curString)); + debug(2,"LinkedTextHandler: add text `%s'\n",m_curString.data()); + m_curString=""; + } + ASSERT(m_ref==0); + m_ref = new LT_Ref; + 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" ? ILT_Ref::Compound : ILT_Ref::Member); +} + +void LinkedTextHandler::endRef() +{ + m_ref->setText(m_curString); + m_children.append(m_ref); + debug(2,"LinkedTextHandler: add ref `%s'\n",m_ref->text()->latin1()); + m_ref=0; +} + +QString LinkedTextHandler::toString(const QList<LinkedTextImpl> &list) +{ + QListIterator<LinkedTextImpl> li(list); + QString result; + LinkedTextImpl *lt; + for (li.toFirst();(lt=li.current());++li) + { + switch(lt->kind()) + { + case ILinkedText::Kind_Text: + result+=dynamic_cast<ILT_Text*>(lt)->text()->latin1(); + break; + case ILinkedText::Kind_Ref: + result+=dynamic_cast<ILT_Ref *>(lt)->text()->latin1(); + break; + } + } + return result; +} + diff --git a/addon/doxmlparser/src/linkedtexthandler.h b/addon/doxmlparser/src/linkedtexthandler.h new file mode 100644 index 0000000..fbc4108 --- /dev/null +++ b/addon/doxmlparser/src/linkedtexthandler.h @@ -0,0 +1,54 @@ +/****************************************************************************** + * + * $Id: doxygen.cpp,v 1.87 2001/03/19 19:27:40 root Exp $ + * + * + * Copyright (C) 1997-2012 by Dimitri van Heesch. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ +#ifndef LINKEDTEXTHANDLER_H +#define LINKEDTEXTHANDLER_H + +#include "baseiterator.h" +#include "basehandler.h" + +class LT_Ref; +class LinkedTextImpl : public ILinkedText +{ + public: + virtual ~LinkedTextImpl() {} +}; + +class LinkedTextHandler : public BaseHandler<LinkedTextHandler> +{ + public: + LinkedTextHandler(IBaseHandler *parent,QList<LinkedTextImpl> &children); + virtual ~LinkedTextHandler(); + virtual void start(const char *endTag); + virtual void end(); + virtual void startRef(const QXmlAttributes& attrib); + virtual void endRef(); + static QString toString(const QList<LinkedTextImpl> &list); + + // ILinkedText + + private: + IBaseHandler *m_parent; + QList<LinkedTextImpl> &m_children; + LT_Ref *m_ref; +}; + +class LinkedTextIterator : public BaseIterator<ILinkedTextIterator,ILinkedText,LinkedTextImpl> +{ + public: + LinkedTextIterator(const QList<LinkedTextImpl> &list) : + BaseIterator<ILinkedTextIterator,ILinkedText,LinkedTextImpl>(list) {} +}; + +#endif diff --git a/addon/doxmlparser/src/loamhandler.cpp b/addon/doxmlparser/src/loamhandler.cpp new file mode 100644 index 0000000..a939b7b --- /dev/null +++ b/addon/doxmlparser/src/loamhandler.cpp @@ -0,0 +1,75 @@ +#include "loamhandler.h" +#include "memberhandler.h" + + +ListOfAllMembersHandler::ListOfAllMembersHandler(IBaseHandler *parent) : m_parent(parent) +{ + m_members.setAutoDelete(TRUE); + + addStartHandler("member",this,&ListOfAllMembersHandler::startMember); + addStartHandler("name",this,&ListOfAllMembersHandler::startName); + addEndHandler("name",this,&ListOfAllMembersHandler::endName); + addStartHandler("scope",this,&ListOfAllMembersHandler::startScope); + addEndHandler("scope",this,&ListOfAllMembersHandler::endScope); + + addEndHandler("listofallmembers",this,&ListOfAllMembersHandler::endListOfAllMembers); +} + +void ListOfAllMembersHandler::initialize(MainHandler *mh) +{ + QListIterator<MemberReference> mli(m_members); + MemberReference *mr; + for (;(mr=mli.current());++mli) + { + mr->initialize(mh); + } +} + +void ListOfAllMembersHandler::startMember(const QXmlAttributes& attrib) +{ + MemberReference *mr = new MemberReference; + mr->m_memId = attrib.value("refid"); + mr->m_virtualness = attrib.value("virt"); + mr->m_protection = attrib.value("prot"); + mr->m_ambiguityScope = attrib.value("ambiguityscope"); + m_members.append(new MemberReference); +} + +void ListOfAllMembersHandler::startName(const QXmlAttributes&) +{ + m_curString=""; +} + +void ListOfAllMembersHandler::endName() +{ + ASSERT(m_members.getLast()); + m_members.getLast()->m_name = m_curString; +} + +void ListOfAllMembersHandler::startScope(const QXmlAttributes&) +{ + m_curString=""; +} + +void ListOfAllMembersHandler::endScope() +{ + ASSERT(m_members.getLast()); + m_members.getLast()->m_scope = m_curString; +} + +void ListOfAllMembersHandler::startListOfAllMembers(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + debug(2,"listofallmembers start\n"); +} + +void ListOfAllMembersHandler::endListOfAllMembers() +{ + m_parent->setDelegate(0); + debug(2,"listofallmembers end\n"); +} + +IMemberReferenceIterator *ListOfAllMembersHandler::members() const +{ + return new MemberReferenceIterator(m_members); +} diff --git a/addon/doxmlparser/src/loamhandler.h b/addon/doxmlparser/src/loamhandler.h new file mode 100644 index 0000000..fce948a --- /dev/null +++ b/addon/doxmlparser/src/loamhandler.h @@ -0,0 +1,52 @@ +/****************************************************************************** + * + * $Id:$ + * + * + * Copyright (C) 1997-2012 by Dimitri van Heesch. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#ifndef _LOAMHANDLER_H +#define _LOAMHANDLER_H + +#include <qstring.h> +#include <qlist.h> +#include <doxmlintf.h> + +#include "basehandler.h" + +class MainHandler; +class MemberReference; + +class ListOfAllMembersHandler : public BaseHandler<ListOfAllMembersHandler> +{ + public: + virtual void startMember(const QXmlAttributes& attrib); + virtual void startName(const QXmlAttributes& attrib); + virtual void endName(); + virtual void startScope(const QXmlAttributes& attrib); + virtual void endScope(); + virtual void startListOfAllMembers(const QXmlAttributes& attrib); + virtual void endListOfAllMembers(); + + ListOfAllMembersHandler(IBaseHandler *parent); + virtual ~ListOfAllMembersHandler() {} + + void initialize(MainHandler *mh); + + virtual IMemberReferenceIterator *members() const; + + protected: + IBaseHandler *m_parent; + QList<MemberReference> m_members; +}; + +#endif + diff --git a/addon/doxmlparser/src/mainhandler.cpp b/addon/doxmlparser/src/mainhandler.cpp new file mode 100644 index 0000000..333da6e --- /dev/null +++ b/addon/doxmlparser/src/mainhandler.cpp @@ -0,0 +1,299 @@ +/****************************************************************************** + * + * $Id: $ + * + * + * Copyright (C) 1997-2012 by Dimitri van Heesch. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#include <qxml.h> +#include "mainhandler.h" +#include "compoundhandler.h" +#include "sectionhandler.h" +#include "graphhandler.h" +#include "dochandler.h" +#include "memberhandler.h" +#include "debug.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 ) + { + debug(1,"Fatal error at line %d column %d: %s\n", + exception.lineNumber(),exception.columnNumber(), + exception.message().data()); + return FALSE; + } + QString errorString() { return ""; } + + private: + QString errorMsg; +}; + +//-------------------------------------------------------------------------- + +class CompoundEntryIterator : public ICompoundIterator, + public QListIterator<CompoundEntry> +{ + public: + CompoundEntryIterator(const MainHandler *m,const QList<CompoundEntry> &list) : + QListIterator<CompoundEntry>(list), m_mainHandler(m) {} + virtual ~CompoundEntryIterator() {} + + virtual void toFirst() + { + QListIterator<CompoundEntry>::toFirst(); + } + virtual void toLast() + { + QListIterator<CompoundEntry>::toLast(); + } + virtual void toNext() + { + QListIterator<CompoundEntry>::operator++(); + } + virtual void toPrev() + { + QListIterator<CompoundEntry>::operator--(); + } + virtual ICompound *current() const + { + CompoundEntry *ch = QListIterator<CompoundEntry>::current(); + return ch ? m_mainHandler->compoundById(ch->id.utf8()) : 0; + } + virtual void release() + { delete this; } + + private: + const MainHandler *m_mainHandler; +}; + +//-------------------------------------------------------------------------- + +MainHandler::MainHandler() : m_compoundDict(2999), m_compoundNameDict(2999), + m_memberDict(12251), m_memberNameDict(12251), + m_compoundsLoaded(1009) +{ + m_compounds.setAutoDelete(TRUE); + m_memberNameDict.setAutoDelete(TRUE); + addStartHandler("doxygenindex"); + addEndHandler("doxygenindex"); + addStartHandler("compound",this,&MainHandler::startCompound); + addEndHandler("compound"); + addStartHandler("member",this,&MainHandler::startMember); + addEndHandler("member",this,&MainHandler::endMember); + addStartHandler("name",this,&MainHandler::startName); + addEndHandler("name",this,&MainHandler::endName); + m_curCompound = 0; + m_insideMember = FALSE; +} + +MainHandler::~MainHandler() +{ + debug(2,"MainHandler::~MainHandler()\n"); +} + +void MainHandler::startCompound(const QXmlAttributes& attrib) +{ + m_curCompound = new CompoundEntry(257); + m_curCompound->id = attrib.value("refid"); + m_compounds.append(m_curCompound); + m_compoundDict.insert(m_curCompound->id.utf8(),m_curCompound); +} + +void MainHandler::startName(const QXmlAttributes& /*attrib*/) +{ + m_curString = ""; +} + +void MainHandler::endName() +{ + if (m_insideMember) + { + m_curMember->name = m_curString; + } + else + { + m_curCompound->name = m_curString; + m_compoundNameDict.insert(m_curString.utf8(),m_curCompound); + } +} + +void MainHandler::startMember(const QXmlAttributes& attrib) +{ + m_insideMember = TRUE; + m_curMember = new MemberEntry; + m_curMember->id = attrib.value("refid"); + m_curMember->compound = m_curCompound; + m_memberDict.insert(m_curMember->id.utf8(),m_curMember); +} + +void MainHandler::endMember() +{ + m_curCompound->memberDict.insert(m_curMember->name.utf8(),m_curMember); + QList<CompoundEntry> *cel=0; + if ((cel=m_memberNameDict.find(m_curMember->name.utf8()))==0) + { + cel = new QList<CompoundEntry>; + m_memberNameDict.insert(m_curMember->name.utf8(),cel); + } + cel->append(m_curCompound); + m_insideMember = FALSE; +} + +void MainHandler::setDebugLevel(int level) +{ + ::setDebugLevel(level); +} + +void MainHandler::dump() +{ + QListIterator<CompoundEntry> cli(m_compounds); + CompoundEntry *ce; + for (cli.toFirst();(ce=cli.current());++cli) + { + debug(2,"compound id=`%s' name=`%s'\n",ce->id.data(),ce->name.data()); + QDictIterator<MemberEntry> mdi(ce->memberDict); + MemberEntry *me; + for (mdi.toFirst();(me=mdi.current());++mdi) + { + debug(2," member id=`%s' name=`%s'\n",me->id.data(),me->name.data()); + } + } +} + +bool MainHandler::readXMLDir(const char * xmlDirName) +{ + m_xmlDirName = xmlDirName; + QString xmlFileName=m_xmlDirName+"/index.xml"; + QFile xmlFile(xmlFileName); + //printf("Trying %s xmlFile.exists()=%d isReadable()=%d\n", + // xmlFileName.data(),xmlFile.exists(),xmlFile.isReadable()); + if (xmlFile.exists()) + { + ErrorHandler errorHandler; + QXmlInputSource source( xmlFile ); + QXmlSimpleReader reader; + reader.setContentHandler( this ); + reader.setErrorHandler( &errorHandler ); + reader.parse( source ); + dump(); + return TRUE; + } + return FALSE; +} + +ICompoundIterator *MainHandler::compounds() const +{ + return new CompoundEntryIterator(this,m_compounds); +} + +ICompound *MainHandler::compoundById(const char *id) const +{ + QString ids = id; + if (ids.isEmpty()) return 0; + CompoundHandler *ch = m_compoundsLoaded[ids.utf8()]; + if (ch) // compound already in memory + { + ch->addref(); // returning alias -> increase reference counter + return ch->toICompound(); + } + CompoundEntry *ce = m_compoundDict.find(ids.utf8()); + if (ce==0) return 0; // id not found + // create and load a new compound + ch = new CompoundHandler(m_xmlDirName); + if (!ch->parseXML(id)) + { + // compound could not be initialized. + delete ch; + return 0; + } + + // we disregard the constness here, because the object stays conceptually + // unchanged. + MainHandler *that = (MainHandler *)this; + ch->initialize(that); + //printf("loading compound %s in memory\n",id); + that->m_compoundsLoaded.insert(id,ch); + return ch->toICompound(); +} + +void MainHandler::unloadCompound(CompoundHandler *ch) +{ + //printf("unloading compound %s from memory\n",ch->id()->latin1()); + bool result = m_compoundsLoaded.remove(ch->id()->latin1()); + if (!result) debug(1,"Failed to unload component!\n"); +} + +ICompound *MainHandler::compoundByName(const char *name) const +{ + QString nameStr = name; + if (nameStr.isEmpty()) return 0; + CompoundEntry *ce = m_compoundNameDict[name]; + if (ce==0) return 0; // name not found + return compoundById(ce->id.utf8()); +} + +ICompound *MainHandler::memberById(const char *id) const +{ + QString ids = id; + if (ids.isEmpty()) return 0; + MemberEntry *me = m_memberDict[id]; + if (me==0) return 0; // id not found + return compoundById(me->compound->id.utf8()); +} + +ICompoundIterator *MainHandler::memberByName(const char *name) const +{ + QString nameStr = name; + if (nameStr.isEmpty()) return 0; + QList<CompoundEntry> *cel = m_memberNameDict[name]; + if (cel==0) return 0; // name not found + return new CompoundEntryIterator(this,*cel); +} + +IDoxygen *createObjectModel() +{ + compoundhandler_init(); + sectionhandler_init(); + memberhandler_init(); + dochandler_init(); + graphhandler_init(); + return new MainHandler; +} + +void MainHandler::release() +{ + //printf("MainHandler::release()\n"); + QDictIterator<CompoundHandler> chi(m_compoundsLoaded); + CompoundHandler *ch; + for (chi.toFirst();(ch=chi.current());++chi) + { + debug(1,"Compound %s not released\n",ch->name()->latin1()); + } + graphhandler_exit(); + dochandler_exit(); + memberhandler_exit(); + sectionhandler_exit(); + compoundhandler_exit(); + delete this; +} + diff --git a/addon/doxmlparser/src/mainhandler.h b/addon/doxmlparser/src/mainhandler.h new file mode 100644 index 0000000..5abc3ce --- /dev/null +++ b/addon/doxmlparser/src/mainhandler.h @@ -0,0 +1,82 @@ +/****************************************************************************** + * + * $Id:$ + * + * + * Copyright (C) 1997-2012 by Dimitri van Heesch. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#ifndef _MAINHANDLER_H +#define _MAINHANDLER_H + +#include <qlist.h> + +#include <doxmlintf.h> +#include "basehandler.h" + +class CompoundHandler; +struct CompoundEntry; + +struct IndexEntry +{ + QString id; + QString name; +}; + +struct MemberEntry : public IndexEntry +{ + CompoundEntry *compound; +}; + +struct CompoundEntry : public IndexEntry +{ + CompoundEntry(int size) : memberDict(size) + { memberDict.setAutoDelete(TRUE); } + QDict<MemberEntry> memberDict; +}; + +class MainHandler : public IDoxygen, public BaseHandler<MainHandler> +{ + public: + virtual void startCompound(const QXmlAttributes& attrib); + virtual void startMember(const QXmlAttributes& attrib); + virtual void endMember(); + virtual void startName(const QXmlAttributes& attrib); + virtual void endName(); + MainHandler(); + virtual ~MainHandler(); + + // IDoxygen + ICompoundIterator *compounds() const; + ICompound *compoundById(const char *id) const; + virtual ICompound *compoundByName(const char *name) const; + virtual ICompound *memberById(const char *id) const; + virtual ICompoundIterator *memberByName(const char *name) const; + + virtual void release(); + void setDebugLevel(int level); + bool readXMLDir(const char *dirName); + void dump(); + void unloadCompound(CompoundHandler *ch); + + private: + CompoundEntry *m_curCompound; + MemberEntry *m_curMember; + QList<CompoundEntry> m_compounds; + QDict<CompoundEntry> m_compoundDict; + QDict<CompoundEntry> m_compoundNameDict; + QDict<MemberEntry> m_memberDict; + QDict<QList<CompoundEntry> > m_memberNameDict; + QString m_xmlDirName; + QDict<CompoundHandler> m_compoundsLoaded; + bool m_insideMember; +}; + +#endif diff --git a/addon/doxmlparser/src/memberhandler.cpp b/addon/doxmlparser/src/memberhandler.cpp new file mode 100644 index 0000000..e7dd4f1 --- /dev/null +++ b/addon/doxmlparser/src/memberhandler.cpp @@ -0,0 +1,600 @@ +/****************************************************************************** + * + * $Id: $ + * + * + * Copyright (C) 1997-2012 by Dimitri van Heesch. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#include "memberhandler.h" +#include "sectionhandler.h" +#include "dochandler.h" +#include "mainhandler.h" +#include "linkedtexthandler.h" +#include "paramhandler.h" +#include "compoundhandler.h" +#include "debug.h" + +//------------------------------------------------------------------------------ + +class MemberTypeMap +{ + public: + MemberTypeMap() + { + m_map.setAutoDelete(TRUE); + m_map.insert("define",new int(IMember::Define)); + m_map.insert("property",new int(IMember::Property)); + m_map.insert("variable",new int(IMember::Variable)); + m_map.insert("typedef",new int(IMember::Typedef)); + m_map.insert("enum",new int(IMember::Enum)); + m_map.insert("function",new int(IMember::Function)); + m_map.insert("signal",new int(IMember::Signal)); + m_map.insert("prototype",new int(IMember::Prototype)); + m_map.insert("friend",new int(IMember::Friend)); + m_map.insert("dcop",new int(IMember::DCOP)); + m_map.insert("slot",new int(IMember::Slot)); + m_map.insert("enumvalue",new int(IMember::EnumValue)); + } + IMember::MemberKind map(const QString &s) + { + int *val = m_map.find(s.utf8()); + if (val==0) + { + debug(1,"Warning: `%s' is an invalid member type\n",s.data()); + return IMember::Invalid; + } + else return (IMember::MemberKind)*val; + } + private: + QDict<int> m_map; +}; + +static MemberTypeMap *s_typeMap; + +void memberhandler_init() +{ + s_typeMap = new MemberTypeMap; +} + +void memberhandler_exit() +{ + delete s_typeMap; +} + +//------------------------------------------------------------------------------ + +void MemberReference::initialize(MainHandler *mh) +{ + m_mainHandler = mh; +} + +IMember *MemberReference::member() const +{ + //return m_mainHandler->memberById(m_memId); + return 0; +} + +//------------------------------------------------------------------------------ + + +#if 0 +EnumValueHandler::EnumValueHandler(IBaseHandler *parent) : + m_parent(parent), m_brief(0), m_detailed(0), m_linkedTextHandler(0) +{ + addEndHandler("enumvalue",this,&EnumValueHandler::endEnumValue); + + addStartHandler("name",this,&EnumValueHandler::startName); + addEndHandler("name",this,&EnumValueHandler::endName); + addStartHandler("initializer",this,&EnumValueHandler::startInitializer); + + addStartHandler("briefdescription",this,&EnumValueHandler::startBriefDesc); + + addStartHandler("detaileddescription",this,&EnumValueHandler::startDetailedDesc); + + m_initializer.setAutoDelete(TRUE); +} + +EnumValueHandler::~EnumValueHandler() +{ + delete m_brief; + delete m_detailed; + delete m_linkedTextHandler; +} + +void EnumValueHandler::startEnumValue(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); +} + +void EnumValueHandler::endEnumValue() +{ + m_parent->setDelegate(0); +} + +void EnumValueHandler::startName(const QXmlAttributes& /*attrib*/) +{ + m_curString=""; +} + +void EnumValueHandler::endName() +{ + m_name = m_curString; +} + +void EnumValueHandler::startInitializer(const QXmlAttributes& /*attrib*/) +{ + delete m_linkedTextHandler; + m_linkedTextHandler = new LinkedTextHandler(this,m_initializer); + m_linkedTextHandler->start("initializer"); +} + +void EnumValueHandler::startBriefDesc(const QXmlAttributes& attrib) +{ + DocHandler *docHandler = new DocHandler(this); + docHandler->startDoc(attrib); + m_brief = docHandler; +} + +void EnumValueHandler::startDetailedDesc(const QXmlAttributes& attrib) +{ + DocHandler *docHandler = new DocHandler(this); + docHandler->startDoc(attrib); + m_detailed = docHandler; +} +#endif + +//------------------------------------------------------------------------------ + +MemberHandler::MemberHandler(IBaseHandler *parent) + : m_brief(0), m_detailed(0), m_inbody(0), + m_compound(0), m_section(0), m_parent(parent) +{ + //printf("MemberHandler::MemberHandler() %p\n",this); + addEndHandler("memberdef",this,&MemberHandler::endMember); + + addStartHandler("templateparamlist",this,&MemberHandler::startTemplateParamList); + addEndHandler("templateparamlist",this,&MemberHandler::endTemplateParamList); + + addStartHandler("type",this,&MemberHandler::startType); + + addStartHandler("definition",this,&MemberHandler::startDefinition); + addEndHandler("definition",this,&MemberHandler::endDefinition); + + addStartHandler("argsstring",this,&MemberHandler::startArgsString); + addEndHandler("argsstring",this,&MemberHandler::endArgsString); + + addStartHandler("name",this,&MemberHandler::startName); + addEndHandler("name",this,&MemberHandler::endName); + + addStartHandler("read",this,&MemberHandler::startRead); + addEndHandler("read",this,&MemberHandler::endRead); + + addStartHandler("write",this,&MemberHandler::startWrite); + addEndHandler("write",this,&MemberHandler::endWrite); + + addStartHandler("reimplements",this,&MemberHandler::startReimplements); + addEndHandler("reimplements",this,&MemberHandler::endReimplements); + + addStartHandler("reimplementedby",this,&MemberHandler::startReimplementedBy); + addEndHandler("reimplementedby",this,&MemberHandler::endReimplementedBy); + + addStartHandler("param",this,&MemberHandler::startParam); + + addStartHandler("enumvalue",this,&MemberHandler::startEnumValue2); + addEndHandler("enumvalue",this,&MemberHandler::endMember); + + addStartHandler("initializer",this,&MemberHandler::startInitializer); + addStartHandler("exceptions",this,&MemberHandler::startException); + + addStartHandler("briefdescription",this,&MemberHandler::startBriefDesc); + + addStartHandler("detaileddescription",this,&MemberHandler::startDetailedDesc); + + addStartHandler("inbodydescription",this,&MemberHandler::startInbodyDesc); + + addStartHandler("location",this,&MemberHandler::startLocation); + addEndHandler("location"); + + addStartHandler("references",this,&MemberHandler::startReferences); + addEndHandler("references",this,&MemberHandler::endReferences); + + addStartHandler("referencedby",this,&MemberHandler::startReferencedBy); + addEndHandler("referencedby",this,&MemberHandler::endReferencedBy); + + m_type.setAutoDelete(TRUE); + m_initializer.setAutoDelete(TRUE); + m_exception.setAutoDelete(TRUE); + m_params.setAutoDelete(TRUE); + m_references.setAutoDelete(TRUE); + m_referencedBy.setAutoDelete(TRUE); + m_reimplements = 0; + m_reimplementedBy.setAutoDelete(TRUE); + m_enumValues.setAutoDelete(TRUE); + m_linkedTextHandler = 0; + m_defLine=0; + m_bodyStart=0; + m_bodyEnd=0; + m_insideTemplateParamList=FALSE; + m_hasTemplateParamList=FALSE; +} + +MemberHandler::~MemberHandler() +{ + debug(2,"MemberHandler::~MemberHandler() %p\n",this); + delete m_brief; + delete m_detailed; + delete m_inbody; + delete m_linkedTextHandler; + delete m_reimplements; +} + +void MemberHandler::startMember(const QXmlAttributes& attrib) +{ + m_parent->setDelegate(this); + m_kindString = attrib.value("kind"); + //printf("startMember kindString=`%s'\n",m_kindString.data()); + m_kind = s_typeMap->map(m_kindString); + m_id = attrib.value("id"); + m_protection = attrib.value("prot"); + m_isStatic = attrib.value("static")=="yes"; + m_isConst = attrib.value("const")=="yes"; + m_isExplicit = attrib.value("explicit")=="yes"; + m_isInline = attrib.value("inline")=="yes"; + m_virtualness = attrib.value("virt"); + m_isVolatile = attrib.value("volatile")=="yes"; + m_isMutable = attrib.value("mutable")=="yes"; + m_isReadable = attrib.value("readable")=="yes"; + m_isWritable = attrib.value("writable")=="yes"; + + debug(2,"member kind=`%s' id=`%s' prot=`%s' virt=`%s'\n", + m_kindString.data(),m_id.data(),m_protection.data(),m_virtualness.data()); +} + +void MemberHandler::startEnumValue(const QXmlAttributes& attrib) +{ + m_parent->setDelegate(this); + m_kindString = "enumvalue"; + //printf("startEnumValue kindString=`%s'\n",m_kindString.data()); + m_kind = s_typeMap->map(m_kindString); + m_id = attrib.value("id"); + m_protection = attrib.value("prot"); + m_isStatic = FALSE; + m_isConst = FALSE; + m_isExplicit = FALSE; + m_isInline = FALSE; + m_virtualness = "non-virtual"; + m_isVolatile = FALSE; + m_isMutable = FALSE; + m_isReadable = FALSE; + m_isWritable = FALSE; + debug(2,"member kind=`%s' id=`%s' prot=`%s' virt=`%s'\n", + m_kindString.data(),m_id.data(),m_protection.data(),m_virtualness.data()); +} + +void MemberHandler::startEnumValue2(const QXmlAttributes& attrib) +{ + MemberHandler *mh = new MemberHandler(this); + mh->startEnumValue(attrib); + m_enumValues.append(mh); +} + + +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::startInbodyDesc(const QXmlAttributes& attrib) +{ + DocHandler *docHandler = new DocHandler(this); + docHandler->startDoc(attrib); + m_inbody = docHandler; +} + +void MemberHandler::startLocation(const QXmlAttributes& attrib) +{ + m_defFile = attrib.value("file"); + m_bodyFile = attrib.value("bodyfile"); + QString s; + s = attrib.value("line"); + if (!s.isEmpty()) m_defLine=s.toInt(); + s = attrib.value("bodystart"); + if (!s.isEmpty()) m_bodyStart=s.toInt(); + s = attrib.value("bodyend"); + if (!s.isEmpty()) m_bodyEnd=s.toInt(); +} + +void MemberHandler::startReferences(const QXmlAttributes& attrib) +{ + MemberReference *mr = new MemberReference; + mr->m_memId = attrib.value("refid"); + m_references.append(mr); + m_curString=""; +} + +void MemberHandler::endReferences() +{ + m_references.getLast()->m_name = m_curString; +} + +void MemberHandler::startReferencedBy(const QXmlAttributes& attrib) +{ + MemberReference *mr = new MemberReference; + mr->m_memId = attrib.value("refid"); + m_referencedBy.append(mr); + m_curString=""; +} + +void MemberHandler::endReferencedBy() +{ + m_referencedBy.getLast()->m_name = m_curString; +} + +void MemberHandler::startReimplements(const QXmlAttributes& attrib) +{ + m_reimplements = new MemberReference; + m_reimplements->m_memId = attrib.value("refid"); + m_curString=""; +} + +void MemberHandler::endReimplements() +{ + m_reimplements->m_name = m_curString; +} + +void MemberHandler::startReimplementedBy(const QXmlAttributes& attrib) +{ + MemberReference *mr = new MemberReference; + mr->m_memId = attrib.value("refid"); + m_reimplementedBy.append(mr); + m_curString=""; +} + +void MemberHandler::endReimplementedBy() +{ + m_reimplementedBy.getLast()->m_name = m_curString; +} + +void MemberHandler::endMember() +{ + m_parent->setDelegate(0); +} + +void MemberHandler::startType(const QXmlAttributes &) +{ + debug(2,"startType!\n"); + delete m_linkedTextHandler; + m_linkedTextHandler = new LinkedTextHandler(this,m_type); + m_linkedTextHandler->start("type"); +} + +void MemberHandler::startInitializer(const QXmlAttributes &) +{ + debug(2,"startInitializer!\n"); + delete m_linkedTextHandler; + m_linkedTextHandler = new LinkedTextHandler(this,m_initializer); + m_linkedTextHandler->start("initializer"); +} + +void MemberHandler::startException(const QXmlAttributes &) +{ + debug(2,"startException!\n"); + delete m_linkedTextHandler; + m_linkedTextHandler = new LinkedTextHandler(this,m_exception); + m_linkedTextHandler->start("exceptions"); +} + +void MemberHandler::startName(const QXmlAttributes &) +{ + m_curString=""; +} + +void MemberHandler::endName() +{ + m_name = m_curString.stripWhiteSpace(); + debug(2,"member name=`%s'\n",m_name.data()); +} + +void MemberHandler::startRead(const QXmlAttributes &) +{ + m_curString=""; +} + +void MemberHandler::endRead() +{ + m_read = m_curString.stripWhiteSpace(); + debug(2,"member read=`%s'\n",m_read.data()); +} + +void MemberHandler::startWrite(const QXmlAttributes &) +{ + m_curString=""; +} + +void MemberHandler::endWrite() +{ + m_write = m_curString.stripWhiteSpace(); + debug(2,"member write=`%s'\n",m_write.data()); +} + +void MemberHandler::startDefinition(const QXmlAttributes&) +{ + m_curString=""; +} + +void MemberHandler::endDefinition() +{ + m_definition = m_curString.stripWhiteSpace(); + debug(2,"definition=%s\n",m_definition.data()); +} + +void MemberHandler::startArgsString(const QXmlAttributes&) +{ + m_curString=""; +} + +void MemberHandler::endArgsString() +{ + m_argsstring = m_curString.stripWhiteSpace(); + debug(2,"arggstring=%s\n",m_argsstring.data()); +} + +void MemberHandler::startParam(const QXmlAttributes& attrib) +{ + ParamHandler *paramHandler = new ParamHandler(this); + paramHandler->startParam(attrib); + if (m_insideTemplateParamList) + { + m_templateParams.append(paramHandler); + } + else + { + m_params.append(paramHandler); + } +} + +void MemberHandler::startTemplateParamList(const QXmlAttributes&) +{ + m_insideTemplateParamList = TRUE; + m_hasTemplateParamList = TRUE; +} + +void MemberHandler::endTemplateParamList() +{ + m_insideTemplateParamList = FALSE; +} + +void MemberHandler::initialize(MainHandler *mh) +{ + { + QListIterator<MemberReference> mli(m_references); + MemberReference *mr; + for (;(mr=mli.current());++mli) + { + mr->initialize(mh); + } + } + { + QListIterator<MemberReference> mli(m_referencedBy); + MemberReference *mr; + for (;(mr=mli.current());++mli) + { + mr->initialize(mh); + } + } + { + QListIterator<MemberReference> mli(m_reimplementedBy); + MemberReference *mr; + for (;(mr=mli.current());++mli) + { + mr->initialize(mh); + } + } + if (m_reimplements) m_reimplements->initialize(mh); +} + +void MemberHandler::setCompoundHandler(CompoundHandler *c) +{ + m_compound = c; +} + +ICompound *MemberHandler::compound() const +{ + m_compound->addref(); + return m_compound->toICompound(); +} + +void MemberHandler::setSectionHandler(SectionHandler *c) +{ + m_section = c; +} + +ISection *MemberHandler::section() const +{ + return m_section; +} + +IMemberIterator *MemberHandler::enumValues() const +{ + return new MemberIterator(m_enumValues); +} + +ILinkedTextIterator *MemberHandler::type() const +{ + return new LinkedTextIterator(m_type); +} + +const IString *MemberHandler::typeString() const +{ + MemberHandler *that = (MemberHandler *)this; + that->m_typeString = LinkedTextHandler::toString(m_type); + return &m_typeString; +} + +IParamIterator *MemberHandler::parameters() const +{ + return new ParamIterator(m_params); +} + +IParamIterator *MemberHandler::templateParameters() const +{ + return m_hasTemplateParamList ? new ParamIterator(m_templateParams) : 0; +} + +IMemberReferenceIterator *MemberHandler::references() const +{ + return new MemberReferenceIterator(m_references); +} + +IMemberReferenceIterator *MemberHandler::referencedBy() const +{ + return new MemberReferenceIterator(m_referencedBy); +} + +ILinkedTextIterator *MemberHandler::initializer() const +{ + return new LinkedTextIterator(m_initializer); +} + +ILinkedTextIterator *MemberHandler::exceptions() const +{ + return new LinkedTextIterator(m_exception); +} + +IMemberReferenceIterator *MemberHandler::reimplementedBy() const +{ + return new MemberReferenceIterator(m_reimplementedBy); +} + +IDocRoot *MemberHandler::briefDescription() const +{ + return m_brief; +} + +IDocRoot *MemberHandler::detailedDescription() const +{ + return m_detailed; +} + +IDocRoot *MemberHandler::inbodyDescription() const +{ + return m_inbody; +} + diff --git a/addon/doxmlparser/src/memberhandler.h b/addon/doxmlparser/src/memberhandler.h new file mode 100644 index 0000000..9dbd280 --- /dev/null +++ b/addon/doxmlparser/src/memberhandler.h @@ -0,0 +1,252 @@ +/****************************************************************************** + * + * $Id:$ + * + * + * Copyright (C) 1997-2012 by Dimitri van Heesch. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#ifndef _MEMBERHANDLER_H +#define _MEMBERHANDLER_H + +#include <qstring.h> +#include <qlist.h> +#include <qxml.h> +#include <doxmlintf.h> + +#include "basehandler.h" +#include "baseiterator.h" +#include "stringimpl.h" + +class MainHandler; +class CompoundHandler; +class SectionHandler; +class ParamHandler; +class LinkedTextImpl; +class LinkedTextHandler; +class DocHandler; + +class MemberReference : public IMemberReference +{ + public: + virtual ~MemberReference() {} + virtual IMember *member() const; + virtual const IString *name() const { return &m_name; } + virtual const IString *scope() const { return &m_scope; } + virtual const IString *protection() const { return &m_protection; } + virtual const IString *virtualness() const { return &m_virtualness; } + virtual const IString *ambiguityScope() const { return &m_ambiguityScope; } + void initialize(MainHandler *m); + + QString m_memId; + StringImpl m_name; + StringImpl m_scope; + StringImpl m_virtualness; + StringImpl m_protection; + StringImpl m_ambiguityScope; + MainHandler *m_mainHandler; +}; + +class MemberReferenceIterator : public BaseIterator<IMemberReferenceIterator,IMemberReference,MemberReference> +{ + public: + MemberReferenceIterator(const QList<MemberReference> &list) : + BaseIterator<IMemberReferenceIterator,IMemberReference,MemberReference>(list) {} +}; + +class MemberHandler : public IDefine, + public IProperty, + public IVariable, + public ITypedef, + public IFunction, + public ISignal, + public IPrototype, + public IFriend, + public IDCOP, + public ISlot, + public IEnum, + public IEnumValue, + public BaseHandler<MemberHandler> +{ + public: + virtual void startMember(const QXmlAttributes& attrib); + virtual void endMember(); + virtual void startParam(const QXmlAttributes& attrib); + virtual void startType(const QXmlAttributes& attrib); + virtual void startName(const QXmlAttributes& attrib); + virtual void endName(); + virtual void startRead(const QXmlAttributes& attrib); + virtual void endRead(); + virtual void startWrite(const QXmlAttributes& attrib); + virtual void endWrite(); + virtual void startDefinition(const QXmlAttributes& attrib); + virtual void endDefinition(); + virtual void startArgsString(const QXmlAttributes& attrib); + virtual void endArgsString(); + virtual void startBriefDesc(const QXmlAttributes& attrib); + virtual void startDetailedDesc(const QXmlAttributes& attrib); + virtual void startInbodyDesc(const QXmlAttributes& attrib); + virtual void startLocation(const QXmlAttributes& attrib); + virtual void startReferences(const QXmlAttributes& attrib); + virtual void endReferences(); + virtual void startReferencedBy(const QXmlAttributes& attrib); + virtual void endReferencedBy(); + virtual void startReimplements(const QXmlAttributes& attrib); + virtual void endReimplements(); + virtual void startReimplementedBy(const QXmlAttributes& attrib); + virtual void endReimplementedBy(); + virtual void startInitializer(const QXmlAttributes& attrib); + virtual void startException(const QXmlAttributes& attrib); + virtual void startEnumValue(const QXmlAttributes& attrib); + virtual void startEnumValue2(const QXmlAttributes& attrib); + virtual void startTemplateParamList(const QXmlAttributes &attrib); + virtual void endTemplateParamList(); + + MemberHandler(IBaseHandler *parent); + virtual ~MemberHandler(); + + // IMember implementation + virtual ICompound *compound() const; + virtual ISection *section() const; + virtual MemberKind kind() const + { return m_kind; } + virtual const IString *kindString() const + { return &m_kindString; } + virtual const IString *id() const + { return &m_id; } + virtual const IString *protection() const + { return &m_protection; } + virtual const IString *virtualness() const + { return &m_virtualness; } + virtual const IString *name() const + { return &m_name; } + virtual const IString *readAccessor() const + { return &m_read; } + virtual const IString *writeAccessor() const + { return &m_write; } + virtual const IString *definition() const + { return &m_definition; } + virtual const IString *argsstring() const + { return &m_argsstring; } + virtual bool isConst() const + { return m_isConst; } + virtual bool isVolatile() const + { return m_isVolatile; } + virtual bool isStatic() const + { return m_isStatic; } + virtual bool isExplicit() const + { return m_isExplicit; } + virtual bool isInline() const + { return m_isInline; } + virtual bool isMutable() const + { return m_isMutable; } + virtual bool isReadable() const + { return m_isReadable; } + virtual bool isWritable() const + { return m_isWritable; } + virtual ILinkedTextIterator *type() const; + virtual const IString *typeString() const; + virtual IParamIterator *parameters() const; + virtual IParamIterator *templateParameters() const; + virtual IMemberReferenceIterator *references() const; + virtual IMemberReferenceIterator *referencedBy() const; + virtual ILinkedTextIterator *initializer() const; + virtual ILinkedTextIterator *exceptions() const; + virtual const IString *bodyFile() const + { return &m_bodyFile; } + virtual int bodyStart() const + { return m_bodyStart; } + virtual int bodyEnd() const + { return m_bodyEnd; } + virtual const IString *definitionFile() const + { return &m_defFile; } + virtual int definitionLine() const + { return m_defLine; } + virtual IMemberReference *reimplements() const + { return m_reimplements; } + virtual IMemberReferenceIterator *reimplementedBy() const; + virtual IDocRoot *briefDescription() const; + virtual IDocRoot *detailedDescription() const; + virtual IDocRoot *inbodyDescription() const; + + // IEnum + virtual IMemberIterator *enumValues() const; + + void initialize(MainHandler *m); + void setCompoundHandler(CompoundHandler *c); + void setSectionHandler(SectionHandler *s); + + private: + // XML elements: + // ----------------- + QList<ParamHandler> m_templateParams; // templateparamlist + QList<LinkedTextImpl> m_type; // type + StringImpl m_definition; // definition + StringImpl m_argsstring; // argsstring + StringImpl m_name; // name + StringImpl m_read; // read + StringImpl m_write; // write + MemberReference *m_reimplements; // reimplements + QList<MemberReference> m_reimplementedBy; // reimplementedby + QList<ParamHandler> m_params; // param + QList<MemberHandler> m_enumValues; // enumvalue + QList<LinkedTextImpl> m_initializer; // initializer + QList<LinkedTextImpl> m_exception; // exceptions + DocHandler *m_brief; // briefdescription + DocHandler *m_detailed; // detaileddescription + DocHandler *m_inbody; // inbodydescription + // location + StringImpl m_defFile; // - file + int m_defLine; // - line + StringImpl m_bodyFile; // - bodyfile + int m_bodyStart; // - bodystart + int m_bodyEnd; // - bodyend + QList<MemberReference> m_references; // references + QList<MemberReference> m_referencedBy; // referencedby + + // XML attributes: + // --------------- + MemberKind m_kind; // kind + StringImpl m_kindString; // kind as a string + StringImpl m_id; // id + StringImpl m_protection; // prot + bool m_isStatic; // static + bool m_isConst; // const + bool m_isExplicit; // explicit + bool m_isInline; // inline + StringImpl m_virtualness; // virt + bool m_isVolatile; // volatile + bool m_isMutable; // mutable + bool m_isReadable; // readable + bool m_isWritable; // writable + + CompoundHandler *m_compound; + SectionHandler *m_section; + StringImpl m_typeString; + LinkedTextHandler *m_linkedTextHandler; + bool m_insideTemplateParamList; + bool m_hasTemplateParamList; + IBaseHandler *m_parent; +}; + +class MemberIterator : public BaseIteratorVia<IMemberIterator, + IMember, + MemberHandler, + IFunction> +{ + public: + MemberIterator(const QList<MemberHandler> &list) : + BaseIteratorVia<IMemberIterator,IMember,MemberHandler,IFunction>(list) {} +}; + +void memberhandler_init(); +void memberhandler_exit(); + +#endif diff --git a/addon/doxmlparser/src/paramhandler.cpp b/addon/doxmlparser/src/paramhandler.cpp new file mode 100644 index 0000000..50b0be1 --- /dev/null +++ b/addon/doxmlparser/src/paramhandler.cpp @@ -0,0 +1,158 @@ +/****************************************************************************** + * + * $Id: $ + * + * + * Copyright (C) 1997-2012 by Dimitri van Heesch. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#include "paramhandler.h" +#include "memberhandler.h" +#include "linkedtexthandler.h" +#include "debug.h" +#include "dochandler.h" + +TemplateParamListHandler::TemplateParamListHandler(IBaseHandler *parent) : m_parent(parent) +{ + addStartHandler("param",this,&TemplateParamListHandler::startParam); + + addEndHandler("templateparamlist",this,&TemplateParamListHandler::endTemplateParamList); +} + +void TemplateParamListHandler::startParam(const QXmlAttributes& attrib) +{ + ParamHandler *ph = new ParamHandler(this); + ph->startParam(attrib); + m_templateParams.append(ph); +} + +void TemplateParamListHandler::endParam() +{ +} + +void TemplateParamListHandler::startTemplateParamList(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + debug(2,"templateparamlist\n"); +} + +void TemplateParamListHandler::endTemplateParamList() +{ + m_parent->setDelegate(0); +} + +/////////////////////////////////////////////////////////////////////////////////////////////////////// + +ParamHandler::ParamHandler(IBaseHandler *parent) : m_brief(0), m_parent(parent) +{ + addEndHandler("param",this,&ParamHandler::endParam); + + addStartHandler("type",this,&ParamHandler::startType); + + addStartHandler("declname"); + addEndHandler("declname",this,&ParamHandler::endDeclName); + + addStartHandler("defname"); + addEndHandler("defname",this,&ParamHandler::endDefName); + + addStartHandler("array"); + addEndHandler("array",this,&ParamHandler::endArray); + + addStartHandler("attribute"); + addEndHandler("attribute",this,&ParamHandler::endAttrib); + + addStartHandler("briefdescription",this,&ParamHandler::startBriefDesc); + + addStartHandler("defval",this,&ParamHandler::startDefVal); + + m_linkedTextHandler = 0; +} + +ParamHandler::~ParamHandler() +{ + delete m_brief; + delete m_linkedTextHandler; +} + +void ParamHandler::startParam(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + debug(2,"param\n"); +} + +void ParamHandler::endParam() +{ + m_parent->setDelegate(0); +} + +void ParamHandler::startType(const QXmlAttributes& /*attrib*/) +{ + delete m_linkedTextHandler; + m_linkedTextHandler = new LinkedTextHandler(this,m_type); + m_linkedTextHandler->start("type"); + debug(2,"param type\n"); +} + +void ParamHandler::endDeclName() +{ + m_declName = m_curString.stripWhiteSpace(); + debug(2,"member declName=`%s'\n",m_declName.data()); +} + +void ParamHandler::endDefName() +{ + m_defName = m_curString.stripWhiteSpace(); + debug(2,"member defName=`%s'\n",m_defName.data()); +} + +void ParamHandler::endAttrib() +{ + m_attrib = m_curString.stripWhiteSpace(); + debug(2,"member attrib=`%s'\n",m_attrib.data()); +} + +void ParamHandler::endArray() +{ + m_array = m_curString.stripWhiteSpace(); + debug(2,"member array=`%s'\n",m_array.data()); +} + +void ParamHandler::startDefVal(const QXmlAttributes& /*attrib*/) +{ + delete m_linkedTextHandler; + m_linkedTextHandler = new LinkedTextHandler(this,m_defVal); + m_linkedTextHandler->start("defval"); + debug(2,"member defVal\n"); +} + +void ParamHandler::startBriefDesc(const QXmlAttributes& attrib) +{ + DocHandler *docHandler = new DocHandler(this); + docHandler->startDoc(attrib); + m_brief = docHandler; +} + +ILinkedTextIterator *ParamHandler::type() const +{ + return new LinkedTextIterator(m_type); +} + +ILinkedTextIterator *ParamHandler::defaultValue() const +{ + return new LinkedTextIterator(m_defVal); +} + +IDocRoot *ParamHandler::briefDescription() const +{ + return m_brief; +} + + + diff --git a/addon/doxmlparser/src/paramhandler.h b/addon/doxmlparser/src/paramhandler.h new file mode 100644 index 0000000..5ec47a3 --- /dev/null +++ b/addon/doxmlparser/src/paramhandler.h @@ -0,0 +1,103 @@ +/****************************************************************************** + * + * $Id:$ + * + * + * Copyright (C) 1997-2012 by Dimitri van Heesch. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#ifndef _PARAMHANDLER_H +#define _PARAMHANDLER_H + +#include <qstring.h> +#include <qlist.h> +#include <qxml.h> +#include <doxmlintf.h> + +#include "stringimpl.h" +#include "basehandler.h" +#include "baseiterator.h" + +class LinkedTextImpl; +class LinkedTextHandler; +class DocHandler; + + +class ParamHandler : public IParam, public BaseHandler<ParamHandler> +{ + public: + virtual void startParam(const QXmlAttributes& attrib); + virtual void endParam(); + virtual void startType(const QXmlAttributes& attrib); + virtual void endDeclName(); + virtual void endDefName(); + virtual void endAttrib(); + virtual void endArray(); + virtual void startDefVal(const QXmlAttributes& attrib); + virtual void startBriefDesc(const QXmlAttributes& attrib); + + ParamHandler(IBaseHandler *parent); + virtual ~ParamHandler(); + + // IParam + virtual ILinkedTextIterator *type() const; + virtual const IString * declarationName() const { return &m_declName; } + virtual const IString * definitionName() const { return &m_defName; } + virtual const IString * attrib() const { return &m_attrib; } + virtual const IString * arraySpecifier() const { return &m_array; } + virtual ILinkedTextIterator *defaultValue() const; + virtual IDocRoot *briefDescription() const; + + private: + + // XML elements: + // ------------- + QList<LinkedTextImpl> m_type; // type + StringImpl m_declName; // declname + StringImpl m_defName; // defname + StringImpl m_array; // array + QList<LinkedTextImpl> m_defVal; // defval + DocHandler *m_brief; // briefdescription + + StringImpl m_attrib; // TODO: not yet in XML output + + IBaseHandler *m_parent; + LinkedTextHandler *m_linkedTextHandler; +}; + +class ParamIterator : public BaseIterator<IParamIterator,IParam,ParamHandler> +{ + public: + ParamIterator(const QList<ParamHandler> &list) : + BaseIterator<IParamIterator,IParam,ParamHandler>(list) {} +}; + +class TemplateParamListHandler : public BaseHandler<TemplateParamListHandler> +{ + public: + + virtual void startParam(const QXmlAttributes& attrib); + virtual void endParam(); + + virtual void startTemplateParamList(const QXmlAttributes& attrib); + virtual void endTemplateParamList(); + + TemplateParamListHandler(IBaseHandler *parent); + virtual ~TemplateParamListHandler() {} + + ParamIterator* templateParams() { return new ParamIterator(m_templateParams); } + + protected: + IBaseHandler *m_parent; + QList<ParamHandler> m_templateParams; +}; + + +#endif diff --git a/addon/doxmlparser/src/sectionhandler.cpp b/addon/doxmlparser/src/sectionhandler.cpp new file mode 100644 index 0000000..4197b10 --- /dev/null +++ b/addon/doxmlparser/src/sectionhandler.cpp @@ -0,0 +1,168 @@ +/****************************************************************************** + * + * $Id: $ + * + * + * Copyright (C) 1997-2012 by Dimitri van Heesch. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#include "mainhandler.h" +#include "compoundhandler.h" +#include "sectionhandler.h" +#include "memberhandler.h" +#include "dochandler.h" +#include "debug.h" + +class SectionTypeMap +{ + public: + SectionTypeMap() : m_map(37) + { + m_map.setAutoDelete(TRUE); + m_map.insert("user-defined",new int(ISection::UserDefined)); + m_map.insert("public-type",new int(ISection::PubTypes)); + m_map.insert("public-func",new int(ISection::PubFuncs)); + m_map.insert("public-attrib",new int(ISection::PubAttribs)); + m_map.insert("public-slot",new int(ISection::PubSlots)); + m_map.insert("signal",new int(ISection::Signals)); + m_map.insert("dcop-func",new int(ISection::DCOPFuncs)); + m_map.insert("property",new int(ISection::Properties)); + m_map.insert("event",new int(ISection::Events)); + m_map.insert("public-static-func",new int(ISection::PubStatFuncs)); + m_map.insert("public-static-attrib",new int(ISection::PubStatAttribs)); + m_map.insert("protected-type",new int(ISection::ProTypes)); + m_map.insert("protected-func",new int(ISection::ProFuncs)); + m_map.insert("protected-attrib",new int(ISection::ProAttribs)); + m_map.insert("protected-slot",new int(ISection::ProSlots)); + m_map.insert("protected-static-func",new int(ISection::ProStatFuncs)); + m_map.insert("protected-static-attrib",new int(ISection::ProStatAttribs)); + m_map.insert("package-type",new int(ISection::PacTypes)); + m_map.insert("package-func",new int(ISection::PacFuncs)); + m_map.insert("package-attrib",new int(ISection::PacAttribs)); + m_map.insert("package-static-func",new int(ISection::PacStatFuncs)); + m_map.insert("package-static-attrib",new int(ISection::PacStatAttribs)); + m_map.insert("private-type",new int(ISection::PriTypes)); + m_map.insert("private-func",new int(ISection::PriFuncs)); + m_map.insert("private-attrib",new int(ISection::PriAttribs)); + m_map.insert("private-slot",new int(ISection::PriSlots)); + m_map.insert("private-static-func",new int(ISection::PriStatFuncs)); + m_map.insert("private-static-attrib",new int(ISection::PriStatAttribs)); + m_map.insert("friend",new int(ISection::Friend)); + m_map.insert("related",new int(ISection::Related)); + m_map.insert("define",new int(ISection::Defines)); + m_map.insert("prototype",new int(ISection::Prototypes)); + m_map.insert("typedef",new int(ISection::Typedefs)); + m_map.insert("enum",new int(ISection::Enums)); + m_map.insert("func",new int(ISection::Functions)); + m_map.insert("var",new int(ISection::Variables)); + } + ISection::SectionKind map(const QString &s) + { + int *val = m_map.find(s.utf8()); + if (val==0) + { + debug(1,"Warning: `%s' is an invalid section type\n",s.data()); + return ISection::Invalid; + } + else return (ISection::SectionKind)*val; + } + private: + QDict<int> m_map; +}; + +static SectionTypeMap *s_typeMap; + +void sectionhandler_init() +{ + s_typeMap = new SectionTypeMap; +} + +void sectionhandler_exit() +{ + delete s_typeMap; +} + +SectionHandler::SectionHandler(IBaseHandler *parent) : m_parent(parent) +{ + //printf("SectionHandler::SectionHandler()\n"); + m_members.setAutoDelete(TRUE); + addEndHandler("sectiondef",this,&SectionHandler::endSection); + addStartHandler("memberdef",this,&SectionHandler::startMember); + addStartHandler("header",this,&SectionHandler::startHeader); + addEndHandler("header",this,&SectionHandler::endHeader); + addStartHandler("description",this,&SectionHandler::startDescription); +} + +SectionHandler::~SectionHandler() +{ + debug(2,"SectionHandler::~SectionHandler()\n"); +} + +void SectionHandler::startSection(const QXmlAttributes& attrib) +{ + m_parent->setDelegate(this); + m_kindString = attrib.value("kind"); + m_kind = s_typeMap->map(m_kindString); + debug(2,"section kind=`%s'\n",m_kindString.data()); +} + +void SectionHandler::startDescription(const QXmlAttributes& attrib) +{ + DocHandler *docHandler = new DocHandler(this); + docHandler->startDoc(attrib); + m_description = docHandler; +} + +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); +} + +void SectionHandler::startHeader(const QXmlAttributes&) +{ + m_header=""; + m_curString=""; +} + +void SectionHandler::endHeader() +{ + m_header = m_curString.stripWhiteSpace(); + debug(2,"member header=`%s'\n",m_header.data()); +} + +void SectionHandler::initialize(CompoundHandler *ch) +{ + QListIterator<MemberHandler> mli(m_members); + MemberHandler *mh; + for (;(mh=mli.current());++mli) + { + mh->setCompoundHandler(ch); + ch->insertMember(mh); + mh->setSectionHandler(this); + } +} + +IDocRoot *SectionHandler::description() const +{ + return m_description; +} + +IMemberIterator *SectionHandler::members() const +{ + return new MemberIterator(m_members); +} + diff --git a/addon/doxmlparser/src/sectionhandler.h b/addon/doxmlparser/src/sectionhandler.h new file mode 100644 index 0000000..6e62af1 --- /dev/null +++ b/addon/doxmlparser/src/sectionhandler.h @@ -0,0 +1,102 @@ +/****************************************************************************** + * + * $Id:$ + * + * + * Copyright (C) 1997-2012 by Dimitri van Heesch. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#ifndef _SECTIONHANDLER_H +#define _SECTIONHANDLER_H + +#include <qstring.h> +#include <qlist.h> +#include <qxml.h> +#include <doxmlintf.h> + +#include "basehandler.h" + +class SectionIterator : + public BaseIterator<ISectionIterator,ISection,SectionHandler> +{ + public: + SectionIterator(const QList<SectionHandler> &list) : + BaseIterator<ISectionIterator,ISection,SectionHandler>(list) {} +}; + + +class SectionHandler : public IUserDefined, public BaseHandler<SectionHandler> +{ + public: + virtual void startMember(const QXmlAttributes& attrib); + virtual void startHeader(const QXmlAttributes& attrib); + virtual void startSection(const QXmlAttributes& attrib); + virtual void startDescription(const QXmlAttributes& attrib); + virtual void endSection(); + virtual void endHeader(); + + SectionHandler(IBaseHandler *parent); + virtual ~SectionHandler(); + + // ISection + virtual const IString *kindString() const + { return &m_kindString; } + virtual SectionKind kind() const + { return m_kind; } + IDocRoot *description() const; + virtual IMemberIterator *members() const; + virtual bool isStatic() const + { + return m_kind==PubStatFuncs || m_kind==PubStatAttribs || + m_kind==ProStatFuncs || m_kind==ProStatAttribs || + m_kind==PriStatFuncs || m_kind==PriStatAttribs; + } + virtual bool isPublic() const + { + return !isProtected() && !isPrivate(); + } + virtual bool isProtected() const + { + return m_kind==ProTypes || m_kind==ProFuncs || m_kind==ProAttribs || + m_kind==ProSlots || m_kind==ProStatFuncs || m_kind==ProStatAttribs; + } + virtual bool isPrivate() const + { + return m_kind==PriTypes || m_kind==PriFuncs || m_kind==PriAttribs || + m_kind==PriSlots || m_kind==PriStatFuncs || m_kind==PriStatAttribs; + } + + void initialize(CompoundHandler *c); + + // IUserDefined implementation + virtual const IString *header() const + { + return &m_header; + } + + private: + IBaseHandler *m_parent; + + // XML elements: + // ------------- + StringImpl m_header; // header + DocHandler* m_description; // description + QList<MemberHandler> m_members; // memberdef + + // XML attributes: + // --------------- + SectionKind m_kind; // kind + StringImpl m_kindString; // kind as a string +}; + +void sectionhandler_init(); +void sectionhandler_exit(); + +#endif diff --git a/addon/doxmlparser/src/stringimpl.h b/addon/doxmlparser/src/stringimpl.h new file mode 100644 index 0000000..013858f --- /dev/null +++ b/addon/doxmlparser/src/stringimpl.h @@ -0,0 +1,30 @@ +#ifndef STRINGIMPL_H +#define STRINGIMPL_H + +#include <qstring.h> +#include "doxmlintf.h" + +class StringImpl : public QString, public IString +{ + public: + StringImpl() {} + StringImpl(const QString &str) : QString(str) {} + StringImpl &operator=(const QString &str) + { QString::operator=(str); return *this; } + virtual ~StringImpl() {} + + // IString + const char *latin1() const + { return QString::latin1(); } + const char *utf8() const + { return QString::utf8(); } + unsigned short unicodeCharAt(int index) const + { return QString::unicode()[index].unicode(); } + bool isEmpty() const + { return QString::isEmpty(); } + int length() const + { return QString::length(); } +}; + +#endif + |