Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/test/utils/nullstream.hpp @ 16:2665513ce2d3
Add boost headers
author | Chris Cannam |
---|---|
date | Tue, 05 Aug 2014 11:11:38 +0100 |
parents | |
children | c530137014c0 |
comparison
equal
deleted
inserted
replaced
15:663ca0da4350 | 16:2665513ce2d3 |
---|---|
1 // (C) Copyright Gennadiy Rozental 2002-2008. | |
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) | |
6 | |
7 // See http://www.boost.org/libs/test for the library home page. | |
8 // | |
9 // File : $RCSfile$ | |
10 // | |
11 // Version : $Revision: 49312 $ | |
12 // | |
13 // Description : simulate /dev/null stream | |
14 // *************************************************************************** | |
15 | |
16 #ifndef BOOST_NULLSTREAM_HPP_071894GER | |
17 #define BOOST_NULLSTREAM_HPP_071894GER | |
18 | |
19 #include <ostream> // for std::basic_ostream | |
20 #include <streambuf> // for std::basic_streambuf | |
21 #include <string> // for std::char_traits | |
22 | |
23 #include <boost/utility/base_from_member.hpp> | |
24 | |
25 #include <boost/test/detail/suppress_warnings.hpp> | |
26 | |
27 //____________________________________________________________________________// | |
28 | |
29 namespace boost { | |
30 | |
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++. | |
37 | |
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; | |
41 public: | |
42 // Types | |
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; | |
48 | |
49 // Use automatic default constructor and destructor | |
50 | |
51 protected: | |
52 // The default implementations of the miscellaneous virtual | |
53 // member functions are sufficient. | |
54 | |
55 // The default implementations of the input & putback virtual | |
56 // member functions, being nowhere but EOF, are sufficient. | |
57 | |
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 ); } | |
62 }; | |
63 | |
64 typedef basic_nullbuf<char> nullbuf; | |
65 typedef basic_nullbuf<wchar_t> wnullbuf; | |
66 | |
67 // ************************************************************************** // | |
68 // ************** basic_onullstream ************** // | |
69 // ************************************************************************** // | |
70 // Output streams based on basic_nullbuf. | |
71 | |
72 #ifdef BOOST_MSVC | |
73 # pragma warning(push) | |
74 # pragma warning(disable: 4355) // 'this' : used in base member initializer list | |
75 #endif | |
76 | |
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; | |
82 public: | |
83 // Constructor | |
84 basic_onullstream() : pbase_type(), base_type( &this->pbase_type::member ) {} | |
85 }; | |
86 | |
87 #ifdef BOOST_MSVC | |
88 # pragma warning(default: 4355) | |
89 #endif | |
90 | |
91 typedef basic_onullstream<char> onullstream; | |
92 typedef basic_onullstream<wchar_t> wonullstream; | |
93 | |
94 } // namespace boost | |
95 | |
96 //____________________________________________________________________________// | |
97 | |
98 #include <boost/test/detail/enable_warnings.hpp> | |
99 | |
100 #endif // BOOST_NULLSTREAM_HPP_071894GER |