From 5faa47482bb944285d4827cb6a88bbc8bd9bb8a4 Mon Sep 17 00:00:00 2001 From: Metin Cakircali Date: Tue, 5 May 2026 11:56:38 +0200 Subject: [PATCH 1/3] add print to Matcher --- src/metkit/mars/Matcher.cc | 12 +++++++++++- src/metkit/mars/Matcher.h | 9 ++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/metkit/mars/Matcher.cc b/src/metkit/mars/Matcher.cc index 5397e71f..3a1173a5 100644 --- a/src/metkit/mars/Matcher.cc +++ b/src/metkit/mars/Matcher.cc @@ -126,4 +126,14 @@ bool Matcher::match(const RequestLike& request, MatchMissingPolicy matchOnMissin }); } -} // namespace metkit::mars \ No newline at end of file +void Matcher::print(std::ostream& s) const { + s << "{"; + const char* sep = ""; + for (const auto& [key, regex] : regexMap_) { + s << sep << key << "=" << static_cast(regex); + sep = ","; + } + s << "}"; +} + +} // namespace metkit::mars diff --git a/src/metkit/mars/Matcher.h b/src/metkit/mars/Matcher.h index 8d963ac9..3ce49293 100644 --- a/src/metkit/mars/Matcher.h +++ b/src/metkit/mars/Matcher.h @@ -62,6 +62,13 @@ class Matcher { bool match(const RequestLike& request, MatchMissingPolicy matchOnMissing = MatchOnMissing) const; bool match(const MarsRequest& request, MatchMissingPolicy matchOnMissing = MatchOnMissing) const; + void print(std::ostream& s) const; + + friend std::ostream& operator<<(std::ostream& s, const Matcher& m) { + m.print(s); + return s; + } + private: std::map regexMap_; @@ -85,4 +92,4 @@ class RequestLike { virtual std::optional get(const std::string& keyword) const = 0; }; -} // namespace metkit::mars \ No newline at end of file +} // namespace metkit::mars From 8a0eae64909bd7f693a1ce7b63f35df4f273261c Mon Sep 17 00:00:00 2001 From: Metin Cakircali Date: Fri, 8 May 2026 13:41:03 +0200 Subject: [PATCH 2/3] test matcher print --- tests/test_matcher.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/test_matcher.cc b/tests/test_matcher.cc index 65ddd26c..b0a65b7e 100644 --- a/tests/test_matcher.cc +++ b/tests/test_matcher.cc @@ -12,6 +12,8 @@ #include "metkit/mars/MarsRequest.h" #include "metkit/mars/Matcher.h" +#include + using namespace eckit::testing; using namespace metkit::mars; @@ -151,6 +153,15 @@ CASE("match empty request") { EXPECT_EQUAL(match_all.match(req, Matcher::MatchOnMissing), true); } +CASE("streaming matcher is deterministic") { + Matcher matcher("stream=^enfo$, expver=(x[0-9a-z]{3}), number=(1|2)", Matcher::Policy::Any); + + std::ostringstream oss; + oss << matcher; + + EXPECT_EQUAL(oss.str(), "{expver=(x[0-9a-z]{3}),number=(1|2),stream=^enfo$}"); +} + // ---------------------------------------------------------------------------------------------------------------------- } // namespace metkit::test From cb01ae2a88a0379aef5d829cd1f52ba3a48dd15b Mon Sep 17 00:00:00 2001 From: Metin Cakircali Date: Fri, 8 May 2026 13:42:08 +0200 Subject: [PATCH 3/3] add matcher iosfwd --- src/metkit/mars/Matcher.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/metkit/mars/Matcher.h b/src/metkit/mars/Matcher.h index 3ce49293..d173c0f9 100644 --- a/src/metkit/mars/Matcher.h +++ b/src/metkit/mars/Matcher.h @@ -14,6 +14,7 @@ #pragma once #include +#include #include #include #include