From 996d5f6c4e21d3d8688674f20e6f4318e3ace607 Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Sat, 2 Jan 2010 22:13:15 +0000 Subject: Cleaned up lifecycle handling of objects that hold library and file resources. Fixed pool stack initialization concurrency issue. Re-enabled watch strings to help watch compound values in debugger. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@895305 13f79535-47bb-0310-9956-ffa450edef68 --- sca-cpp/trunk/kernel/stream.hpp | 54 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) (limited to 'sca-cpp/trunk/kernel/stream.hpp') diff --git a/sca-cpp/trunk/kernel/stream.hpp b/sca-cpp/trunk/kernel/stream.hpp index a3e532c4ce..f3efb13479 100644 --- a/sca-cpp/trunk/kernel/stream.hpp +++ b/sca-cpp/trunk/kernel/stream.hpp @@ -39,6 +39,7 @@ namespace tuscany { class ostream { public: virtual ostream& vprintf(const char* fmt, ...) = 0; + virtual ostream& write(const string& s) = 0; virtual ostream& flush() = 0; }; @@ -68,10 +69,18 @@ ostream& operator<<(ostream& os, const int v) { return os.vprintf("%d", v); } +ostream& operator<<(ostream& os, const unsigned int v) { + return os.vprintf("%u", v); +} + ostream& operator<<(ostream& os, const long int v) { return os.vprintf("%ld", v); } +ostream& operator<<(ostream& os, const long unsigned int v) { + return os.vprintf("%lu", v); +} + ostream& operator<<(ostream& os, const double v) { return os.vprintf("%g", v); } @@ -81,7 +90,7 @@ ostream& operator<<(ostream& os, const void* v) { } ostream& operator<<(ostream& os, const string& v) { - return os.vprintf("%s", c_str(v)); + return os.write(v); } class stream_endl { @@ -143,6 +152,49 @@ template ostream& operator<<(ostream& out, const gc_ptr& p) { return out << p.ptr; } +#ifdef _DEBUG + +/** + * Debug stream implementation with no dependencies on anything else. + */ +class odebugstream : public ostream { +public: + odebugstream() { + } + + odebugstream& vprintf(const char* fmt, ...) { + va_list args; + va_start (args, fmt); + string s; + s.len = vsnprintf(NULL, 0, fmt, args); + s.buf = gc_cnew(s.len + 1); + vsnprintf(s.buf, s.len + 1, fmt, args); + buf = buf + s; + va_end (args); + return *this; + } + + odebugstream& write(const string& s) { + buf = buf + s; + return *this; + } + + odebugstream& flush() { + return *this; + } + +private: + friend const string str(odebugstream& os); + + string buf; +}; + +const string str(odebugstream& os) { + return os.buf; +} + +#endif + } #endif /* tuscany_stream_hpp */ -- cgit v1.2.3