LCOV - code coverage report
Current view: top level - source/common/matcher - prefix_map_matcher.h (source / functions) Hit Total Coverage
Test: coverage.dat Lines: 0 11 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/common/utility.h"
       4             : #include "source/common/matcher/map_matcher.h"
       5             : 
       6             : namespace Envoy {
       7             : namespace Matcher {
       8             : 
       9             : /**
      10             :  * Implementation of a trie match tree which resolves to the OnMatch with the longest matching
      11             :  * prefix.
      12             :  */
      13             : template <class DataType> class PrefixMapMatcher : public MapMatcher<DataType> {
      14             : public:
      15             :   PrefixMapMatcher(DataInputPtr<DataType>&& data_input,
      16             :                    absl::optional<OnMatch<DataType>> on_no_match)
      17           0 :       : MapMatcher<DataType>(std::move(data_input), std::move(on_no_match)) {}
      18             : 
      19           0 :   void addChild(std::string value, OnMatch<DataType>&& on_match) override {
      20           0 :     children_.add(value, std::make_shared<OnMatch<DataType>>(std::move(on_match)));
      21           0 :   }
      22             : 
      23             : protected:
      24           0 :   absl::optional<OnMatch<DataType>> doMatch(const std::string& data) override {
      25           0 :     const auto result = children_.findLongestPrefix(data.c_str());
      26           0 :     if (result) {
      27           0 :       return *result;
      28           0 :     }
      29             : 
      30           0 :     return absl::nullopt;
      31           0 :   }
      32             : 
      33             : private:
      34             :   TrieLookupTable<std::shared_ptr<OnMatch<DataType>>> children_;
      35             : };
      36             : 
      37             : } // namespace Matcher
      38             : } // namespace Envoy

Generated by: LCOV version 1.15