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

Unified Diff: mojo/edk/util/string_printf.h

Issue 1486923002: EDK: Add mojo::util::StringPrintf() (etc.) and convert away from base's. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: there is no try Created 5 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/edk/util/BUILD.gn ('k') | mojo/edk/util/string_printf.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/util/string_printf.h
diff --git a/mojo/edk/util/string_printf.h b/mojo/edk/util/string_printf.h
new file mode 100644
index 0000000000000000000000000000000000000000..584b5b9aa3fa923ee5196ddc0d143a655ff4b324
--- /dev/null
+++ b/mojo/edk/util/string_printf.h
@@ -0,0 +1,38 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// |printf()|-like formatting functions that output/append to C++ strings.
+//
+// TODO(vtl): We don't have the |PRINTF_FORMAT()| macros/warnings like
+// Chromium's version -- should we? (I've rarely seen them being useful.)
+
+#ifndef MOJO_EDK_UTIL_STRING_PRINTF_H_
+#define MOJO_EDK_UTIL_STRING_PRINTF_H_
+
+#include <stdarg.h>
+
+#include <string>
+
+#include "mojo/public/c/system/macros.h"
+
+namespace mojo {
+namespace util {
+
+// Formats |printf()|-like input and returns it as an |std::string|.
+std::string StringPrintf(const char* format, ...) MOJO_WARN_UNUSED_RESULT;
+
+// Formats |vprintf()|-like input and returns it as an |std::string|.
+std::string StringVPrintf(const char* format,
+ va_list ap) MOJO_WARN_UNUSED_RESULT;
+
+// Formats |printf()|-like input and appends it to |*dest|.
+void StringAppendf(std::string* dest, const char* format, ...);
+
+// Formats |vprintf()|-like input and appends it to |*dest|.
+void StringVAppendf(std::string* dest, const char* format, va_list ap);
+
+} // namespace util
+} // namespace mojo
+
+#endif // MOJO_EDK_UTIL_STRING_PRINTF_H_
« no previous file with comments | « mojo/edk/util/BUILD.gn ('k') | mojo/edk/util/string_printf.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698