Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 08:52:49

0001 // Copyright (c) 2012 Artyom Beilis (Tonkikh)
0002 // Copyright (c) 2020-2021 Alexander Grund
0003 //
0004 // Distributed under the Boost Software License, Version 1.0.
0005 // https://www.boost.org/LICENSE_1_0.txt
0006 
0007 #ifndef BOOST_NOWIDE_IOSTREAM_HPP_INCLUDED
0008 #define BOOST_NOWIDE_IOSTREAM_HPP_INCLUDED
0009 
0010 #include <boost/nowide/config.hpp>
0011 #ifdef BOOST_WINDOWS
0012 #include <istream>
0013 #include <memory>
0014 #include <ostream>
0015 
0016 #include <boost/config/abi_prefix.hpp> // must be the last #include
0017 #else
0018 #include <iostream>
0019 #endif
0020 
0021 #ifdef BOOST_MSVC
0022 #pragma warning(push)
0023 #pragma warning(disable : 4251)
0024 #endif
0025 
0026 namespace boost {
0027 namespace nowide {
0028 #if !defined(BOOST_WINDOWS) && !defined(BOOST_NOWIDE_DOXYGEN)
0029     using std::cout;
0030     using std::cerr;
0031     using std::cin;
0032     using std::clog;
0033 #else
0034 
0035     /// \cond INTERNAL
0036     namespace detail {
0037         class console_output_buffer;
0038         class console_input_buffer;
0039 
0040         class BOOST_NOWIDE_DECL winconsole_ostream : public std::ostream
0041         {
0042         public:
0043             enum class target_stream
0044             {
0045                 output,
0046                 error,
0047                 log,
0048             };
0049             winconsole_ostream(target_stream target, bool isBuffered, winconsole_ostream* tieStream);
0050             ~winconsole_ostream();
0051 
0052         private:
0053             std::unique_ptr<console_output_buffer> d;
0054             // Ensure the std streams are initialized and alive during the lifetime of this instance
0055             std::ios_base::Init init_;
0056         };
0057 
0058         class BOOST_NOWIDE_DECL winconsole_istream : public std::istream
0059         {
0060         public:
0061             explicit winconsole_istream(winconsole_ostream* tieStream);
0062             ~winconsole_istream();
0063 
0064         private:
0065             std::unique_ptr<console_input_buffer> d;
0066             // Ensure the std streams are initialized and alive during the lifetime of this instance
0067             std::ios_base::Init init_;
0068         };
0069     } // namespace detail
0070 
0071     /// \endcond
0072 
0073     ///
0074     /// \brief Same as std::cin, but uses UTF-8
0075     ///
0076     /// Note, the stream is not synchronized with stdio and not affected by std::ios::sync_with_stdio
0077     ///
0078     extern BOOST_NOWIDE_DECL detail::winconsole_istream cin;
0079     ///
0080     /// \brief Same as std::cout, but uses UTF-8
0081     ///
0082     /// Note, the stream is not synchronized with stdio and not affected by std::ios::sync_with_stdio
0083     ///
0084     extern BOOST_NOWIDE_DECL detail::winconsole_ostream cout;
0085     ///
0086     /// \brief Same as std::cerr, but uses UTF-8
0087     ///
0088     /// Note, the stream is not synchronized with stdio and not affected by std::ios::sync_with_stdio
0089     ///
0090     extern BOOST_NOWIDE_DECL detail::winconsole_ostream cerr;
0091     ///
0092     /// \brief Same as std::clog, but uses UTF-8
0093     ///
0094     /// Note, the stream is not synchronized with stdio and not affected by std::ios::sync_with_stdio
0095     ///
0096     extern BOOST_NOWIDE_DECL detail::winconsole_ostream clog;
0097 
0098 #endif
0099 
0100 } // namespace nowide
0101 } // namespace boost
0102 
0103 #ifdef BOOST_MSVC
0104 #pragma warning(pop)
0105 #endif
0106 
0107 #ifdef BOOST_WINDOWS
0108 #include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
0109 #endif
0110 
0111 #endif