root/library/tests/unittest-cpp/MemoryOutStream.h @ 927

Revision 706, 1.2 kB (checked in by smidl, 15 years ago)

eol-native

  • Property svn:eol-style set to native
Line 
1#ifndef UNITTEST_MEMORYOUTSTREAM_H
2#define UNITTEST_MEMORYOUTSTREAM_H
3
4#include "Config.h"
5
6#ifndef UNITTEST_USE_CUSTOM_STREAMS
7
8#include <sstream>
9
10namespace UnitTest {
11
12class MemoryOutStream : public std::ostringstream {
13public:
14        MemoryOutStream() {}
15        ~MemoryOutStream() {}
16        char const* GetText() const;
17
18private:
19        MemoryOutStream ( MemoryOutStream const& );
20        void operator = ( MemoryOutStream const& );
21
22        mutable std::string m_text;
23};
24
25}
26
27#else
28
29#include <cstddef>
30
31namespace UnitTest {
32
33class MemoryOutStream {
34public:
35        explicit MemoryOutStream ( int const size = 256 );
36        ~MemoryOutStream();
37
38        char const* GetText() const;
39
40        MemoryOutStream& operator << ( char const* txt );
41        MemoryOutStream& operator << ( int n );
42        MemoryOutStream& operator << ( long n );
43        MemoryOutStream& operator << ( unsigned long n );
44        MemoryOutStream& operator << ( float f );
45        MemoryOutStream& operator << ( double d );
46        MemoryOutStream& operator << ( void const* p );
47        MemoryOutStream& operator << ( unsigned int s );
48
49        enum { GROW_CHUNK_SIZE = 32 };
50        int GetCapacity() const;
51
52private:
53        void operator= ( MemoryOutStream const& );
54        void GrowBuffer ( int capacity );
55
56        int m_capacity;
57        char* m_buffer;
58};
59
60}
61
62#endif
63
64#endif
Note: See TracBrowser for help on using the browser.