diff options
author | dimitri <dimitri@afe2bf4a-e733-0410-8a33-86f594647bc7> | 2002-10-30 20:57:53 (GMT) |
---|---|---|
committer | dimitri <dimitri@afe2bf4a-e733-0410-8a33-86f594647bc7> | 2002-10-30 20:57:53 (GMT) |
commit | c6d6555a949e86be5c859311eb4db5dcc092c258 (patch) | |
tree | dd06bd100b0bd88b6ee40c8464efac800a749c32 /addon/doxmlparser | |
parent | 7c34dd2b1594925d0a012e9ba290bf9c80574db5 (diff) | |
download | Doxygen-c6d6555a949e86be5c859311eb4db5dcc092c258.zip Doxygen-c6d6555a949e86be5c859311eb4db5dcc092c258.tar.gz Doxygen-c6d6555a949e86be5c859311eb4db5dcc092c258.tar.bz2 |
Release-1.2.18-20021030
Diffstat (limited to 'addon/doxmlparser')
-rw-r--r-- | addon/doxmlparser/include/doxmlintf.h | 128 | ||||
-rw-r--r-- | addon/doxmlparser/src/compoundhandler.cpp | 38 | ||||
-rw-r--r-- | addon/doxmlparser/src/compoundhandler.h | 5 | ||||
-rw-r--r-- | addon/doxmlparser/src/dochandler.cpp | 37 | ||||
-rw-r--r-- | addon/doxmlparser/src/dochandler.h | 26 | ||||
-rw-r--r-- | addon/doxmlparser/src/doxmlintf.h | 128 | ||||
-rw-r--r-- | addon/doxmlparser/src/doxmlparser.pro.in | 6 | ||||
-rw-r--r-- | addon/doxmlparser/src/loamhandler.cpp | 60 | ||||
-rw-r--r-- | addon/doxmlparser/src/loamhandler.h | 50 | ||||
-rw-r--r-- | addon/doxmlparser/src/memberhandler.cpp | 71 | ||||
-rw-r--r-- | addon/doxmlparser/src/memberhandler.h | 42 | ||||
-rw-r--r-- | addon/doxmlparser/src/paramhandler.cpp | 2 | ||||
-rw-r--r-- | addon/doxmlparser/test/main.cpp | 30 |
13 files changed, 524 insertions, 99 deletions
diff --git a/addon/doxmlparser/include/doxmlintf.h b/addon/doxmlparser/include/doxmlintf.h index 55eb946..7ab2c79 100644 --- a/addon/doxmlparser/include/doxmlintf.h +++ b/addon/doxmlparser/include/doxmlintf.h @@ -16,7 +16,16 @@ #ifndef _DOXMLINTF_H #define _DOXMLINTF_H -#include <qstring.h> +/*! \file + * \brief The interface to the object model provided by the XML parser + * library. + * + * To start using this library one calls createObjectModel and then + * uses the returned IDoxygen interface to read doxygen generated + * XML output and navigate through the information contained in it. + * + * @see createObjectModel() + */ class IMember; class IDocIterator; @@ -24,12 +33,20 @@ class ICompound; class ISection; class INode; +/*! \brief Read only interface to a string. + */ class IString { public: + /*! Returns a latin1 character representation of the string. */ virtual const char *latin1() const = 0; + /*! Returns a 16-bit unicode character representation of the character at + * position \a index in the string. The first character is at index 0. + */ virtual unsigned short unicodeCharAt(int index) const = 0; + /*! Returns true if this string is empty or false otherwise */ virtual bool isEmpty() const = 0; + /*! Returns the number of characters in the string. */ virtual int length() const = 0; }; @@ -107,24 +124,6 @@ class IMemberReferenceIterator virtual void release() = 0; }; -class IEnumValue -{ - public: - virtual const IString * name() const = 0; - virtual const IString * initializer() const = 0; -}; - -class IEnumValueIterator -{ - public: - virtual IEnumValue *toFirst() = 0; - virtual IEnumValue *toLast() = 0; - virtual IEnumValue *toNext() = 0; - virtual IEnumValue *toPrev() = 0; - virtual IEnumValue *current() const = 0; - virtual void release() = 0; -}; - class IDoc { public: @@ -161,8 +160,9 @@ class IDoc Entry, // 28 -> IDocEntry Section, // 29 -> IDocSection Preformatted, // 30 -> IDocPreformatted - Symbol, // 31 -> IDocSymbol - Root // 32 -> IDocRoot + Verbatim, // 31 -> IDocVerbatim + Symbol, // 32 -> IDocSymbol + Root // 33 -> IDocRoot }; virtual Kind kind() const = 0; }; @@ -399,6 +399,12 @@ class IDocPreformatted : public IDoc virtual IDocIterator *contents() const = 0; }; +class IDocVerbatim : public IDoc +{ + public: + virtual const IString *text() const = 0; +}; + class IDocSymbol : public IDoc { public: @@ -499,7 +505,8 @@ class IMember public: enum MemberKind { Invalid=0, Define, Property, Variable, Typedef, Enum, - Function, Signal, Prototype, Friend, DCOP, Slot + Function, Signal, Prototype, Friend, DCOP, Slot, + EnumValue }; virtual ICompound *compound() const = 0; virtual ISection *section() const = 0; @@ -525,11 +532,80 @@ class IMember virtual int definitionLine() const = 0; virtual IMemberReference *reimplements() const = 0; virtual IMemberReferenceIterator *reimplementedBy() const = 0; - virtual IEnumValueIterator *enumValues() const = 0; virtual IDocRoot *briefDescription() const = 0; virtual IDocRoot *detailedDescription() const = 0; }; +class IDefine : public IMember +{ + public: +}; + +class IProperty : public IMember +{ + public: +}; + +class IVariable : public IMember +{ + public: +}; + +class ITypedef : public IMember +{ + public: +}; + +class IFunction : public IMember +{ + public: +}; + +class ISignal : public IMember +{ + public: +}; + +class IPrototype : public IMember +{ + public: +}; + +class IFriend : public IMember +{ + public: +}; + +class IDCOP : public IMember +{ + public: +}; + +class ISlot : public IMember +{ + public: +}; + +class IEnumValue : public IMember +{ + public: + virtual const IString * name() const = 0; +}; + +#if 0 +class IEnumValueIterator +{ + public: + virtual IEnumValue *toFirst() = 0; + virtual IEnumValue *toLast() = 0; + virtual IEnumValue *toNext() = 0; + virtual IEnumValue *toPrev() = 0; + virtual IEnumValue *current() const = 0; + virtual void release() = 0; +}; +#endif + + class IMemberIterator { public: @@ -541,6 +617,12 @@ class IMemberIterator virtual void release() = 0; }; +class IEnum : public IMember +{ + public: + virtual IMemberIterator *enumValues() const = 0; +}; + /*! \brief The interface to a section in the object model. * * A compound can have a number of sections, where each diff --git a/addon/doxmlparser/src/compoundhandler.cpp b/addon/doxmlparser/src/compoundhandler.cpp index 623ac71..df69d2a 100644 --- a/addon/doxmlparser/src/compoundhandler.cpp +++ b/addon/doxmlparser/src/compoundhandler.cpp @@ -19,6 +19,7 @@ #include "debug.h" #include "graphhandler.h" #include "sectionhandler.h" +#include "loamhandler.h" //---------------------------------------------------------------------------- @@ -146,7 +147,7 @@ CompoundHandler::CompoundHandler(const QString &xmlDir) m_xmlDir(xmlDir), m_refCount(1), m_memberDict(257), m_memberNameDict(257), m_mainHandler(0), m_inheritanceGraph(0), m_collaborationGraph(0), m_includeDependencyGraph(0), m_includedByDependencyGraph(0), m_templateParamList(0), - m_titleHandler(0) + m_titleHandler(0), m_members(0) { m_superClasses.setAutoDelete(TRUE); m_subClasses.setAutoDelete(TRUE); @@ -202,12 +203,10 @@ CompoundHandler::CompoundHandler(const QString &xmlDir) addEndHandler("innergroup"); addStartHandler("templateparamlist",this,&CompoundHandler::startTemplateParamList); - addEndHandler("templateparamlist"); - - addStartHandler("param",this,&CompoundHandler::startParam); - addEndHandler("param"); addStartHandler("title",this,&CompoundHandler::startTitle); + + addStartHandler("listofallmembers",this,&CompoundHandler::startListOfAllMembers); } CompoundHandler::~CompoundHandler() @@ -221,6 +220,8 @@ CompoundHandler::~CompoundHandler() delete m_collaborationGraph; delete m_includeDependencyGraph; delete m_includedByDependencyGraph; + delete m_templateParamList; + delete m_members; } void CompoundHandler::startSection(const QXmlAttributes& attrib) @@ -298,17 +299,16 @@ void CompoundHandler::startInnerGroup(const QXmlAttributes& attrib) m_innerCompounds.append(new QString(attrib.value("refid"))); } -void CompoundHandler::startParam(const QXmlAttributes& attrib) +void CompoundHandler::startTemplateParamList(const QXmlAttributes& attrib) { - ParamHandler *ph = new ParamHandler(this); - ph->startParam(attrib); - m_params.append(ph); + m_templateParamList = new TemplateParamListHandler(this); + m_templateParamList->startTemplateParamList(attrib); } -void CompoundHandler::startTemplateParamList(const QXmlAttributes& attrib) +void CompoundHandler::startListOfAllMembers(const QXmlAttributes& attrib) { - m_templateParamList = new TemplateParamListHandler(this); - m_templateParamList->startParam(attrib); + m_members = new ListOfAllMembersHandler(this); + m_members->startListOfAllMembers(attrib); } void CompoundHandler::addSuperClass(const QXmlAttributes& attrib) @@ -388,11 +388,16 @@ void CompoundHandler::initialize(MainHandler *mh) { 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) { @@ -478,7 +483,7 @@ IDocRoot *CompoundHandler::detailedDescription() const IMember *CompoundHandler::memberById(const char *id) const { - return m_memberDict[id]; + return (IFunction*)m_memberDict[id]; } IGraph *CompoundHandler::inheritanceGraph() const @@ -530,3 +535,10 @@ 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 index b099be4..e68faf3 100644 --- a/addon/doxmlparser/src/compoundhandler.h +++ b/addon/doxmlparser/src/compoundhandler.h @@ -34,6 +34,7 @@ class SectionHandler; class ParamHandler; class TemplateParamListHandler; class TitleHandler; +class ListOfAllMembersHandler; class RelatedCompound : public IRelatedCompound { @@ -97,9 +98,9 @@ class CompoundHandler : public IClass, virtual void startInnerNamespace(const QXmlAttributes& attrib); virtual void startInnerFile(const QXmlAttributes& attrib); virtual void startInnerGroup(const QXmlAttributes& attrib); - virtual void startParam(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); @@ -133,6 +134,7 @@ class CompoundHandler : public IClass, int locationLine() const { return m_defLine; } int locationBodyStartLine() const { return m_defBodyStart; } int locationBodyEndLine() const { return m_defBodyEnd; } + IMemberReferenceIterator *members() const; // IFile implementation IGraph *includeDependencyGraph() const; @@ -171,6 +173,7 @@ class CompoundHandler : public IClass, ProgramListingHandler* m_source; TemplateParamListHandler* m_templateParamList; TitleHandler* m_titleHandler; + ListOfAllMembersHandler* m_members; }; void compoundhandler_init(); diff --git a/addon/doxmlparser/src/dochandler.cpp b/addon/doxmlparser/src/dochandler.cpp index b822a90..e771761 100644 --- a/addon/doxmlparser/src/dochandler.cpp +++ b/addon/doxmlparser/src/dochandler.cpp @@ -1097,7 +1097,7 @@ void ImageHandler::endImage() DotFileHandler::DotFileHandler(IBaseHandler *parent) : m_parent(parent) { - addEndHandler("image",this,&DotFileHandler::endDotFile); + addEndHandler("dotfile",this,&DotFileHandler::endDotFile); } DotFileHandler::~DotFileHandler() @@ -1328,6 +1328,32 @@ IDocIterator *PreformattedHandler::contents() const } //---------------------------------------------------------------------- +// VerbatimHandler +//---------------------------------------------------------------------- + +VerbatimHandler::VerbatimHandler(IBaseHandler *parent) + : m_parent(parent) +{ + addEndHandler("verbatim",this,&VerbatimHandler::endVerbatim); +} + +VerbatimHandler::~VerbatimHandler() +{ +} + +void VerbatimHandler::startVerbatim(const QXmlAttributes&) +{ + m_parent->setDelegate(this); + m_curString=""; +} + +void VerbatimHandler::endVerbatim() +{ + m_text = m_curString; + m_parent->setDelegate(0); +} + +//---------------------------------------------------------------------- // SymbolHandler //---------------------------------------------------------------------- @@ -1393,6 +1419,7 @@ ParagraphHandler::ParagraphHandler(IBaseHandler *parent) addStartHandler("indexentry",this,&ParagraphHandler::startIndexEntry); addStartHandler("table",this,&ParagraphHandler::startTable); addStartHandler("preformatted",this,&ParagraphHandler::startPreformatted); + addStartHandler("verbatim",this,&ParagraphHandler::startVerbatim); addStartHandler("umlaut",this,&ParagraphHandler::startUmlaut); addStartHandler("acute",this,&ParagraphHandler::startAcute); addStartHandler("grave",this,&ParagraphHandler::startGrave); @@ -1567,6 +1594,14 @@ void ParagraphHandler::startPreformatted(const QXmlAttributes& attrib) m_children.append(ph); } +void ParagraphHandler::startVerbatim(const QXmlAttributes& attrib) +{ + addTextNode(); + VerbatimHandler *vh = new VerbatimHandler(this); + vh->startVerbatim(attrib); + m_children.append(vh); +} + void ParagraphHandler::startUmlaut(const QXmlAttributes& attrib) { addTextNode(); diff --git a/addon/doxmlparser/src/dochandler.h b/addon/doxmlparser/src/dochandler.h index 0e657f1..37c7df4 100644 --- a/addon/doxmlparser/src/dochandler.h +++ b/addon/doxmlparser/src/dochandler.h @@ -65,6 +65,7 @@ DEFINE_CLS_IMPL(DocRow); DEFINE_CLS_IMPL(DocEntry); DEFINE_CLS_IMPL(DocSection); DEFINE_CLS_IMPL(DocPreformatted); +DEFINE_CLS_IMPL(DocVerbatim); DEFINE_CLS_IMPL(DocSymbol); DEFINE_CLS_IMPL(DocRoot); @@ -190,6 +191,7 @@ class ParagraphHandler : public DocParaImpl, virtual void startIndexEntry(const QXmlAttributes& attrib); virtual void startTable(const QXmlAttributes& attrib); virtual void startPreformatted(const QXmlAttributes& attrib); + virtual void startVerbatim(const QXmlAttributes& attrib); virtual void startUmlaut(const QXmlAttributes& attrib); virtual void startAcute(const QXmlAttributes& attrib); virtual void startGrave(const QXmlAttributes& attrib); @@ -1019,6 +1021,30 @@ class PreformattedIterator : //----------------------------------------------------------------------------- +/*! \brief Node representing an preformatted section + */ +class VerbatimHandler : public DocVerbatimImpl, + public BaseHandler<VerbatimHandler> +{ + friend class VerbatimIterator; + public: + VerbatimHandler(IBaseHandler *parent); + virtual ~VerbatimHandler(); + void startVerbatim(const QXmlAttributes& attrib); + void endVerbatim(); + + // IDocVerbatim + virtual Kind kind() const { return DocImpl::Verbatim; } + virtual const IString *text() const { return &m_text; } + + private: + IBaseHandler *m_parent; + StringImpl m_text; +}; + + +//----------------------------------------------------------------------------- + /*! \brief Node representing an special symbol. * */ diff --git a/addon/doxmlparser/src/doxmlintf.h b/addon/doxmlparser/src/doxmlintf.h index 55eb946..7ab2c79 100644 --- a/addon/doxmlparser/src/doxmlintf.h +++ b/addon/doxmlparser/src/doxmlintf.h @@ -16,7 +16,16 @@ #ifndef _DOXMLINTF_H #define _DOXMLINTF_H -#include <qstring.h> +/*! \file + * \brief The interface to the object model provided by the XML parser + * library. + * + * To start using this library one calls createObjectModel and then + * uses the returned IDoxygen interface to read doxygen generated + * XML output and navigate through the information contained in it. + * + * @see createObjectModel() + */ class IMember; class IDocIterator; @@ -24,12 +33,20 @@ class ICompound; class ISection; class INode; +/*! \brief Read only interface to a string. + */ class IString { public: + /*! Returns a latin1 character representation of the string. */ virtual const char *latin1() const = 0; + /*! Returns a 16-bit unicode character representation of the character at + * position \a index in the string. The first character is at index 0. + */ virtual unsigned short unicodeCharAt(int index) const = 0; + /*! Returns true if this string is empty or false otherwise */ virtual bool isEmpty() const = 0; + /*! Returns the number of characters in the string. */ virtual int length() const = 0; }; @@ -107,24 +124,6 @@ class IMemberReferenceIterator virtual void release() = 0; }; -class IEnumValue -{ - public: - virtual const IString * name() const = 0; - virtual const IString * initializer() const = 0; -}; - -class IEnumValueIterator -{ - public: - virtual IEnumValue *toFirst() = 0; - virtual IEnumValue *toLast() = 0; - virtual IEnumValue *toNext() = 0; - virtual IEnumValue *toPrev() = 0; - virtual IEnumValue *current() const = 0; - virtual void release() = 0; -}; - class IDoc { public: @@ -161,8 +160,9 @@ class IDoc Entry, // 28 -> IDocEntry Section, // 29 -> IDocSection Preformatted, // 30 -> IDocPreformatted - Symbol, // 31 -> IDocSymbol - Root // 32 -> IDocRoot + Verbatim, // 31 -> IDocVerbatim + Symbol, // 32 -> IDocSymbol + Root // 33 -> IDocRoot }; virtual Kind kind() const = 0; }; @@ -399,6 +399,12 @@ class IDocPreformatted : public IDoc virtual IDocIterator *contents() const = 0; }; +class IDocVerbatim : public IDoc +{ + public: + virtual const IString *text() const = 0; +}; + class IDocSymbol : public IDoc { public: @@ -499,7 +505,8 @@ class IMember public: enum MemberKind { Invalid=0, Define, Property, Variable, Typedef, Enum, - Function, Signal, Prototype, Friend, DCOP, Slot + Function, Signal, Prototype, Friend, DCOP, Slot, + EnumValue }; virtual ICompound *compound() const = 0; virtual ISection *section() const = 0; @@ -525,11 +532,80 @@ class IMember virtual int definitionLine() const = 0; virtual IMemberReference *reimplements() const = 0; virtual IMemberReferenceIterator *reimplementedBy() const = 0; - virtual IEnumValueIterator *enumValues() const = 0; virtual IDocRoot *briefDescription() const = 0; virtual IDocRoot *detailedDescription() const = 0; }; +class IDefine : public IMember +{ + public: +}; + +class IProperty : public IMember +{ + public: +}; + +class IVariable : public IMember +{ + public: +}; + +class ITypedef : public IMember +{ + public: +}; + +class IFunction : public IMember +{ + public: +}; + +class ISignal : public IMember +{ + public: +}; + +class IPrototype : public IMember +{ + public: +}; + +class IFriend : public IMember +{ + public: +}; + +class IDCOP : public IMember +{ + public: +}; + +class ISlot : public IMember +{ + public: +}; + +class IEnumValue : public IMember +{ + public: + virtual const IString * name() const = 0; +}; + +#if 0 +class IEnumValueIterator +{ + public: + virtual IEnumValue *toFirst() = 0; + virtual IEnumValue *toLast() = 0; + virtual IEnumValue *toNext() = 0; + virtual IEnumValue *toPrev() = 0; + virtual IEnumValue *current() const = 0; + virtual void release() = 0; +}; +#endif + + class IMemberIterator { public: @@ -541,6 +617,12 @@ class IMemberIterator virtual void release() = 0; }; +class IEnum : public IMember +{ + public: + virtual IMemberIterator *enumValues() const = 0; +}; + /*! \brief The interface to a section in the object model. * * A compound can have a number of sections, where each diff --git a/addon/doxmlparser/src/doxmlparser.pro.in b/addon/doxmlparser/src/doxmlparser.pro.in index ddbe82a..841a46c 100644 --- a/addon/doxmlparser/src/doxmlparser.pro.in +++ b/addon/doxmlparser/src/doxmlparser.pro.in @@ -4,12 +4,14 @@ HEADERS = basehandler.h mainhandler.h \ compoundhandler.h sectionhandler.h \ memberhandler.h paramhandler.h \ dochandler.h linkedtexthandler.h \ - debug.h graphhandler.h stringimpl.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 + basehandler.cpp debug.cpp graphhandler.cpp \ + loamhandler.cpp unix:LIBS += -L../../../lib -lqtools win32:INCLUDEPATH += . win32-mingw:LIBS += -L../../../lib -lqtools diff --git a/addon/doxmlparser/src/loamhandler.cpp b/addon/doxmlparser/src/loamhandler.cpp new file mode 100644 index 0000000..de726c1 --- /dev/null +++ b/addon/doxmlparser/src/loamhandler.cpp @@ -0,0 +1,60 @@ +#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); + + 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"); + // TODO: extract prot, virt, ambiguityscope and scope as well + 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::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..24c05b1 --- /dev/null +++ b/addon/doxmlparser/src/loamhandler.h @@ -0,0 +1,50 @@ +/****************************************************************************** + * + * $Id$ + * + * + * Copyright (C) 1997-2002 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 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/memberhandler.cpp b/addon/doxmlparser/src/memberhandler.cpp index 74b1e32..ad35a91 100644 --- a/addon/doxmlparser/src/memberhandler.cpp +++ b/addon/doxmlparser/src/memberhandler.cpp @@ -39,6 +39,7 @@ class MemberTypeMap 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) { @@ -82,19 +83,28 @@ IMember *MemberReference::member() const //------------------------------------------------------------------------------ -EnumValueHandler::EnumValueHandler(IBaseHandler *parent) : m_parent(parent), m_brief(0), m_detailed(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); - addEndHandler("initializer",this,&EnumValueHandler::endInitializer); 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*/) @@ -119,12 +129,9 @@ void EnumValueHandler::endName() void EnumValueHandler::startInitializer(const QXmlAttributes& /*attrib*/) { - m_curString=""; -} - -void EnumValueHandler::endInitializer() -{ - m_initializer = m_curString; + delete m_linkedTextHandler; + m_linkedTextHandler = new LinkedTextHandler(this,m_initializer); + m_linkedTextHandler->start("initializer"); } void EnumValueHandler::startBriefDesc(const QXmlAttributes& attrib) @@ -140,7 +147,7 @@ void EnumValueHandler::startDetailedDesc(const QXmlAttributes& attrib) docHandler->startDoc(attrib); m_detailed = docHandler; } - +#endif //------------------------------------------------------------------------------ @@ -149,13 +156,14 @@ MemberHandler::MemberHandler(IBaseHandler *parent) { //printf("MemberHandler::MemberHandler() %p\n",this); addEndHandler("memberdef",this,&MemberHandler::endMember); + addEndHandler("enumvalue",this,&MemberHandler::endMember); addStartHandler("type",this,&MemberHandler::startType); addStartHandler("initializer",this,&MemberHandler::startInitializer); addStartHandler("exception",this,&MemberHandler::startException); - addStartHandler("enumvalue",this,&MemberHandler::startEnumValue); + addStartHandler("enumvalue",this,&MemberHandler::startEnumValue2); - addStartHandler("name"); + addStartHandler("name",this,&MemberHandler::startName); addEndHandler("name",this,&MemberHandler::endName); addStartHandler("param",this,&MemberHandler::startParam); @@ -212,6 +220,7 @@ 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_virtualness = attrib.value("virt"); @@ -222,6 +231,29 @@ void MemberHandler::startMember(const QXmlAttributes& attrib) 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_virtualness = "non-virtual"; + m_protection = attrib.value("prot"); + m_isConst = FALSE; + m_isVolatile = 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); @@ -328,6 +360,11 @@ void MemberHandler::startException(const QXmlAttributes &) m_linkedTextHandler->start("exception"); } +void MemberHandler::startName(const QXmlAttributes &) +{ + m_curString=""; +} + void MemberHandler::endName() { m_name = m_curString.stripWhiteSpace(); @@ -348,13 +385,6 @@ void MemberHandler::startParam(const QXmlAttributes& attrib) } } -void MemberHandler::startEnumValue(const QXmlAttributes& attrib) -{ - EnumValueHandler *evh = new EnumValueHandler(this); - evh->startEnumValue(attrib); - m_enumValues.append(evh); -} - void MemberHandler::startTemplateParamList(const QXmlAttributes&) { m_insideTemplateParamList = TRUE; @@ -416,4 +446,9 @@ ISection *MemberHandler::section() const return m_section; } +IMemberIterator *MemberHandler::enumValues() const +{ + return new MemberIterator(m_enumValues); +} + diff --git a/addon/doxmlparser/src/memberhandler.h b/addon/doxmlparser/src/memberhandler.h index f76655c..6280013 100644 --- a/addon/doxmlparser/src/memberhandler.h +++ b/addon/doxmlparser/src/memberhandler.h @@ -51,6 +51,8 @@ class MemberReferenceIterator : public BaseIterator<IMemberReferenceIterator,IMe BaseIterator<IMemberReferenceIterator,IMemberReference,MemberReference>(list) {} }; + +#if 0 class EnumValueHandler : public IEnumValue, public BaseHandler<EnumValueHandler> { public: @@ -65,12 +67,12 @@ class EnumValueHandler : public IEnumValue, public BaseHandler<EnumValueHandler> // IEnumValue virtual const IString *name() const { return &m_name; } - virtual const IString *initializer() const { return &m_initializer; } + virtual ILinkedTextIterator *initializer() const + { return new LinkedTextIterator(m_initializer); } void setName(const QString &name) { m_name=name; } - void setInitializer(const QString &init) { m_initializer=init; } - virtual ~EnumValueHandler() { delete m_brief; delete m_detailed; } + virtual ~EnumValueHandler(); EnumValueHandler(IBaseHandler *parent); virtual IDocRoot *briefDescription() const @@ -80,10 +82,11 @@ class EnumValueHandler : public IEnumValue, public BaseHandler<EnumValueHandler> private: StringImpl m_name; - StringImpl m_initializer; + QList<LinkedTextImpl> m_initializer; IBaseHandler *m_parent; DocHandler *m_brief; DocHandler *m_detailed; + LinkedTextHandler *m_linkedTextHandler; }; class EnumValueIterator : public BaseIterator<IEnumValueIterator,IEnumValue,EnumValueHandler> @@ -92,15 +95,29 @@ class EnumValueIterator : public BaseIterator<IEnumValueIterator,IEnumValue,Enum EnumValueIterator(const QList<EnumValueHandler> &list) : BaseIterator<IEnumValueIterator,IEnumValue,EnumValueHandler>(list) {} }; +#endif -class MemberHandler : public IMember, public BaseHandler<MemberHandler> +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 startBriefDesc(const QXmlAttributes& attrib); virtual void startDetailedDesc(const QXmlAttributes& attrib); @@ -116,6 +133,7 @@ class MemberHandler : public IMember, public BaseHandler<MemberHandler> 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(); @@ -172,13 +190,14 @@ class MemberHandler : public IMember, public BaseHandler<MemberHandler> { return m_reimplements; } virtual IMemberReferenceIterator *reimplementedBy() const { return new MemberReferenceIterator(m_reimplementedBy); } - virtual IEnumValueIterator *enumValues() const - { return new EnumValueIterator(m_enumValues); } virtual IDocRoot *briefDescription() const { return m_brief; } virtual IDocRoot *detailedDescription() const { return m_detailed; } + // IEnum + virtual IMemberIterator *enumValues() const; + void initialize(MainHandler *m); void setCompoundHandler(CompoundHandler *c); void setSectionHandler(SectionHandler *s); @@ -212,16 +231,19 @@ class MemberHandler : public IMember, public BaseHandler<MemberHandler> bool m_isConst; bool m_isVolatile; LinkedTextHandler *m_linkedTextHandler; - QList<EnumValueHandler> m_enumValues; + QList<MemberHandler> m_enumValues; bool m_insideTemplateParamList; bool m_hasTemplateParamList; }; -class MemberIterator : public BaseIterator<IMemberIterator,IMember,MemberHandler> +class MemberIterator : public BaseIteratorVia<IMemberIterator, + IMember, + MemberHandler, + IFunction> { public: MemberIterator(const QList<MemberHandler> &list) : - BaseIterator<IMemberIterator,IMember,MemberHandler>(list) {} + BaseIteratorVia<IMemberIterator,IMember,MemberHandler,IFunction>(list) {} }; void memberhandler_init(); diff --git a/addon/doxmlparser/src/paramhandler.cpp b/addon/doxmlparser/src/paramhandler.cpp index ecfdda2..0278e86 100644 --- a/addon/doxmlparser/src/paramhandler.cpp +++ b/addon/doxmlparser/src/paramhandler.cpp @@ -20,10 +20,8 @@ TemplateParamListHandler::TemplateParamListHandler(IBaseHandler *parent) : m_parent(parent) { addStartHandler("param",this,&TemplateParamListHandler::startParam); - //addEndHandler("param",this,&TemplateParamListHandler::endParam); addEndHandler("templateparamlist",this,&TemplateParamListHandler::endTemplateParamList); - } void TemplateParamListHandler::startParam(const QXmlAttributes& attrib) diff --git a/addon/doxmlparser/test/main.cpp b/addon/doxmlparser/test/main.cpp index 7ac7720..067dfc9 100644 --- a/addon/doxmlparser/test/main.cpp +++ b/addon/doxmlparser/test/main.cpp @@ -16,6 +16,7 @@ #include <stdio.h> #include <stdlib.h> #include <doxmlintf.h> +#include <qstring.h> /*! Dumps the contents of a hyperlinked text fragment as plain text to the * output. @@ -390,6 +391,15 @@ void DumpDoc(IDoc *doc,int level) InPrint(("<preformatted/>\n")); } break; + case IDoc::Verbatim: + { + InPrint(("<verbatim>\n")); + IDocVerbatim *vt = dynamic_cast<IDocVerbatim*>(doc); + ASSERT(vt!=0); + InPrint(("%s",vt->text()->latin1())); + InPrint(("<verbatim/>\n")); + } + break; case IDoc::Symbol: { IDocSymbol *sym = dynamic_cast<IDocSymbol*>(doc); @@ -540,14 +550,22 @@ int main(int argc,char **argv) } mri->release(); - IEnumValueIterator *evi = mem->enumValues(); - IEnumValue *ev; - for (evi->toFirst();(ev=evi->current());evi->toNext()) + if (mem->kind()==IMember::Enum) // we have found an enum { - printf(" Enum value `%s' init=`%s'\n", - ev->name()->latin1(),ev->initializer()->latin1()); + IEnum *e = dynamic_cast<IEnum*>(mem); + IMemberIterator *evi = e->enumValues(); // get the enum values + IMember *mev; + for (evi->toFirst();(mev=evi->current());evi->toNext()) + { + IEnumValue *ev = dynamic_cast<IEnumValue*>(mev); + ILinkedTextIterator *lti = ev->initializer(); + QString init = linkedTextToString(lti); + lti->release(); + printf(" Enum value `%s' init=`%s'\n", + ev->name()->latin1(),init.latin1()); + } + evi->release(); } - evi->release(); pli = mem->templateParameters(); if (pli) |