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 12 matching lines...) Expand all Loading... |
23 #define BASE_STRINGS_STRING_PIECE_H_ | 23 #define BASE_STRINGS_STRING_PIECE_H_ |
24 | 24 |
25 #include <stddef.h> | 25 #include <stddef.h> |
26 | 26 |
27 #include <iosfwd> | 27 #include <iosfwd> |
28 #include <string> | 28 #include <string> |
29 | 29 |
30 #include "base/base_export.h" | 30 #include "base/base_export.h" |
31 #include "base/logging.h" | 31 #include "base/logging.h" |
32 #include "base/strings/string16.h" | 32 #include "base/strings/string16.h" |
33 #include "base/strings/string_piece_forward.h" | |
34 | 33 |
35 namespace base { | 34 namespace base { |
36 | 35 |
| 36 template <typename STRING_TYPE> class BasicStringPiece; |
| 37 typedef BasicStringPiece<std::string> StringPiece; |
| 38 typedef BasicStringPiece<string16> StringPiece16; |
| 39 |
37 // internal -------------------------------------------------------------------- | 40 // internal -------------------------------------------------------------------- |
38 | 41 |
39 // Many of the StringPiece functions use different implementations for the | 42 // Many of the StringPiece functions use different implementations for the |
40 // 8-bit and 16-bit versions, and we don't want lots of template expansions in | 43 // 8-bit and 16-bit versions, and we don't want lots of template expansions in |
41 // this (very common) header that will slow down compilation. | 44 // this (very common) header that will slow down compilation. |
42 // | 45 // |
43 // So here we define overloaded functions called by the StringPiece template. | 46 // So here we define overloaded functions called by the StringPiece template. |
44 // For those that share an implementation, the two versions will expand to a | 47 // For those that share an implementation, the two versions will expand to a |
45 // template internal to the .cc file. | 48 // template internal to the .cc file. |
46 namespace internal { | 49 namespace internal { |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 }; | 458 }; |
456 struct StringPiece16Hash { | 459 struct StringPiece16Hash { |
457 std::size_t operator()(const StringPiece16& sp16) const { | 460 std::size_t operator()(const StringPiece16& sp16) const { |
458 HASH_STRING_PIECE(StringPiece16, sp16); | 461 HASH_STRING_PIECE(StringPiece16, sp16); |
459 } | 462 } |
460 }; | 463 }; |
461 | 464 |
462 } // namespace base | 465 } // namespace base |
463 | 466 |
464 #endif // BASE_STRINGS_STRING_PIECE_H_ | 467 #endif // BASE_STRINGS_STRING_PIECE_H_ |
OLD | NEW |