1
#pragma once
2

            
3
#include <memory>
4

            
5
#include "envoy/common/optref.h"
6
#include "envoy/common/pure.h"
7
#include "envoy/stream_info/stream_info.h"
8

            
9
#include "absl/strings/string_view.h"
10

            
11
namespace Envoy {
12
namespace Matchers {
13

            
14
/**
15
 * Generic string matching interface.
16
 */
17
class StringMatcher {
18
public:
19
26586
  virtual ~StringMatcher() = default;
20

            
21
  struct Context {
22
    OptRef<const StreamInfo::StreamInfo> stream_info_;
23
  };
24

            
25
  /**
26
   * Return whether a passed string value matches.
27
   */
28
  virtual bool match(absl::string_view value) const PURE;
29

            
30
  /**
31
   * Return whether a passed string value matches with context.
32
   * Because most implementations don't use the context, provides a default implementation.
33
   */
34
  virtual bool match(absl::string_view value, const Context&) const { return match(value); }
35
};
36

            
37
using StringMatcherPtr = std::unique_ptr<const StringMatcher>;
38

            
39
} // namespace Matchers
40
} // namespace Envoy