Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(192)

Side by Side Diff: base/strings/stringprintf.h

Issue 1410333006: Enough hacks to make wstring printfs unneeded (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "build/build_config.h" 14 #include "build/build_config.h"
15 15
16 #ifdef COMPILER_MSVC 16 #ifdef COMPILER_MSVC
17 // For _Printf_format_string_. 17 // For _Printf_format_string_.
18 #include <sal.h> 18 #include <sal.h>
19 #else 19 #else
20 // For nacl builds when sal.h is not available. 20 // For nacl builds when sal.h is not available.
21 #define _Printf_format_string_ 21 #define _Printf_format_string_
22 #endif 22 #endif
23 23
24 namespace base { 24 namespace base {
25 25
26 // Return a C++ string given printf-like input. 26 // Return a C++ string given printf-like input.
27 BASE_EXPORT std::string StringPrintf(_Printf_format_string_ const char* format, 27 BASE_EXPORT std::string StringPrintf(_Printf_format_string_ const char* format,
28 ...) 28 ...)
29 PRINTF_FORMAT(1, 2) WARN_UNUSED_RESULT; 29 PRINTF_FORMAT(1, 2) WARN_UNUSED_RESULT;
30 #if defined(OS_WIN) 30 /*#if defined(OS_WIN)
31 BASE_EXPORT std::wstring StringPrintf( 31 BASE_EXPORT std::wstring StringPrintf(
32 _Printf_format_string_ const wchar_t* format, 32 _Printf_format_string_ const wchar_t* format,
33 ...) WPRINTF_FORMAT(1, 2) WARN_UNUSED_RESULT; 33 ...) WPRINTF_FORMAT(1, 2) WARN_UNUSED_RESULT;
34 #endif 34 #endif*/
35 35
36 // Return a C++ string given vprintf-like input. 36 // Return a C++ string given vprintf-like input.
37 BASE_EXPORT std::string StringPrintV(const char* format, va_list ap) 37 BASE_EXPORT std::string StringPrintV(const char* format, va_list ap)
38 PRINTF_FORMAT(1, 0) WARN_UNUSED_RESULT; 38 PRINTF_FORMAT(1, 0) WARN_UNUSED_RESULT;
39 39
40 // Store result into a supplied string and return it. 40 // Store result into a supplied string and return it.
41 BASE_EXPORT const std::string& SStringPrintf( 41 /*#if defined(OS_WIN)
42 std::string* dst,
43 _Printf_format_string_ const char* format,
44 ...) PRINTF_FORMAT(2, 3);
45 #if defined(OS_WIN)
46 BASE_EXPORT const std::wstring& SStringPrintf( 42 BASE_EXPORT const std::wstring& SStringPrintf(
47 std::wstring* dst, 43 std::wstring* dst,
48 _Printf_format_string_ const wchar_t* format, 44 _Printf_format_string_ const wchar_t* format,
49 ...) WPRINTF_FORMAT(2, 3); 45 ...) WPRINTF_FORMAT(2, 3);
50 #endif 46 #endif*/
51 47
52 // Append result to a supplied string. 48 // Append result to a supplied string.
53 BASE_EXPORT void StringAppendF(std::string* dst, 49 BASE_EXPORT void StringAppendF(std::string* dst,
54 _Printf_format_string_ const char* format, 50 _Printf_format_string_ const char* format,
55 ...) PRINTF_FORMAT(2, 3); 51 ...) PRINTF_FORMAT(2, 3);
56 #if defined(OS_WIN) 52 /*#if defined(OS_WIN)
57 BASE_EXPORT void StringAppendF(std::wstring* dst, 53 BASE_EXPORT void StringAppendF(std::wstring* dst,
58 _Printf_format_string_ const wchar_t* format, 54 _Printf_format_string_ const wchar_t* format,
59 ...) WPRINTF_FORMAT(2, 3); 55 ...) WPRINTF_FORMAT(2, 3);
60 #endif 56 #endif*/
61 57
62 // Lower-level routine that takes a va_list and appends to a specified 58 // Lower-level routine that takes a va_list and appends to a specified
63 // string. All other routines are just convenience wrappers around it. 59 // string. All other routines are just convenience wrappers around it.
64 BASE_EXPORT void StringAppendV(std::string* dst, const char* format, va_list ap) 60 BASE_EXPORT void StringAppendV(std::string* dst, const char* format, va_list ap)
65 PRINTF_FORMAT(2, 0); 61 PRINTF_FORMAT(2, 0);
66 #if defined(OS_WIN) 62 /*#if defined(OS_WIN)
67 BASE_EXPORT void StringAppendV(std::wstring* dst, 63 BASE_EXPORT void StringAppendV(std::wstring* dst,
68 const wchar_t* format, va_list ap) 64 const wchar_t* format, va_list ap)
69 WPRINTF_FORMAT(2, 0); 65 WPRINTF_FORMAT(2, 0);
70 #endif 66 #endif*/
71 67
72 } // namespace base 68 } // namespace base
73 69
74 #endif // BASE_STRINGS_STRINGPRINTF_H_ 70 #endif // BASE_STRINGS_STRINGPRINTF_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698