< prev index next >

src/hotspot/share/utilities/ostream.hpp

Print this page
@@ -163,10 +163,24 @@
     // an automatic buffer on the stack (with O_BUFLEN len) is used.
     void set_scratch_buffer(char* p, size_t len) { _scratch = p; _scratch_len = len; }
  
     void dec_cr() { dec(); cr(); }
     void inc_cr() { inc(); cr(); }
+ 
+    // Append strings returned by gen, separating each with separator.
+    // Stops when gen returns null.
+    template <typename Generator>
+    void join(Generator gen, const char* separator) {
+      bool first = true;
+      const char* str = gen();
+      while (str != nullptr) {
+        const char* sep = first ? "" : separator;
+        print("%s%s", sep, str);
+        first = false;
+        str = gen();
+      }
+    }
  };
  
  // standard output
  // ANSI C++ name collision
  extern outputStream* tty;           // tty output
< prev index next >