Public Member Functions | Private Attributes | List of all members
MainHandler Class Reference

#include <mainhandler.h>

Inheritance diagram for MainHandler:
IDoxygen BaseHandler< MainHandler > QXmlDefaultHandler ElementMapper< MainHandler > LocatorContainer IBaseHandler QXmlContentHandler QXmlErrorHandler QXmlDTDHandler QXmlEntityResolver QXmlLexicalHandler QXmlDeclHandler

Public Member Functions

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 ()
 
ICompoundIteratorcompounds () const
 
ICompoundcompoundById (const char *id) const
 
virtual ICompoundcompoundByName (const char *name) const
 
virtual ICompoundmemberById (const char *id) const
 
virtual ICompoundIteratormemberByName (const char *name) const
 
virtual void release ()
 
void setDebugLevel (int level)
 
bool readXMLDir (const char *dirName)
 
void dump ()
 
void unloadCompound (CompoundHandler *ch)
 
- Public Member Functions inherited from BaseHandler< MainHandler >
 BaseHandler ()
 
virtual ~BaseHandler ()
 
virtual bool startDocument ()
 
virtual bool startElement (const QString &namespaceURI, const QString &localName, const QString &name, const QXmlAttributes &attrib)
 
virtual bool endElement (const QString &namespaceURI, const QString &localName, const QString &name)
 
bool skippedEntity (const QString &s)
 
virtual bool characters (const QString &ch)
 
void setDelegate (QXmlDefaultHandler *delegate)
 
QXmlDefaultHandlerdelegate () const
 
void setFallBackHandler (IFallBackHandler *h)
 
IFallBackHandlerfallBackHandler () const
 
void setDocumentLocator (QXmlLocator *locator)
 
- Public Member Functions inherited from QXmlDefaultHandler
 QXmlDefaultHandler ()
 
virtual ~QXmlDefaultHandler ()
 
bool endDocument ()
 
bool startPrefixMapping (const QString &prefix, const QString &uri)
 
bool endPrefixMapping (const QString &prefix)
 
bool ignorableWhitespace (const QString &ch)
 
bool processingInstruction (const QString &target, const QString &data)
 
bool warning (const QXmlParseException &exception)
 
bool error (const QXmlParseException &exception)
 
bool fatalError (const QXmlParseException &exception)
 
bool notationDecl (const QString &name, const QString &publicId, const QString &systemId)
 
bool unparsedEntityDecl (const QString &name, const QString &publicId, const QString &systemId, const QString &notationName)
 
bool resolveEntity (const QString &publicId, const QString &systemId, QXmlInputSource *&ret)
 
bool startDTD (const QString &name, const QString &publicId, const QString &systemId)
 
bool endDTD ()
 
bool startCDATA ()
 
bool endCDATA ()
 
bool comment (const QString &ch)
 
bool attributeDecl (const QString &eName, const QString &aName, const QString &type, const QString &valueDefault, const QString &value)
 
bool internalEntityDecl (const QString &name, const QString &value)
 
bool externalEntityDecl (const QString &name, const QString &publicId, const QString &systemId)
 
QString errorString ()
 
- Public Member Functions inherited from QXmlContentHandler
virtual ~QXmlContentHandler ()
 
- Public Member Functions inherited from QXmlErrorHandler
virtual ~QXmlErrorHandler ()
 
- Public Member Functions inherited from QXmlDTDHandler
virtual ~QXmlDTDHandler ()
 
- Public Member Functions inherited from QXmlEntityResolver
virtual ~QXmlEntityResolver ()
 
- Public Member Functions inherited from QXmlLexicalHandler
virtual ~QXmlLexicalHandler ()
 
- Public Member Functions inherited from QXmlDeclHandler
virtual ~QXmlDeclHandler ()
 
- Public Member Functions inherited from ElementMapper< MainHandler >
 ElementMapper ()
 
virtual ~ElementMapper ()
 
void addStartHandler (const char *key)
 
void addStartHandler (const char *key, MainHandler *obj, void(MainHandler::*handler)(const QXmlAttributes &))
 
void addEndHandler (const char *key)
 
void addEndHandler (const char *key, MainHandler *obj, void(MainHandler::*handler)())
 
- Public Member Functions inherited from IBaseHandler
virtual ~IBaseHandler ()
 

