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

Side by Side Diff: url/gurl.cc

Issue 2421383003: Add operator==(const GURL&, const StringPiece&) to gurl.h (Closed)
Patch Set: Created 4 years, 2 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 unified diff | Download patch
« url/gurl.h ('K') | « url/gurl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "url/gurl.h" 5 #include "url/gurl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <ostream> 10 #include <ostream>
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 } 173 }
174 174
175 const std::string& GURL::spec() const { 175 const std::string& GURL::spec() const {
176 if (is_valid_ || spec_.empty()) 176 if (is_valid_ || spec_.empty())
177 return spec_; 177 return spec_;
178 178
179 DCHECK(false) << "Trying to get the spec of an invalid URL!"; 179 DCHECK(false) << "Trying to get the spec of an invalid URL!";
180 return EmptyStringForGURL(); 180 return EmptyStringForGURL();
181 } 181 }
182 182
183 bool GURL::operator==(const GURL& other) const {
184 return spec_ == other.spec_;
185 }
186
187 bool GURL::operator!=(const GURL& other) const {
188 return spec_ != other.spec_;
189 }
190
191 bool GURL::operator<(const GURL& other) const { 183 bool GURL::operator<(const GURL& other) const {
192 return spec_ < other.spec_; 184 return spec_ < other.spec_;
193 } 185 }
194 186
195 bool GURL::operator>(const GURL& other) const { 187 bool GURL::operator>(const GURL& other) const {
196 return spec_ > other.spec_; 188 return spec_ > other.spec_;
197 } 189 }
198 190
199 // Note: code duplicated below (it's inconvenient to use a template here). 191 // Note: code duplicated below (it's inconvenient to use a template here).
200 GURL GURL::Resolve(const std::string& relative) const { 192 GURL GURL::Resolve(const std::string& relative) const {
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 void GURL::Swap(GURL* other) { 495 void GURL::Swap(GURL* other) {
504 spec_.swap(other->spec_); 496 spec_.swap(other->spec_);
505 std::swap(is_valid_, other->is_valid_); 497 std::swap(is_valid_, other->is_valid_);
506 std::swap(parsed_, other->parsed_); 498 std::swap(parsed_, other->parsed_);
507 inner_url_.swap(other->inner_url_); 499 inner_url_.swap(other->inner_url_);
508 } 500 }
509 501
510 std::ostream& operator<<(std::ostream& out, const GURL& url) { 502 std::ostream& operator<<(std::ostream& out, const GURL& url) {
511 return out << url.possibly_invalid_spec(); 503 return out << url.possibly_invalid_spec();
512 } 504 }
505
506 bool operator==(const GURL& x, const GURL& y) {
507 return x.possibly_invalid_spec() == y.possibly_invalid_spec();
508 }
509
510 bool operator!=(const GURL& x, const GURL& y) {
511 return !(x == y);
512 }
513
514 bool operator==(const GURL& x, const base::StringPiece& spec) {
515 return x.possibly_invalid_spec() == spec;
516 }
517
518 bool operator!=(const GURL& x, const base::StringPiece& spec) {
519 return !(x == spec);
520 }
OLDNEW
« url/gurl.h ('K') | « url/gurl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698