Boost.Nowide
iostream.hpp
1 //
2 // Copyright (c) 2012 Artyom Beilis (Tonkikh)
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See
5 // accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7 //
8 #ifndef BOOST_NOWIDE_IOSTREAM_HPP_INCLUDED
9 #define BOOST_NOWIDE_IOSTREAM_HPP_INCLUDED
10 
11 #include <boost/nowide/config.hpp>
12 #include <boost/scoped_ptr.hpp>
13 #include <iostream>
14 #include <ostream>
15 #include <istream>
16 
17 #ifdef BOOST_MSVC
18 # pragma warning(push)
19 # pragma warning(disable : 4251)
20 #endif
21 
22 
23 namespace boost {
24 namespace nowide {
25  #if !defined(BOOST_WINDOWS) && !defined(BOOST_NOWIDE_DOXYGEN)
26  using std::cout;
27  using std::cerr;
28  using std::cin;
29  using std::clog;
30  #else
31 
33  namespace details {
34  class console_output_buffer;
35  class console_input_buffer;
36 
37  class BOOST_NOWIDE_DECL winconsole_ostream : public std::ostream {
38  winconsole_ostream(winconsole_ostream const &);
39  void operator=(winconsole_ostream const &);
40  public:
41  winconsole_ostream(int fd);
42  ~winconsole_ostream();
43  private:
44  boost::scoped_ptr<console_output_buffer> d;
45  };
46 
47  class BOOST_NOWIDE_DECL winconsole_istream : public std::istream {
48  winconsole_istream(winconsole_istream const &);
49  void operator=(winconsole_istream const &);
50  public:
51 
52  winconsole_istream();
53  ~winconsole_istream();
54  private:
55  struct data;
56  boost::scoped_ptr<console_input_buffer> d;
57  };
58  } // details
59 
61 
67  extern BOOST_NOWIDE_DECL details::winconsole_istream cin;
73  extern BOOST_NOWIDE_DECL details::winconsole_ostream cout;
79  extern BOOST_NOWIDE_DECL details::winconsole_ostream cerr;
85  extern BOOST_NOWIDE_DECL details::winconsole_ostream clog;
86 
87  #endif
88 
89 } // nowide
90 } // namespace boost
91 
92 #ifdef BOOST_MSVC
93 # pragma warning(pop)
94 #endif
95 
96 
97 #endif
98 // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
Definition: args.hpp:18
details::winconsole_ostream cout
Same as std::cout, but uses UTF-8.
details::winconsole_ostream clog
Same as std::clog, but uses UTF-8.
details::winconsole_istream cin
Same as std::cin, but uses UTF-8.
details::winconsole_ostream cerr
Same as std::cerr, but uses UTF-8.