Private Attributes

CompoundEntrym_curCompound
 
MemberEntrym_curMember
 
QList< CompoundEntrym_compounds
 
QDict< CompoundEntrym_compoundDict
 
QDict< CompoundEntrym_compoundNameDict
 
QDict< MemberEntrym_memberDict
 
QDict< QList< CompoundEntry > > m_memberNameDict
 
QString m_xmlDirName
 
QDict< CompoundHandlerm_compoundsLoaded
 
bool m_insideMember
 

Additional Inherited Members

- Public Types inherited from BaseHandler< MainHandler >
typedef ElementMapper< MainHandler >::StartElementHandlerT StartElementHandlerT
 
typedef ElementMapper< MainHandler >::EndElementHandlerT EndElementHandlerT
 
- Public Types inherited from ElementMapper< MainHandler >
typedef StartElementHandler StartElementHandlerT
 
typedef EndElementHandler EndElementHandlerT
 
- Static Public Attributes inherited from LocatorContainer
static QXmlLocators_theLocator =0
 
- Protected Attributes inherited from BaseHandler< MainHandler >
QString m_curString
 
QString m_skipUntil
 
int m_skipCount
 
QXmlDefaultHandlerm_delegateHandler
 
IFallBackHandlerm_fallBackHandler
 
- Protected Attributes inherited from ElementMapper< MainHandler >
QDict< StartElementHandlerTm_startHandlers
 
QDict< EndElementHandlerTm_endHandlers
 

Detailed Description

Definition at line 45 of file mainhandler.h.

Constructor & Destructor Documentation

MainHandler::MainHandler ( )

Definition at line 91 of file mainhandler.cpp.

91  : m_compoundDict(2999), m_compoundNameDict(2999),
92  m_memberDict(12251), m_memberNameDict(12251),
93  m_compoundsLoaded(1009)
94 {
96  m_memberNameDict.setAutoDelete(TRUE);
97  addStartHandler("doxygenindex");
98  addEndHandler("doxygenindex");
100  addEndHandler("compound");
102  addEndHandler("member",this,&MainHandler::endMember);
104  addEndHandler("name",this,&MainHandler::endName);
105  m_curCompound = 0;
107 }
CompoundEntry * m_curCompound
Definition: mainhandler.h:70
virtual void endName()
const bool FALSE
Definition: qglobal.h:370
QDict< MemberEntry > m_memberDict
Definition: mainhandler.h:75
bool m_insideMember
Definition: mainhandler.h:79
virtual void endMember()
QDict< CompoundEntry > m_compoundNameDict
Definition: mainhandler.h:74
virtual void startName(const QXmlAttributes &attrib)
virtual void startMember(const QXmlAttributes &attrib)
QList< CompoundEntry > m_compounds
Definition: mainhandler.h:72
QDict< CompoundHandler > m_compoundsLoaded
Definition: mainhandler.h:78
QDict< CompoundEntry > m_compoundDict
Definition: mainhandler.h:73
void addStartHandler(const char *key)
Definition: basehandler.h:91
virtual void startCompound(const QXmlAttributes &attrib)
QDict< QList< CompoundEntry > > m_memberNameDict
Definition: mainhandler.h:76
void setAutoDelete(bool enable)
Definition: qlist.h:99
const bool TRUE
Definition: qglobal.h:371
void addEndHandler(const char *key)
Definition: basehandler.h:101
MainHandler::~MainHandler ( )
virtual

Definition at line 109 of file mainhandler.cpp.

110 {
111  debug(2,"MainHandler::~MainHandler()\n");
112 }

Member Function Documentation

ICompound * MainHandler::compoundById ( const char *  id) const
virtual

Returns a compound given its unique id. If you have a compound id this function is much more efficient than iterating over the compound list. Returns 0 if the id is not valid.

Implements IDoxygen.

Definition at line 209 of file mainhandler.cpp.

