| OLD | NEW |
| 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 class StringPiece { | 27 class StringPiece { |
| 28 public: | 28 public: |
| 29 typedef size_t size_type; | 29 typedef size_t size_type; |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 return !(x > y); | 174 return !(x > y); |
| 175 } | 175 } |
| 176 | 176 |
| 177 inline bool operator>=(const StringPiece& x, const StringPiece& y) { | 177 inline bool operator>=(const StringPiece& x, const StringPiece& y) { |
| 178 return !(x < y); | 178 return !(x < y); |
| 179 } | 179 } |
| 180 | 180 |
| 181 // allow StringPiece to be logged (needed for unit testing). | 181 // allow StringPiece to be logged (needed for unit testing). |
| 182 extern std::ostream& operator<<(std::ostream& o, const StringPiece& piece); | 182 extern std::ostream& operator<<(std::ostream& o, const StringPiece& piece); |
| 183 | 183 |
| 184 #endif // BASE_STRING_PIECE_H__ | 184 #endif // BASE_STRING_PIECE_H_ |
| 185 | |
| OLD | NEW |