00001 // 00002 // Boost.Process 00003 // ~~~~~~~~~~~~~ 00004 // 00005 // Copyright (c) 2006, 2007 Julio M. Merino Vidal 00006 // Copyright (c) 2008 Boris Schaeling 00007 // 00008 // Distributed under the Boost Software License, Version 1.0. (See accompanying 00009 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 00010 // 00011 00018 #ifndef BOOST_PROCESS_POSTREAM_HPP 00019 #define BOOST_PROCESS_POSTREAM_HPP 00020 00021 #include <boost/process/detail/file_handle.hpp> 00022 #include <boost/process/detail/systembuf.hpp> 00023 #include <boost/noncopyable.hpp> 00024 #include <ostream> 00025 00026 namespace boost { 00027 namespace process { 00028 00056 class postream : public std::ostream, public boost::noncopyable 00057 { 00058 public: 00070 explicit postream(detail::file_handle &fh) 00071 : std::ostream(0), 00072 handle_(fh), 00073 systembuf_(handle_.get()) 00074 { 00075 rdbuf(&systembuf_); 00076 } 00077 00084 detail::file_handle &handle() 00085 { 00086 return handle_; 00087 } 00088 00096 void close() 00097 { 00098 systembuf_.sync(); 00099 handle_.close(); 00100 } 00101 00102 private: 00106 detail::file_handle handle_; 00107 00111 detail::systembuf systembuf_; 00112 }; 00113 00114 } 00115 } 00116 00117 #endif