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

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: Review comments 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..5c642f097d9acd564b0f59d42c85d5dc96ad4c88 100644
--- a/extensions/common/url_pattern_set.cc
+++ b/extensions/common/url_pattern_set.cc
@@ -99,6 +99,27 @@ bool URLPatternSet::operator==(const URLPatternSet& other) const {
return patterns_ == other.patterns_;
}
+std::ostream& operator<<(std::ostream& out,
+ const URLPatternSet& url_pattern_set) {
+ out << "{ ";
Jeffrey Yasskin 2014/05/28 22:32:04 And <ostream>
aboxhall 2014/05/28 22:44:10 Done.
+
+ using const_iterator = std::set<URLPattern>::const_iterator;
Jeffrey Yasskin 2014/05/28 22:32:04 This is C++11 so won't work everywhere. Use typede
aboxhall 2014/05/28 22:44:10 Done.
+ const_iterator iter = url_pattern_set.patterns().begin();
+ if (!url_pattern_set.patterns().empty()) {
+ out << *iter;
+ ++iter;
+ }
+
+ for (;iter != url_pattern_set.patterns().end(); ++iter)
+ out << ", " << *iter;
+
+ if (!url_pattern_set.patterns().empty())
+ out << " ";
+
+ out << "}";
+ return out;
+}
+
bool URLPatternSet::is_empty() const {
return patterns_.empty();
}

Powered by Google App Engine
This is Rietveld 408576698