File indexing completed on 2024-11-15 09:14:39
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_IO_OSTREAM_PUT_HPP
0009 #define BOOST_IO_OSTREAM_PUT_HPP
0010
0011 #include <boost/io/detail/buffer_fill.hpp>
0012 #include <boost/io/detail/ostream_guard.hpp>
0013
0014 namespace boost {
0015 namespace io {
0016
0017 template<class charT, class traits>
0018 inline std::basic_ostream<charT, traits>&
0019 ostream_put(std::basic_ostream<charT, traits>& os, const charT* data,
0020 std::size_t size)
0021 {
0022 typedef std::basic_ostream<charT, traits> stream;
0023 detail::ostream_guard<charT, traits> guard(os);
0024 typename stream::sentry entry(os);
0025 if (entry) {
0026 std::basic_streambuf<charT, traits>& buf = *os.rdbuf();
0027 std::size_t width = static_cast<std::size_t>(os.width());
0028 if (width <= size) {
0029 if (static_cast<std::size_t>(buf.sputn(data, size)) != size) {
0030 return os;
0031 }
0032 } else if ((os.flags() & stream::adjustfield) == stream::left) {
0033 if (static_cast<std::size_t>(buf.sputn(data, size)) != size ||
0034 !detail::buffer_fill(buf, os.fill(), width - size)) {
0035 return os;
0036 }
0037 } else if (!detail::buffer_fill(buf, os.fill(), width - size) ||
0038 static_cast<std::size_t>(buf.sputn(data, size)) != size) {
0039 return os;
0040 }
0041 os.width(0);
0042 }
0043 guard.release();
0044 return os;
0045 }
0046
0047 }
0048 }
0049
0050 #endif