📄 tagreader.cpp
字号:
msg(" kind: `%s'\n",md->kind.data()); msg(" name: `%s'\n",md->name.data()); msg(" anchor: `%s'\n",md->anchor.data()); msg(" arglist: `%s'\n",md->arglist.data()); } } //============== GROUPS QListIterator<TagGroupInfo> lgi(m_tagFileGroups); TagGroupInfo *gd; for (;(gd=lgi.current());++lgi) { msg("group `%s'\n",gd->name.data()); msg(" filename `%s'\n",gd->filename.data()); QStringList::Iterator it; for ( it = gd->namespaceList.begin(); it != gd->namespaceList.end(); ++it ) { msg( " namespace: %s \n", (*it).latin1() ); } for ( it = gd->classList.begin(); it != gd->classList.end(); ++it ) { msg( " class: %s \n", (*it).latin1() ); } for ( it = gd->fileList.begin(); it != gd->fileList.end(); ++it ) { msg( " file: %s \n", (*it).latin1() ); } for ( it = gd->subgroupList.begin(); it != gd->subgroupList.end(); ++it ) { msg( " subgroup: %s \n", (*it).latin1() ); } for ( it = gd->pageList.begin(); it != gd->pageList.end(); ++it ) { msg( " page: %s \n", (*it).latin1() ); } QListIterator<TagMemberInfo> mci(gd->members); TagMemberInfo *md; for (;(md=mci.current());++mci) { msg(" member:\n"); msg(" kind: `%s'\n",md->kind.data()); msg(" name: `%s'\n",md->name.data()); msg(" anchor: `%s'\n",md->anchor.data()); msg(" arglist: `%s'\n",md->arglist.data()); } } //============== PAGES QListIterator<TagPageInfo> lpi(m_tagFilePages); TagPageInfo *pd; for (;(pd=lpi.current());++lpi) { msg("page `%s'\n",pd->name.data()); msg(" title `%s'\n",pd->title.data()); msg(" filename `%s'\n",pd->filename.data()); }}void TagFileParser::addDocAnchors(Entry *e,QStrList &l){ char *s=l.first(); while (s) { QCString *anchorName = new QCString(s); //if (anchorName->left(5)=="_todo") //{ // int todoItemId = todoList.addRefItem(); // char anchorLabel[12]; // sprintf(anchorLabel,"_todo%06d",todoItemId); // RefItem *item = todoList.getRefItem(todoItemId); // item->listAnchor = anchorLabel; //} //else if (anchorName->left(5)=="_test") //{ // int testItemId = testList.addRefItem(); // char anchorLabel[12]; // sprintf(anchorLabel,"_test%06d",testItemId); // RefItem *item = testList.getRefItem(testItemId); // item->listAnchor = anchorLabel; //} //else //{ if (Doxygen::sectionDict.find(*anchorName)==0) { SectionInfo *si=new SectionInfo(*anchorName,*anchorName, SectionInfo::Anchor,m_tagName); Doxygen::sectionDict.insert(*anchorName,si); e->anchors->append(anchorName); } else { err("Duplicate anchor %s found\n",anchorName->data()); } //} s=l.next(); }}void TagFileParser::buildMemberList(Entry *ce,QList<TagMemberInfo> &members){ QListIterator<TagMemberInfo> mii(members); TagMemberInfo *tmi; for (;(tmi=mii.current());++mii) { Entry *me = new Entry; me->type = tmi->type; me->name = tmi->name; me->args = tmi->arglist; me->protection = tmi->prot; me->virt = tmi->virt; me->stat = tmi->isStatic; me->fileName = ce->fileName; addDocAnchors(me,tmi->docAnchors); TagInfo *ti = new TagInfo; ti->tagName = m_tagName; ti->anchor = tmi->anchor; me->tagInfo = ti; if (tmi->kind=="define") { me->type="#define"; me->section = Entry::DEFINE_SEC; } else if (tmi->kind=="enumvalue") { me->section = Entry::VARIABLE_SEC; me->mtype = Method; } else if (tmi->kind=="property") { me->section = Entry::FUNCTION_SEC; me->mtype = Property; } else if (tmi->kind=="variable") { me->section = Entry::VARIABLE_SEC; me->mtype = Method; } else if (tmi->kind=="typedef") { me->section = Entry::VARIABLE_SEC; //Entry::TYPEDEF_SEC; me->mtype = Method; } else if (tmi->kind=="enumeration") { me->section = Entry::ENUM_SEC; me->mtype = Method; } else if (tmi->kind=="function") { me->section = Entry::FUNCTION_SEC; me->mtype = Method; } else if (tmi->kind=="signal") { me->section = Entry::FUNCTION_SEC; me->mtype = Signal; } else if (tmi->kind=="prototype") { me->section = Entry::FUNCTION_SEC; me->mtype = Method; } else if (tmi->kind=="friend") { me->section = Entry::FUNCTION_SEC; me->mtype = Method; } else if (tmi->kind=="dcop") { me->section = Entry::FUNCTION_SEC; me->mtype = DCOP; } else if (tmi->kind=="slot") { me->section = Entry::FUNCTION_SEC; me->mtype = Slot; } ce->addSubEntry(me); }}static QString stripPath(const QString &s){ int i=s.findRev('/'); if (i!=-1) { return s.right(s.length()-i-1); } else { return s; }}/*! Injects the info gathered by the XML parser into the Entry tree. * This tree contains the information extracted from the input in a * "unrelated" form. */void TagFileParser::buildLists(Entry *root){ // build class list TagClassInfo *tci = m_tagFileClasses.first(); while (tci) { Entry *ce = new Entry; switch (tci->kind) { case TagClassInfo::Class: ce->section = Entry::CLASS_SEC; break; case TagClassInfo::Struct: ce->section = Entry::STRUCT_SEC; break; case TagClassInfo::Union: ce->section = Entry::UNION_SEC; break; case TagClassInfo::Interface: ce->section = Entry::INTERFACE_SEC; break; case TagClassInfo::Exception: ce->section = Entry::EXCEPTION_SEC; break; } ce->name = tci->name; addDocAnchors(ce,tci->docAnchors); TagInfo *ti = new TagInfo; ti->tagName = m_tagName; ti->fileName = tci->filename; ce->tagInfo = ti; // transfer base class list if (tci->bases) { ce->extends = tci->bases; tci->bases = 0; } if (tci->templateArguments) { if (ce->tArgLists==0) ce->tArgLists = new QList<ArgumentList>; ArgumentList *al = new ArgumentList; ce->tArgLists->append(al); QListIterator<QString> sli(*tci->templateArguments); QString *argName; for (;(argName=sli.current());++sli) { Argument *a = new Argument; a->type = "class"; a->name = *argName; al->append(a); } } buildMemberList(ce,tci->members); root->addSubEntry(ce); tci = m_tagFileClasses.next(); } // build file list TagFileInfo *tfi = m_tagFileFiles.first(); while (tfi) { Entry *fe = new Entry; fe->section = guessSection(tfi->name); fe->name = tfi->name; addDocAnchors(fe,tfi->docAnchors); TagInfo *ti = new TagInfo; ti->tagName = m_tagName; ti->fileName = tfi->filename; fe->tagInfo = ti; QString fullName = m_tagName+":"+tfi->path+stripPath(tfi->name); fe->fileName = fullName; FileDef *fd = new FileDef(m_tagName+":"+tfi->path,tfi->name,m_tagName); FileName *mn; if ((mn=Doxygen::inputNameDict->find(tfi->name))) { mn->append(fd); } else { mn = new FileName(fullName,tfi->name); mn->append(fd); Doxygen::inputNameList.inSort(mn); Doxygen::inputNameDict->insert(tfi->name,mn); } buildMemberList(fe,tfi->members); root->addSubEntry(fe); tfi = m_tagFileFiles.next(); } // build namespace list TagNamespaceInfo *tni = m_tagFileNamespaces.first(); while (tni) { Entry *ne = new Entry; ne->section = Entry::NAMESPACE_SEC; ne->name = tni->name; addDocAnchors(ne,tni->docAnchors); TagInfo *ti = new TagInfo; ti->tagName = m_tagName; ti->fileName = tni->filename; ne->tagInfo = ti; buildMemberList(ne,tni->members); root->addSubEntry(ne); tni = m_tagFileNamespaces.next(); } // build package list TagPackageInfo *tpgi = m_tagFilePackages.first(); while (tpgi) { Entry *pe = new Entry; pe->section = Entry::PACKAGE_SEC; pe->name = tpgi->name; addDocAnchors(pe,tpgi->docAnchors); TagInfo *ti = new TagInfo; ti->tagName = m_tagName; ti->fileName = tpgi->filename; pe->tagInfo = ti; buildMemberList(pe,tpgi->members); root->addSubEntry(pe); tpgi = m_tagFilePackages.next(); } // build group list TagGroupInfo *tgi = m_tagFileGroups.first(); while (tgi) { Entry *ge = new Entry; ge->section = Entry::GROUPDOC_SEC; ge->name = tgi->name; ge->type = tgi->title; addDocAnchors(ge,tgi->docAnchors); TagInfo *ti = new TagInfo; ti->tagName = m_tagName; ti->fileName = tgi->filename; ge->tagInfo = ti; buildMemberList(ge,tgi->members); root->addSubEntry(ge); tgi = m_tagFileGroups.next(); } // build page list TagPageInfo *tpi = m_tagFilePages.first(); while (tpi) { Entry *pe = new Entry; pe->section = Entry::PAGEDOC_SEC; pe->name = tpi->name; pe->args = tpi->title; addDocAnchors(pe,tpi->docAnchors); TagInfo *ti = new TagInfo; ti->tagName = m_tagName; ti->fileName = tpi->filename; pe->tagInfo = ti; root->addSubEntry(pe); tpi = m_tagFilePages.next(); }}void parseTagFile(Entry *root,const char *fullName,const char *tagName){ QFileInfo fi(fullName); if (!fi.exists()) return; TagFileParser handler( tagName ); TagFileErrorHandler errorHandler; QFile xmlFile( fullName ); QXmlInputSource source( xmlFile ); QXmlSimpleReader reader; reader.setContentHandler( &handler ); reader.setErrorHandler( &errorHandler ); reader.parse( source ); handler.buildLists(root);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -