From 71c4e55fd955d6dd405a12bed293034e14fb1afc Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 1 Feb 2017 01:43:11 +0100 Subject: [PATCH] Return enum, not untyped int, when classifying Doxygen commands This makes the purpose of DoxygenParser::commandBelongs() more clear and also allows the compiler to check that we handle all of its possible return values. And it actually turns out that we didn't, so add the missing values now to avoid changing the behaviour in any way in this commit, but they will be dealt with later. --- Source/DoxygenTranslator/src/DoxygenParser.cpp | 10 +++++++++- Source/DoxygenTranslator/src/DoxygenParser.h | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Source/DoxygenTranslator/src/DoxygenParser.cpp b/Source/DoxygenTranslator/src/DoxygenParser.cpp index ba8882404..dce394798 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.cpp +++ b/Source/DoxygenTranslator/src/DoxygenParser.cpp @@ -128,7 +128,8 @@ void DoxygenParser::printTree(const DoxygenEntityList &rootList) } } -int DoxygenParser::commandBelongs(const std::string &theCommand) +DoxygenParser::DoxyCommandEnum +DoxygenParser::commandBelongs(const std::string &theCommand) { DoxyCommandsMapIt it = doxygenCommands.find(stringToLower(theCommand)); @@ -1046,6 +1047,13 @@ int DoxygenParser::addCommand(const std::string &commandString, return addCommandHtmlEntity(theCommand, tokList, doxyList); case COMMAND_IGNORE: return ignoreCommand(commandString, tokList, doxyList); + case NONE: + case END_LINE: + case PARAGRAPH_END: + case PLAINSTRING: + case COMMAND: + // TODO: Ensure that these values either are correctly ignored here or can't happen. + break; } return 0; } diff --git a/Source/DoxygenTranslator/src/DoxygenParser.h b/Source/DoxygenTranslator/src/DoxygenParser.h index bbb519092..753b996d8 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.h +++ b/Source/DoxygenTranslator/src/DoxygenParser.h @@ -130,7 +130,7 @@ private: * Determines how a command should be handled (what group it belongs to * for parsing rules */ - int commandBelongs(const std::string &theCommand); + DoxyCommandEnum commandBelongs(const std::string &theCommand); /* *prints the parse tree