Doxygen
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
29{
30 // public functions
31 public:
33 bool parse(const DString &fileName,int lineNr,const DString &expr);
34
35 // enumerations
36 private:
45 {
47 AND = 1,
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
DString m_token
holds the token
Definition condparser.h:59
DString m_err
error state
Definition condparser.h:55
bool parseLevel2()
NOT.
bool parse(const DString &fileName, int lineNr, const DString &expr)
parses and evaluates the given expression.
TOKENTYPE m_tokenType
type of the token
Definition condparser.h:60
DString m_expr
holds the expression
Definition condparser.h:56
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
Definition condparser.h:57
bool parseVar()
bool parseLevel3()
parenthesized expression or variable
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition dstring.h:84