OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1238 | 1238 |
1239 std::wstring StringPrintf(const wchar_t* format, ...) { | 1239 std::wstring StringPrintf(const wchar_t* format, ...) { |
1240 va_list ap; | 1240 va_list ap; |
1241 va_start(ap, format); | 1241 va_start(ap, format); |
1242 std::wstring result; | 1242 std::wstring result; |
1243 StringAppendV(&result, format, ap); | 1243 StringAppendV(&result, format, ap); |
1244 va_end(ap); | 1244 va_end(ap); |
1245 return result; | 1245 return result; |
1246 } | 1246 } |
1247 | 1247 |
| 1248 std::string StringPrintV(const char* format, va_list ap) { |
| 1249 std::string result; |
| 1250 StringAppendV(&result, format, ap); |
| 1251 return result; |
| 1252 } |
| 1253 |
1248 const std::string& SStringPrintf(std::string* dst, const char* format, ...) { | 1254 const std::string& SStringPrintf(std::string* dst, const char* format, ...) { |
1249 va_list ap; | 1255 va_list ap; |
1250 va_start(ap, format); | 1256 va_start(ap, format); |
1251 dst->clear(); | 1257 dst->clear(); |
1252 StringAppendV(dst, format, ap); | 1258 StringAppendV(dst, format, ap); |
1253 va_end(ap); | 1259 va_end(ap); |
1254 return *dst; | 1260 return *dst; |
1255 } | 1261 } |
1256 | 1262 |
1257 const std::wstring& SStringPrintf(std::wstring* dst, | 1263 const std::wstring& SStringPrintf(std::wstring* dst, |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1817 // Each input byte creates two output hex characters. | 1823 // Each input byte creates two output hex characters. |
1818 std::string ret(size * 2, '\0'); | 1824 std::string ret(size * 2, '\0'); |
1819 | 1825 |
1820 for (size_t i = 0; i < size; ++i) { | 1826 for (size_t i = 0; i < size; ++i) { |
1821 char b = reinterpret_cast<const char*>(bytes)[i]; | 1827 char b = reinterpret_cast<const char*>(bytes)[i]; |
1822 ret[(i * 2)] = kHexChars[(b >> 4) & 0xf]; | 1828 ret[(i * 2)] = kHexChars[(b >> 4) & 0xf]; |
1823 ret[(i * 2) + 1] = kHexChars[b & 0xf]; | 1829 ret[(i * 2) + 1] = kHexChars[b & 0xf]; |
1824 } | 1830 } |
1825 return ret; | 1831 return ret; |
1826 } | 1832 } |
OLD | NEW |