Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Unified Diff: extensions/common/url_pattern_set.cc

Issue 300573002: Add stream operators for URLPattern and URLPatternSet and unit test for URLPatternSet (Closed) Base URL: https://chromium.googlesource.com/chromium/src@permissions
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: extensions/common/url_pattern_set.cc
diff --git a/extensions/common/url_pattern_set.cc b/extensions/common/url_pattern_set.cc
index a04d6346d7e470446da5d9d3e2d670a50ff1e5e6..1f06be430246b1bc00e8d10e0700ce4205abdd01 100644
--- a/extensions/common/url_pattern_set.cc
+++ b/extensions/common/url_pattern_set.cc
@@ -99,6 +99,24 @@ bool URLPatternSet::operator==(const URLPatternSet& other) const {
return patterns_ == other.patterns_;
}
+std::ostream& operator<<(std::ostream& out,
+ const URLPatternSet& url_pattern_set) {
+ out << "{ ";
+ std::set<URLPattern>::const_iterator end = url_pattern_set.patterns().end();
+ if (!url_pattern_set.patterns().empty())
+ --end;
+
+ copy(url_pattern_set.patterns().begin(),
Jeffrey Yasskin 2014/05/28 21:06:08 Heh. Nice use of the STL, but I think it'll wind u
aboxhall 2014/05/28 22:06:44 Done (not much simpler actually!)
+ end,
+ std::ostream_iterator<URLPattern>(out, ", "));
+
+ if (!url_pattern_set.patterns().empty())
+ out << *end << " ";
+
+ out << "}";
+ return out;
+}
+
bool URLPatternSet::is_empty() const {
return patterns_.empty();
}

Powered by Google App Engine
This is Rietveld 408576698