diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2021-10-15 11:15:28 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2021-10-15 11:15:28 +0900 |
commit | 4aa4e498d10e343b3b2a49e06195f62a49120002 (patch) | |
tree | ff9645788017052b9d83d196cc25bddcfcf1708b /src/parserintf.h | |
parent | fd5021ef77ddac91004a2b9c549e08ea952bce89 (diff) | |
download | doxygen-upstream/1.9.0.tar.gz doxygen-upstream/1.9.0.tar.bz2 doxygen-upstream/1.9.0.zip |
Imported Upstream version 1.9.0upstream/1.9.0
Diffstat (limited to 'src/parserintf.h')
-rw-r--r-- | src/parserintf.h | 55 |
1 files changed, 38 insertions, 17 deletions
diff --git a/src/parserintf.h b/src/parserintf.h index 911b707..2fde2f1 100644 --- a/src/parserintf.h +++ b/src/parserintf.h @@ -137,6 +137,7 @@ class CodeParserInterface //----------------------------------------------------------------------------- using OutlineParserFactory = std::function<std::unique_ptr<OutlineParserInterface>()>; +using CodeParserFactory = std::function<std::unique_ptr<CodeParserInterface>()>; /** \brief Manages programming language parsers. * @@ -145,38 +146,42 @@ using OutlineParserFactory = std::function<std::unique_ptr<OutlineParserInterfac */ class ParserManager { - public: struct ParserPair { - ParserPair(OutlineParserFactory opf, std::unique_ptr<CodeParserInterface> cpi) - : outlineParserFactory(opf), codeParserInterface(std::move(cpi)) + ParserPair(OutlineParserFactory opf, CodeParserFactory cpf, const QCString pn) + : outlineParserFactory(opf), codeParserFactory(cpf), parserName(pn) { } OutlineParserFactory outlineParserFactory; - std::unique_ptr<CodeParserInterface> codeParserInterface; + CodeParserFactory codeParserFactory; + QCString parserName; }; + public: + /** Create the parser manager + * @param outlineParserFactory the fallback outline parser factory to use for unknown extensions + * @param codeParserFactory the fallback code parser factory to use for unknown extensions + */ ParserManager(OutlineParserFactory outlineParserFactory, - std::unique_ptr<CodeParserInterface> codeParserInterface) - : m_defaultParsers(outlineParserFactory,std::move(codeParserInterface)) + CodeParserFactory codeParserFactory) + : m_defaultParsers(outlineParserFactory,codeParserFactory, "") { } /** Registers an additional parser. * @param[in] name A symbolic name of the parser, i.e. "c", * "python", "fortran", "vhdl", ... - * @param[in] outlineParser The language parser (scanner) that is to be used for the - * given name. - * @param[in] codeParser The code parser that is to be used for the - * given name. + * @param[in] outlineParserFactory A factory method to create a language parser (scanner) that + * is to be used for the given name. + * @param[in] codeParserFactory A factory method to create a code parser that is to be used + * for the given name. */ void registerParser(const char *name,OutlineParserFactory outlineParserFactory, - std::unique_ptr<CodeParserInterface> codeParserInterface) + CodeParserFactory codeParserFactory) { - m_parsers.emplace(std::string(name), - ParserPair(outlineParserFactory,std::move(codeParserInterface))); + m_parsers.emplace(std::string(name),ParserPair(outlineParserFactory,codeParserFactory,name)); } /** Registers a file \a extension with a parser with name \a parserName. @@ -198,7 +203,7 @@ class ParserManager return TRUE; } - /** Gets the interface to the parser associated with given \a extension. + /** Gets the interface to the parser associated with a given \a extension. * If there is no parser explicitly registered for the supplied extension, * the interface to the default parser will be returned. */ @@ -207,13 +212,29 @@ class ParserManager return getParsers(extension).outlineParserFactory(); } - /** Gets the interface to the parser associated with given \a extension. + /** Gets the interface to the parser associated with a given \a extension. * If there is no parser explicitly registered for the supplied extension, * the interface to the default parser will be returned. */ - CodeParserInterface &getCodeParser(const char *extension) + std::unique_ptr<CodeParserInterface> getCodeParser(const char *extension) + { + auto factory = getCodeParserFactory(extension); + return factory(); + } + + /** Get the factory for create code parser objects with a given \a extension. */ + CodeParserFactory &getCodeParserFactory(const char *extension) + { + return getParsers(extension).codeParserFactory; + } + + /** Gets the name of the parser associated with given \a extension. + * If there is no parser explicitly registered for the supplied extension, + * te empty string will be reurned. + */ + QCString getParserName(const char *extension) { - return *getParsers(extension).codeParserInterface; + return getParsers(extension).parserName; } private: |