iostream.hpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. //
  2. // Copyright (c) 2012 Artyom Beilis (Tonkikh)
  3. // Copyright (c) 2020 Alexander Grund
  4. //
  5. // Distributed under the Boost Software License, Version 1.0. (See
  6. // accompanying file LICENSE or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //
  9. #ifndef BOOST_NOWIDE_IOSTREAM_HPP_INCLUDED
  10. #define BOOST_NOWIDE_IOSTREAM_HPP_INCLUDED
  11. #include <boost/nowide/config.hpp>
  12. #ifdef BOOST_WINDOWS
  13. #include <istream>
  14. #include <memory>
  15. #include <ostream>
  16. #include <boost/config/abi_prefix.hpp> // must be the last #include
  17. #else
  18. #include <iostream>
  19. #endif
  20. #ifdef BOOST_MSVC
  21. #pragma warning(push)
  22. #pragma warning(disable : 4251)
  23. #endif
  24. namespace boost {
  25. namespace nowide {
  26. #if !defined(BOOST_WINDOWS) && !defined(BOOST_NOWIDE_DOXYGEN)
  27. using std::cout;
  28. using std::cerr;
  29. using std::cin;
  30. using std::clog;
  31. #else
  32. /// \cond INTERNAL
  33. namespace detail {
  34. class console_output_buffer;
  35. class console_input_buffer;
  36. class BOOST_NOWIDE_DECL winconsole_ostream : public std::ostream
  37. {
  38. public:
  39. winconsole_ostream(int fd, winconsole_ostream* tieStream);
  40. ~winconsole_ostream();
  41. private:
  42. std::unique_ptr<console_output_buffer> d;
  43. };
  44. class BOOST_NOWIDE_DECL winconsole_istream : public std::istream
  45. {
  46. public:
  47. explicit winconsole_istream(winconsole_ostream* tieStream);
  48. ~winconsole_istream();
  49. private:
  50. std::unique_ptr<console_input_buffer> d;
  51. };
  52. } // namespace detail
  53. /// \endcond
  54. ///
  55. /// \brief Same as std::cin, but uses UTF-8
  56. ///
  57. /// Note, the stream is not synchronized with stdio and not affected by std::ios::sync_with_stdio
  58. ///
  59. extern BOOST_NOWIDE_DECL detail::winconsole_istream cin;
  60. ///
  61. /// \brief Same as std::cout, but uses UTF-8
  62. ///
  63. /// Note, the stream is not synchronized with stdio and not affected by std::ios::sync_with_stdio
  64. ///
  65. extern BOOST_NOWIDE_DECL detail::winconsole_ostream cout;
  66. ///
  67. /// \brief Same as std::cerr, but uses UTF-8
  68. ///
  69. /// Note, the stream is not synchronized with stdio and not affected by std::ios::sync_with_stdio
  70. ///
  71. extern BOOST_NOWIDE_DECL detail::winconsole_ostream cerr;
  72. ///
  73. /// \brief Same as std::clog, but uses UTF-8
  74. ///
  75. /// Note, the stream is not synchronized with stdio and not affected by std::ios::sync_with_stdio
  76. ///
  77. extern BOOST_NOWIDE_DECL detail::winconsole_ostream clog;
  78. #endif
  79. } // namespace nowide
  80. } // namespace boost
  81. #ifdef BOOST_MSVC
  82. #pragma warning(pop)
  83. #endif
  84. #ifdef BOOST_WINDOWS
  85. #include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
  86. #endif
  87. #endif