patrick
/
plasp
Archived
1
0
Fork 0
This repository has been archived on 2023-07-19. You can view files and clone it, but cannot push or open issues or pull requests.
plasp/tests/NullOutputStream.h

45 lines
952 B
C++

#ifndef __PLASP__TESTS__NULL_OUTPUT_STREAM_H
#define __PLASP__TESTS__NULL_OUTPUT_STREAM_H
#include <iostream>
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// NullOutputStream
//
////////////////////////////////////////////////////////////////////////////////////////////////////
class NullStreamBuffer : public std::streambuf
{
private:
char dummyBuffer[64];
protected:
virtual int overflow(int c)
{
setp(dummyBuffer, dummyBuffer + sizeof(dummyBuffer));
return (c == traits_type::eof()) ? '\0' : c;
}
};
////////////////////////////////////////////////////////////////////////////////////////////////////
class NullOutputStream : public std::ostream
{
public:
NullOutputStream()
: std::ostream(&m_nullStreamBuffer)
{
}
NullStreamBuffer *rdbuf() const
{
return &m_nullStreamBuffer;
}
private:
mutable NullStreamBuffer m_nullStreamBuffer;
};
#endif