LCOV - code coverage report
Current view: top level - source/common/matcher - exact_map_matcher.h (source / functions) Hit Total Coverage
Test: coverage.dat Lines: 0 12 0.0 %
Date: 2024-01-05 06:35:25 Functions: 0 9 0.0 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include "source/common/matcher/map_matcher.h"
       4             : 
       5             : namespace Envoy {
       6             : namespace Matcher {
       7             : 
       8             : /**
       9             :  * Implementation of a `sublinear` match tree that provides O(1) lookup of exact values,
      10             :  * with one OnMatch per result.
      11             :  */
      12             : template <class DataType> class ExactMapMatcher : public MapMatcher<DataType> {
      13             : public:
      14             :   ExactMapMatcher(DataInputPtr<DataType>&& data_input,
      15             :                   absl::optional<OnMatch<DataType>> on_no_match)
      16           0 :       : MapMatcher<DataType>(std::move(data_input), std::move(on_no_match)) {}
      17             : 
      18           0 :   void addChild(std::string value, OnMatch<DataType>&& on_match) override {
      19           0 :     const auto itr_and_exists = children_.emplace(value, std::move(on_match));
      20           0 :     ASSERT(itr_and_exists.second);
      21           0 :   }
      22             : 
      23             : protected:
      24           0 :   absl::optional<OnMatch<DataType>> doMatch(const std::string& data) override {
      25           0 :     const auto itr = children_.find(data);
      26           0 :     if (itr != children_.end()) {
      27           0 :       return itr->second;
      28           0 :     }
      29             : 
      30           0 :     return absl::nullopt;
      31           0 :   }
      32             : 
      33             : private:
      34             :   absl::flat_hash_map<std::string, OnMatch<DataType>> children_;
      35             : };
      36             : } // namespace Matcher
      37             : } // namespace Envoy

Generated by: LCOV version 1.15