OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 | 4 |
5 #include "base/string_util.h" | 5 #include "base/string_util.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #include <ctype.h> | 9 #include <ctype.h> |
10 #include <errno.h> | 10 #include <errno.h> |
(...skipping 1410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1421 return TokenizeT(str, delimiters, tokens); | 1421 return TokenizeT(str, delimiters, tokens); |
1422 } | 1422 } |
1423 #endif | 1423 #endif |
1424 | 1424 |
1425 size_t Tokenize(const std::string& str, | 1425 size_t Tokenize(const std::string& str, |
1426 const std::string& delimiters, | 1426 const std::string& delimiters, |
1427 std::vector<std::string>* tokens) { | 1427 std::vector<std::string>* tokens) { |
1428 return TokenizeT(str, delimiters, tokens); | 1428 return TokenizeT(str, delimiters, tokens); |
1429 } | 1429 } |
1430 | 1430 |
| 1431 size_t Tokenize(const base::StringPiece& str, |
| 1432 const base::StringPiece& delimiters, |
| 1433 std::vector<base::StringPiece>* tokens) { |
| 1434 return TokenizeT(str, delimiters, tokens); |
| 1435 } |
| 1436 |
1431 template<typename STR> | 1437 template<typename STR> |
1432 static STR JoinStringT(const std::vector<STR>& parts, | 1438 static STR JoinStringT(const std::vector<STR>& parts, |
1433 typename STR::value_type sep) { | 1439 typename STR::value_type sep) { |
1434 if (parts.size() == 0) return STR(); | 1440 if (parts.size() == 0) return STR(); |
1435 | 1441 |
1436 STR result(parts[0]); | 1442 STR result(parts[0]); |
1437 typename std::vector<STR>::const_iterator iter = parts.begin(); | 1443 typename std::vector<STR>::const_iterator iter = parts.begin(); |
1438 ++iter; | 1444 ++iter; |
1439 | 1445 |
1440 for (; iter != parts.end(); ++iter) { | 1446 for (; iter != parts.end(); ++iter) { |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1903 // Each input byte creates two output hex characters. | 1909 // Each input byte creates two output hex characters. |
1904 std::string ret(size * 2, '\0'); | 1910 std::string ret(size * 2, '\0'); |
1905 | 1911 |
1906 for (size_t i = 0; i < size; ++i) { | 1912 for (size_t i = 0; i < size; ++i) { |
1907 char b = reinterpret_cast<const char*>(bytes)[i]; | 1913 char b = reinterpret_cast<const char*>(bytes)[i]; |
1908 ret[(i * 2)] = kHexChars[(b >> 4) & 0xf]; | 1914 ret[(i * 2)] = kHexChars[(b >> 4) & 0xf]; |
1909 ret[(i * 2) + 1] = kHexChars[b & 0xf]; | 1915 ret[(i * 2) + 1] = kHexChars[b & 0xf]; |
1910 } | 1916 } |
1911 return ret; | 1917 return ret; |
1912 } | 1918 } |
OLD | NEW |