VectorVal methods to leverage ZVal representation

This commit is contained in:
Vern Paxson 2021-04-19 16:00:08 -07:00
parent e80ab06775
commit 1f15f53f4b

View file

@ -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