Sierra Toolkit  Version of the Day
Null_Streambuf.hpp
1 /* ------------------------------------------------------------------ */
2 /* Copyright 2000 Sandia Corporation, Albuquerque, NM. */
3 /* ------------------------------------------------------------------ */
4 
5 #ifndef STK_UTIL_UTIL_null_streambuf_hpp
6 #define STK_UTIL_UTIL_null_streambuf_hpp
7 
8 #include <iostream>
9 #include <cstdio> /* Defines EOF */
10 
11 //: Specialize the ANSI Standard C++ streambuf class
12 //: that throws away everything given to it without
13 //: generating an error.
14 
15 class null_streambuf : public std::streambuf {
16 public:
17 
18  //: Constructor
19  null_streambuf();
20 
21  //: Destructor
22  virtual ~null_streambuf();
23 
24 protected:
25 
26  //: Called when output buffer is filled
27  virtual int overflow( int c = EOF );
28 
29  //: Sync is a no-op
30  virtual int sync();
31 
32  //: Setbuf is a no-op
33  virtual std::streambuf * setbuf( char * s , std::streamsize n );
34 
35 private:
36 
37  null_streambuf( const null_streambuf & ); // Not allowed
38  null_streambuf & operator = ( const null_streambuf & ); // Not allowed
39 
40  char buf[64]; // Throw away buffer
41 };
42 
43 /*--------------------------------------------------------------------*/
44 
45 #endif // STK_UTIL_UTIL_null_streambuf_hpp