From 31755d65806fda34a9b5f6b40dbfec54978d5b99 Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Sat, 16 Jan 2021 19:44:54 +0100 Subject: Refactoring: modernize IndexList::m_intfs --- src/doxygen.cpp | 10 +++++----- src/index.h | 26 ++++++++++++++------------ 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/doxygen.cpp b/src/doxygen.cpp index e7cb5d7..b7076d7 100644 --- a/src/doxygen.cpp +++ b/src/doxygen.cpp @@ -11576,11 +11576,11 @@ void generateOutput() bool generateQhp = Config_getBool(GENERATE_QHP); bool generateTreeView = Config_getBool(GENERATE_TREEVIEW); bool generateDocSet = Config_getBool(GENERATE_DOCSET); - if (generateEclipseHelp) Doxygen::indexList->addIndex(new EclipseHelp); - if (generateHtmlHelp) Doxygen::indexList->addIndex(new HtmlHelp); - if (generateQhp) Doxygen::indexList->addIndex(new Qhp); - if (generateTreeView) Doxygen::indexList->addIndex(new FTVHelp(TRUE)); - if (generateDocSet) Doxygen::indexList->addIndex(new DocSets); + if (generateEclipseHelp) Doxygen::indexList->addIndex(); + if (generateHtmlHelp) Doxygen::indexList->addIndex(); + if (generateQhp) Doxygen::indexList->addIndex(); + if (generateTreeView) Doxygen::indexList->addIndex(TRUE); + if (generateDocSet) Doxygen::indexList->addIndex(); Doxygen::indexList->initialize(); HtmlGenerator::writeTabData(); } diff --git a/src/index.h b/src/index.h index 5088c46..e11304e 100644 --- a/src/index.h +++ b/src/index.h @@ -1,8 +1,6 @@ /****************************************************************************** * - * - * - * Copyright (C) 1997-2015 by Dimitri van Heesch. + * Copyright (C) 1997-2021 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 @@ -19,7 +17,9 @@ #define INDEX_H #include -#include +#include +#include + #include class Definition; @@ -55,7 +55,7 @@ class IndexIntf class IndexList : public IndexIntf { private: - QList m_intfs; + std::vector< std::unique_ptr > m_intfs; // For each index format we forward the method call. // We use C++11 variadic templates and perfect forwarding to implement foreach() generically, @@ -63,19 +63,21 @@ class IndexList : public IndexIntf template void foreach(void (IndexIntf::*methodPtr)(Ts...),As&&... args) { - QListIterator li(m_intfs); - for (li.toFirst();li.current();++li) + for (const auto &intf : m_intfs) { - (li.current()->*methodPtr)(std::forward(args)...); + (intf.get()->*methodPtr)(std::forward(args)...); } } public: /** Creates a list of indexes */ - IndexList() { m_intfs.setAutoDelete(TRUE); m_enabled=TRUE; } - /** Add an index generator to the list */ - void addIndex(IndexIntf *intf) - { m_intfs.append(intf); } + IndexList() { m_enabled=TRUE; } + + /** Add an index generator to the list, using a syntax similar to std::make_unique() */ + template + void addIndex(As&&... args) + { m_intfs.push_back(std::make_unique(std::forward(args)...)); } + void disable() { m_enabled = FALSE; } void enable() -- cgit v0.12