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