summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/kernel/stream.hpp
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-01-02 22:13:15 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-01-02 22:13:15 +0000
commit996d5f6c4e21d3d8688674f20e6f4318e3ace607 (patch)
treebe6a3d80f2cab11cd39d0f55bd4bc55793a2e735 /sca-cpp/trunk/kernel/stream.hpp
parentdda9255a5c9336cd3078f85f02e88120563ad304 (diff)
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
Diffstat (limited to 'sca-cpp/trunk/kernel/stream.hpp')
-rw-r--r--sca-cpp/trunk/kernel/stream.hpp54
1 files changed, 53 insertions, 1 deletions
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<typename T> ostream& operator<<(ostream& out, const gc_ptr<T>& 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 */