210 {
211  QString ids = id;
212  if (ids.isEmpty()) return 0;
214  if (ch) // compound already in memory
215  {
216  ch->addref(); // returning alias -> increase reference counter
217  return ch->toICompound();
218  }
219  CompoundEntry *ce = m_compoundDict.find(ids.utf8());
220  if (ce==0) return 0; // id not found
221  // create and load a new compound
222  ch = new CompoundHandler(m_xmlDirName);
223  if (!ch->parseXML(id))
224  {
225  // compound could not be initialized.
226  delete ch;
227  return 0;
228  }
229 
230  // we disregard the constness here, because the object stays conceptually
231  // unchanged.
232  MainHandler *that = (MainHandler *)this;
233  ch->initialize(that);
234  //printf("loading compound %s in memory\n",id);
235  that->m_compoundsLoaded.insert(id,ch);
236  return ch->toICompound();
237 }
bool isEmpty() const
Definition: qstring.h:682
virtual void addref()
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
ICompound * toICompound() const
bool parseXML(const char *compId)
void initialize(MainHandler *mh)
QDict< CompoundHandler > m_compoundsLoaded
Definition: mainhandler.h:78
QDict< CompoundEntry > m_compoundDict
Definition: mainhandler.h:73
QCString utf8() const
Definition: qstring.cpp:14507
QString m_xmlDirName
Definition: mainhandler.h:77
ICompound * MainHandler::compoundByName ( const char *  name) const
virtual

Returns a compound given its name (including the scope). Returns 0 if the name is not found in the project.

Implements IDoxygen.

Definition at line 246 of file mainhandler.cpp.

247 {
248  QString nameStr = name;
249  if (nameStr.isEmpty()) return 0;
251  if (ce==0) return 0; // name not found
252  return compoundById(ce->id.utf8());
253 }
static QCString name
Definition: declinfo.cpp:673
bool isEmpty() const
Definition: qstring.h:682
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
QDict< CompoundEntry > m_compoundNameDict
Definition: mainhandler.h:74
ICompound * compoundById(const char *id) const
QString id
Definition: mainhandler.h:29
QCString utf8() const
Definition: qstring.cpp:14507
ICompoundIterator * MainHandler::compounds ( ) const
virtual

Returns an iterator that can be used to iterate over the list of compounds found in the project.

Implements IDoxygen.

Definition at line 204 of file mainhandler.cpp.

205 {
206  return new CompoundEntryIterator(this,m_compounds);
207 }
QList< CompoundEntry > m_compounds
Definition: mainhandler.h:72
void MainHandler::dump ( )

Definition at line 167 of file mainhandler.cpp.

168 {
170  CompoundEntry *ce;
171  for (cli.toFirst();(ce=cli.current());++cli)
172  {
173  debug(2,"compound id=`%s' name=`%s'\n",ce->id.data(),ce->name.data());
174  QDictIterator<MemberEntry> mdi(ce->memberDict);
175  MemberEntry *me;
176  for (mdi.toFirst();(me=mdi.current());++mdi)
177  {
178  debug(2," member id=`%s' name=`%s'\n",me->id.data(),me->name.data());
179  }
180  }
181 }
QDict< MemberEntry > memberDict
Definition: mainhandler.h:42
def cli(ctx)
Definition: main.py:7
const char * data() const
Definition: qstring.h:542
QString name
Definition: mainhandler.h:30
QList< CompoundEntry > m_compounds
Definition: mainhandler.h:72
QString id
Definition: mainhandler.h:29
void MainHandler::endMember ( )
virtual

Definition at line 149 of file mainhandler.cpp.

150 {
152  QList<CompoundEntry> *cel=0;
153  if ((cel=m_memberNameDict.find(m_curMember->name.utf8()))==0)
154  {
155  cel = new QList<CompoundEntry>;
156  m_memberNameDict.insert(m_curMember->name.utf8(),cel);
157  }
158  cel->append(m_curCompound);
160 }
CompoundEntry * m_curCompound
Definition: mainhandler.h:70
QDict< MemberEntry > memberDict
Definition: mainhandler.h:42
void append(const type *d)
Definition: qlist.h:73
const bool FALSE
Definition: qglobal.h:370
bool m_insideMember
Definition: mainhandler.h:79
MemberEntry * m_curMember
Definition: mainhandler.h:71
QString name
Definition: mainhandler.h:30
QCString utf8() const
Definition: qstring.cpp:14507
QDict< QList< CompoundEntry > > m_memberNameDict
Definition: mainhandler.h:76
void MainHandler::endName ( )
virtual

