sbuild  1.7.1
nostream.h
1 /* Copyright © 2005-2013 Roger Leigh <rleigh@debian.org>
2  *
3  * schroot is free software: you can redistribute it and/or modify it
4  * under the terms of the GNU General Public License as published by
5  * the Free Software Foundation, either version 3 of the License, or
6  * (at your option) any later version.
7  *
8  * schroot is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see
15  * <http://www.gnu.org/licenses/>.
16  *
17  *********************************************************************/
18 
19 #ifndef SBUILD_NOSTREAM_H
20 #define SBUILD_NOSTREAM_H
21 
22 #include <streambuf>
23 #include <ostream>
24 
25 namespace sbuild
26 {
27 
32  template <class cT, class traits = std::char_traits<cT> >
33  class basic_nbuf: public std::basic_streambuf<cT, traits>
34  {
41  typename traits::int_type
42  overflow (typename traits::int_type c)
43  {
44  return traits::not_eof(c); // indicate success
45  }
46  };
47 
52  template <class cT, class traits = std::char_traits<cT> >
53  class basic_nostream: public std::basic_ostream<cT, traits>
54  {
55  public:
58  std::basic_ios<cT, traits>(&nbuf),
59  std::basic_ostream<cT, traits>(&nbuf)
60  {
61  this->init(&nbuf);
62  }
63 
64  private:
67  };
68 
73 
75  extern nostream cnull;
76 
77 }
78 
79 #endif /* SBUILD_NOSTREAM_H */
80 
81 /*
82  * Local Variables:
83  * mode:C++
84  * End:
85  */