Doxygen
Toggle main menu visibility
Loading...
Searching...
No Matches
condparser.h
Go to the documentation of this file.
1
/**
2
* Copyright (C) 1997-2026 by Dimitri van Heesch.
3
*
4
* Permission to use, copy, modify, and distribute this software and its
5
* documentation under the terms of the GNU General Public License is hereby
6
* granted. No representations are made about the suitability of this software
7
* for any purpose. It is provided "as is" without express or implied warranty.
8
* See the GNU General Public License for more details.
9
*
10
* Documents produced by Doxygen are derivative works derived from the
11
* input used in their production; they are not affected by this license.
12
*
13
* C++ Expression parser for ENABLED_SECTIONS in Doxygen
14
*
15
* Features used:
16
* Operators:
17
* && AND operator
18
* || OR operator
19
* ! NOT operator
20
*/
21
22
#ifndef CONDPARSER_H
23
#define CONDPARSER_H
24
25
26
#include "
dstring.h
"
27
28
class
CondParser
29
{
30
// public functions
31
public
:
32
CondParser
() :
m_e
(nullptr),
m_tokenType
(
NOTHING
) {}
33
bool
parse
(
const
DString
&fileName,
int
lineNr,
const
DString
&expr);
34
35
// enumerations
36
private
:
37
enum
TOKENTYPE
38
{
39
NOTHING
= -1,
40
DELIMITER
,
41
VARIABLE
,
42
UNKNOWN
43
};
44
enum
OPERATOR_ID
45
{
46
UNKNOWN_OP
= -1,
47
AND
= 1,
48
OR
,
49
NOT
50
};
51
52
// data
53
private
:
54
55
DString
m_err
;
//!< error state
56
DString
m_expr
;
//!< holds the expression
57
const
char
*
m_e
;
//!< points to a character in expr
58
59
DString
m_token
;
//!< holds the token
60
TOKENTYPE
m_tokenType
;
//!< type of the token
61
62
// private functions
63
private
:
64
void
getToken
();
65
66
bool
parseLevel1
();
67
bool
parseLevel2
();
68
bool
parseLevel3
();
69
bool
parseVar
();
70
71
bool
evalOperator
(
const
int
opId,
bool
lhs,
bool
rhs);
72
bool
evalVariable
(
const
DString
&varName);
73
int
getOperatorId
(
const
DString
&opName);
74
};
75
76
#endif
77
CondParser::m_token
DString m_token
holds the token
Definition
condparser.h:59
CondParser::CondParser
CondParser()
Definition
condparser.h:32
CondParser::m_err
DString m_err
error state
Definition
condparser.h:55
CondParser::parseLevel2
bool parseLevel2()
NOT.
Definition
condparser.cpp:199
CondParser::TOKENTYPE
TOKENTYPE
Definition
condparser.h:38
CondParser::UNKNOWN
@ UNKNOWN
Definition
condparser.h:42
CondParser::VARIABLE
@ VARIABLE
Definition
condparser.h:41
CondParser::DELIMITER
@ DELIMITER
Definition
condparser.h:40
CondParser::NOTHING
@ NOTHING
Definition
condparser.h:39
CondParser::OPERATOR_ID
OPERATOR_ID
Definition
condparser.h:45
CondParser::OR
@ OR
Definition
condparser.h:48
CondParser::NOT
@ NOT
Definition
condparser.h:49
CondParser::AND
@ AND
Definition
condparser.h:47
CondParser::UNKNOWN_OP
@ UNKNOWN_OP
Definition
condparser.h:46
CondParser::parse
bool parse(const DString &fileName, int lineNr, const DString &expr)
parses and evaluates the given expression.
Definition
condparser.cpp:45
CondParser::m_tokenType
TOKENTYPE m_tokenType
type of the token
Definition
condparser.h:60
CondParser::m_expr
DString m_expr
holds the expression
Definition
condparser.h:56
CondParser::getOperatorId
int getOperatorId(const DString &opName)
returns the id of the given operator returns -1 if the operator is not recognized
Definition
condparser.cpp:99
CondParser::parseLevel1
bool parseLevel1()
conditional operators AND and OR
Definition
condparser.cpp:181
CondParser::getToken
void getToken()
Get next token in the current string expr.
Definition
condparser.cpp:116
CondParser::evalVariable
bool evalVariable(const DString &varName)
evaluate a variable
Definition
condparser.cpp:288
CondParser::evalOperator
bool evalOperator(const int opId, bool lhs, bool rhs)
evaluate an operator for given values
Definition
condparser.cpp:272
CondParser::m_e
const char * m_e
points to a character in expr
Definition
condparser.h:57
CondParser::parseVar
bool parseVar()
Definition
condparser.cpp:241
CondParser::parseLevel3
bool parseLevel3()
parenthesized expression or variable
Definition
condparser.cpp:217
DString
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition
dstring.h:84
dstring.h
src
condparser.h
Generated by
1.19.0