1 /*============================================================================= 2 Copyright (c) 2009 Daniel James 3 4 Use, modification and distribution is subject to the Boost Software 5 License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 6 http://www.boost.org/LICENSE_1_0.txt) 7 =============================================================================*/ 8 9 // For handling native strings and streams. 10 11 #if !defined(BOOST_QUICKBOOK_DETAIL_STREAM_HPP) 12 #define BOOST_QUICKBOOK_DETAIL_STREAM_HPP 13 14 #include <iostream> 15 #include <boost/filesystem/path.hpp> 16 #include "native_text.hpp" 17 18 namespace quickbook 19 { 20 namespace fs = boost::filesystem; 21 22 namespace detail 23 { 24 // A light wrapper around C++'s streams that gets things right 25 // in the quickbook context. 26 // 27 // This is far from perfect but it fixes some issues. 28 struct ostream 29 { 30 typedef stream_string string; 31 #if QUICKBOOK_WIDE_STREAMS 32 typedef std::wostream base_ostream; 33 typedef std::wios base_ios; 34 #else 35 typedef std::ostream base_ostream; 36 typedef std::ios base_ios; 37 #endif 38 base_ostream& base; 39 ostreamquickbook::detail::ostream40 explicit ostream(base_ostream& x) : base(x) {} 41 42 // C strings should always be ascii. 43 ostream& operator<<(char); 44 ostream& operator<<(char const*); 45 46 // std::string should be UTF-8 (what a mess!) 47 ostream& operator<<(std::string const&); 48 ostream& operator<<(quickbook::string_view); 49 50 // Other value types. 51 ostream& operator<<(int x); 52 ostream& operator<<(unsigned int x); 53 ostream& operator<<(long x); 54 ostream& operator<<(unsigned long x); 55 56 #if !defined(BOOST_NO_LONG_LONG) 57 ostream& operator<<(boost::long_long_type x); 58 ostream& operator<<(boost::ulong_long_type x); 59 #endif 60 61 ostream& operator<<(fs::path const&); 62 63 // Modifiers 64 ostream& operator<<(base_ostream& (*)(base_ostream&)); 65 ostream& operator<<(base_ios& (*)(base_ios&)); 66 }; 67 68 void initialise_output(); 69 70 ostream& out(); 71 72 // Preformats an error/warning message so that it can be parsed by 73 // common IDEs. Set 'ms_errors' to determine if VS format 74 // or GCC format. Returns the stream to continue ouput of the verbose 75 // error message. 76 void set_ms_errors(bool); 77 ostream& outerr(); 78 ostream& outerr(fs::path const& file, std::ptrdiff_t line = -1); 79 ostream& outwarn(fs::path const& file, std::ptrdiff_t line = -1); 80 ostream& outerr(file_ptr const&, string_iterator); 81 ostream& outwarn(file_ptr const&, string_iterator); 82 } 83 } 84 85 #endif 86