From 1f15f53f4b2978d438168fd4aeb8bb0d9fa3ed3c Mon Sep 17 00:00:00 2001 From: Vern Paxson Date: Mon, 19 Apr 2021 16:00:08 -0700 Subject: [PATCH] VectorVal methods to leverage ZVal representation --- src/Val.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Val.h b/src/Val.h index 27f0034260..ef04bfa206 100644 --- a/src/Val.h +++ b/src/Val.h @@ -1552,6 +1552,11 @@ public: ValPtr ValAt(unsigned int index) const { return At(index); } + bool Has(unsigned int index) const + // Version to use once std::optional implementation is merged. + // { return index < vector_val->size() && vector_val[index]; } + { return At(index) != nullptr; } + /** * Returns the given element in a given underlying representation. * Enables efficient vector access. Caller must ensure that the @@ -1560,8 +1565,12 @@ public: * @param index The position in the vector of the element to return. * @return The element's underlying value. */ + bro_int_t IntAt(unsigned int index) const + { return (*vector_val)[index]->int_val; } bro_uint_t CountAt(unsigned int index) const { return (*vector_val)[index]->uint_val; } + double DoubleAt(unsigned int index) const + { return (*vector_val)[index]->double_val; } const RecordVal* RecordValAt(unsigned int index) const { return (*vector_val)[index]->record_val; } bool BoolAt(unsigned int index) const