mirror of
https://github.com/zeek/zeek.git
synced 2025-10-13 20:18:20 +00:00
[ADD] builtin function enum_to_int()
[ADD] added tests for the new enum_to_int function
This commit is contained in:
parent
9045288ad3
commit
b36d5fc81b
3 changed files with 50 additions and 0 deletions
15
src/bro.bif
15
src/bro.bif
|
@ -2159,6 +2159,21 @@ function counts_to_addr%(v: index_vec%): addr
|
|||
}
|
||||
%}
|
||||
|
||||
## Converts an :bro:type:`enum` to an :bro:type:`int`
|
||||
##
|
||||
## e: The :bro:type:`enum` to convert.
|
||||
##
|
||||
## Returns: The :bro:type:`enum` as :bro:type:`int`.
|
||||
function enum_to_int%(e: any%): int
|
||||
%{
|
||||
if ( e->Type()->Tag() != TYPE_ENUM )
|
||||
{
|
||||
builtin_error("enum_to_int() requires enum_val");
|
||||
return new Val(-1, TYPE_INT);
|
||||
}
|
||||
return new Val(e->AsEnum(), TYPE_INT);
|
||||
%}
|
||||
|
||||
## Converts a :bro:type:`string` to an :bro:type:`int`.
|
||||
##
|
||||
## str: The :bro:type:`string` to convert.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue