Val: Move TablePatternMatcher into detail namespace

There's anyway only prototype in the headers, so detail seems better
than the public zeek namespace.
This commit is contained in:
Arne Welzel 2023-11-01 15:00:05 +01:00
parent 43a5473919
commit c426304c27
2 changed files with 6 additions and 9 deletions

View file

@ -1427,11 +1427,9 @@ static void find_nested_record_types(const TypePtr& t, std::set<RecordType*>* fo
} }
} }
using PatternValPtr = IntrusivePtr<PatternVal>;
// Support class for returning multiple values from a table[pattern] // Support class for returning multiple values from a table[pattern]
// when indexed with a string. // when indexed with a string.
class TablePatternMatcher { class detail::TablePatternMatcher {
public: public:
TablePatternMatcher(const TableVal* _tbl, TypePtr _yield) : tbl(_tbl) { TablePatternMatcher(const TableVal* _tbl, TypePtr _yield) : tbl(_tbl) {
vtype = make_intrusive<VectorType>(std::move(_yield)); vtype = make_intrusive<VectorType>(std::move(_yield));
@ -1465,7 +1463,7 @@ private:
std::vector<ValPtr> matcher_yields; std::vector<ValPtr> matcher_yields;
}; };
VectorValPtr TablePatternMatcher::Lookup(const StringVal* s) { VectorValPtr detail::TablePatternMatcher::Lookup(const StringVal* s) {
auto results = make_intrusive<VectorVal>(vtype); auto results = make_intrusive<VectorVal>(vtype);
if ( ! matcher ) { if ( ! matcher ) {
@ -1484,7 +1482,7 @@ VectorValPtr TablePatternMatcher::Lookup(const StringVal* s) {
return results; return results;
} }
void TablePatternMatcher::Build() { void detail::TablePatternMatcher::Build() {
matcher_yields.clear(); matcher_yields.clear();
matcher_yields.push_back(nullptr); matcher_yields.push_back(nullptr);
@ -1544,7 +1542,7 @@ void TableVal::Init(TableTypePtr t, bool ordered) {
subnets = nullptr; subnets = nullptr;
if ( table_type->IsPatternIndex() && table_type->Yield() ) if ( table_type->IsPatternIndex() && table_type->Yield() )
pattern_matcher = new TablePatternMatcher(this, table_type->Yield()); pattern_matcher = new detail::TablePatternMatcher(this, table_type->Yield());
table_hash = new detail::CompositeHash(table_type->GetIndices()); table_hash = new detail::CompositeHash(table_type->GetIndices());
if ( ordered ) if ( ordered )

View file

@ -51,6 +51,7 @@ class Frame;
class PrefixTable; class PrefixTable;
class CompositeHash; class CompositeHash;
class HashKey; class HashKey;
class TablePatternMatcher;
class ValTrace; class ValTrace;
class ZBody; class ZBody;
@ -718,8 +719,6 @@ protected:
TableVal* table; TableVal* table;
}; };
class TablePatternMatcher;
class TableVal final : public Val, public notifier::detail::Modifiable { class TableVal final : public Val, public notifier::detail::Modifiable {
public: public:
explicit TableVal(TableTypePtr t, detail::AttributesPtr attrs = nullptr); explicit TableVal(TableTypePtr t, detail::AttributesPtr attrs = nullptr);
@ -1039,7 +1038,7 @@ protected:
TableValTimer* timer; TableValTimer* timer;
RobustDictIterator<TableEntryVal>* expire_iterator; RobustDictIterator<TableEntryVal>* expire_iterator;
detail::PrefixTable* subnets; detail::PrefixTable* subnets;
TablePatternMatcher* pattern_matcher = nullptr; detail::TablePatternMatcher* pattern_matcher = nullptr;
ValPtr def_val; ValPtr def_val;
detail::ExprPtr change_func; detail::ExprPtr change_func;
std::string broker_store; std::string broker_store;