Skip to Content.
Sympa Menu

charm - Re: [charm] ckout << std::string

charm AT lists.cs.illinois.edu

Subject: Charm++ parallel programming system

List archive

Re: [charm] ckout << std::string


Chronological Thread 
  • From: Ed Karrels <edk AT illinois.edu>
  • To: <charm AT cs.uiuc.edu>
  • Subject: Re: [charm] ckout << std::string
  • Date: Fri, 21 Oct 2016 16:57:08 -0500

Please ignore my suggested solution--it doesn't always work.

But it would be nice if C++ strings were supported.


On Fri, Oct 21, 2016 at 12:40 PM, Ed Karrels <edk AT illinois.edu> wrote:
Hello Charm++ group,
ckout doesn't currently support C++ string objects, and it would be nice if it did. I added it to src/ck-core/ckstream.h, but I'm not a C++ streams expert. My changes are append.

While I was looking at the code, I noticed that the routine for handling C strings (and my C++ string hack) don't handle the overflow of _obuf well. It would be nice if, for long strings, it would just flush the buffer and then output the string. Also, for efficiency it should probably do strcat(_obuf + _actlen, str) rather than strcat(_obuf, str).


diff --git a/src/ck-core/ckstream.h b/src/ck-core/ckstream.h
index 04fed7c..ebe2967 100644
--- a/src/ck-core/ckstream.h
+++ b/src/ck-core/ckstream.h
@@ -75,6 +75,13 @@ class _CkOStream {
       output(str);
       return *this;
     }
+
+    _CkOStream& operator << (const std::string &str) {
+      output(str.c_str());
+      return *this;
+    }
+
+   
 };
 
 static inline _CkOStream& endl(_CkOStream& s)  { return s.endl(); }
@@ -114,6 +121,7 @@ class CkOStream {
   SHIFTLEFT(float);
   SHIFTLEFT(double);
   SHIFTLEFT(const char*);
+  SHIFTLEFT(const std::string&);
   SHIFTLEFT(void*);
 };
 
@@ -143,6 +151,7 @@ class CkOutStream : public CkOStream {
     OUTSHIFTLEFT(float);
     OUTSHIFTLEFT(double);
     OUTSHIFTLEFT(const char*);
+    OUTSHIFTLEFT(const std::string&);
     OUTSHIFTLEFT(void*);
 };
 
@@ -172,6 +181,7 @@ class CkErrStream : public CkOStream {
     ERRSHIFTLEFT(float);
     ERRSHIFTLEFT(double);
     ERRSHIFTLEFT(const char*);
+    ERRSHIFTLEFT(const std::string&);
     ERRSHIFTLEFT(void*);
 };
 







Archive powered by MHonArc 2.6.19.

Top of Page