Kea 2.7.6
isc::dhcp::TokenMatch Class Reference

Token that represents regular expression (regex) matching. More...

#include <token.h>

+ Inheritance diagram for isc::dhcp::TokenMatch:

Public Member Functions

 TokenMatch (const std::string &reg_exp)
 Constructor.
 
virtual unsigned evaluate (Pkt &pkt, ValueStack &values)
 Match regular expression.
 
const std::string & getRegExp () const
 Returns regular expression.
 
- Public Member Functions inherited from isc::dhcp::Token
virtual ~Token ()
 Virtual destructor.
 
virtual unsigned getLabel () const
 Return the label of this token.
 

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 regular expression (regex) matching.

For example "match('foo', '_foobar_')" is true

Definition at line 1379 of file token.h.

Constructor & Destructor Documentation

◆ TokenMatch()

TokenMatch::TokenMatch ( const std::string & reg_exp)

Constructor.

Parameters
reg_expregular expression string
Exceptions
EvalParseErrorwhen the regular expression is not valid

Definition at line 1472 of file token.cc.

References isc_throw.

Member Function Documentation

◆ evaluate()

unsigned TokenMatch::evaluate ( Pkt & pkt,
ValueStack & values )
virtual

Match regular expression.

Evaluation uses only the last parameter (top of stack) which is popped. Pushes "true" when the regular expression evaluates to true, pushes "false" otherwise.

Parameters
pkt(unused)
values- stack of values (1 popped, 1 pushed)
Exceptions
EvalBadStackif there is no value on the stack
Returns
0 which means evaluate next token if any.

Implements isc::dhcp::Token.

Definition at line 1482 of file token.cc.

References isc::dhcp::EVAL_DBG_STACK, isc::dhcp::EVAL_DEBUG_MATCH, isc::dhcp::EVAL_DEBUG_MATCH_ERROR, isc::dhcp::eval_logger, isc_throw, LOG_DEBUG, and LOG_ERROR.

◆ getRegExp()

const std::string & isc::dhcp::TokenMatch::getRegExp ( ) const
inline

Returns regular expression.

This method is used in testing to determine if the parser had instantiated TokenMatch with correct parameters.

Returns
regular expression as a string.

Definition at line 1405 of file token.h.


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