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