From 9557029cf2bceb7987ffe61cc38101b789000fd6 Mon Sep 17 00:00:00 2001 From: Vern Paxson Date: Thu, 1 Apr 2021 18:45:42 -0700 Subject: [PATCH] method to add a fully-qualified enum name (module name included) --- src/Type.cc | 8 ++++++-- src/Type.h | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Type.cc b/src/Type.cc index 2343cfdfe9..b9b230130c 100644 --- a/src/Type.cc +++ b/src/Type.cc @@ -1414,8 +1414,12 @@ void EnumType::AddNameInternal(const string& full_name, bro_int_t val) bro_int_t EnumType::Lookup(const string& module_name, const char* name) const { - NameMap::const_iterator pos = - names.find(detail::make_full_var_name(module_name.c_str(), name).c_str()); + return Lookup(detail::make_full_var_name(module_name.c_str(), name)); + } + +bro_int_t EnumType::Lookup(const string& full_name) const + { + NameMap::const_iterator pos = names.find(full_name.c_str()); if ( pos == names.end() ) return -1; diff --git a/src/Type.h b/src/Type.h index 5ff7330e8c..0ed8548d96 100644 --- a/src/Type.h +++ b/src/Type.h @@ -720,8 +720,10 @@ public: // added that aren't likewise explicitly initalized. void AddName(const std::string& module_name, const char* name, bro_int_t val, bool is_export, detail::Expr* deprecation = nullptr, bool from_redef = false); - // -1 indicates not found. + // -1 indicates not found. Second version is for full names + // that already incorporate the module. bro_int_t Lookup(const std::string& module_name, const char* name) const; + bro_int_t Lookup(const std::string& full_name) const; const char* Lookup(bro_int_t value) const; // Returns 0 if not found