systemc: Implement sc_time::to_string.
authorGabe Black <gabeblack@google.com>
Thu, 6 Sep 2018 00:34:43 +0000 (17:34 -0700)
committerGabe Black <gabeblack@google.com>
Tue, 9 Oct 2018 21:37:14 +0000 (21:37 +0000)
This is just another way to call sc_time::print, but it returns a
string instead of printing to a stream.

Change-Id: Idc90c539127e6153af9511bfe5f258b870362330
Reviewed-on: https://gem5-review.googlesource.com/c/12596
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>

src/systemc/core/sc_time.cc

index 74345d0416b609edc92fb65004b45a08eadf8ac0..69d58e5122539284df95589ac5a4fd14a00831a0 100644 (file)
@@ -27,6 +27,7 @@
  * Authors: Gabe Black
  */
 
+#include <sstream>
 #include <vector>
 
 #include "base/logging.hh"
@@ -211,8 +212,9 @@ sc_time::to_seconds() const
 const std::string
 sc_time::to_string() const
 {
-    warn("%s not implemented.\n", __PRETTY_FUNCTION__);
-    return "";
+    std::ostringstream ss;
+    print(ss);
+    return ss.str();
 }
 
 bool