00001 #ifndef UNITTEST_MEMORYOUTSTREAM_H
00002 #define UNITTEST_MEMORYOUTSTREAM_H
00003
00004 #include "Config.h"
00005
00006 #ifndef UNITTEST_USE_CUSTOM_STREAMS
00007
00008 #include <sstream>
00009
00010 namespace UnitTest {
00011
00012 class MemoryOutStream : public std::ostringstream {
00013 public:
00014 MemoryOutStream() {}
00015 ~MemoryOutStream() {}
00016 char const* GetText() const;
00017
00018 private:
00019 MemoryOutStream ( MemoryOutStream const& );
00020 void operator = ( MemoryOutStream const& );
00021
00022 mutable std::string m_text;
00023 };
00024
00025 }
00026
00027 #else
00028
00029 #include <cstddef>
00030
00031 namespace UnitTest {
00032
00033 class MemoryOutStream {
00034 public:
00035 explicit MemoryOutStream ( int const size = 256 );
00036 ~MemoryOutStream();
00037
00038 char const* GetText() const;
00039
00040 MemoryOutStream& operator << ( char const* txt );
00041 MemoryOutStream& operator << ( int n );
00042 MemoryOutStream& operator << ( long n );
00043 MemoryOutStream& operator << ( unsigned long n );
00044 MemoryOutStream& operator << ( float f );
00045 MemoryOutStream& operator << ( double d );
00046 MemoryOutStream& operator << ( void const* p );
00047 MemoryOutStream& operator << ( unsigned int s );
00048
00049 enum { GROW_CHUNK_SIZE = 32 };
00050 int GetCapacity() const;
00051
00052 private:
00053 void operator= ( MemoryOutStream const& );
00054 void GrowBuffer ( int capacity );
00055
00056 int m_capacity;
00057 char* m_buffer;
00058 };
00059
00060 }
00061
00062 #endif
00063
00064 #endif