summaryrefslogtreecommitdiffstats
path: root/addon/doxmlparser/src/compoundhandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'addon/doxmlparser/src/compoundhandler.cpp')
-rw-r--r--addon/doxmlparser/src/compoundhandler.cpp154
1 files changed, 137 insertions, 17 deletions
diff --git a/addon/doxmlparser/src/compoundhandler.cpp b/addon/doxmlparser/src/compoundhandler.cpp
index 1ce6c6b..18a8c0c 100644
--- a/addon/doxmlparser/src/compoundhandler.cpp
+++ b/addon/doxmlparser/src/compoundhandler.cpp
@@ -3,7 +3,7 @@
* $Id$
*
*
- * Copyright (C) 1997-2001 by Dimitri van Heesch.
+ * 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
@@ -16,14 +16,97 @@
#include "mainhandler.h"
#include "compoundhandler.h"
#include "dochandler.h"
+#include "debug.h"
-CompoundHandler::CompoundHandler(IBaseHandler *parent)
- : m_parent(parent), m_brief(0), m_detailed(0), m_programListing(0)
+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("exception",new int(ICompound::Exception));
+ m_map.insert("namespace",new int(ICompound::Namespace));
+ m_map.insert("file",new int(ICompound::File));
+ m_map.insert("group",new int(ICompound::Group));
+ m_map.insert("page",new int(ICompound::Page));
+ m_map.insert("package",new int(ICompound::Package));
+ }
+ virtual ~CompoundTypeMap()
+ {
+ }
+ ICompound::CompoundKind map(const QString &s)
+ {
+ int *val = m_map.find(s);
+ 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_brief(0), m_detailed(0), m_programListing(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);
+ addStartHandler("doxygen");
+ addEndHandler("doxygen");
+
+ addStartHandler("compounddef",this,&CompoundHandler::startCompound);
addEndHandler("compounddef",this,&CompoundHandler::endCompound);
addStartHandler("compoundname");
@@ -45,10 +128,12 @@ CompoundHandler::CompoundHandler(IBaseHandler *parent)
addEndHandler("location");
addStartHandler("programlisting",this,&CompoundHandler::startProgramListing);
+
}
CompoundHandler::~CompoundHandler()
{
+ debug(2,"CompoundHandler::~CompoundHandler()\n");
delete m_brief;
delete m_detailed;
delete m_programListing;
@@ -84,28 +169,27 @@ void CompoundHandler::startProgramListing(const QXmlAttributes& attrib)
void CompoundHandler::startCompound(const QXmlAttributes& attrib)
{
- m_parent->setDelegate(this);
m_id = attrib.value("id");
- m_kind = attrib.value("kind");
- printf("startCompound(id=`%s' type=`%s')\n",m_id.data(),m_kind.data());
+ m_kindString = attrib.value("kind");
+ m_kind = s_typeMap->map(m_kindString);
+ debug(2,"startCompound(id=`%s' type=`%s')\n",m_id.data(),m_kindString.data());
}
-void CompoundHandler::startLocation(const QXmlAttributes& attrib)
+void CompoundHandler::endCompound()
{
- m_defFile = attrib.value("file");
- m_defLine = attrib.value("line").toInt();
+ debug(2,"endCompound()\n");
}
-void CompoundHandler::endCompound()
+void CompoundHandler::startLocation(const QXmlAttributes& attrib)
{
- printf("endCompound()\n");
- m_parent->setDelegate(0);
+ m_defFile = attrib.value("file");
+ m_defLine = attrib.value("line").toInt();
}
void CompoundHandler::endCompoundName()
{
m_name = m_curString.stripWhiteSpace();
- printf("Compound name `%s'\n",m_name.data());
+ debug(2,"Compound name `%s'\n",m_name.data());
}
void CompoundHandler::addSuperClass(const QXmlAttributes& attrib)
@@ -115,7 +199,7 @@ void CompoundHandler::addSuperClass(const QXmlAttributes& attrib)
attrib.value("prot"),
attrib.value("virt")
);
- printf("super class id=`%s' prot=`%s' virt=`%s'\n",
+ debug(2,"super class id=`%s' prot=`%s' virt=`%s'\n",
sc->m_id.data(),
sc->m_protection.data(),
sc->m_virtualness.data());
@@ -129,20 +213,56 @@ void CompoundHandler::addSubClass(const QXmlAttributes& attrib)
attrib.value("prot"),
attrib.value("virt")
);
- printf("sub class id=`%s' prot=`%s' virt=`%s'\n",
+ debug(2,"sub class id=`%s' prot=`%s' virt=`%s'\n",
sc->m_id.data(),
sc->m_protection.data(),
sc->m_virtualness.data());
m_subClasses.append(sc);
}
-void CompoundHandler::initialize(MainHandler *m)
+bool CompoundHandler::parseXML(const QString &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<ISection> msi(m_sections);
SectionHandler *sec;
for (;(sec=(SectionHandler *)msi.current());++msi)
{
- sec->initialize(m);
+ sec->initialize(this);
+ }
+}
+
+void CompoundHandler::insertMember(MemberHandler *mh)
+{
+ m_memberDict.insert(mh->id(),mh);
+ QList<MemberHandler> *mhl = m_memberNameDict.find(mh->id());
+ if (mhl==0)
+ {
+ mhl = new QList<MemberHandler>;
+ m_memberNameDict.insert(mh->name(),mhl);
+ }
+ mhl->append(mh);
+}
+
+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;
}
}