LCOV - code coverage report
Current view: top level - envoy/common - regex.h (source / functions) Hit Total Coverage
Test: coverage.dat Lines: 2 2 100.0 %
Date: 2024-01-05 06:35:25 Functions: 2 2 100.0 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <memory>
       4             : 
       5             : #include "envoy/common/matchers.h"
       6             : #include "envoy/config/typed_config.h"
       7             : #include "envoy/server/factory_context.h"
       8             : 
       9             : namespace Envoy {
      10             : namespace Regex {
      11             : 
      12             : /**
      13             :  * A compiled regex expression matcher which uses an abstract regex engine.
      14             :  */
      15             : class CompiledMatcher : public Matchers::StringMatcher {
      16             : public:
      17             :   /**
      18             :    * Replaces all non-overlapping occurrences of the pattern in "value" with
      19             :    * "substitution". The "substitution" string can make references to
      20             :    * capture groups in the pattern, using the syntax specific to that
      21             :    * regular expression engine.
      22             :    */
      23             :   virtual std::string replaceAll(absl::string_view value,
      24             :                                  absl::string_view substitution) const PURE;
      25             : };
      26             : 
      27             : using CompiledMatcherPtr = std::unique_ptr<const CompiledMatcher>;
      28             : 
      29             : /**
      30             :  * A regular expression engine which turns regular expressions into compiled matchers.
      31             :  */
      32             : class Engine {
      33             : public:
      34         628 :   virtual ~Engine() = default;
      35             : 
      36             :   /**
      37             :    * Create a @ref CompiledMatcher with the given regex expression.
      38             :    * @param regex the regex expression match string
      39             :    */
      40             :   virtual CompiledMatcherPtr matcher(const std::string& regex) const PURE;
      41             : };
      42             : 
      43             : using EnginePtr = std::shared_ptr<Engine>;
      44             : 
      45             : /**
      46             :  * Factory for Engine.
      47             :  */
      48             : class EngineFactory : public Config::TypedFactory {
      49             : public:
      50             :   /**
      51             :    * Creates an Engine from the provided config.
      52             :    */
      53             :   virtual EnginePtr
      54             :   createEngine(const Protobuf::Message& config,
      55             :                Server::Configuration::ServerFactoryContext& server_factory_context) PURE;
      56             : 
      57         138 :   std::string category() const override { return "envoy.regex_engines"; }
      58             : };
      59             : 
      60             : } // namespace Regex
      61             : } // namespace Envoy

Generated by: LCOV version 1.15