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