mirror of
https://github.com/boostorg/process.git
synced 2026-01-20 04:42:24 +00:00
Compare commits
2 Commits
boost-1.85
...
options
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
248af92cfa | ||
|
|
85345157d3 |
155
include/boost/process/detail/posix/tuple.hpp
Normal file
155
include/boost/process/detail/posix/tuple.hpp
Normal file
@@ -0,0 +1,155 @@
|
||||
// Copyright (c) 2016 Klemens D. Morgenstern
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_PROCESS_DETAIL_POSIX_TUPLE_HPP_
|
||||
#define BOOST_PROCESS_DETAIL_POSIX_TUPLE_HPP_
|
||||
|
||||
#include <boost/process/detail/windows/handler.hpp>
|
||||
#include <boost/fusion/tuple.hpp>
|
||||
#include <boost/fusion/algorithm/iteration/for_each.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace process
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
namespace windows
|
||||
{
|
||||
|
||||
template<typename Executor>
|
||||
struct tuple_on_setup
|
||||
{
|
||||
Executor & exec;
|
||||
template<typename T>
|
||||
void operator()(T *p)
|
||||
{
|
||||
p->on_setup(exec);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Executor>
|
||||
struct tuple_on_error
|
||||
{
|
||||
Executor & exec;
|
||||
const std::error_code & ec;
|
||||
template<typename T>
|
||||
void operator()(T *p)
|
||||
{
|
||||
p->on_setup(exec);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Executor>
|
||||
struct tuple_on_success
|
||||
{
|
||||
Executor & exec;
|
||||
template<typename T>
|
||||
void operator()(T *p)
|
||||
{
|
||||
p->on_setup(exec);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename Executor>
|
||||
struct tuple_on_fork_error
|
||||
{
|
||||
Executor & exec;
|
||||
const std::error_code &ec;
|
||||
|
||||
template<typename T>
|
||||
void operator()(T *t)
|
||||
{
|
||||
t->on_fork_error(exec, ec);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Executor>
|
||||
struct tuple_on_exec_setup
|
||||
{
|
||||
Executor & exec;
|
||||
|
||||
template<typename T>
|
||||
void operator()(T *t)
|
||||
{
|
||||
t->on_exec_setup(exec);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename Executor>
|
||||
struct tuple_on_exec_error
|
||||
{
|
||||
Executor & exec;
|
||||
const std::error_code &ec;
|
||||
|
||||
template<typename T>
|
||||
void operator()(T *t)
|
||||
{
|
||||
t->on_exec_error(exec, ec);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename ...Args>
|
||||
struct initializer_tuple : Args...
|
||||
{
|
||||
template <class Executor>
|
||||
void on_setup(Executor& exec)
|
||||
{
|
||||
auto tup = boost::fusion::make_tuple(static_cast<Args*>(this)...);
|
||||
tuple_on_setup<Executor> func{exec};
|
||||
boost::fusion::for_each(tup, func);
|
||||
}
|
||||
|
||||
template <class Executor>
|
||||
void on_error(Executor& exec, const std::error_code & ec)
|
||||
{
|
||||
auto tup = boost::fusion::make_tuple(static_cast<Args*>(this)...);
|
||||
tuple_on_setup<Executor> func{exec};
|
||||
boost::fusion::for_each(tup, func);
|
||||
}
|
||||
|
||||
template <class Executor>
|
||||
void on_success(Executor& exec)
|
||||
{
|
||||
auto tup = boost::fusion::make_tuple(static_cast<Args*>(this)...);
|
||||
tuple_on_setup<Executor> func{exec};
|
||||
boost::fusion::for_each(tup, func);
|
||||
}
|
||||
|
||||
template<typename Executor>
|
||||
void on_fork_error (Executor & exec, const std::error_code& ec)
|
||||
{
|
||||
auto tup = boost::fusion::make_tuple(static_cast<Args*>(this)...);
|
||||
tuple_on_fork_error<Executor> func{exec, ec};
|
||||
boost::fusion::for_each(tup, func);
|
||||
}
|
||||
|
||||
template<typename Executor>
|
||||
void on_exec_setup (Executor & exec)
|
||||
{
|
||||
auto tup = boost::fusion::make_tuple(static_cast<Args*>(this)...);
|
||||
tuple_on_exec_setup<Executor> func{exec};
|
||||
boost::fusion::for_each(tup, func);
|
||||
}
|
||||
|
||||
template<typename Executor>
|
||||
void on_exec_error (Executor & exec, const std::error_code& ec)
|
||||
{
|
||||
auto tup = boost::fusion::make_tuple(static_cast<Args*>(this)...);
|
||||
tuple_on_exec_error<Executor> func{exec, ec};
|
||||
boost::fusion::for_each(tup, func);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
157
include/boost/process/detail/posix/variant.hpp
Normal file
157
include/boost/process/detail/posix/variant.hpp
Normal file
@@ -0,0 +1,157 @@
|
||||
// Copyright (c) 2016 Klemens D. Morgenstern
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_PROCESS_DETAIL_POSIX_VARIANT_HPP_
|
||||
#define BOOST_PROCESS_DETAIL_POSIX_VARIANT_HPP_
|
||||
|
||||
#include <boost/process/detail/posix/handler.hpp>
|
||||
#include <boost/variant/variant.hpp>
|
||||
#include <boost/variant/static_visitor.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace process
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
namespace posix
|
||||
{
|
||||
|
||||
|
||||
template<typename Executor>
|
||||
struct on_setup_visitor : boost::static_visitor<void>
|
||||
{
|
||||
Executor & exec;
|
||||
|
||||
template<typename T>
|
||||
void operator()(T &t)
|
||||
{
|
||||
t.on_setup(exec);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Executor>
|
||||
struct on_error_visitor : boost::static_visitor<void>
|
||||
{
|
||||
Executor & exec;
|
||||
const std::error_code &ec;
|
||||
|
||||
template<typename T>
|
||||
void operator()(T &t)
|
||||
{
|
||||
t.on_error(exec, ec);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Executor>
|
||||
struct on_success_visitor : boost::static_visitor<void>
|
||||
{
|
||||
Executor & exec;
|
||||
|
||||
template<typename T>
|
||||
void operator()(T &t)
|
||||
{
|
||||
t.on_success(exec);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Executor>
|
||||
struct on_fork_error_visitor : boost::static_visitor<void>
|
||||
{
|
||||
Executor & exec;
|
||||
const std::error_code &ec;
|
||||
|
||||
template<typename T>
|
||||
void operator()(T &t)
|
||||
{
|
||||
t.on_fork_error(exec, ec);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Executor>
|
||||
struct on_exec_setup_visitor : boost::static_visitor<void>
|
||||
{
|
||||
Executor & exec;
|
||||
|
||||
template<typename T>
|
||||
void operator()(T &t)
|
||||
{
|
||||
t.on_exec_setup(exec);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename Executor>
|
||||
struct on_exec_error_visitor : boost::static_visitor<void>
|
||||
{
|
||||
Executor & exec;
|
||||
const std::error_code &ec;
|
||||
|
||||
template<typename T>
|
||||
void operator()(T &t)
|
||||
{
|
||||
t.on_exec_error(exec, ec);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename ...Args>
|
||||
struct handler_variant : handler_base_ext, boost::variant<Args...>
|
||||
{
|
||||
using boost::variant<Args...>::variant;
|
||||
using boost::variant<Args...>::operator=;
|
||||
|
||||
template <class Executor>
|
||||
void on_setup(Executor& exec)
|
||||
{
|
||||
on_setup_visitor<Executor> vis{exec};
|
||||
boost::apply_visitor(vis, *this);
|
||||
}
|
||||
|
||||
template <class Executor>
|
||||
void on_error(Executor& exec, const std::error_code & ec)
|
||||
{
|
||||
on_error_visitor<Executor> vis{exec, ec};
|
||||
boost::apply_visitor(vis, *this);
|
||||
}
|
||||
|
||||
template <class Executor>
|
||||
void on_success(Executor& exec)
|
||||
{
|
||||
on_success_visitor<Executor> vis{exec};
|
||||
boost::apply_visitor(vis, *this);
|
||||
}
|
||||
|
||||
template<typename Executor>
|
||||
void on_fork_error (Executor & exec, const std::error_code& ec)
|
||||
{
|
||||
on_fork_error_visitor<Executor> vis{exec, ec};
|
||||
boost::apply_visitor(vis, *this);
|
||||
}
|
||||
|
||||
template<typename Executor>
|
||||
void on_exec_setup (Executor & exec)
|
||||
{
|
||||
on_exec_setup_visitor<Executor> vis{exec};
|
||||
boost::apply_visitor(vis, *this);
|
||||
}
|
||||
|
||||
template<typename Executor>
|
||||
void on_exec_error (Executor & exec, const std::error_code& ec)
|
||||
{
|
||||
on_exec_error_visitor<Executor> vis{exec, ec};
|
||||
boost::apply_visitor(vis, *this);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -33,7 +33,6 @@ struct on_exit_ : boost::process::detail::windows::async_handler
|
||||
{
|
||||
handler(static_cast<int>(exit_code), ec);
|
||||
};
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
91
include/boost/process/detail/windows/tuple.hpp
Normal file
91
include/boost/process/detail/windows/tuple.hpp
Normal file
@@ -0,0 +1,91 @@
|
||||
// Copyright (c) 2016 Klemens D. Morgenstern
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_PROCESS_DETAIL_WINDOWS_TUPLE_HPP_
|
||||
#define BOOST_PROCESS_DETAIL_WINDOWS_TUPLE_HPP_
|
||||
|
||||
#include <boost/process/detail/windows/handler.hpp>
|
||||
#include <boost/fusion/tuple.hpp>
|
||||
#include <boost/fusion/algorithm/iteration/for_each.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace process
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
namespace windows
|
||||
{
|
||||
|
||||
template<typename Executor>
|
||||
struct tuple_on_setup
|
||||
{
|
||||
Executor & exec;
|
||||
template<typename T>
|
||||
void operator()(T *p)
|
||||
{
|
||||
p->on_setup(exec);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Executor>
|
||||
struct tuple_on_error
|
||||
{
|
||||
Executor & exec;
|
||||
const std::error_code & ec;
|
||||
template<typename T>
|
||||
void operator()(T *p)
|
||||
{
|
||||
p->on_setup(exec);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Executor>
|
||||
struct tuple_on_success
|
||||
{
|
||||
Executor & exec;
|
||||
template<typename T>
|
||||
void operator()(T *p)
|
||||
{
|
||||
p->on_setup(exec);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename ...Args>
|
||||
struct initializer_tuple : Args...
|
||||
{
|
||||
template <class Executor>
|
||||
void on_setup(Executor& exec)
|
||||
{
|
||||
auto tup = boost::fusion::make_tuple(static_cast<Args*>(this)...);
|
||||
tuple_on_setup<Executor> func{exec};
|
||||
boost::fusion::for_each(tup, func);
|
||||
}
|
||||
|
||||
template <class Executor>
|
||||
void on_error(Executor& exec, const std::error_code & ec)
|
||||
{
|
||||
auto tup = boost::fusion::make_tuple(static_cast<Args*>(this)...);
|
||||
tuple_on_setup<Executor> func{exec};
|
||||
boost::fusion::for_each(tup, func);
|
||||
}
|
||||
|
||||
template <class Executor>
|
||||
void on_success(Executor& exec)
|
||||
{
|
||||
auto tup = boost::fusion::make_tuple(static_cast<Args*>(this)...);
|
||||
tuple_on_setup<Executor> func{exec};
|
||||
boost::fusion::for_each(tup, func);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
114
include/boost/process/detail/windows/variant.hpp
Normal file
114
include/boost/process/detail/windows/variant.hpp
Normal file
@@ -0,0 +1,114 @@
|
||||
// Copyright (c) 2016 Klemens D. Morgenstern
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_PROCESS_DETAIL_POSIX_VARIANT_HPP_
|
||||
#define BOOST_PROCESS_DETAIL_POSIX_VARIANT_HPP_
|
||||
|
||||
#include <boost/process/detail/windows/handler.hpp>
|
||||
#include <boost/variant/variant.hpp>
|
||||
#include <boost/variant/static_visitor.hpp>
|
||||
#include <boost/process/detail/async_handler.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace process
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
namespace windows
|
||||
{
|
||||
|
||||
|
||||
template<typename Executor>
|
||||
struct on_setup_visitor : boost::static_visitor<void>
|
||||
{
|
||||
Executor & exec;
|
||||
|
||||
template<typename T>
|
||||
void operator()(T &t)
|
||||
{
|
||||
t.on_setup(exec);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Executor>
|
||||
struct on_error_visitor : boost::static_visitor<void>
|
||||
{
|
||||
Executor & exec;
|
||||
const std::error_code &ec;
|
||||
|
||||
template<typename T>
|
||||
void operator()(T &t)
|
||||
{
|
||||
t.on_error(exec, ec);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Executor>
|
||||
struct on_success_visitor : boost::static_visitor<void>
|
||||
{
|
||||
Executor & exec;
|
||||
|
||||
template<typename T>
|
||||
void operator()(T &t)
|
||||
{
|
||||
t.on_success(exec);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct variant_require_ios_tag_empty {};
|
||||
|
||||
template<typename ...Args>
|
||||
struct variant_require_ios_tag
|
||||
{
|
||||
using needs_io_service = typename needs_io_service<Args...>::type;
|
||||
using type = typename std::conditional<
|
||||
needs_io_service,
|
||||
require_io_service,
|
||||
variant_require_ios_tag_empty>::type;
|
||||
};
|
||||
|
||||
|
||||
template<typename ...Args>
|
||||
using variant_require_ios_tag_t = typename variant_require_ios_tag<Args...>::type;
|
||||
|
||||
template<typename ...Args>
|
||||
struct handler_variant : handler_base_ext, boost::variant<Args...>, variant_require_ios_tag_t<Args...>
|
||||
{
|
||||
using boost::variant<Args...>::variant;
|
||||
using boost::variant<Args...>::operator=;
|
||||
|
||||
template <class Executor>
|
||||
void on_setup(Executor& exec)
|
||||
{
|
||||
on_setup_visitor<Executor> vis{exec};
|
||||
boost::apply_visitor(vis, *this);
|
||||
}
|
||||
|
||||
template <class Executor>
|
||||
void on_error(Executor& exec, const std::error_code & ec)
|
||||
{
|
||||
on_error_visitor<Executor> vis{exec, ec};
|
||||
boost::apply_visitor(vis, *this);
|
||||
}
|
||||
|
||||
template <class Executor>
|
||||
void on_success(Executor& exec)
|
||||
{
|
||||
on_success_visitor<Executor> vis{exec};
|
||||
boost::apply_visitor(vis, *this);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
93
include/boost/process/io_variant.hpp
Normal file
93
include/boost/process/io_variant.hpp
Normal file
@@ -0,0 +1,93 @@
|
||||
// Copyright (c) 2016 Klemens D. Morgenstern
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_PROCESS_IO_VARIANT_HPP_
|
||||
#define BOOST_PROCESS_IO_VARIANT_HPP_
|
||||
|
||||
#include <boost/process/variant.hpp>
|
||||
#include <boost/process/io.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace process
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
using std_in_variant_base =
|
||||
handler_variant<
|
||||
api::null_in,
|
||||
api::close_in,
|
||||
api::pipe_in,
|
||||
api::file_in,
|
||||
api::async_in_buffer<boost::asio::mutable_buffer>,
|
||||
api::async_in_buffer<boost::asio::const_buffer>,
|
||||
api::async_in_buffer<boost::asio::mutable_buffers_1>,
|
||||
api::async_in_buffer<boost::asio::const_buffers_1>,
|
||||
api::async_in_buffer<boost::asio::streambuf>>;
|
||||
|
||||
template<int p1, int p2>
|
||||
using std_sink_variant_base =
|
||||
handler_variant<
|
||||
api::null_out<p1, p2>,
|
||||
api::close_out<p1, p2>,
|
||||
api::pipe_out<p1, p2>,
|
||||
api::file_out<p1, p2>,
|
||||
api::async_out_buffer<p1, p2, const asio::mutable_buffer> ,
|
||||
api::async_out_buffer<p1, p2, const asio::mutable_buffers_1>,
|
||||
api::async_out_buffer<p1, p2, asio::streambuf>,
|
||||
api::async_out_buffer<p1, p2, const asio::mutable_buffer>,
|
||||
api::async_out_buffer<p1, p2, const asio::mutable_buffers_1>,
|
||||
api::async_out_buffer<p1, p2, asio::streambuf>,
|
||||
api::async_out_future<p1, p2, std::string>,
|
||||
api::async_out_future<p1, p2, std::string>,
|
||||
api::async_out_future<p1, p2, std::vector<char>>,
|
||||
api::async_out_future<p1, p2, std::vector<char>>>;
|
||||
|
||||
template<int p1, int p2 = -1>
|
||||
struct std_sink_variant : std_sink_variant_base<p1, p2>,
|
||||
::boost::process::detail::api::require_io_service
|
||||
{
|
||||
using std_sink_variant_base<p1, p2>::std_sink_variant_base;
|
||||
using std_sink_variant_base<p1, p2>::operator=;
|
||||
|
||||
void null() {*this = api:: null_out<p1, p2>();}
|
||||
void close() {*this = api::close_out<p1, p2>();}
|
||||
|
||||
template<typename T>
|
||||
void set(T& t)
|
||||
{
|
||||
*this = (std_out_<p1, p2>() > t);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
struct std_in_variant : detail::std_in_variant_base,
|
||||
::boost::process::detail::api::require_io_service
|
||||
{
|
||||
using detail::std_in_variant_base::std_in_variant_base;
|
||||
using detail::std_in_variant_base::operator=;
|
||||
|
||||
void null() {*this = detail::api:: null_in();}
|
||||
void close() {*this = detail::api::close_in();}
|
||||
|
||||
template<typename T>
|
||||
void set(T& t)
|
||||
{
|
||||
*this = (std_in < t);
|
||||
}
|
||||
};
|
||||
|
||||
using std_out_variant = ::boost::process::detail::std_sink_variant_base<1>;
|
||||
using std_err_variant = ::boost::process::detail::std_sink_variant_base<2>;
|
||||
using std_out_err_variant = ::boost::process::detail::std_sink_variant_base<1,2>;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
20
include/boost/process/options.hpp
Normal file
20
include/boost/process/options.hpp
Normal file
@@ -0,0 +1,20 @@
|
||||
// Copyright (c) 2016 Klemens D. Morgenstern
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_PROCESS_OPTIONS_HPP_
|
||||
#define BOOST_PROCESS_OPTIONS_HPP_
|
||||
|
||||
#include <boost/process/options/args.hpp>
|
||||
#include <boost/process/options/async.hpp>
|
||||
#include <boost/process/options/cmd.hpp>
|
||||
#include <boost/process/options/env.hpp>
|
||||
#include <boost/process/options/group.hpp>
|
||||
#include <boost/process/options/io.hpp>
|
||||
#include <boost/process/options/posix.hpp>
|
||||
#include <boost/process/options/shell.hpp>
|
||||
#include <boost/process/options/start_dir.hpp>
|
||||
#include <boost/process/options/windows.hpp>
|
||||
|
||||
#endif
|
||||
69
include/boost/process/options/async.hpp
Normal file
69
include/boost/process/options/async.hpp
Normal file
@@ -0,0 +1,69 @@
|
||||
// Copyright (c) 2016 Klemens D. Morgenstern
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
/** \file boost/process/options/async.hpp
|
||||
|
||||
The header which provides the asynchrounous features for the option style.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_PROCESS_ASYNC_HPP_
|
||||
#define BOOST_PROCESS_ASYNC_HPP_
|
||||
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/process/async.hpp>
|
||||
#include <boost/process/options/make_options.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace process
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<>
|
||||
class options_t<api::on_exit_> : api::async_handler
|
||||
{
|
||||
std::vector<std::function<void(int, const std::error_code&)>> _handlers;
|
||||
public:
|
||||
|
||||
template<typename Executor>
|
||||
std::function<void(int, const std::error_code&)> on_exit_handler(Executor & exec)
|
||||
{
|
||||
return [_handlers](int exit_code, const std::error_code & ec)
|
||||
{
|
||||
for (auto & h : _handlers)
|
||||
h(static_cast<int>(exit_code), ec);
|
||||
};
|
||||
}
|
||||
|
||||
void add_on_exit(const std::function<void(int, const std::error_code&)> &f)
|
||||
{
|
||||
_handlers.push_back(f);
|
||||
}
|
||||
void add_on_exit(std::future<int> &f)
|
||||
{
|
||||
_handlers.push_back(::boost::process::detail::on_exit_from_future(f));
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
class options_t<api::io_service_ref> : api::io_service_ref
|
||||
{
|
||||
boost::asio::io_service _ios;
|
||||
public:
|
||||
options_t() : api::io_service_ref(_ios) {}
|
||||
|
||||
boost::asio::io_service & get_io_service() {return _ios;}
|
||||
};
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* INCLUDE_BOOST_PROCESS_DETAIL_ASYNC_HPP_ */
|
||||
48
include/boost/process/options/make_options.hpp
Normal file
48
include/boost/process/options/make_options.hpp
Normal file
@@ -0,0 +1,48 @@
|
||||
// Copyright (c) 2016 Klemens D. Morgenstern
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_PROCESS_OPTIONS_MAKE_OPTIONS_HPP_
|
||||
#define BOOST_PROCESS_OPTIONS_MAKE_OPTIONS_HPP_
|
||||
|
||||
#include <boost/process/detail/config.hpp>
|
||||
|
||||
#if defined(BOOST_WINDOWS_API)
|
||||
#include <boost/process/detail/windows/tuple.hpp>
|
||||
#elif defined(BOOST_POSIX_API)
|
||||
#include <boost/process/detail/posix/tuple.hpp>
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace process
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<typename T>
|
||||
struct option_t;
|
||||
|
||||
template<typename ... Args>
|
||||
struct options
|
||||
{
|
||||
using needs_io_service = typename needs_io_service<Args...>::type;
|
||||
|
||||
std::conditional<needs_io_service,
|
||||
::boost::process::detail::api::initializer_tuple<api::io_service_ref, option_t<Args>...>,
|
||||
::boost::process::detail::api::initializer_tuple<option_t<Args>>>;
|
||||
};
|
||||
|
||||
template<typename ... Args>
|
||||
using options_t = typename options<Args...>::type;
|
||||
|
||||
}
|
||||
|
||||
template<typename ...Args>
|
||||
inline detail::options_t<Args...> make_options(const Args & ...) {return {};}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
30
include/boost/process/variant.hpp
Normal file
30
include/boost/process/variant.hpp
Normal file
@@ -0,0 +1,30 @@
|
||||
// Copyright (c) 2016 Klemens D. Morgenstern
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_PROCESS_VARIANT_HPP_
|
||||
#define BOOST_PROCESS_VARIANT_HPP_
|
||||
|
||||
#include <boost/process/detail/config.hpp>
|
||||
#if defined(BOOST_WINDOWS_API)
|
||||
#include <boost/process/detail/windows/variant.hpp>
|
||||
#elif defined(BOOST_POSIX_API)
|
||||
#include <boost/process/detail/posix/variant.hpp>
|
||||
#endif
|
||||
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace process
|
||||
{
|
||||
|
||||
using ::boost::process::detail::api::handler_variant;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* INCLUDE_BOOST_PROCESS_IO_VARIANT_HPP_ */
|
||||
Reference in New Issue
Block a user