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

Side by Side Diff: base/stringprintf.h

Issue 6725001: Base: First pass at having base.dll: definition of (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 9 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 | Annotate | Revision Log
OLDNEW
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 #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_api.h"
12 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
13 14
14 namespace base { 15 namespace base {
15 16
16 // Return a C++ string given printf-like input. 17 // Return a C++ string given printf-like input.
17 std::string StringPrintf(const char* format, ...) PRINTF_FORMAT(1, 2); 18 BASE_API std::string StringPrintf(const char* format, ...) PRINTF_FORMAT(1, 2);
18 std::wstring StringPrintf(const wchar_t* format, ...) WPRINTF_FORMAT(1, 2); 19 BASE_API std::wstring StringPrintf(const wchar_t* format, ...)
20 WPRINTF_FORMAT(1, 2);
19 21
20 // Return a C++ string given vprintf-like input. 22 // Return a C++ string given vprintf-like input.
21 std::string StringPrintV(const char* format, va_list ap) PRINTF_FORMAT(1, 0); 23 BASE_API std::string StringPrintV(const char* format, va_list ap)
24 PRINTF_FORMAT(1, 0);
22 25
23 // Store result into a supplied string and return it. 26 // Store result into a supplied string and return it.
24 const std::string& SStringPrintf(std::string* dst, const char* format, ...) 27 BASE_API const std::string& SStringPrintf(std::string* dst,
28 const char* format, ...)
25 PRINTF_FORMAT(2, 3); 29 PRINTF_FORMAT(2, 3);
26 const std::wstring& SStringPrintf(std::wstring* dst, 30 BASE_API const std::wstring& SStringPrintf(std::wstring* dst,
27 const wchar_t* format, ...) 31 const wchar_t* format, ...)
28 WPRINTF_FORMAT(2, 3); 32 WPRINTF_FORMAT(2, 3);
29 33
30 // Append result to a supplied string. 34 // Append result to a supplied string.
31 void StringAppendF(std::string* dst, const char* format, ...) 35 BASE_API void StringAppendF(std::string* dst, const char* format, ...)
32 PRINTF_FORMAT(2, 3); 36 PRINTF_FORMAT(2, 3);
33 // TODO(evanm): this is only used in a few places in the code; 37 // TODO(evanm): this is only used in a few places in the code;
34 // replace with string16 version. 38 // replace with string16 version.
35 void StringAppendF(std::wstring* dst, const wchar_t* format, ...) 39 BASE_API void StringAppendF(std::wstring* dst, const wchar_t* format, ...)
36 WPRINTF_FORMAT(2, 3); 40 WPRINTF_FORMAT(2, 3);
37 41
38 // Lower-level routine that takes a va_list and appends to a specified 42 // Lower-level routine that takes a va_list and appends to a specified
39 // string. All other routines are just convenience wrappers around it. 43 // string. All other routines are just convenience wrappers around it.
40 void StringAppendV(std::string* dst, const char* format, va_list ap) 44 BASE_API void StringAppendV(std::string* dst, const char* format, va_list ap)
41 PRINTF_FORMAT(2, 0); 45 PRINTF_FORMAT(2, 0);
42 void StringAppendV(std::wstring* dst, const wchar_t* format, va_list ap) 46 BASE_API void StringAppendV(std::wstring* dst,
47 const wchar_t* format, va_list ap)
43 WPRINTF_FORMAT(2, 0); 48 WPRINTF_FORMAT(2, 0);
44 49
45 } // namespace base 50 } // namespace base
46 51
47 // Don't require the namespace for legacy code. New code should use "base::" or 52 // Don't require the namespace for legacy code. New code should use "base::" or
48 // have its own using decl. 53 // have its own using decl.
49 // 54 //
50 // TODO(brettw) remove these when calling code is converted. 55 // TODO(brettw) remove these when calling code is converted.
51 using base::StringPrintf; 56 using base::StringPrintf;
52 57
53 #endif // BASE_STRINGPRINTF_H_ 58 #endif // BASE_STRINGPRINTF_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698