Re: doxmlparser won't iterate past "protocol" compound
Dimitri Van Heesch <[email protected]> Mon, 16 Jul 2012 10:15:22 +0200
| Newsgroups | gmane.text.doxygen.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi Isaac, I think a somewhat cleaner solution is given by the attached patch. Can you check if that works for you? Regards, Dimitri On Jul 15, 2012, at 19:59 , Isaac Wagner wrote: > I put together a slightly dirty hack. It could be done a bit clear with the CompoundTypeMap class, and perhaps even cleaner another way, but this solves the problem by simply not including compound types in the list which aren't recognized as one of the subclasses of ICompound. I attached an svn patch if you're interested in merging it or just seeing where I fixed the issue. > > On Sun, Jul 15, 2012 at 1:26 PM, Isaac Wagner <[email protected]> wrote: > Hello everyone, > > I'm trying to figure out how to use the doxmlparser classes and I've run into a bit of trouble using the compounds() iterator. I have a bit of code like the following: > > ICompoundIterator *cli = dox->compounds(); > ICompound *comp; > > for(cli->toFirst(); comp = cli->current(); cli->toNext()) > { > std::cout << "Processing " << comp->name()->latin1() << std::endl; > } > > But cli->current() returns 0 when it hits a compound with the kind "prototype." I did a bit of digging and the offending code is in compoundhandler.cpp's CompoundHandler::toICompound() which returns 0 if the compound kind is not a class, struct, union, exception, interface, namespace, file, group, or page. Surely the iterator shouldn't be halted by an unknown type, should it? I think that the best behavior would be to simply skip over compounds which aren't one of these predefined types. > > My first thought was to change current() to something like this: > > CompoundEntry *ch = QListIterator<CompoundEntry>::current(); > > if(ch && !m_mainHandler->compoundById(ch->id.utf8())) > { > toNext(); > return current(); > } > else > return ch ? m_mainHandler->compoundById(ch->id.utf8()) : 0; > > But that violates the const-ness of current() and doing away with the const would be a very dirty hack (and I'm not actually sure if it would be possible with the inheritance tree). > > First I would like to know if this is indeed broken behavior. If it is, what is the cleanest way to solve the problem? I am not particularly familiar with doxmlparser. I'll keep hacking away, but I would love to know if you have any simple solutions to the problem. > > Regards, > > Isaac > > <doxmlparser_fix.diff>------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/_______________________________________________ > Doxygen-develop mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/doxygen-develop ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Doxygen-develop mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/doxygen-develop
doxmlparser.patch
(application/octet-stream, 2.4 KB)
diff -u compoundhandler.cpp.orig compoundhandler.cpp
--- compoundhandler.cpp.orig 2012-07-09 20:08:54.000000000 +0200
+++ compoundhandler.cpp 2012-07-16 10:04:28.000000000 +0200
@@ -507,15 +507,19 @@
{
switch (m_kind)
{
- case IClass::Class: return (IClass *)this;
- case IStruct::Struct: return (IStruct *)this;
- case IUnion::Union: return (IUnion *)this;
- case IException::Exception: return (IException *)this;
- case IInterface::Interface: return (IInterface *)this;
- case INamespace::Namespace: return (INamespace *)this;
- case IFile::File: return (IFile *)this;
- case IGroup::Group: return (IGroup *)this;
- case IPage::Page: return (IPage *)this;
+ 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;
diff -u compoundhandler.h.orig compoundhandler.h
--- compoundhandler.h.orig 2012-01-29 16:25:52.000000000 +0100
+++ compoundhandler.h 2012-07-16 10:04:44.000000000 +0200
@@ -110,6 +110,7 @@
public IFile,
public IGroup,
public IPage,
+ public IDir,
public BaseHandler<CompoundHandler>
{
friend class RelatedCompound;
diff -u doxmlintf.h.orig doxmlintf.h
--- doxmlintf.h.orig 2008-08-16 22:21:55.000000000 +0200
+++ doxmlintf.h 2012-07-16 10:05:59.000000000 +0200
@@ -1070,6 +1070,13 @@
virtual const IDocTitle *title() const = 0;
};
+/** \brief Interface to a directory in the object model. */
+class IDir : public ICompound
+{
+ public:
+ virtual ICompoundIterator *nestedCompounds() const = 0;
+};
+
/*! Root node of the object model. */
class IDoxygen
{