/proc/self/cwd/source/common/matcher/validation_visitor.h
Line | Count | Source |
1 | | #pragma once |
2 | | |
3 | | #include "envoy/matcher/matcher.h" |
4 | | |
5 | | #include "absl/status/status.h" |
6 | | |
7 | | namespace Envoy { |
8 | | namespace Matcher { |
9 | | |
10 | | /** |
11 | | * Interface for a validator that is used during match tree construction to validate |
12 | | * the paths, nodes, subtrees, etc. of the match tree. Currently only node-based (i.e. without |
13 | | * knowledge of the resulting leaf action) validation of data input is supported. |
14 | | * |
15 | | * As the match tree itself can have any structure, this class is used to accumulate a list of |
16 | | * violations that occur during tree construction. This has the benefit of being able to emit |
17 | | * an error containing all the violations, not just the first one. |
18 | | */ |
19 | | template <class DataType> class MatchTreeValidationVisitor { |
20 | | public: |
21 | 14.3k | virtual ~MatchTreeValidationVisitor() = default; Envoy::Matcher::MatchTreeValidationVisitor<Envoy::Http::HttpMatchingData>::~MatchTreeValidationVisitor() Line | Count | Source | 21 | 14.2k | virtual ~MatchTreeValidationVisitor() = default; |
Envoy::Matcher::MatchTreeValidationVisitor<Envoy::Network::MatchingData>::~MatchTreeValidationVisitor() Line | Count | Source | 21 | 35 | virtual ~MatchTreeValidationVisitor() = default; |
Unexecuted instantiation: Envoy::Matcher::MatchTreeValidationVisitor<Envoy::Network::UdpMatchingData>::~MatchTreeValidationVisitor() |
22 | | |
23 | | // Validates a single DataInput its type_url. |
24 | 32.2k | void validateDataInput(const DataInputFactory<DataType>& data_input, absl::string_view type_url) { |
25 | 32.2k | auto status = performDataInputValidation(data_input, type_url); |
26 | | |
27 | 32.2k | if (!status.ok()) { |
28 | 4.27k | errors_.emplace_back(std::move(status)); |
29 | 4.27k | } |
30 | 32.2k | } Envoy::Matcher::MatchTreeValidationVisitor<Envoy::Http::HttpMatchingData>::validateDataInput(Envoy::Matcher::DataInputFactory<Envoy::Http::HttpMatchingData> const&, std::__1::basic_string_view<char, std::__1::char_traits<char> >) Line | Count | Source | 24 | 32.2k | void validateDataInput(const DataInputFactory<DataType>& data_input, absl::string_view type_url) { | 25 | 32.2k | auto status = performDataInputValidation(data_input, type_url); | 26 | | | 27 | 32.2k | if (!status.ok()) { | 28 | 4.27k | errors_.emplace_back(std::move(status)); | 29 | 4.27k | } | 30 | 32.2k | } |
Unexecuted instantiation: Envoy::Matcher::MatchTreeValidationVisitor<Envoy::Network::MatchingData>::validateDataInput(Envoy::Matcher::DataInputFactory<Envoy::Network::MatchingData> const&, std::__1::basic_string_view<char, std::__1::char_traits<char> >) Unexecuted instantiation: Envoy::Matcher::MatchTreeValidationVisitor<Envoy::Network::UdpMatchingData>::validateDataInput(Envoy::Matcher::DataInputFactory<Envoy::Network::UdpMatchingData> const&, std::__1::basic_string_view<char, std::__1::char_traits<char> >) |
31 | | |
32 | 6.86k | const std::vector<absl::Status>& errors() const { return errors_; } Envoy::Matcher::MatchTreeValidationVisitor<Envoy::Http::HttpMatchingData>::errors() const Line | Count | Source | 32 | 6.86k | const std::vector<absl::Status>& errors() const { return errors_; } |
Unexecuted instantiation: Envoy::Matcher::MatchTreeValidationVisitor<Envoy::Network::UdpMatchingData>::errors() const |
33 | | |
34 | | protected: |
35 | | // Implementations would subclass this to specify the validation logic for data inputs, |
36 | | // returning a helpful error message if validation fails. |
37 | | virtual absl::Status performDataInputValidation(const DataInputFactory<DataType>& data_input, |
38 | | absl::string_view type_url) PURE; |
39 | | |
40 | | private: |
41 | | std::vector<absl::Status> errors_; |
42 | | }; |
43 | | } // namespace Matcher |
44 | | } // namespace Envoy |