33
44#pragma once
55
6- #include < vector>
7- #include " opentelemetry/common/macros.h"
8- #include " opentelemetry/nostd/string_view.h"
9- #include " opentelemetry/sdk/common/global_log_handler.h"
6+ #include < memory>
7+ #include < string>
108
11- #if OPENTELEMETRY_HAVE_WORKING_REGEX
12- # include < regex>
13- #endif
9+ #include " opentelemetry/nostd/string_view.h"
10+ #include " opentelemetry/version.h"
1411
1512OPENTELEMETRY_BEGIN_NAMESPACE
1613namespace sdk
@@ -35,39 +32,39 @@ class Predicate
3532class PatternPredicate : public Predicate
3633{
3734public:
38- PatternPredicate (opentelemetry::nostd::string_view pattern) : reg_key_{pattern.data ()} {}
39- bool Match (opentelemetry::nostd::string_view str) const noexcept override
40- {
41- #if OPENTELEMETRY_HAVE_WORKING_REGEX
42- return std::regex_match (str.data (), reg_key_);
43- #else
44- // TBD - Support regex match for GCC4.8
45- OTEL_INTERNAL_LOG_ERROR (
46- " PatternPredicate::Match - failed. std::regex not fully supported for this compiler." );
47- return false ; // not supported
48- #endif
49- }
35+ explicit PatternPredicate (opentelemetry::nostd::string_view pattern);
36+
37+ PatternPredicate (const PatternPredicate &) = delete ;
38+ PatternPredicate (PatternPredicate &&) = delete ;
39+ PatternPredicate &operator =(const PatternPredicate &) = delete ;
40+ PatternPredicate &operator =(PatternPredicate &&) = delete ;
41+
42+ ~PatternPredicate () override ;
43+
44+ bool Match (opentelemetry::nostd::string_view str) const noexcept override ;
45+
46+ private:
47+ class Impl ;
48+ std::unique_ptr<Impl> impl_;
49+ };
50+
51+ class WildcardPredicate : public Predicate
52+ {
53+ public:
54+ explicit WildcardPredicate (opentelemetry::nostd::string_view pattern);
55+
56+ bool Match (opentelemetry::nostd::string_view str) const noexcept override ;
5057
5158private:
52- #if OPENTELEMETRY_HAVE_WORKING_REGEX
53- std::regex reg_key_;
54- #else
55- std::string reg_key_;
56- #endif
59+ std::string pattern_;
5760};
5861
5962class ExactPredicate : public Predicate
6063{
6164public:
62- ExactPredicate (opentelemetry::nostd::string_view pattern) : pattern_{pattern} {}
63- bool Match (opentelemetry::nostd::string_view str) const noexcept override
64- {
65- if (pattern_ == str)
66- {
67- return true ;
68- }
69- return false ;
70- }
65+ explicit ExactPredicate (opentelemetry::nostd::string_view pattern);
66+
67+ bool Match (opentelemetry::nostd::string_view str) const noexcept override ;
7168
7269private:
7370 std::string pattern_;
@@ -76,13 +73,13 @@ class ExactPredicate : public Predicate
7673class MatchEverythingPattern : public Predicate
7774{
7875public:
79- bool Match (opentelemetry::nostd::string_view /* str */ ) const noexcept override { return true ; }
76+ bool Match (opentelemetry::nostd::string_view str) const noexcept override ;
8077};
8178
8279class MatchNothingPattern : public Predicate
8380{
8481public:
85- bool Match (opentelemetry::nostd::string_view /* str */ ) const noexcept override { return false ; }
82+ bool Match (opentelemetry::nostd::string_view str) const noexcept override ;
8683};
8784} // namespace metrics
8885} // namespace sdk
0 commit comments