OpenMEEG
Loading...
Searching...
No Matches
NullStream.h
Go to the documentation of this file.
1// Project Name: OpenMEEG (http://openmeeg.github.io)
2// © INRIA and ENPC under the French open source license CeCILL-B.
3// See full copyright notice in the file LICENSE.txt
4// If you make a copy of this file, you must either:
5// - provide also LICENSE.txt and modify this header to refer to it.
6// - replace this header by the LICENSE.txt content.
7
8#pragma once
9
10#include <ostream>
11#include <streambuf>
12
13namespace OpenMEEG {
14
15 // Null buffer that store nothing.
16
17 template<typename CharType,typename CharTraits=std::char_traits<CharType>>
18 class NullBuffer: public std::basic_streambuf<CharType,CharTraits> {
19
20 typedef std::basic_streambuf<CharType,CharTraits> base;
21
22 public:
23
24 using typename base::char_type;
25 using typename base::int_type;
26 using typename base::traits_type;
27
28 NullBuffer() : std::streambuf() {}
29
30 virtual std::streamsize
31 xsputn(char_type const*,std::streamsize n) { return n; }
32
33 virtual int_type
34 overflow(int_type c=traits_type::eof()) { return traits_type::not_eof(c); }
35 };
36
37 // Null stream that outputs nothing.
38
39 template<typename CharType,typename CharTraits=std::char_traits<CharType>>
40 class NullStream: public std::basic_ostream<CharType,CharTraits> {
41
42 typedef std::basic_ostream<CharType,CharTraits> base;
43
44 public:
45
46 NullStream(): base(&nullbuf) {}
47
48 private:
49
51 };
52}
virtual std::streamsize xsputn(char_type const *, std::streamsize n)
Definition NullStream.h:31
virtual int_type overflow(int_type c=traits_type::eof())
Definition NullStream.h:34