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
3 // found in the LICENSE file.
5 #ifndef BASE_STRINGS_STRINGPRINTF_H_
6 #define BASE_STRINGS_STRINGPRINTF_H_
8 #include <stdarg.h> // va_list
12 #include "base/base_export.h"
13 #include "base/compiler_specific.h"
17 // Return a C++ string given printf-like input.
18 BASE_EXPORT std::string StringPrintf(const char* format, ...)
20 // OS_ANDROID's libc does not support wchar_t, so several overloads are omitted.
21 #if !defined(OS_ANDROID)
22 BASE_EXPORT std::wstring StringPrintf(const wchar_t* format, ...)
26 // Return a C++ string given vprintf-like input.
27 BASE_EXPORT std::string StringPrintV(const char* format, va_list ap)
30 // Store result into a supplied string and return it.
31 BASE_EXPORT const std::string& SStringPrintf(std::string* dst,
32 const char* format, ...)
34 #if !defined(OS_ANDROID)
35 BASE_EXPORT const std::wstring& SStringPrintf(std::wstring* dst,
36 const wchar_t* format, ...)
40 // Append result to a supplied string.
41 BASE_EXPORT void StringAppendF(std::string* dst, const char* format, ...)
43 #if !defined(OS_ANDROID)
44 // TODO(evanm): this is only used in a few places in the code;
45 // replace with string16 version.
46 BASE_EXPORT void StringAppendF(std::wstring* dst, const wchar_t* format, ...)
50 // Lower-level routine that takes a va_list and appends to a specified
51 // string. All other routines are just convenience wrappers around it.
52 BASE_EXPORT void StringAppendV(std::string* dst, const char* format, va_list ap)
54 #if !defined(OS_ANDROID)
55 BASE_EXPORT void StringAppendV(std::wstring* dst,
56 const wchar_t* format, va_list ap)
62 #endif // BASE_STRINGS_STRINGPRINTF_H_