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

Side by Side Diff: base/stringprintf.h

Issue 10800078: Remove wchar_t versions of StringPrintf from Android (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: First cut, compiles on Android Created 8 years, 5 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
« no previous file with comments | « no previous file | base/stringprintf.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_STRINGPRINTF_H_ 5 #ifndef BASE_STRINGPRINTF_H_
6 #define BASE_STRINGPRINTF_H_ 6 #define BASE_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);
20 BASE_EXPORT std::wstring StringPrintf(const wchar_t* format, ...)
21 WPRINTF_FORMAT(1, 2);
22
23 // Return a C++ string given vprintf-like input. 20 // Return a C++ string given vprintf-like input.
24 BASE_EXPORT std::string StringPrintV(const char* format, va_list ap) 21 BASE_EXPORT std::string StringPrintV(const char* format, va_list ap)
25 PRINTF_FORMAT(1, 0); 22 PRINTF_FORMAT(1, 0);
26 23
27 // Store result into a supplied string and return it. 24 // Store result into a supplied string and return it.
28 BASE_EXPORT const std::string& SStringPrintf(std::string* dst, 25 BASE_EXPORT const std::string& SStringPrintf(std::string* dst,
29 const char* format, ...) 26 const char* format, ...)
30 PRINTF_FORMAT(2, 3); 27 PRINTF_FORMAT(2, 3);
28
29 // Append result to a supplied string.
30 BASE_EXPORT void StringAppendF(std::string* dst, const char* format, ...)
31 PRINTF_FORMAT(2, 3);
32
33 // Lower-level routine that takes a va_list and appends to a specified
34 // string. All other routines are just convenience wrappers around it.
35 BASE_EXPORT void StringAppendV(std::string* dst, const char* format, va_list ap)
36 PRINTF_FORMAT(2, 0);
37
38 // wchar_t variants of above functions. Not supported by Android's libc.
39 #if !defined(OS_ANDROID)
jar (doing other things) 2012/07/24 18:15:34 IMO, this grouping (by whether we're Android or no
Iain Merrick 2012/07/25 10:57:23 Sure, no problem! I considered both and made the o
jar (doing other things) 2012/07/25 18:54:04 Mixed feelings: Macros are frowned upon. If you
Iain Merrick 2012/07/26 11:15:56 Done.
40 BASE_EXPORT std::wstring StringPrintf(const wchar_t* format, ...)
41 WPRINTF_FORMAT(1, 2);
42
31 BASE_EXPORT const std::wstring& SStringPrintf(std::wstring* dst, 43 BASE_EXPORT const std::wstring& SStringPrintf(std::wstring* dst,
32 const wchar_t* format, ...) 44 const wchar_t* format, ...)
33 WPRINTF_FORMAT(2, 3); 45 WPRINTF_FORMAT(2, 3);
34 46
35 // Append result to a supplied string.
36 BASE_EXPORT void StringAppendF(std::string* dst, const char* format, ...)
jar (doing other things) 2012/07/24 18:15:34 This is interesting.... it was previously only adv
Iain Merrick 2012/07/25 10:57:23 Hmm, probably more interesting than I intended! I'
37 PRINTF_FORMAT(2, 3);
38 // TODO(evanm): this is only used in a few places in the code; 47 // TODO(evanm): this is only used in a few places in the code;
39 // replace with string16 version. 48 // replace with string16 version.
40 BASE_EXPORT void StringAppendF(std::wstring* dst, const wchar_t* format, ...) 49 BASE_EXPORT void StringAppendF(std::wstring* dst, const wchar_t* format, ...)
41 WPRINTF_FORMAT(2, 3); 50 WPRINTF_FORMAT(2, 3);
42 51
43 // Lower-level routine that takes a va_list and appends to a specified
44 // string. All other routines are just convenience wrappers around it.
45 BASE_EXPORT void StringAppendV(std::string* dst, const char* format, va_list ap)
46 PRINTF_FORMAT(2, 0);
47 BASE_EXPORT void StringAppendV(std::wstring* dst, 52 BASE_EXPORT void StringAppendV(std::wstring* dst,
48 const wchar_t* format, va_list ap) 53 const wchar_t* format, va_list ap)
49 WPRINTF_FORMAT(2, 0); 54 WPRINTF_FORMAT(2, 0);
55 #endif
50 56
51 } // namespace base 57 } // namespace base
52 58
53 // Don't require the namespace for legacy code. New code should use "base::" or 59 // Don't require the namespace for legacy code. New code should use "base::" or
54 // have its own using decl. 60 // have its own using decl.
55 // 61 //
56 // TODO(brettw) remove these when calling code is converted. 62 // TODO(brettw) remove these when calling code is converted.
57 using base::StringPrintf; 63 using base::StringPrintf;
58 64
59 #endif // BASE_STRINGPRINTF_H_ 65 #endif // BASE_STRINGPRINTF_H_
OLDNEW
« no previous file with comments | « no previous file | base/stringprintf.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698