aboutsummaryrefslogtreecommitdiffstats
path: root/tests/UnitTest++/src/MemoryOutStream.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/UnitTest++/src/MemoryOutStream.h')
-rw-r--r--tests/UnitTest++/src/MemoryOutStream.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/tests/UnitTest++/src/MemoryOutStream.h b/tests/UnitTest++/src/MemoryOutStream.h
new file mode 100644
index 0000000..e03227e
--- /dev/null
+++ b/tests/UnitTest++/src/MemoryOutStream.h
@@ -0,0 +1,67 @@
+#ifndef UNITTEST_MEMORYOUTSTREAM_H
+#define UNITTEST_MEMORYOUTSTREAM_H
+
+#include "Config.h"
+
+#ifndef UNITTEST_USE_CUSTOM_STREAMS
+
+#include <sstream>
+
+namespace UnitTest
+{
+
+class MemoryOutStream : public std::ostringstream
+{
+public:
+ MemoryOutStream() {}
+ char const* GetText() const;
+
+private:
+ MemoryOutStream(MemoryOutStream const&);
+ void operator =(MemoryOutStream const&);
+
+ mutable std::string m_text;
+};
+
+}
+
+#else
+
+#include <cstddef>
+
+namespace UnitTest
+{
+
+class MemoryOutStream
+{
+public:
+ explicit MemoryOutStream(int const size = 256);
+ ~MemoryOutStream();
+
+ char const* GetText() const;
+
+ MemoryOutStream& operator << (char const* txt);
+ MemoryOutStream& operator << (int n);
+ MemoryOutStream& operator << (long n);
+ MemoryOutStream& operator << (unsigned long n);
+ MemoryOutStream& operator << (float f);
+ MemoryOutStream& operator << (double d);
+ MemoryOutStream& operator << (void const* p);
+ MemoryOutStream& operator << (unsigned int s);
+
+ enum { GROW_CHUNK_SIZE = 32 };
+ int GetCapacity() const;
+
+private:
+ void operator= (MemoryOutStream const&);
+ void GrowBuffer(int capacity);
+
+ int m_capacity;
+ char* m_buffer;
+};
+
+}
+
+#endif
+
+#endif