OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 // |printf()|-like formatting functions that output/append to C++ strings. | 5 // |printf()|-like formatting functions that output/append to C++ strings. |
6 // | 6 // |
7 // TODO(vtl): We don't have the |PRINTF_FORMAT()| macros/warnings like | 7 // TODO(vtl): We don't have the |PRINTF_FORMAT()| macros/warnings like |
8 // Chromium's version -- should we? (I've rarely seen them being useful.) | 8 // Chromium's version -- should we? (I've rarely seen them being useful.) |
9 | 9 |
10 #ifndef MOJO_EDK_UTIL_STRING_PRINTF_H_ | 10 #ifndef MOJO_EDK_UTIL_STRING_PRINTF_H_ |
11 #define MOJO_EDK_UTIL_STRING_PRINTF_H_ | 11 #define MOJO_EDK_UTIL_STRING_PRINTF_H_ |
12 | 12 |
| 13 #include <mojo/macros.h> |
13 #include <stdarg.h> | 14 #include <stdarg.h> |
14 | 15 |
15 #include <string> | 16 #include <string> |
16 | 17 |
17 #include "mojo/public/c/system/macros.h" | |
18 | |
19 namespace mojo { | 18 namespace mojo { |
20 namespace util { | 19 namespace util { |
21 | 20 |
22 // Formats |printf()|-like input and returns it as an |std::string|. | 21 // Formats |printf()|-like input and returns it as an |std::string|. |
23 std::string StringPrintf(const char* format, ...) MOJO_WARN_UNUSED_RESULT; | 22 std::string StringPrintf(const char* format, ...) MOJO_WARN_UNUSED_RESULT; |
24 | 23 |
25 // Formats |vprintf()|-like input and returns it as an |std::string|. | 24 // Formats |vprintf()|-like input and returns it as an |std::string|. |
26 std::string StringVPrintf(const char* format, | 25 std::string StringVPrintf(const char* format, |
27 va_list ap) MOJO_WARN_UNUSED_RESULT; | 26 va_list ap) MOJO_WARN_UNUSED_RESULT; |
28 | 27 |
29 // Formats |printf()|-like input and appends it to |*dest|. | 28 // Formats |printf()|-like input and appends it to |*dest|. |
30 void StringAppendf(std::string* dest, const char* format, ...); | 29 void StringAppendf(std::string* dest, const char* format, ...); |
31 | 30 |
32 // Formats |vprintf()|-like input and appends it to |*dest|. | 31 // Formats |vprintf()|-like input and appends it to |*dest|. |
33 void StringVAppendf(std::string* dest, const char* format, va_list ap); | 32 void StringVAppendf(std::string* dest, const char* format, va_list ap); |
34 | 33 |
35 } // namespace util | 34 } // namespace util |
36 } // namespace mojo | 35 } // namespace mojo |
37 | 36 |
38 #endif // MOJO_EDK_UTIL_STRING_PRINTF_H_ | 37 #endif // MOJO_EDK_UTIL_STRING_PRINTF_H_ |
OLD | NEW |