Update contrib.
1 // (C) Copyright Gennadiy Rozental 2002-2005.
2 // (C) Copyright Daryle Walker 2000-2001.
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
7 // See http://www.boost.org/libs/test for the library home page.
9 // File : $RCSfile: nullstream.hpp,v $
11 // Version : $Revision: 1.4 $
13 // Description : simulate /dev/null stream
14 // ***************************************************************************
16 #ifndef BOOST_NULLSTREAM_HPP_071894GER
17 #define BOOST_NULLSTREAM_HPP_071894GER
19 #include <ostream> // for std::basic_ostream
20 #include <streambuf> // for std::basic_streambuf
21 #include <string> // for std::char_traits
23 #include <boost/utility/base_from_member.hpp>
25 #include <boost/test/detail/suppress_warnings.hpp>
27 //____________________________________________________________________________//
31 // ************************************************************************** //
32 // ************** basic_nullbuf ************** //
33 // ************************************************************************** //
34 // Class for a buffer that reads nothing and writes to nothing.
35 // Idea from an Usenet post by Tom <the_wid@my-deja.com> at
36 // 27 Oct 2000 14:06:21 GMT on comp.lang.c++.
38 template<typename CharType, class CharTraits = ::std::char_traits<CharType> >
39 class basic_nullbuf : public ::std::basic_streambuf<CharType, CharTraits> {
40 typedef ::std::basic_streambuf<CharType, CharTraits> base_type;
43 typedef typename base_type::char_type char_type;
44 typedef typename base_type::traits_type traits_type;
45 typedef typename base_type::int_type int_type;
46 typedef typename base_type::pos_type pos_type;
47 typedef typename base_type::off_type off_type;
49 // Use automatic default constructor and destructor
52 // The default implementations of the miscellaneous virtual
53 // member functions are sufficient.
55 // The default implementations of the input & putback virtual
56 // member functions, being nowhere but EOF, are sufficient.
58 // The output virtual member functions need to be changed to
59 // accept anything without any problems, instead of being at EOF.
60 virtual ::std::streamsize xsputn( char_type const* /*s*/, ::std::streamsize n ) { return n; } // "s" is unused
61 virtual int_type overflow( int_type c = traits_type::eof() ) { return traits_type::not_eof( c ); }
64 typedef basic_nullbuf<char> nullbuf;
65 typedef basic_nullbuf<wchar_t> wnullbuf;
67 // ************************************************************************** //
68 // ************** basic_onullstream ************** //
69 // ************************************************************************** //
70 // Output streams based on basic_nullbuf.
73 # pragma warning(push)
74 # pragma warning(disable: 4355) // 'this' : used in base member initializer list
77 template< typename CharType, class CharTraits = ::std::char_traits<CharType> >
78 class basic_onullstream : private boost::base_from_member<basic_nullbuf<CharType, CharTraits> >
79 , public ::std::basic_ostream<CharType, CharTraits> {
80 typedef boost::base_from_member<basic_nullbuf<CharType, CharTraits> > pbase_type;
81 typedef ::std::basic_ostream<CharType, CharTraits> base_type;
84 basic_onullstream() : pbase_type(), base_type( &this->pbase_type::member ) {}
88 # pragma warning(default: 4355)
91 typedef basic_onullstream<char> onullstream;
92 typedef basic_onullstream<wchar_t> wonullstream;
96 //____________________________________________________________________________//
98 #include <boost/test/detail/enable_warnings.hpp>
100 // ***************************************************************************
101 // Revision History :
103 // $Log: nullstream.hpp,v $
104 // Revision 1.4 2005/02/20 08:27:08 rogeeff
105 // This a major update for Boost.Test framework. See release docs for complete list of fixes/updates
107 // Revision 1.3 2005/02/01 06:40:07 rogeeff
109 // old log entries removed
110 // minor stilistic changes
111 // depricated tools removed
113 // Revision 1.2 2005/01/30 01:42:49 rogeeff
114 // warnings suppressed
116 // Revision 1.1 2005/01/22 18:21:40 rogeeff
117 // moved sharable staff into utils
119 // ***************************************************************************
121 #endif // BOOST_NULLSTREAM_HPP_071894GER