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

Revision 418, 1.2 kB (checked in by vbarta, 15 years ago)

#27: added UnitTest?++ to bdm sources, changed test_user_data to use it

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{
12
13class MemoryOutStream : public std::ostringstream
14{
15public:
16    MemoryOutStream() {}
17    ~MemoryOutStream() {}
18    char const* GetText() const;
19
20private:
21    MemoryOutStream(MemoryOutStream const&);
22    void operator =(MemoryOutStream const&);
23
24    mutable std::string m_text;
25};
26
27}
28
29#else
30
31#include <cstddef>
32
33namespace UnitTest
34{
35
36class MemoryOutStream
37{
38public:
39    explicit MemoryOutStream(int const size = 256);
40    ~MemoryOutStream();
41
42    char const* GetText() const;
43
44    MemoryOutStream& operator << (char const* txt);
45    MemoryOutStream& operator << (int n);
46    MemoryOutStream& operator << (long n);
47    MemoryOutStream& operator << (unsigned long n);
48    MemoryOutStream& operator << (float f);
49    MemoryOutStream& operator << (double d);
50    MemoryOutStream& operator << (void const* p);
51    MemoryOutStream& operator << (unsigned int s);
52
53    enum { GROW_CHUNK_SIZE = 32 };
54    int GetCapacity() const;
55
56private:
57    void operator= (MemoryOutStream const&);
58    void GrowBuffer(int capacity);
59
60    int m_capacity;
61    char* m_buffer;
62};
63
64}
65
66#endif
67
68#endif
Note: See TracBrowser for help on using the browser.