aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/lib/strings/stringprintf.h
diff options
context:
space:
mode:
Diffstat (limited to 'tensorflow/core/lib/strings/stringprintf.h')
-rw-r--r--tensorflow/core/lib/strings/stringprintf.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/tensorflow/core/lib/strings/stringprintf.h b/tensorflow/core/lib/strings/stringprintf.h
new file mode 100644
index 0000000000..23ca2583ca
--- /dev/null
+++ b/tensorflow/core/lib/strings/stringprintf.h
@@ -0,0 +1,37 @@
+// Printf variants that place their output in a C++ string.
+//
+// Usage:
+// string result = strings::Printf("%d %s\n", 10, "hello");
+// strings::SPrintf(&result, "%d %s\n", 10, "hello");
+// strings::Appendf(&result, "%d %s\n", 20, "there");
+
+#ifndef TENSORFLOW_LIB_STRINGS_STRINGPRINTF_H_
+#define TENSORFLOW_LIB_STRINGS_STRINGPRINTF_H_
+
+#include <stdarg.h>
+#include <string>
+#include <vector>
+
+#include "tensorflow/core/platform/port.h"
+
+namespace tensorflow {
+namespace strings {
+
+// Return a C++ string
+extern string Printf(const char* format, ...)
+ // Tell the compiler to do printf format string checking.
+ TF_PRINTF_ATTRIBUTE(1, 2);
+
+// Append result to a supplied string
+extern void Appendf(string* dst, const char* format, ...)
+ // Tell the compiler to do printf format string checking.
+ TF_PRINTF_ATTRIBUTE(2, 3);
+
+// Lower-level routine that takes a va_list and appends to a specified
+// string. All other routines are just convenience wrappers around it.
+extern void Appendv(string* dst, const char* format, va_list ap);
+
+} // namespace strings
+} // namespace tensorflow
+
+#endif // TENSORFLOW_LIB_STRINGS_STRINGPRINTF_H_