Kea: isc::dhcp::TokenMatch Class Reference

| Kea 3.0.2-git

isc::dhcp::TokenMatch Class Reference

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

`#include <token.h>`

Inheritance diagram for isc::dhcp::TokenMatch:
[legend]

## 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_exp | regular expression string

Exceptions

  EvalParseError | when 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

  EvalBadStack | if 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:

- token.h
- token.cc