Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-11-15 09:14:39

0001 /*
0002 Copyright 2019 Glen Joseph Fernandes
0003 (glenjofe@gmail.com)
0004 
0005 Distributed under the Boost Software License, Version 1.0.
0006 (http://www.boost.org/LICENSE_1_0.txt)
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 } /* io */
0048 } /* boost */
0049 
0050 #endif