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

Side by Side Diff: base/string_piece.h

Issue 193072: Move StringPiece into the base namespace. It is colliding (Closed)
Patch Set: take 2 Created 11 years, 3 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
« no previous file with comments | « base/file_path.cc ('k') | base/string_piece.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 // Copied from strings/stringpiece.h with modifications 4 // Copied from strings/stringpiece.h with modifications
5 // 5 //
6 // A string-like object that points to a sized piece of memory. 6 // A string-like object that points to a sized piece of memory.
7 // 7 //
8 // Functions or methods may use const StringPiece& parameters to accept either 8 // Functions or methods may use const StringPiece& parameters to accept either
9 // a "const char*" or a "string" value that will be implicitly converted to 9 // a "const char*" or a "string" value that will be implicitly converted to
10 // a StringPiece. The implicit conversion means that it is often appropriate 10 // a StringPiece. The implicit conversion means that it is often appropriate
11 // to include this .h file in other files rather than forward-declaring 11 // to include this .h file in other files rather than forward-declaring
12 // StringPiece as would be appropriate for most other Google classes. 12 // StringPiece as would be appropriate for most other Google classes.
13 // 13 //
14 // Systematic usage of StringPiece is encouraged as it will reduce unnecessary 14 // Systematic usage of StringPiece is encouraged as it will reduce unnecessary
15 // conversions from "const char*" to "string" and back again. 15 // conversions from "const char*" to "string" and back again.
16 // 16 //
17 17
18 #ifndef BASE_STRING_PIECE_H_ 18 #ifndef BASE_STRING_PIECE_H_
19 #define BASE_STRING_PIECE_H_ 19 #define BASE_STRING_PIECE_H_
20 20
21 #include <algorithm> 21 #include <algorithm>
22 #include <iosfwd> 22 #include <iosfwd>
23 #include <string> 23 #include <string>
24 24
25 #include "base/basictypes.h" 25 #include "base/basictypes.h"
26 26
27 namespace base {
28
27 class StringPiece { 29 class StringPiece {
28 public: 30 public:
29 typedef size_t size_type; 31 typedef size_t size_type;
30 32
31 private: 33 private:
32 const char* ptr_; 34 const char* ptr_;
33 size_type length_; 35 size_type length_;
34 36
35 public: 37 public:
36 // We provide non-explicit singleton constructors so users can pass 38 // We provide non-explicit singleton constructors so users can pass
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 return !(x > y); 176 return !(x > y);
175 } 177 }
176 178
177 inline bool operator>=(const StringPiece& x, const StringPiece& y) { 179 inline bool operator>=(const StringPiece& x, const StringPiece& y) {
178 return !(x < y); 180 return !(x < y);
179 } 181 }
180 182
181 // allow StringPiece to be logged (needed for unit testing). 183 // allow StringPiece to be logged (needed for unit testing).
182 extern std::ostream& operator<<(std::ostream& o, const StringPiece& piece); 184 extern std::ostream& operator<<(std::ostream& o, const StringPiece& piece);
183 185
186 } // namespace base
187
184 #endif // BASE_STRING_PIECE_H_ 188 #endif // BASE_STRING_PIECE_H_
OLDNEW
« no previous file with comments | « base/file_path.cc ('k') | base/string_piece.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698