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 00019 #ifndef BOOST_PROCESS_STREAM_BEHAVIOR_HPP 00020 #define BOOST_PROCESS_STREAM_BEHAVIOR_HPP 00021 00022 #include <boost/process/config.hpp> 00023 00024 namespace boost { 00025 namespace process { 00026 00027 namespace detail { 00028 struct stream_info; 00029 } 00030 00034 class stream_behavior 00035 { 00036 public: 00037 friend struct detail::stream_info; 00038 friend stream_behavior capture_stream(); 00039 friend stream_behavior close_stream(); 00040 friend stream_behavior inherit_stream(); 00041 friend stream_behavior redirect_stream_to_stdout(); 00042 friend stream_behavior silence_stream(); 00043 #if defined(BOOST_POSIX_API) || defined(BOOST_PROCESS_DOXYGEN) 00044 friend stream_behavior posix_redirect_stream(int to); 00045 #endif 00046 00050 enum type 00051 { 00057 capture, 00058 00063 close, 00064 00070 inherit, 00071 00077 redirect_to_stdout, 00078 00087 silence, 00088 00089 #if defined(BOOST_POSIX_API) || defined(BOOST_PROCESS_DOXYGEN) 00090 00095 posix_redirect 00096 #endif 00097 }; 00098 00107 stream_behavior() 00108 : type_(stream_behavior::close) 00109 { 00110 } 00111 00115 type get_type() const 00116 { 00117 return type_; 00118 } 00119 00120 private: 00128 stream_behavior(type t) 00129 : type_(t) 00130 { 00131 } 00132 00136 type type_; 00137 00138 #if defined(BOOST_POSIX_API) || defined(BOOST_PROCESS_DOXYGEN) 00139 00142 int desc_to_; 00143 #endif 00144 }; 00145 00154 inline stream_behavior capture_stream() 00155 { 00156 return stream_behavior(stream_behavior::capture); 00157 } 00158 00166 inline stream_behavior close_stream() 00167 { 00168 return stream_behavior(stream_behavior::close); 00169 } 00170 00179 inline stream_behavior inherit_stream() 00180 { 00181 return stream_behavior(stream_behavior::inherit); 00182 } 00183 00193 inline stream_behavior redirect_stream_to_stdout() 00194 { 00195 return stream_behavior(stream_behavior::redirect_to_stdout); 00196 } 00197 00209 inline stream_behavior silence_stream() 00210 { 00211 return stream_behavior(stream_behavior::silence); 00212 } 00213 00214 #if defined(BOOST_POSIX_API) || defined(BOOST_PROCESS_DOXYGEN) 00215 00223 inline stream_behavior posix_redirect_stream(int to) 00224 { 00225 stream_behavior sb(stream_behavior::posix_redirect); 00226 sb.desc_to_ = to; 00227 return sb; 00228 } 00229 #endif 00230 00231 } 00232 } 00233 00234 #endif