aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/framework/op_gen_lib.cc
diff options
context:
space:
mode:
authorGravatar Manjunath Kudlur <keveman@gmail.com>2015-11-06 16:27:58 -0800
committerGravatar Manjunath Kudlur <keveman@gmail.com>2015-11-06 16:27:58 -0800
commitf41959ccb2d9d4c722fe8fc3351401d53bcf4900 (patch)
treeef0ca22cb2a5ac4bdec9d080d8e0788a53ed496d /tensorflow/core/framework/op_gen_lib.cc
TensorFlow: Initial commit of TensorFlow library.
TensorFlow is an open source software library for numerical computation using data flow graphs. Base CL: 107276108
Diffstat (limited to 'tensorflow/core/framework/op_gen_lib.cc')
-rw-r--r--tensorflow/core/framework/op_gen_lib.cc55
1 files changed, 55 insertions, 0 deletions
diff --git a/tensorflow/core/framework/op_gen_lib.cc b/tensorflow/core/framework/op_gen_lib.cc
new file mode 100644
index 0000000000..04f4b7cacd
--- /dev/null
+++ b/tensorflow/core/framework/op_gen_lib.cc
@@ -0,0 +1,55 @@
+#include "tensorflow/core/framework/op_gen_lib.h"
+
+#include "tensorflow/core/lib/strings/strcat.h"
+
+namespace tensorflow {
+
+string WordWrap(StringPiece prefix, StringPiece str, int width) {
+ const string indent_next_line = "\n" + Spaces(prefix.size());
+ width -= prefix.size();
+ string result;
+ strings::StrAppend(&result, prefix);
+
+ while (!str.empty()) {
+ if (static_cast<int>(str.size()) <= width) {
+ // Remaining text fits on one line.
+ strings::StrAppend(&result, str);
+ break;
+ }
+ auto space = str.rfind(' ', width);
+ if (space == StringPiece::npos) {
+ // Rather make a too-long line and break at a space.
+ space = str.find(' ');
+ if (space == StringPiece::npos) {
+ strings::StrAppend(&result, str);
+ break;
+ }
+ }
+ // Breaking at character at position <space>.
+ StringPiece to_append = str.substr(0, space);
+ str.remove_prefix(space + 1);
+ // Remove spaces at break.
+ while (to_append.ends_with(" ")) {
+ to_append.remove_suffix(1);
+ }
+ while (str.Consume(" ")) {
+ }
+
+ // Go on to the next line.
+ strings::StrAppend(&result, to_append);
+ if (!str.empty()) strings::StrAppend(&result, indent_next_line);
+ }
+
+ return result;
+}
+
+bool ConsumeEquals(StringPiece* description) {
+ if (description->Consume("=")) {
+ while (description->Consume(" ")) { // Also remove spaces after "=".
+ }
+ return true;
+ }
+ return false;
+}
+
+} // namespace tensorflow