Determine type of RecordVal

Hi there,

in the old Bro version you could create new RecordVal and determine/check its type in C++ this way:

RecordVal* item = new RecordVal(BifType::Record::foo:RecordType);

if ( item->Type() == BifType::Record::foo:RecordType) { … }

Now in Zeek, we are using IntrusivePtr datatype, which is straigth forward, but who can I determine or check the type of the assigned RecordType? Is there no Type() method anymore?

Thanks!

Dane

The old Type() is now GetType(). Happy to provide further pointers if helpful.

Thanks Vern! That helped me a lot!

Hey Vern, may I ask another question regarding IntrusivePtr?

Consider following code:

void createEvent() {
      Args vl;
      EventHandlerPtr ev = fooEvent;

      ...

      vl.emplace_back(ConnVal());
      vl.emplace_back(IntrusivePtr{AdoptRef{}, CreateRecordVal()});

      ...
      EnqueueConnEvent(ev, std::move(vl));

}
zeek::RecordVal* CreateRecordVal() {
      RecordVal* h = new RecordVal(BifType::Record::foo::fooRecord);
      return h;
}

Would that be the correct use of AdoptRef{}, IntrusivePtr and std::move in that combination?

Sorry, I missed this until now :frowning: . What you show is correct. More idiomatic would be to use:

vl.emplace_back(make_intrusive<RecordVal>(BifType::Record::foo::fooRecord);