| 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.cc with modifications | 4 // Copied from strings/stringpiece.cc with modifications |
| 5 | 5 |
| 6 #include "base/strings/string_piece.h" |
| 7 |
| 6 #include <algorithm> | 8 #include <algorithm> |
| 7 #include <ostream> | 9 #include <ostream> |
| 8 | 10 |
| 9 #include "base/string_piece.h" | |
| 10 | |
| 11 namespace base { | 11 namespace base { |
| 12 | 12 |
| 13 // MSVC doesn't like complex extern templates and DLLs. | 13 // MSVC doesn't like complex extern templates and DLLs. |
| 14 #if !defined(COMPILER_MSVC) | 14 #if !defined(COMPILER_MSVC) |
| 15 namespace internal { | 15 namespace internal { |
| 16 template class StringPieceDetail<std::string>; | 16 template class StringPieceDetail<std::string>; |
| 17 template class StringPieceDetail<string16>; | 17 template class StringPieceDetail<string16>; |
| 18 } // namespace internal | 18 } // namespace internal |
| 19 | 19 |
| 20 template class BasicStringPiece<string16>; | 20 template class BasicStringPiece<string16>; |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 StringPiece substr(const StringPiece& self, | 246 StringPiece substr(const StringPiece& self, |
| 247 StringPiece::size_type pos, | 247 StringPiece::size_type pos, |
| 248 StringPiece::size_type n) { | 248 StringPiece::size_type n) { |
| 249 if (pos > self.size()) pos = self.size(); | 249 if (pos > self.size()) pos = self.size(); |
| 250 if (n > self.size() - pos) n = self.size() - pos; | 250 if (n > self.size() - pos) n = self.size() - pos; |
| 251 return StringPiece(self.data() + pos, n); | 251 return StringPiece(self.data() + pos, n); |
| 252 } | 252 } |
| 253 | 253 |
| 254 } // namespace internal | 254 } // namespace internal |
| 255 } // namespace base | 255 } // namespace base |
| OLD | NEW |