Skip to content

Commit

Permalink
Represent enum in the config file also as an enum in the code
Browse files Browse the repository at this point in the history
Benefits:
- This improves type safety and consistency (no more comparisons against
  string literals and case conversions).
- This allows enums to be used in a switch and let the compiler point
  out if a value is missing.
  • Loading branch information
doxygen committed Aug 28, 2021
1 parent c1ccaeb commit a0fb56e
Show file tree
Hide file tree
Showing 19 changed files with 1,057 additions and 1,165 deletions.
10 changes: 5 additions & 5 deletions src/classdef.cpp
Expand Up @@ -1605,15 +1605,15 @@ int ClassDefImpl::countInheritanceNodes() const

void ClassDefImpl::writeInheritanceGraph(OutputList &ol) const
{
static bool haveDot = Config_getBool(HAVE_DOT);
static QCString classGraph = Config_getEnum(CLASS_GRAPH).upper();
static bool haveDot = Config_getBool(HAVE_DOT);
static auto classGraph = Config_getEnum(CLASS_GRAPH);

if (classGraph == "NO") return;
if (classGraph == CLASS_GRAPH_t::NO) return;
// count direct inheritance relations
const int count=countInheritanceNodes();

bool renderDiagram = FALSE;
if (haveDot && (classGraph == "YES" || classGraph =="GRAPH"))
if (haveDot && (classGraph==CLASS_GRAPH_t::YES || classGraph==CLASS_GRAPH_t::GRAPH))
// write class diagram using dot
{
DotClassGraph inheritanceGraph(this,Inheritance);
Expand All @@ -1633,7 +1633,7 @@ void ClassDefImpl::writeInheritanceGraph(OutputList &ol) const
renderDiagram = TRUE;
}
}
else if ((classGraph == "YES" || classGraph =="GRAPH") && count>0)
else if ((classGraph==CLASS_GRAPH_t::YES || classGraph==CLASS_GRAPH_t::GRAPH) && count>0)
// write class diagram using built-in generator
{
ClassDiagram diagram(this); // create a diagram of this class.
Expand Down
4 changes: 2 additions & 2 deletions src/commentscan.l
Expand Up @@ -741,7 +741,7 @@ STopt [^\n@\\]*
<Comment>{B}*{CMD}"~"[a-z_A-Z-]* { // language switch command
QCString langId = QCString(yytext).stripWhiteSpace().mid(2);
if (!langId.isEmpty() &&
qstricmp(Config_getEnum(OUTPUT_LANGUAGE).data(),langId.data())!=0)
qstricmp(Config_getEnumAsString(OUTPUT_LANGUAGE).data(),langId.data())!=0)
{ // enable language specific section
BEGIN(SkipLang);
}
Expand Down Expand Up @@ -1897,7 +1897,7 @@ STopt [^\n@\\]*
<SkipLang>[\\@]"~"[a-zA-Z-]* { /* language switch */
QCString langId(&yytext[2]);
if (langId.isEmpty() ||
qstricmp(Config_getEnum(OUTPUT_LANGUAGE).data(),langId.data())==0)
qstricmp(Config_getEnumAsString(OUTPUT_LANGUAGE).data(),langId.data())==0)
{ // enable language specific section
BEGIN(Comment);
}
Expand Down
1 change: 1 addition & 0 deletions src/config.h
Expand Up @@ -33,6 +33,7 @@
#define Config_getBool(name) (ConfigValues::instance().name())
#define Config_getInt(name) (ConfigValues::instance().name())
#define Config_getEnum(name) (ConfigValues::instance().name())
#define Config_getEnumAsString(name) (ConfigValues::instance().name##_str())
#define Config_getList(name) (ConfigValues::instance().name())
#define Config_updateString(name,value) (ConfigValues::instance().update_##name(value));
#define Config_updateBool(name,value) (ConfigValues::instance().update_##name(value));
Expand Down

0 comments on commit a0fb56e

Please sign in to comment.