Definition at line 127 of file mainhandler.cpp.

128 {
129  if (m_insideMember)
130  {
132  }
133  else
134  {
137  }
138 }
CompoundEntry * m_curCompound
Definition: mainhandler.h:70
bool m_insideMember
Definition: mainhandler.h:79
MemberEntry * m_curMember
Definition: mainhandler.h:71
QString name
Definition: mainhandler.h:30
QDict< CompoundEntry > m_compoundNameDict
Definition: mainhandler.h:74
QCString utf8() const
Definition: qstring.cpp:14507
ICompound * MainHandler::memberById ( const char *  id) const
virtual

Returns an interface to a compound containing a member given it the member's id. Given the ICompound interface one can use the same id to obtain the IMember interface.

Parameters
idThe member id.

Implements IDoxygen.

Definition at line 255 of file mainhandler.cpp.

256 {
257  QString ids = id;
258  if (ids.isEmpty()) return 0;
259  MemberEntry *me = m_memberDict[id];
260  if (me==0) return 0; // id not found
261  return compoundById(me->compound->id.utf8());
262 }
bool isEmpty() const
Definition: qstring.h:682
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
CompoundEntry * compound
Definition: mainhandler.h:35
QDict< MemberEntry > m_memberDict
Definition: mainhandler.h:75
ICompound * compoundById(const char *id) const
QString id
Definition: mainhandler.h:29
QCString utf8() const
Definition: qstring.cpp:14507
ICompoundIterator * MainHandler::memberByName ( const char *  name) const
virtual

Returns a list of all compounds containing at least one members with a certain name. Each compound can be asked to return the list of members with that name.

Parameters
nameThe name of the member.

Implements IDoxygen.

Definition at line 264 of file mainhandler.cpp.

265 {
266  QString nameStr = name;
267  if (nameStr.isEmpty()) return 0;
269  if (cel==0) return 0; // name not found
270  return new CompoundEntryIterator(this,*cel);
271 }
static QCString name
Definition: declinfo.cpp:673
bool isEmpty() const
Definition: qstring.h:682
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
QDict< QList< CompoundEntry > > m_memberNameDict
Definition: mainhandler.h:76
bool MainHandler::readXMLDir ( const char *  xmlDirName)
virtual

Reads an XML directory produced by doxygen and builds up a data structure representing the contents of the XML files in the directory.

Implements IDoxygen.

Definition at line 183 of file mainhandler.cpp.

184 {
185  m_xmlDirName = xmlDirName;
186  QString xmlFileName=m_xmlDirName+"/index.xml";
187  QFile xmlFile(xmlFileName);
188  //printf("Trying %s xmlFile.exists()=%d isReadable()=%d\n",
189  // xmlFileName.data(),xmlFile.exists(),xmlFile.isReadable());
190  if (xmlFile.exists())
191  {
192  ErrorHandler errorHandler;
193  QXmlInputSource source( xmlFile );
194  QXmlSimpleReader reader;
195  reader.setContentHandler( this );
196  reader.setErrorHandler( &errorHandler );
197  reader.parse( source );
198  dump();
199  return TRUE;
200  }
201  return FALSE;
202 }
bool parse(const QXmlInputSource &input)
Definition: qxml.cpp:2077
const bool FALSE
Definition: qglobal.h:370
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
void setErrorHandler(QXmlErrorHandler *handler)
Definition: qxml.cpp:2051
The QXmlSimpleReader class provides an implementation of a simple XML reader (i.e. parser).
Definition: qxml.h:238
void setContentHandler(QXmlContentHandler *handler)
Definition: qxml.cpp:2043
The QFile class is an I/O device that operates on files.
Definition: qfile.h:50
The QXmlInputSource class is the source where XML data is read from.
Definition: qxml.h:162
QString m_xmlDirName
Definition: mainhandler.h:77
const bool TRUE
Definition: qglobal.h:371
void MainHandler::release ( )
virtual

Releases the memory for the object hierarchy obtained by createdObjecModelFromXML(). First release all iterators before calling this function.

Implements IDoxygen.

Definition at line 283 of file mainhandler.cpp.

