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.
4 
5 #ifndef BASE_STRINGS_STRINGPRINTF_H_
6 #define BASE_STRINGS_STRINGPRINTF_H_
7 
8 #include <stdarg.h>   // va_list
9 
10 #include <string>
11 
12 #include "base/base_export.h"
13 #include "base/compiler_specific.h"
14 #include "build/build_config.h"
15 
16 namespace base {
17 
18 // Return a C++ string given printf-like input.
19 std::string StringPrintf(const char* format, ...)
20     PRINTF_FORMAT(1, 2) WARN_UNUSED_RESULT;
21 
22 // Return a C++ string given vprintf-like input.
23 std::string StringPrintV(const char* format, va_list ap)
24     PRINTF_FORMAT(1, 0) WARN_UNUSED_RESULT;
25 
26 // Store result into a supplied string and return it.
27 const std::string& SStringPrintf(std::string* dst, const char* format, ...)
28     PRINTF_FORMAT(2, 3);
29 
30 // Append result to a supplied string.
31 void StringAppendF(std::string* dst, const char* format, ...)
32     PRINTF_FORMAT(2, 3);
33 
34 // Lower-level routine that takes a va_list and appends to a specified
35 // string.  All other routines are just convenience wrappers around it.
36 void StringAppendV(std::string* dst, const char* format, va_list ap)
37     PRINTF_FORMAT(2, 0);
38 
39 }  // namespace base
40 
41 #endif  // BASE_STRINGS_STRINGPRINTF_H_
42