47 if (expr.
empty())
return false;
66 warn(fileName,lineNr,
"problem evaluating expression '{}': {}", expr,
m_err);
79 return c==
'&' || c==
'|' || c==
'!';
87 return (c>=
'A' && c<=
'Z') || (c>=
'a' && c<=
'z') || c==
'_';
92 return isAlpha(c) || (c>=
'0' && c<=
'9') || c==
'-' || c==
'.' || (
static_cast<unsigned char>(c)>=0x80);
102 if (opName==
"&&") {
return AND; }
103 if (opName==
"||") {
return OR; }
106 if (opName==
"!") {
return NOT; }
124 while (*
m_e ==
' ' || *
m_e ==
'\t' || *
m_e ==
'\n')
138 if (*
m_e ==
'(' || *
m_e ==
')')
186 while (opId==
AND || opId==
OR)
228 m_err=
"Parenthesis ) missing";
256 m_err=
"Unexpected end of expression";
261 m_err=
"Value expected";
277 case AND:
return lhs && rhs;
278 case OR:
return lhs || rhs;
290 if (varName ==
"YES")
return true;
291 if (varName ==
"NO")
return false;
293 return std::find(list.begin(),list.end(),varName.
str())!=list.end();
308 return((
static_cast<ConfigBool*
>(opt)->valueRef())?
"YES" :
"NO");
311 warn(fileName,lineNr,
312 "String setting '{}' not possible in conditional statement, ignored", expr);
315 return(*(
static_cast<ConfigEnum*
>(opt)->valueRef()));
319 warn(fileName,lineNr,
320 "List setting '{}' not possible in conditional statement, ignored", expr);
323 warn(fileName,lineNr,
324 "Obsolete setting '{}' not possible in conditional statement, ignored", expr);
327 warn(fileName,lineNr,
328 "Disabled setting '{}' not possible in conditional statement, ignored", expr);
331 warn(fileName,lineNr,
332 "Info setting '{}' not possible in conditional statement, ignored", expr);
335 warn(fileName,lineNr,
336 "Unknown error occurrence '{}', ignored", expr);
342 warn(fileName,lineNr,
343 "Unknown setting '{}' not possible in conditional statement, ignored", expr);
357 const char *p=expr.
data();
364 if (*p ==
'd' &&
DString(p).startsWith(
"doxyconfig"))
367 while (*p==
' ' || *p==
'\t') {p++;}
371 if ((c>=
'A' && c<=
'Z') || (c>=
'0' && c<=
'9') || c==
'_') bufConfig += c;
378 loc_expr +=
getConfig(fileName, lineNr, bufConfig);
DString m_token
holds the token
bool parse(const DString &fileName, int lineNr, const DString &expr)
parses and evaluates the given expression.
TOKENTYPE m_tokenType
type of the token
DString m_expr
holds the expression
int getOperatorId(const DString &opName)
returns the id of the given operator returns -1 if the operator is not recognized
bool parseLevel1()
conditional operators AND and OR
void getToken()
Get next token in the current string expr.
bool evalVariable(const DString &varName)
evaluate a variable
bool evalOperator(const int opId, bool lhs, bool rhs)
evaluate an operator for given values
const char * m_e
points to a character in expr
bool parseLevel3()
parenthesized expression or variable
Class representing a Boolean type option.
Class representing an enum type option.
static ConfigImpl * instance()
ConfigOption * get(const DString &name) const
Class representing an integer type option.
Abstract base class for any configuration option.
@ O_Disabled
Disabled compile time option.
@ O_Enum
A fixed set of items.
@ O_Obsolete
An obsolete option.
@ O_Info
A section header.
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
DString & setNum(short n)
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
const std::string & str() const
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
static bool isDelimiter(const char c)
checks if the given char c is a delimiter minus is checked apart, can be unary minus
static bool isAlphaNumSpec(const char c)
static DString resolveConfig(const DString &fileName, int lineNr, const DString &expr)
static DString getConfig(const DString &fileName, int lineNr, const DString &expr)
static DString error_str
Copyright (C) 1997-2015 by Dimitri van Heesch.
static bool isAlpha(const char c)
checks if the given char c is a letter or underscore
#define Config_getList(name)
std::vector< std::string > StringVector
#define warn(file, line, fmt,...)