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