284 {
285  //printf("MainHandler::release()\n");
286  QDictIterator<CompoundHandler> chi(m_compoundsLoaded);
287  CompoundHandler *ch;
288  for (chi.toFirst();(ch=chi.current());++chi)
289  {
290  debug(1,"Compound %s not released\n",ch->name()->latin1());
291  }
293  dochandler_exit();
297  delete this;
298 }
void dochandler_exit()
Definition: dochandler.cpp:90
void memberhandler_exit()
virtual const char * latin1() const =0
const IString * name() const
void compoundhandler_exit()
QDict< CompoundHandler > m_compoundsLoaded
Definition: mainhandler.h:78
void sectionhandler_exit()
void graphhandler_exit()
void MainHandler::setDebugLevel ( int  level)
virtual

Sets the debug level.

  • 0 all debugging messages are disabled (the default).
  • 1 display important messages only
  • 2 display any messages.

Implements IDoxygen.

Definition at line 162 of file mainhandler.cpp.

163 {
165 }
void setDebugLevel(int level)
void MainHandler::startCompound ( const QXmlAttributes attrib)
virtual

Definition at line 114 of file mainhandler.cpp.

115 {
116  m_curCompound = new CompoundEntry(257);
117  m_curCompound->id = attrib.value("refid");
120 }
CompoundEntry * m_curCompound
Definition: mainhandler.h:70
void append(const type *d)
Definition: qlist.h:73
QString value(int index) const
Definition: qxml.cpp:664
QList< CompoundEntry > m_compounds
Definition: mainhandler.h:72
QDict< CompoundEntry > m_compoundDict
Definition: mainhandler.h:73
QString id
Definition: mainhandler.h:29
QCString utf8() const
Definition: qstring.cpp:14507
void MainHandler::startMember ( const QXmlAttributes attrib)
virtual

Definition at line 140 of file mainhandler.cpp.

141 {
143  m_curMember = new MemberEntry;
144  m_curMember->id = attrib.value("refid");
147 }
CompoundEntry * m_curCompound
Definition: mainhandler.h:70
QString value(int index) const
Definition: qxml.cpp:664
CompoundEntry * compound
Definition: mainhandler.h:35
QDict< MemberEntry > m_memberDict
Definition: mainhandler.h:75
bool m_insideMember
Definition: mainhandler.h:79
MemberEntry * m_curMember
Definition: mainhandler.h:71
QString id
Definition: mainhandler.h:29
QCString utf8() const
Definition: qstring.cpp:14507
const bool TRUE
Definition: qglobal.h:371
void MainHandler::startName ( const QXmlAttributes attrib)
virtual

Definition at line 122 of file mainhandler.cpp.

123 {
124  m_curString = "";
125 }
void MainHandler::unloadCompound ( CompoundHandler ch)

Definition at line 239 of file mainhandler.cpp.

240 {
241  //printf("unloading compound %s from memory\n",ch->id()->latin1());
242  bool result = m_compoundsLoaded.remove(ch->id()->latin1());
243  if (!result) debug(1,"Failed to unload component!\n");
244 }
static QCString result
virtual const char * latin1() const =0
const IString * id() const
QDict< CompoundHandler > m_compoundsLoaded
Definition: mainhandler.h:78

Member Data Documentation

QDict<CompoundEntry> MainHandler::m_compoundDict
private

Definition at line 73 of file mainhandler.h.

QDict<CompoundEntry> MainHandler::m_compoundNameDict
private

Definition at line 74 of file mainhandler.h.

QList<CompoundEntry> MainHandler::m_compounds
private

Definition at line 72 of file mainhandler.h.

QDict<CompoundHandler> MainHandler::m_compoundsLoaded
private

Definition at line 78 of file mainhandler.h.

CompoundEntry* MainHandler::m_curCompound
private

Definition at line 70 of file mainhandler.h.

MemberEntry* MainHandler::m_curMember
private

Definition at line 71 of file mainhandler.h.

bool MainHandler::m_insideMember
private

Definition at line 79 of file mainhandler.h.

QDict<MemberEntry> MainHandler::m_memberDict
private

Definition at line 75 of file mainhandler.h.

QDict<QList<CompoundEntry> > MainHandler::m_memberNameDict
private

Definition at line 76 of file mainhandler.h.

QString MainHandler::m_xmlDirName
private

Definition at line 77 of file mainhandler.h.


The documentation for this class was generated from the following files: