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_PISTREAM_HPP 00019 #define BOOST_PROCESS_PISTREAM_HPP 00020 00021 #include <boost/process/detail/file_handle.hpp> 00022 #include <boost/process/detail/systembuf.hpp> 00023 #include <boost/noncopyable.hpp> 00024 #include <istream> 00025 00026 namespace boost { 00027 namespace process { 00028 00056 class pistream : public std::istream, public boost::noncopyable 00057 { 00058 public: 00070 explicit pistream(detail::file_handle &fh) 00071 : std::istream(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 handle_.close(); 00099 } 00100 00101 private: 00105 detail::file_handle handle_; 00106 00110 detail::systembuf systembuf_; 00111 }; 00112 00113 } 00114 } 00115 00116 #endif