OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef BASE_STRINGS_STRINGPRINTF_H_ | 5 #ifndef BASE_STRINGS_STRINGPRINTF_H_ |
6 #define BASE_STRINGS_STRINGPRINTF_H_ | 6 #define BASE_STRINGS_STRINGPRINTF_H_ |
7 | 7 |
8 #include <stdarg.h> // va_list | 8 #include <stdarg.h> // va_list |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/base_export.h" | 12 #include "base/base_export.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 | 14 |
15 namespace base { | 15 namespace base { |
16 | 16 |
17 // Return a C++ string given printf-like input. | 17 // Return a C++ string given printf-like input. |
18 BASE_EXPORT std::string StringPrintf(const char* format, ...) | 18 BASE_EXPORT std::string StringPrintf(const char* format, ...) |
19 PRINTF_FORMAT(1, 2); | 19 PRINTF_FORMAT(1, 2) WARN_UNUSED_RESULT; |
20 // OS_ANDROID's libc does not support wchar_t, so several overloads are omitted. | 20 // OS_ANDROID's libc does not support wchar_t, so several overloads are omitted. |
21 #if !defined(OS_ANDROID) | 21 #if !defined(OS_ANDROID) |
22 BASE_EXPORT std::wstring StringPrintf(const wchar_t* format, ...) | 22 BASE_EXPORT std::wstring StringPrintf(const wchar_t* format, ...) |
23 WPRINTF_FORMAT(1, 2); | 23 WPRINTF_FORMAT(1, 2) WARN_UNUSED_RESULT; |
24 #endif | 24 #endif |
25 | 25 |
26 // Return a C++ string given vprintf-like input. | 26 // Return a C++ string given vprintf-like input. |
27 BASE_EXPORT std::string StringPrintV(const char* format, va_list ap) | 27 BASE_EXPORT std::string StringPrintV(const char* format, va_list ap) |
28 PRINTF_FORMAT(1, 0); | 28 PRINTF_FORMAT(1, 0) WARN_UNUSED_RESULT; |
29 | 29 |
30 // Store result into a supplied string and return it. | 30 // Store result into a supplied string and return it. |
31 BASE_EXPORT const std::string& SStringPrintf(std::string* dst, | 31 BASE_EXPORT const std::string& SStringPrintf(std::string* dst, |
32 const char* format, ...) | 32 const char* format, ...) |
33 PRINTF_FORMAT(2, 3); | 33 PRINTF_FORMAT(2, 3); |
34 #if !defined(OS_ANDROID) | 34 #if !defined(OS_ANDROID) |
35 BASE_EXPORT const std::wstring& SStringPrintf(std::wstring* dst, | 35 BASE_EXPORT const std::wstring& SStringPrintf(std::wstring* dst, |
36 const wchar_t* format, ...) | 36 const wchar_t* format, ...) |
37 WPRINTF_FORMAT(2, 3); | 37 WPRINTF_FORMAT(2, 3); |
38 #endif | 38 #endif |
(...skipping 14 matching lines...) Expand all Loading... |
53 PRINTF_FORMAT(2, 0); | 53 PRINTF_FORMAT(2, 0); |
54 #if !defined(OS_ANDROID) | 54 #if !defined(OS_ANDROID) |
55 BASE_EXPORT void StringAppendV(std::wstring* dst, | 55 BASE_EXPORT void StringAppendV(std::wstring* dst, |
56 const wchar_t* format, va_list ap) | 56 const wchar_t* format, va_list ap) |
57 WPRINTF_FORMAT(2, 0); | 57 WPRINTF_FORMAT(2, 0); |
58 #endif | 58 #endif |
59 | 59 |
60 } // namespace base | 60 } // namespace base |
61 | 61 |
62 #endif // BASE_STRINGS_STRINGPRINTF_H_ | 62 #endif // BASE_STRINGS_STRINGPRINTF_H_ |
OLD | NEW |