| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // You can use StringPiece as a function or method parameter. A StringPiece | 8 // You can use StringPiece as a function or method parameter. A StringPiece |
| 9 // parameter can receive a double-quoted string literal argument, a "const | 9 // parameter can receive a double-quoted string literal argument, a "const |
| 10 // char*" argument, a string argument, or a StringPiece argument with no data | 10 // char*" argument, a string argument, or a StringPiece argument with no data |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 protected: | 360 protected: |
| 361 const value_type* ptr_; | 361 const value_type* ptr_; |
| 362 size_type length_; | 362 size_type length_; |
| 363 }; | 363 }; |
| 364 | 364 |
| 365 template <typename STRING_TYPE> | 365 template <typename STRING_TYPE> |
| 366 const typename BasicStringPiece<STRING_TYPE>::size_type | 366 const typename BasicStringPiece<STRING_TYPE>::size_type |
| 367 BasicStringPiece<STRING_TYPE>::npos = | 367 BasicStringPiece<STRING_TYPE>::npos = |
| 368 typename BasicStringPiece<STRING_TYPE>::size_type(-1); | 368 typename BasicStringPiece<STRING_TYPE>::size_type(-1); |
| 369 | 369 |
| 370 template <size_t size> |
| 371 inline StringPiece LiteralStringPiece(const char (&array)[size]) { |
| 372 return StringPiece(array, size - 1); |
| 373 } |
| 374 |
| 370 // MSVC doesn't like complex extern templates and DLLs. | 375 // MSVC doesn't like complex extern templates and DLLs. |
| 371 #if !defined(COMPILER_MSVC) | 376 #if !defined(COMPILER_MSVC) |
| 372 extern template class BASE_EXPORT BasicStringPiece<std::string>; | 377 extern template class BASE_EXPORT BasicStringPiece<std::string>; |
| 373 extern template class BASE_EXPORT BasicStringPiece<string16>; | 378 extern template class BASE_EXPORT BasicStringPiece<string16>; |
| 374 #endif | 379 #endif |
| 375 | 380 |
| 376 // StingPiece operators -------------------------------------------------------- | 381 // StingPiece operators -------------------------------------------------------- |
| 377 | 382 |
| 378 BASE_EXPORT bool operator==(const StringPiece& x, const StringPiece& y); | 383 BASE_EXPORT bool operator==(const StringPiece& x, const StringPiece& y); |
| 379 | 384 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 }; | 460 }; |
| 456 struct StringPiece16Hash { | 461 struct StringPiece16Hash { |
| 457 std::size_t operator()(const StringPiece16& sp16) const { | 462 std::size_t operator()(const StringPiece16& sp16) const { |
| 458 HASH_STRING_PIECE(StringPiece16, sp16); | 463 HASH_STRING_PIECE(StringPiece16, sp16); |
| 459 } | 464 } |
| 460 }; | 465 }; |
| 461 | 466 |
| 462 } // namespace base | 467 } // namespace base |
| 463 | 468 |
| 464 #endif // BASE_STRINGS_STRING_PIECE_H_ | 469 #endif // BASE_STRINGS_STRING_PIECE_H_ |
| OLD | NEW |