Kea 2.5.8
isc::dhcp::TokenIfElse Class Reference

Token that represents an alternative. More...

#include <token.h>

+ Inheritance diagram for isc::dhcp::TokenIfElse:

Public Member Functions

 TokenIfElse ()
 Constructor (does nothing)
 
void evaluate (Pkt &pkt, ValueStack &values)
 Alternative.
 
- Public Member Functions inherited from isc::dhcp::Token
virtual ~Token ()
 Virtual destructor.
 
virtual void evaluate (Pkt &pkt, ValueStack &values)=0
 This is a generic method for evaluating a packet.
 

Additional Inherited Members

- Static Public Member Functions inherited from isc::dhcp::Token
static bool toBool (std::string value)
 Coverts a (string) value to a boolean.
 

Detailed Description

Token that represents an alternative.

For example in the sub-expression "ifelse(cond, iftrue, iffalse)" the boolean "cond" expression is evaluated, if it is true then the "iftrue" value is returned else the "iffalse" value is returned. Please note that "iftrue" and "iffalse" must be plain string (vs. boolean) expressions and they are always evaluated. If you want a similar operator on boolean expressions it can be built from "and", "or" and "not" boolean operators.

Definition at line 905 of file token.h.

Constructor & Destructor Documentation

◆ TokenIfElse()

isc::dhcp::TokenIfElse::TokenIfElse ( )
inline

Constructor (does nothing)

Definition at line 908 of file token.h.

Member Function Documentation

◆ evaluate()

void TokenIfElse::evaluate ( Pkt pkt,
ValueStack values 
)
virtual

Alternative.

Evaluation does not use packet information, but rather consumes the last three results. It does a simple string comparison on the condition (third value on the stack) which is required to be either "true" or "false", and leaves the second and first value if the condition is "true" or "false".

Exceptions
EvalBadStackif there are less than 3 values on stack
EvalTypeErrorif the third value (the condition) is not either "true" or "false"
Parameters
pkt(unused)
values- stack of values (two items are removed)

Implements isc::dhcp::Token.

Definition at line 945 of file token.cc.

References isc::dhcp::EVAL_DBG_STACK, isc::dhcp::EVAL_DEBUG_IFELSE_FALSE, isc::dhcp::EVAL_DEBUG_IFELSE_TRUE, isc::dhcp::eval_logger, isc::dhcp::Pkt::getLabel(), isc_throw, LOG_DEBUG, and isc::dhcp::Token::toBool().

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: