Kea  1.9.9-git
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) More...
void evaluate (Pkt &pkt, ValueStack &values)
 Alternative. More...
- Public Member Functions inherited from isc::dhcp::Token
virtual ~Token ()
 Virtual destructor. More...

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. More...

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 831 of file token.h.

Constructor & Destructor Documentation

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

Constructor (does nothing)

Definition at line 834 of file token.h.

Member Function Documentation

void TokenIfElse::evaluate ( Pkt pkt,
ValueStack values 


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".

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

Implements isc::dhcp::Token.

Definition at line 801 of file

References isc::dhcp::EVAL_DBG_STACK, isc::dhcp::EVAL_DEBUG_IFELSE_FALSE, isc::dhcp::EVAL_DEBUG_IFELSE_TRUE, isc::dhcp::eval_logger, isc_throw, LOG_DEBUG, isc::dhcp::Token::toBool(), and isc::util::encode::toHex().

+ Here is the call graph for this function:

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