]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/quickbook/src/stream.cpp
1 /*=============================================================================
2 Copyright (c) 2009 Daniel James
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 =============================================================================*/
13 #if QUICKBOOK_WIDE_PATHS || QUICKBOOK_WIDE_STREAMS
24 bool ms_errors
= false;
27 void set_ms_errors(bool x
) { ms_errors
= x
; }
29 #if QUICKBOOK_WIDE_STREAMS
31 void initialise_output()
33 if (_isatty(_fileno(stdout
))) _setmode(_fileno(stdout
), _O_U16TEXT
);
34 if (_isatty(_fileno(stderr
))) _setmode(_fileno(stderr
), _O_U16TEXT
);
37 void write_utf8(ostream::base_ostream
& out
, quickbook::string_view x
)
44 static ostream
x(std::wcout
);
50 inline ostream
& error_stream()
52 static ostream
x(std::wcerr
);
59 void initialise_output() {}
61 void write_utf8(ostream::base_ostream
& out
, quickbook::string_view x
)
68 static ostream
x(std::cout
);
74 inline ostream
& error_stream()
76 static ostream
x(std::clog
);
83 ostream
& outerr() { return error_stream() << "Error: "; }
85 ostream
& outerr(fs::path
const& file
, std::ptrdiff_t line
)
89 return error_stream() << path_to_stream(file
) << "(" << line
92 return error_stream() << path_to_stream(file
) << ":" << line
96 return error_stream() << path_to_stream(file
) << ": error: ";
100 ostream
& outerr(file_ptr
const& f
, string_iterator pos
)
102 return outerr(f
->path
, f
->position_of(pos
).line
);
105 ostream
& outwarn(fs::path
const& file
, std::ptrdiff_t line
)
109 return error_stream() << path_to_stream(file
) << "(" << line
112 return error_stream() << path_to_stream(file
) << ":" << line
116 return error_stream() << path_to_stream(file
) << ": warning: ";
120 ostream
& outwarn(file_ptr
const& f
, string_iterator pos
)
122 return outwarn(f
->path
, f
->position_of(pos
).line
);
125 ostream
& ostream::operator<<(char c
)
127 assert(c
&& !(c
& 0x80));
132 inline bool check_ascii(char const* x
)
135 if (*x
& 0x80) return false;
139 ostream
& ostream::operator<<(char const* x
)
141 assert(check_ascii(x
));
146 ostream
& ostream::operator<<(std::string
const& x
)
152 ostream
& ostream::operator<<(quickbook::string_view x
)
158 ostream
& ostream::operator<<(int x
)
164 ostream
& ostream::operator<<(unsigned int x
)
170 ostream
& ostream::operator<<(long x
)
176 ostream
& ostream::operator<<(unsigned long x
)
182 #if !defined(BOOST_NO_LONG_LONG)
183 ostream
& ostream::operator<<(boost::long_long_type x
)
189 ostream
& ostream::operator<<(boost::ulong_long_type x
)
196 ostream
& ostream::operator<<(fs::path
const& x
)
198 base
<< path_to_stream(x
);
202 ostream
& ostream::operator<<(base_ostream
& (*x
)(base_ostream
&))
208 ostream
& ostream::operator<<(base_ios
& (*x
)(base_ios
&))