diff options
author | Dimitri van Heesch <doxygen@gmail.com> | 2021-04-29 17:26:11 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-29 17:26:11 (GMT) |
commit | b8a3ff6c33264c43cdf30c04baa9793e7e8d51a2 (patch) | |
tree | 9d60ced4b8fceb00c068b56d699c1ba57540d415 /src/perlmodgen.cpp | |
parent | 4dba9fbdda10889d2285b85b7e9ff6282b34fccf (diff) | |
parent | c6d77227efaf332a5d24bc12d32f4b1fec6b13b9 (diff) | |
download | Doxygen-b8a3ff6c33264c43cdf30c04baa9793e7e8d51a2.zip Doxygen-b8a3ff6c33264c43cdf30c04baa9793e7e8d51a2.tar.gz Doxygen-b8a3ff6c33264c43cdf30c04baa9793e7e8d51a2.tar.bz2 |
Merge branch 'master' into feature/bug_305773
Diffstat (limited to 'src/perlmodgen.cpp')
-rw-r--r-- | src/perlmodgen.cpp | 482 |
1 files changed, 219 insertions, 263 deletions
diff --git a/src/perlmodgen.cpp b/src/perlmodgen.cpp index 854b3df..3954daa 100644 --- a/src/perlmodgen.cpp +++ b/src/perlmodgen.cpp @@ -18,11 +18,10 @@ */ #include <stdlib.h> +#include <stack> -#include <qdir.h> -#include <qstack.h> -#include <qdict.h> -#include <qfile.h> +#include <fstream> +#include <iostream> #include "perlmodgen.h" #include "docparser.h" @@ -30,7 +29,6 @@ #include "doxygen.h" #include "pagedef.h" #include "memberlist.h" -#include "ftextstream.h" #include "arguments.h" #include "config.h" #include "groupdef.h" @@ -44,63 +42,58 @@ #include "util.h" #include "htmlentity.h" #include "emoji.h" +#include "dir.h" #define PERLOUTPUT_MAX_INDENTATION 40 class PerlModOutputStream { -public: - - QCString m_s; - FTextStream *m_t; + public: + //QCString m_s; + std::ostream &m_t; - PerlModOutputStream(FTextStream *t = 0) : m_t(t) { } + PerlModOutputStream(std::ostream &t) : m_t(t) { } - void add(char c); - void add(const char *s); - void add(QCString &s); - void add(int n); - void add(unsigned int n); + void add(char c); + void add(const QCString &s); + void add(int n); + void add(unsigned int n); }; void PerlModOutputStream::add(char c) { - if (m_t != 0) - (*m_t) << c; - else - m_s += c; -} - -void PerlModOutputStream::add(const char *s) -{ - if (m_t != 0) - (*m_t) << s; - else - m_s += s; + m_t << c; + //if (m_t != 0) + // (*m_t) << c; + //else + // m_s += c; } -void PerlModOutputStream::add(QCString &s) +void PerlModOutputStream::add(const QCString &s) { - if (m_t != 0) - (*m_t) << s; - else - m_s += s; + m_t << s; + //if (m_t != 0) + // (*m_t) << s; + //else + // m_s += s; } void PerlModOutputStream::add(int n) { - if (m_t != 0) - (*m_t) << n; - else - m_s += QCString().setNum(n); + m_t << n; + //if (m_t != 0) + // (*m_t) << n; + //else + // m_s += QCString().setNum(n); } void PerlModOutputStream::add(unsigned int n) { - if (m_t != 0) - (*m_t) << n; - else - m_s += QCString().setNum(n); + m_t << n; + //if (m_t != 0) + // (*m_t) << n; + //else + // m_s += QCString().setNum(n); } class PerlModOutput @@ -119,8 +112,8 @@ public: inline void setPerlModOutputStream(PerlModOutputStream *os) { m_stream = os; } - inline PerlModOutput &openSave() { iopenSave(); return *this; } - inline PerlModOutput &closeSave(QCString &s) { icloseSave(s); return *this; } + //inline PerlModOutput &openSave() { iopenSave(); return *this; } + //inline PerlModOutput &closeSave(QCString &s) { icloseSave(s); return *this; } inline PerlModOutput &continueBlock() { @@ -133,12 +126,12 @@ public: } inline PerlModOutput &add(char c) { m_stream->add(c); return *this; } - inline PerlModOutput &add(const char *s) { m_stream->add(s); return *this; } + inline PerlModOutput &add(const QCString &s) { m_stream->add(s); return *this; } inline PerlModOutput &add(QCString &s) { m_stream->add(s); return *this; } inline PerlModOutput &add(int n) { m_stream->add(n); return *this; } inline PerlModOutput &add(unsigned int n) { m_stream->add(n); return *this; } - PerlModOutput &addQuoted(const char *s) { iaddQuoted(s); return *this; } + PerlModOutput &addQuoted(const QCString &s) { iaddQuoted(s); return *this; } inline PerlModOutput &indent() { @@ -149,41 +142,41 @@ public: return *this; } - inline PerlModOutput &open(char c, const char *s = 0) { iopen(c, s); return *this; } + inline PerlModOutput &open(char c, const QCString &s = QCString()) { iopen(c, s); return *this; } inline PerlModOutput &close(char c = 0) { iclose(c); return *this; } - inline PerlModOutput &addField(const char *s) { iaddField(s); return *this; } - inline PerlModOutput &addFieldQuotedChar(const char *field, char content) + inline PerlModOutput &addField(const QCString &s) { iaddField(s); return *this; } + inline PerlModOutput &addFieldQuotedChar(const QCString &field, char content) { iaddFieldQuotedChar(field, content); return *this; } - inline PerlModOutput &addFieldQuotedString(const char *field, const char *content) + inline PerlModOutput &addFieldQuotedString(const QCString &field, const QCString &content) { iaddFieldQuotedString(field, content); return *this; } - inline PerlModOutput &addFieldBoolean(const char *field, bool content) + inline PerlModOutput &addFieldBoolean(const QCString &field, bool content) { return addFieldQuotedString(field, content ? "yes" : "no"); } - inline PerlModOutput &openList(const char *s = 0) { open('[', s); return *this; } + inline PerlModOutput &openList(const QCString &s = QCString()) { open('[', s); return *this; } inline PerlModOutput &closeList() { close(']'); return *this; } - inline PerlModOutput &openHash(const char *s = 0 ) { open('{', s); return *this; } + inline PerlModOutput &openHash(const QCString &s = QCString() ) { open('{', s); return *this; } inline PerlModOutput &closeHash() { close('}'); return *this; } protected: - void iopenSave(); - void icloseSave(QCString &); + //void iopenSave(); + //void icloseSave(QCString &); void incIndent(); void decIndent(); - void iaddQuoted(const char *); - void iaddFieldQuotedChar(const char *, char); - void iaddFieldQuotedString(const char *, const char *); - void iaddField(const char *); + void iaddQuoted(const QCString &); + void iaddFieldQuotedChar(const QCString &, char); + void iaddFieldQuotedString(const QCString &, const QCString &); + void iaddField(const QCString &); - void iopen(char, const char *); + void iopen(char, const QCString &); void iclose(char); private: @@ -192,22 +185,23 @@ private: int m_indentation; bool m_blockstart; - QStack<PerlModOutputStream> m_saved; + //std::stack<PerlModOutputStream*> m_saved; char m_spaces[PERLOUTPUT_MAX_INDENTATION * 2 + 2]; }; -void PerlModOutput::iopenSave() -{ - m_saved.push(m_stream); - m_stream = new PerlModOutputStream(); -} +//void PerlModOutput::iopenSave() +//{ +// m_saved.push(m_stream); +// m_stream = new PerlModOutputStream(); +//} -void PerlModOutput::icloseSave(QCString &s) -{ - s = m_stream->m_s; - delete m_stream; - m_stream = m_saved.pop(); -} +//void PerlModOutput::icloseSave(QCString &s) +//{ +// s = m_stream->m_s; +// delete m_stream; +// m_stream = m_saved.top(); +// m_saved.pop(); +//} void PerlModOutput::incIndent() { @@ -226,24 +220,29 @@ void PerlModOutput::decIndent() m_spaces[m_indentation * 2] = 0; } -void PerlModOutput::iaddQuoted(const char *s) +void PerlModOutput::iaddQuoted(const QCString &str) { + if (str.isEmpty()) return; + const char *s = str.data(); char c; - while ((c = *s++) != 0) { + while ((c = *s++) != 0) + { if ((c == '\'') || (c == '\\')) + { m_stream->add('\\'); + } m_stream->add(c); } } -void PerlModOutput::iaddField(const char *s) +void PerlModOutput::iaddField(const QCString &s) { continueBlock(); m_stream->add(s); m_stream->add(m_pretty ? " => " : "=>"); } -void PerlModOutput::iaddFieldQuotedChar(const char *field, char content) +void PerlModOutput::iaddFieldQuotedChar(const QCString &field, char content) { iaddField(field); m_stream->add('\''); @@ -253,7 +252,7 @@ void PerlModOutput::iaddFieldQuotedChar(const char *field, char content) m_stream->add('\''); } -void PerlModOutput::iaddFieldQuotedString(const char *field, const char *content) +void PerlModOutput::iaddFieldQuotedString(const QCString &field, const QCString &content) { if (content == 0) return; @@ -263,7 +262,7 @@ void PerlModOutput::iaddFieldQuotedString(const char *field, const char *content m_stream->add('\''); } -void PerlModOutput::iopen(char c, const char *s) +void PerlModOutput::iopen(char c, const QCString &s) { if (s != 0) iaddField(s); @@ -409,13 +408,13 @@ private: void enterText(); void leaveText(); - void openItem(const char *); + void openItem(const QCString &); void closeItem(); - void singleItem(const char *); - void openSubBlock(const char * = 0); + void singleItem(const QCString &); + void openSubBlock(const QCString & = QCString()); void closeSubBlock(); - void openOther(); - void closeOther(); + //void openOther(); + //void closeOther(); //-------------------------------------- // state variables @@ -448,7 +447,7 @@ void PerlModDocVisitor::addLink(const QCString &,const QCString &file,const QCSt m_output.addFieldQuotedString("link", link); } -void PerlModDocVisitor::openItem(const char *name) +void PerlModDocVisitor::openItem(const QCString &name) { leaveText(); m_output.openHash().addFieldQuotedString("type", name); @@ -479,13 +478,13 @@ void PerlModDocVisitor::leaveText() .closeHash(); } -void PerlModDocVisitor::singleItem(const char *name) +void PerlModDocVisitor::singleItem(const QCString &name) { openItem(name); closeItem(); } -void PerlModDocVisitor::openSubBlock(const char *s) +void PerlModDocVisitor::openSubBlock(const QCString &s) { leaveText(); m_output.openList(s); @@ -498,18 +497,18 @@ void PerlModDocVisitor::closeSubBlock() m_output.closeList(); } -void PerlModDocVisitor::openOther() -{ +//void PerlModDocVisitor::openOther() +//{ // Using a secondary text stream will corrupt the perl file. Instead of // printing doc => [ data => [] ], it will print doc => [] data => []. /* leaveText(); m_output.openSave(); */ -} +//} -void PerlModDocVisitor::closeOther() -{ +//void PerlModDocVisitor::closeOther() +//{ // Using a secondary text stream will corrupt the perl file. Instead of // printing doc => [ data => [] ], it will print doc => [] data => []. /* @@ -518,7 +517,7 @@ void PerlModDocVisitor::closeOther() m_output.closeSave(other); m_other += other; */ -} +//} void PerlModDocVisitor::visit(DocWord *w) { @@ -688,9 +687,7 @@ void PerlModDocVisitor::visit(DocVerbatim *s) if (s->hasCaption()) { openSubBlock("caption"); - QListIterator<DocNode> cli(s->children()); - DocNode *n; - for (cli.toFirst();(n=cli.current());++cli) n->accept(this); + for (const auto &n : s->children()) n->accept(this); closeSubBlock(); } m_output.addFieldQuotedString("content", s->text()); @@ -711,23 +708,8 @@ void PerlModDocVisitor::visit(DocInclude *inc) switch(inc->type()) { case DocInclude::IncWithLines: - #if 0 - { - m_t << "<div class=\"fragment\"><pre>"; - QFileInfo cfi( inc->file() ); - FileDef fd( cfi.dirPath(), cfi.fileName() ); - parseCode(m_ci,inc->context(),inc->text().latin1(),inc->isExample(),inc->exampleFile(), &fd); - m_t << "</pre></div>"; - } - break; - #endif return; case DocInclude::Include: -#if 0 - m_output.add("<programlisting>"); - parseCode(m_ci,inc->context(),inc->text(),FALSE,0); - m_output.add("</programlisting>"); -#endif return; case DocInclude::DontInclude: return; case DocInclude::DontIncWithLines: return; @@ -891,14 +873,14 @@ void PerlModDocVisitor::visitPre(DocSimpleSect *s) } leaveText(); m_output.openHash(); - openOther(); + //openOther(); openSubBlock(type); } void PerlModDocVisitor::visitPost(DocSimpleSect *) { closeSubBlock(); - closeOther(); + //closeOther(); m_output.closeHash(); } @@ -948,6 +930,17 @@ void PerlModDocVisitor::visitPre(DocHtmlList *l) { openItem("list"); m_output.addFieldQuotedString("style", (l->type() == DocHtmlList::Ordered) ? "ordered" : "itemized"); + for (const auto &opt : l->attribs()) + { + if (opt.name=="type") + { + m_output.addFieldQuotedString("list_type", qPrint(opt.value)); + } + if (opt.name=="start") + { + m_output.addFieldQuotedString("start", qPrint(opt.value)); + } + } openSubBlock("content"); } @@ -1278,14 +1271,14 @@ void PerlModDocVisitor::visitPre(DocParamSect *s) break; } m_output.openHash(); - openOther(); + //openOther(); openSubBlock(type); } void PerlModDocVisitor::visitPost(DocParamSect *) { closeSubBlock(); - closeOther(); + //closeOther(); m_output.closeHash(); } @@ -1294,25 +1287,21 @@ void PerlModDocVisitor::visitPre(DocParamList *pl) leaveText(); m_output.openHash() .openList("parameters"); - //QStrListIterator li(pl->parameters()); - //const char *s; - QListIterator<DocNode> li(pl->parameters()); - DocNode *param; - for (li.toFirst();(param=li.current());++li) + for (const auto ¶m : pl->parameters()) { QCString name; if (param->kind()==DocNode::Kind_Word) { - name = ((DocWord*)param)->word(); + name = ((DocWord*)param.get())->word(); } else if (param->kind()==DocNode::Kind_LinkedWord) { - name = ((DocLinkedWord*)param)->word(); + name = ((DocLinkedWord*)param.get())->word(); } QCString dir = ""; DocParamSect *sect = 0; - if (pl->parent()->kind()==DocNode::Kind_ParamSect) + if (pl->parent() && pl->parent()->kind()==DocNode::Kind_ParamSect) { sect=(DocParamSect*)pl->parent(); } @@ -1380,7 +1369,7 @@ void PerlModDocVisitor::visitPost(DocXRefItem *x) void PerlModDocVisitor::visitPre(DocInternalRef *ref) { openItem("ref"); - addLink(0,ref->file(),ref->anchor()); + addLink(QCString(),ref->file(),ref->anchor()); openSubBlock("content"); } @@ -1427,7 +1416,7 @@ void PerlModDocVisitor::visitPost(DocParBlock *) } -static void addTemplateArgumentList(const ArgumentList &al,PerlModOutput &output,const char *) +static void addTemplateArgumentList(const ArgumentList &al,PerlModOutput &output,const QCString &) { if (!al.hasParameters()) return; output.openList("template_parameters"); @@ -1451,8 +1440,13 @@ static void addTemplateList(const ClassDef *cd,PerlModOutput &output) addTemplateArgumentList(cd->templateArguments(),output,cd->name()); } +static void addTemplateList(const ConceptDef *cd,PerlModOutput &output) +{ + addTemplateArgumentList(cd->getTemplateParameterList(),output,cd->name()); +} + static void addPerlModDocBlock(PerlModOutput &output, - const char *name, + const QCString &name, const QCString &fileName, int lineNr, const Definition *scope, @@ -1464,7 +1458,7 @@ static void addPerlModDocBlock(PerlModOutput &output, output.addField(name).add("{}"); else { DocNode *root = validatingParseDoc(fileName,lineNr,scope,md,stext,FALSE,FALSE, - 0,FALSE,FALSE,Config_getBool(MARKDOWN_SUPPORT)); + QCString(),FALSE,FALSE,Config_getBool(MARKDOWN_SUPPORT)); output.openHash(name); PerlModDocVisitor *visitor = new PerlModDocVisitor(output); root->accept(visitor); @@ -1504,7 +1498,7 @@ static QCString pathDoxyExec; void setPerlModDoxyfile(const QCString &qs) { pathDoxyfile = qs; - pathDoxyExec = QDir::currentDirPath().utf8(); + pathDoxyExec = Dir::currentDirPath(); } class PerlModGenerator @@ -1531,16 +1525,18 @@ public: void generatePerlModForMember(const MemberDef *md, const Definition *); void generatePerlUserDefinedSection(const Definition *d, const MemberGroupList &mgl); void generatePerlModSection(const Definition *d, MemberList *ml, - const char *name, const char *header=0); + const QCString &name, const QCString &header=QCString()); void addListOfAllMembers(const ClassDef *cd); + void addIncludeInfo(const IncludeInfo *ii); void generatePerlModForClass(const ClassDef *cd); + void generatePerlModForConcept(const ConceptDef *cd); void generatePerlModForNamespace(const NamespaceDef *nd); void generatePerlModForFile(const FileDef *fd); void generatePerlModForGroup(const GroupDef *gd); void generatePerlModForPage(PageDef *pi); - bool createOutputFile(QFile &f, const char *s); - bool createOutputDir(QDir &perlModDir); + bool createOutputFile(std::ofstream &f, const QCString &s); + bool createOutputDir(Dir &perlModDir); bool generateDoxyLatexTex(); bool generateDoxyFormatTex(); bool generateDoxyStructurePM(); @@ -1671,18 +1667,16 @@ void PerlModGenerator::generatePerlModForMember(const MemberDef *md,const Defini if (!md->initializer().isEmpty()) m_output.addFieldQuotedString("initializer", md->initializer()); - if (md->excpString()) + if (!md->excpString().isEmpty()) m_output.addFieldQuotedString("exceptions", md->excpString()); if (md->memberType()==MemberType_Enumeration) // enum { - const MemberList *enumFields = md->enumFieldList(); - if (enumFields) + const MemberList &enumFields = md->enumFieldList(); + if (!enumFields.empty()) { m_output.openList("values"); - MemberListIterator emli(*enumFields); - const MemberDef *emd; - for (emli.toFirst();(emd=emli.current());++emli) + for (const auto &emd : enumFields) { m_output.openHash() .addFieldQuotedString("name", emd->name()); @@ -1700,7 +1694,7 @@ void PerlModGenerator::generatePerlModForMember(const MemberDef *md,const Defini } } - if (md->memberType() == MemberType_Variable && md->bitfieldString()) + if (md->memberType() == MemberType_Variable && !md->bitfieldString().isEmpty()) { QCString bitfield = md->bitfieldString(); if (bitfield.at(0) == ':') bitfield = bitfield.mid(1); @@ -1713,14 +1707,13 @@ void PerlModGenerator::generatePerlModForMember(const MemberDef *md,const Defini .addFieldQuotedString("name", rmd->name()) .closeHash(); - MemberList *rbml = md->reimplementedBy(); - if (rbml) + const MemberList &rbml = md->reimplementedBy(); + if (!rbml.empty()) { - MemberListIterator mli(*rbml); m_output.openList("reimplemented_by"); - for (mli.toFirst();(rmd=mli.current());++mli) + for (const auto &rbmd : rbml) m_output.openHash() - .addFieldQuotedString("name", rmd->name()) + .addFieldQuotedString("name", rbmd->name()) .closeHash(); m_output.closeList(); } @@ -1729,19 +1722,17 @@ void PerlModGenerator::generatePerlModForMember(const MemberDef *md,const Defini } void PerlModGenerator::generatePerlModSection(const Definition *d, - MemberList *ml,const char *name,const char *header) + MemberList *ml,const QCString &name,const QCString &header) { if (ml==0) return; // empty list m_output.openHash(name); - if (header) + if (!header.isEmpty()) m_output.addFieldQuotedString("header", header); m_output.openList("members"); - MemberListIterator mli(*ml); - const MemberDef *md; - for (mli.toFirst();(md=mli.current());++mli) + for (const auto &md : *ml) { generatePerlModForMember(md,d); } @@ -1784,15 +1775,15 @@ void PerlModGenerator::generatePerlUserDefinedSection(const Definition *d, const for (const auto &mg : mgl) { m_output.openHash(); - if (mg->header()) + if (!mg->header().isEmpty()) + { m_output.addFieldQuotedString("header", mg->header()); + } - if (mg->members()) + if (!mg->members().empty()) { m_output.openList("members"); - MemberListIterator mli(*mg->members()); - const MemberDef *md; - for (mli.toFirst(); (md = mli.current()); ++mli) + for (const auto &md : mg->members()) { generatePerlModForMember(md, d); } @@ -1804,6 +1795,22 @@ void PerlModGenerator::generatePerlUserDefinedSection(const Definition *d, const } } +void PerlModGenerator::addIncludeInfo(const IncludeInfo *ii) +{ + if (ii) + { + QCString nm = ii->includeName; + if (nm.isEmpty() && ii->fileDef) nm = ii->fileDef->docName(); + if (!nm.isEmpty()) + { + m_output.openHash("includes"); + m_output.addFieldBoolean("local", ii->local) + .addFieldQuotedString("name", nm) + .closeHash(); + } + } +} + void PerlModGenerator::generatePerlModForClass(const ClassDef *cd) { // + brief description @@ -1868,23 +1875,7 @@ void PerlModGenerator::generatePerlModForClass(const ClassDef *cd) m_output.closeList(); } - IncludeInfo *ii=cd->includeInfo(); - if (ii) - { - QCString nm = ii->includeName; - if (nm.isEmpty() && ii->fileDef) nm = ii->fileDef->docName(); - if (!nm.isEmpty()) - { - m_output.openHash("includes"); -#if 0 - if (ii->fileDef && !ii->fileDef->isReference()) // TODO: support external references - t << " id=\"" << ii->fileDef->getOutputFileBase() << "\""; -#endif - m_output.addFieldBoolean("local", ii->local) - .addFieldQuotedString("name", nm) - .closeHash(); - } - } + addIncludeInfo(cd->includeInfo()); addTemplateList(cd,m_output); addListOfAllMembers(cd); @@ -1946,6 +1937,22 @@ void PerlModGenerator::generatePerlModForClass(const ClassDef *cd) m_output.closeHash(); } +void PerlModGenerator::generatePerlModForConcept(const ConceptDef *cd) +{ + if (cd->isReference()) return; // skip external references + + m_output.openHash() + .addFieldQuotedString("name", cd->name()); + + addIncludeInfo(cd->includeInfo()); + addTemplateList(cd,m_output); + m_output.addFieldQuotedString("initializer", cd->initializer()); + addPerlModDocBlock(m_output,"brief",cd->getDefFileName(),cd->getDefLine(),0,0,cd->briefDescription()); + addPerlModDocBlock(m_output,"detailed",cd->getDefFileName(),cd->getDefLine(),0,0,cd->documentation()); + + m_output.closeHash(); +} + void PerlModGenerator::generatePerlModForNamespace(const NamespaceDef *nd) { // + contained class definitions @@ -2018,38 +2025,29 @@ void PerlModGenerator::generatePerlModForFile(const FileDef *fd) m_output.openHash() .addFieldQuotedString("name", fd->name()); - IncludeInfo *inc; m_output.openList("includes"); - if (fd->includeFileList()) + for (const auto &inc: fd->includeFileList()) { - QListIterator<IncludeInfo> ili1(*fd->includeFileList()); - for (ili1.toFirst();(inc=ili1.current());++ili1) + m_output.openHash() + .addFieldQuotedString("name", inc.includeName); + if (inc.fileDef && !inc.fileDef->isReference()) { - m_output.openHash() - .addFieldQuotedString("name", inc->includeName); - if (inc->fileDef && !inc->fileDef->isReference()) - { - m_output.addFieldQuotedString("ref", inc->fileDef->getOutputFileBase()); - } - m_output.closeHash(); + m_output.addFieldQuotedString("ref", inc.fileDef->getOutputFileBase()); } + m_output.closeHash(); } m_output.closeList(); m_output.openList("included_by"); - if (fd->includedByFileList()) + for (const auto &inc : fd->includedByFileList()) { - QListIterator<IncludeInfo> ili2(*fd->includedByFileList()); - for (ili2.toFirst();(inc=ili2.current());++ili2) + m_output.openHash() + .addFieldQuotedString("name", inc.includeName); + if (inc.fileDef && !inc.fileDef->isReference()) { - m_output.openHash() - .addFieldQuotedString("name", inc->includeName); - if (inc->fileDef && !inc->fileDef->isReference()) - { - m_output.addFieldQuotedString("ref", inc->fileDef->getOutputFileBase()); - } - m_output.closeHash(); + m_output.addFieldQuotedString("ref", inc.fileDef->getOutputFileBase()); } + m_output.closeHash(); } m_output.closeList(); @@ -2088,13 +2086,10 @@ void PerlModGenerator::generatePerlModForGroup(const GroupDef *gd) .addFieldQuotedString("name", gd->name()) .addFieldQuotedString("title", gd->groupTitle()); - FileList *fl = gd->getFiles(); - if (fl) + if (!gd->getFiles().empty()) { m_output.openList("files"); - QListIterator<FileDef> fli(*fl); - const FileDef *fd; - for (fli.toFirst();(fd=fli.current());++fli) + for (const auto &fd : gd->getFiles()) m_output.openHash() .addFieldQuotedString("name", fd->name()) .closeHash(); @@ -2169,7 +2164,7 @@ void PerlModGenerator::generatePerlModForPage(PageDef *pd) const SectionInfo *si = SectionManager::instance().find(pd->name()); if (si) - m_output.addFieldQuotedString("title4", filterTitle(si->title())); + m_output.addFieldQuotedString("title4", filterTitle(si->title().str())); addPerlModDocBlock(m_output,"detailed",pd->docFile(),pd->docLine(),0,0,pd->documentation()); m_output.closeHash(); @@ -2177,12 +2172,11 @@ void PerlModGenerator::generatePerlModForPage(PageDef *pd) bool PerlModGenerator::generatePerlModOutput() { - QFile outputFile; - if (!createOutputFile(outputFile, pathDoxyDocsPM)) + std::ofstream outputFileStream; + if (!createOutputFile(outputFileStream, pathDoxyDocsPM)) return false; - FTextStream outputTextStream(&outputFile); - PerlModOutputStream outputStream(&outputTextStream); + PerlModOutputStream outputStream(outputFileStream); m_output.setPerlModOutputStream(&outputStream); m_output.add("$doxydocs=").openHash(); @@ -2191,6 +2185,11 @@ bool PerlModGenerator::generatePerlModOutput() generatePerlModForClass(cd.get()); m_output.closeList(); + m_output.openList("concepts"); + for (const auto &cd : *Doxygen::conceptLinkedMap) + generatePerlModForConcept(cd.get()); + m_output.closeList(); + m_output.openList("namespaces"); for (const auto &nd : *Doxygen::namespaceLinkedMap) generatePerlModForNamespace(nd.get()); @@ -2228,56 +2227,20 @@ bool PerlModGenerator::generatePerlModOutput() return true; } -bool PerlModGenerator::createOutputFile(QFile &f, const char *s) +bool PerlModGenerator::createOutputFile(std::ofstream &f, const QCString &s) { - f.setName(s); - if (!f.open(IO_WriteOnly)) + f.open(s.str(),std::ofstream::out | std::ofstream::binary); + if (!f.is_open()) { - err("Cannot open file %s for writing!\n", s); + err("Cannot open file %s for writing!\n", qPrint(s)); return false; } return true; } -bool PerlModGenerator::createOutputDir(QDir &perlModDir) +bool PerlModGenerator::createOutputDir(Dir &perlModDir) { - QCString outputDirectory = Config_getString(OUTPUT_DIRECTORY); - if (outputDirectory.isEmpty()) - { - outputDirectory=QDir::currentDirPath().utf8(); - } - else - { - QDir dir(outputDirectory); - if (!dir.exists()) - { - dir.setPath(QDir::currentDirPath()); - if (!dir.mkdir(outputDirectory)) - { - term("tag OUTPUT_DIRECTORY: Output directory '%s' does not " - "exist and cannot be created\n",outputDirectory.data()); - } - else - { - msg("Notice: Output directory '%s' does not exist. " - "I have created it for you.\n", outputDirectory.data()); - } - dir.cd(outputDirectory); - } - outputDirectory=dir.absPath().utf8(); - } - - QDir dir(outputDirectory); - if (!dir.exists()) - { - dir.setPath(QDir::currentDirPath()); - if (!dir.mkdir(outputDirectory)) - { - err("Cannot create directory %s\n",outputDirectory.data()); - return false; - } - } - + std::string outputDirectory = Config_getString(OUTPUT_DIRECTORY).str(); perlModDir.setPath(outputDirectory+"/perlmod"); if (!perlModDir.exists() && !perlModDir.mkdir(outputDirectory+"/perlmod")) { @@ -2289,11 +2252,10 @@ bool PerlModGenerator::createOutputDir(QDir &perlModDir) bool PerlModGenerator::generateDoxyStructurePM() { - QFile doxyModelPM; - if (!createOutputFile(doxyModelPM, pathDoxyStructurePM)) + std::ofstream doxyModelPMStream; + if (!createOutputFile(doxyModelPMStream, pathDoxyStructurePM)) return false; - FTextStream doxyModelPMStream(&doxyModelPM); doxyModelPMStream << "sub memberlist($) {\n" " my $prefix = $_[0];\n" @@ -2473,14 +2435,13 @@ bool PerlModGenerator::generateDoxyStructurePM() bool PerlModGenerator::generateDoxyRules() { - QFile doxyRules; - if (!createOutputFile(doxyRules, pathDoxyRules)) + std::ofstream doxyRulesStream; + if (!createOutputFile(doxyRulesStream, pathDoxyRules)) return false; bool perlmodLatex = Config_getBool(PERLMOD_LATEX); QCString prefix = Config_getString(PERLMOD_MAKEVAR_PREFIX); - FTextStream doxyRulesStream(&doxyRules); doxyRulesStream << prefix << "DOXY_EXEC_PATH = " << pathDoxyExec << "\n" << prefix << "DOXYFILE = " << pathDoxyfile << "\n" << @@ -2570,14 +2531,13 @@ bool PerlModGenerator::generateDoxyRules() bool PerlModGenerator::generateMakefile() { - QFile makefile; - if (!createOutputFile(makefile, pathMakefile)) + std::ofstream makefileStream; + if (!createOutputFile(makefileStream, pathMakefile)) return false; bool perlmodLatex = Config_getBool(PERLMOD_LATEX); QCString prefix = Config_getString(PERLMOD_MAKEVAR_PREFIX); - FTextStream makefileStream(&makefile); makefileStream << ".PHONY: default clean" << (perlmodLatex ? " pdf" : "") << "\n" "default: " << (perlmodLatex ? "pdf" : "clean") << "\n" @@ -2597,11 +2557,10 @@ bool PerlModGenerator::generateMakefile() bool PerlModGenerator::generateDoxyLatexStructurePL() { - QFile doxyLatexStructurePL; - if (!createOutputFile(doxyLatexStructurePL, pathDoxyLatexStructurePL)) + std::ofstream doxyLatexStructurePLStream; + if (!createOutputFile(doxyLatexStructurePLStream, pathDoxyLatexStructurePL)) return false; - FTextStream doxyLatexStructurePLStream(&doxyLatexStructurePL); doxyLatexStructurePLStream << "use DoxyStructure;\n" "\n" @@ -2631,11 +2590,10 @@ bool PerlModGenerator::generateDoxyLatexStructurePL() bool PerlModGenerator::generateDoxyLatexPL() { - QFile doxyLatexPL; - if (!createOutputFile(doxyLatexPL, pathDoxyLatexPL)) + std::ofstream doxyLatexPLStream; + if (!createOutputFile(doxyLatexPLStream, pathDoxyLatexPL)) return false; - FTextStream doxyLatexPLStream(&doxyLatexPL); doxyLatexPLStream << "use DoxyStructure;\n" "use DoxyDocs;\n" @@ -2754,11 +2712,10 @@ bool PerlModGenerator::generateDoxyLatexPL() bool PerlModGenerator::generateDoxyFormatTex() { - QFile doxyFormatTex; - if (!createOutputFile(doxyFormatTex, pathDoxyFormatTex)) + std::ofstream doxyFormatTexStream; + if (!createOutputFile(doxyFormatTexStream, pathDoxyFormatTex)) return false; - FTextStream doxyFormatTexStream(&doxyFormatTex); doxyFormatTexStream << "\\def\\Defcs#1{\\long\\expandafter\\def\\csname#1\\endcsname}\n" "\\Defcs{Empty}{}\n" @@ -2917,11 +2874,10 @@ bool PerlModGenerator::generateDoxyFormatTex() bool PerlModGenerator::generateDoxyLatexTex() { - QFile doxyLatexTex; - if (!createOutputFile(doxyLatexTex, pathDoxyLatexTex)) + std::ofstream doxyLatexTexStream; + if (!createOutputFile(doxyLatexTexStream, pathDoxyLatexTex)) return false; - FTextStream doxyLatexTexStream(&doxyLatexTex); doxyLatexTexStream << "\\documentclass[a4paper,12pt]{article}\n" "\\usepackage[latin1]{inputenc}\n" @@ -2951,13 +2907,13 @@ void PerlModGenerator::generate() // + related pages // - examples - QDir perlModDir; + Dir perlModDir; if (!createOutputDir(perlModDir)) return; bool perlmodLatex = Config_getBool(PERLMOD_LATEX); - QCString perlModAbsPath = perlModDir.absPath().utf8(); + QCString perlModAbsPath = perlModDir.absPath(); pathDoxyDocsPM = perlModAbsPath + "/DoxyDocs.pm"; pathDoxyStructurePM = perlModAbsPath + "/DoxyStructure.pm"; pathMakefile = perlModAbsPath + "/Makefile"; |