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 00013 class MemoryOutStream : public std::ostringstream 00014 { 00015 public: 00016 MemoryOutStream() {} 00017 ~MemoryOutStream() {} 00018 char const* GetText() const; 00019 00020 private: 00021 MemoryOutStream(MemoryOutStream const&); 00022 void operator =(MemoryOutStream const&); 00023 00024 mutable std::string m_text; 00025 }; 00026 00027 } 00028 00029 #else 00030 00031 #include <cstddef> 00032 00033 namespace UnitTest 00034 { 00035 00036 class MemoryOutStream 00037 { 00038 public: 00039 explicit MemoryOutStream(int const size = 256); 00040 ~MemoryOutStream(); 00041 00042 char const* GetText() const; 00043 00044 MemoryOutStream& operator << (char const* txt); 00045 MemoryOutStream& operator << (int n); 00046 MemoryOutStream& operator << (long n); 00047 MemoryOutStream& operator << (unsigned long n); 00048 MemoryOutStream& operator << (float f); 00049 MemoryOutStream& operator << (double d); 00050 MemoryOutStream& operator << (void const* p); 00051 MemoryOutStream& operator << (unsigned int s); 00052 00053 enum { GROW_CHUNK_SIZE = 32 }; 00054 int GetCapacity() const; 00055 00056 private: 00057 void operator= (MemoryOutStream const&); 00058 void GrowBuffer(int capacity); 00059 00060 int m_capacity; 00061 char* m_buffer; 00062 }; 00063 00064 } 00065 00066 #endif 00067 00068 #endif