Kea 2.7.6
isc::dhcp::TokenSplit Class Reference

#include <token.h>

+ Inheritance diagram for isc::dhcp::TokenSplit:

Public Member Functions

 TokenSplit ()
 Constructor (does nothing)
 
virtual unsigned evaluate (Pkt &pkt, ValueStack &values)
 Extract a field from a delimited string.
 
- 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

Definition at line 863 of file token.h.

Constructor & Destructor Documentation

◆ TokenSplit()

isc::dhcp::TokenSplit::TokenSplit ( )
inline

Constructor (does nothing)

Definition at line 866 of file token.h.

Member Function Documentation

◆ evaluate()

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

Extract a field from a delimited string.

Evaluation does not use packet information. It requires at least three values to be present on the stack. It will consume the top three values on the stack as parameters and push the resulting substring onto the stack. From the top it expects the values on the stack as:

  • field
  • delims
  • str

str is the string to split. If it is empty, an empty string is pushed onto the value stack. delims is string of character delimiters by which to split str. If it is empty the entire value of str will be pushed on onto the value stack. field is the field number (starting at 1) of the desired field. If it is out of range an empty string is pushed on the value stack.

The following examples all use the base string "one.two..four" and shows the value returned for a given field:

field => value
--------------
- 0 => ""
- 1 => "one"
- 2 => "two"
- 3 => ""
- 4 => "four"
- 5 => ""
Exceptions
EvalBadStackif there are less than 3 values on stack
EvalTypeErrorif field is not a number
Parameters
pkt(unused)
values- stack of values (3 arguments will be popped, 1 result will be pushed)
Returns
0 which means evaluate next token if any.

Implements isc::dhcp::Token.

Definition at line 876 of file token.cc.

References isc::dhcp::EVAL_DBG_STACK, isc::dhcp::EVAL_DEBUG_SPLIT, isc::dhcp::EVAL_DEBUG_SPLIT_DELIM_EMPTY, isc::dhcp::EVAL_DEBUG_SPLIT_EMPTY, isc::dhcp::EVAL_DEBUG_SPLIT_FIELD_OUT_OF_RANGE, isc::dhcp::eval_logger, isc::dhcp::Pkt::getLabel(), isc_throw, and LOG_DEBUG.

+ Here is the call graph for this function:

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