Desc: Add obj_desc_short()

Same as obj_desc() but use the short version and do not include the
location information by default. New method instead of bool parameters
for readability.
This commit is contained in:
Arne Welzel 2023-03-21 21:32:27 +01:00
parent 92f09f0db7
commit c18366eacf
2 changed files with 15 additions and 1 deletions

View file

@ -432,4 +432,15 @@ std::string obj_desc(const Obj* o)
return std::string(d.Description());
}
std::string obj_desc_short(const Obj* o)
{
static ODesc d;
d.SetShort(true);
d.Clear();
o->Describe(&d);
return std::string(d.Description());
}
} // namespace zeek

View file

@ -230,6 +230,9 @@ protected:
// IntrusivePtr because the latter is harder to deal with when making
// calls from a debugger like lldb, which is the main use of this function.
class Obj;
extern std::string obj_desc(const Obj* o);
std::string obj_desc(const Obj* o);
// Same as obj_desc(), but ensure it is short and don't include location info.
std::string obj_desc_short(const Obj* o);
} // namespace zeek