1 #ifndef LogicalExpressions_h 2 #define LogicalExpressions_h 1 11 typedef std::map< const std::string, bool >
ResultMap ;
56 Tokenizer( std::vector< Expression >& tokens ) : _tokens(tokens) , _last(0), needToken(true)
57 , openPar(0), closedPar(0) ,
65 if( c !=
' ' && c !=
'\t' ) {
67 if( c ==
'(' ) ++openPar ;
69 if( c ==
')' ) ++closedPar ;
80 _tokens.back().isNot = true ;
83 _state = parenthesis ;
86 _tokens.back().Value += c ;
93 if( closedPar == openPar ) {
99 _tokens.back().Value += c ;
105 if( c ==
'&' || c==
'|' ){
107 if ( c ==
'&' && _last ==
'&' ) {
112 if ( c ==
'|' && _last ==
'|' ) {
120 _tokens.back().Value += c ;
157 void addCondition(
const std::string& name,
const std::string& expression ) ;
163 bool conditionIsTrue(
const std::string& name )
const ;
166 bool expressionIsTrue(
const std::string& expression )
const ;
169 void setValue(
const std::string& key,
bool val ) ;
175 bool getValue(
const std::string& key )
const ;
std::map< const std::string, bool > ResultMap
std::ostream & operator<<(std::ostream &stream, const Configuration &cfg)
Stream operator.
std::vector< Expression > & _tokens
Helper struct for LogicalExpression.
std::vector< Expression > & result()
Tokenizer(std::vector< Expression > &tokens)
std::map< const std::string, std::string > ConditionsMap
virtual ~LogicalExpressions()
Virtual d'tor.
Helper class that holds named boolean values and named conditions that are expressions of these value...
Helper class for LogicalExpressions that splits the expression into subexpressions - needs to be apll...
void operator()(const char &c)
Save the current character and change state if necessary.