diff --git a/doc/v1/design.qbk b/doc/v1/design.qbk index 2611c29dd..0dd49f16e 100644 --- a/doc/v1/design.qbk +++ b/doc/v1/design.qbk @@ -75,9 +75,9 @@ but the one of the launching process, not the one passed to the child process.] The simplest form to extend functionality is to provide another handler, which will be called on the respective events on process launching. The names are: -*`boost::process::on_setup` -*`boost::process::on_error` -*`boost::process::on_success` +*`boost::process::v1::on_setup` +*`boost::process::v1::on_error` +*`boost::process::v1::on_success` As an example: diff --git a/doc/v1/extend.qbk b/doc/v1/extend.qbk index fad4db545..dfe4f8517 100644 --- a/doc/v1/extend.qbk +++ b/doc/v1/extend.qbk @@ -1,14 +1,14 @@ -[def __on_exit__ [globalref boost::process::on_exit on_exit]] -[def __on_success__ [globalref boost::process::extend::on_success ex::on_success]] -[def __child__ [classref boost::process::child child]] -[def __handler__ [classref boost::process::extend::handler handler]] -[def __on_success__ [memberref boost::process::extend::handler::on_success on_success]] -[def __posix_executor__ [classref boost::process::extend::posix_executor ex::posix_executor]] -[def __windows_executor__ [classref boost::process::extend::windows_executor ex::windows_executor]] +[def __on_exit__ [globalref boost::process::v1::on_exit on_exit]] +[def __on_success__ [globalref boost::process::v1::extend::on_success ex::on_success]] +[def __child__ [classref boost::process::v1::child child]] +[def __handler__ [classref boost::process::v1::extend::handler handler]] +[def __on_success__ [memberref boost::process::v1::extend::handler::on_success on_success]] +[def __posix_executor__ [classref boost::process::v1::extend::posix_executor ex::posix_executor]] +[def __windows_executor__ [classref boost::process::v1::extend::windows_executor ex::windows_executor]] [def __io_context__ [@http://www.boost.org/doc/libs/release/doc/html/boost_asio/reference/io_context.html boost::asio::io_context]] -[def __require_io_context__ [classref boost::process::extend::require_io_context ex::require_io_context]] -[def __async_handler__ [classref boost::process::extend::async_handler ex::async_handler]] -[def __get_io_context__ [funcref boost::process::extend::get_io_context ex::get_io_context]] +[def __require_io_context__ [classref boost::process::v1::extend::require_io_context ex::require_io_context]] +[def __async_handler__ [classref boost::process::v1::extend::async_handler ex::async_handler]] +[def __get_io_context__ [funcref boost::process::v1::extend::get_io_context ex::get_io_context]] [section:extend Extensions] To extend the library, the header [headerref boost/process/extend.hpp extend] is provided. @@ -16,7 +16,7 @@ To extend the library, the header [headerref boost/process/extend.hpp extend] is It only provides the explicit style for custom properties, but no implicit style. What this means is, that a custom initializer can be implemented, a reference which can be passed to one of the launching functions. -If a class inherits [classref boost::process::extend::handler] it will be regarded as an initializer and thus directly put into the sequence +If a class inherits [classref boost::process::v1::extend::handler] it will be regarded as an initializer and thus directly put into the sequence the executor gets passed. [section:structure Structure] @@ -24,9 +24,9 @@ the executor gets passed. The executor calls different handlers of the initializers during the process launch. The basic structure consists of three functions, as given below: -* [globalref boost::process::extend::on_setup on_setup] -* [globalref boost::process::extend::on_error on_error] -* [globalref boost::process::extend::on_success on_success] +* [globalref boost::process::v1::extend::on_setup on_setup] +* [globalref boost::process::v1::extend::on_error on_error] +* [globalref boost::process::v1::extend::on_success on_success] ''' @@ -34,11 +34,11 @@ The basic structure consists of three functions, as given below: Additionally posix provides three more handlers, listed below: -* [globalref boost::process::extend::on_fork_error on_fork_error] -* [globalref boost::process::extend::on_exec_setup on_exec_setup] -* [globalref boost::process::extend::on_exec_error on_exec_error] +* [globalref boost::process::v1::extend::on_fork_error on_fork_error] +* [globalref boost::process::v1::extend::on_exec_setup on_exec_setup] +* [globalref boost::process::v1::extend::on_exec_error on_exec_error] -For more information see the reference of [classref boost::process::extend::posix_executor posix_executor]. +For more information see the reference of [classref boost::process::v1::extend::posix_executor posix_executor]. [endsect] [section:simple Simple extensions] @@ -55,8 +55,8 @@ __child__ c("foo", __on_success__=[](auto & exec) {std::cout << "hello world" << Considering that lambdas can also capture values, data can easily be shared between handlers. -To see which members the executor has, refer to [classref boost::process::extend::windows_executor windows_executor] -and [classref boost::process::extend::posix_executor posix_executor]. +To see which members the executor has, refer to [classref boost::process::v1::extend::windows_executor windows_executor] +and [classref boost::process::v1::extend::posix_executor posix_executor]. [note Combined with __on_exit__ this can also handle the process exit.] @@ -67,7 +67,7 @@ and [classref boost::process::extend::posix_executor posix_executor]. [section:handler Handler Types] Since the previous example is in a functional style, it is not very reusable. -To solve that problem, the [classref boost::process::extend::handler handler] has an alias in the `boost::process::extend` namespace, to be inherited. +To solve that problem, the [classref boost::process::v1::extend::handler handler] has an alias in the `boost::process::v1::extend` namespace, to be inherited. So let's implement the hello world example in a class. ``` @@ -86,7 +86,7 @@ __child__ c("foo", hello_world()); [note The implementation is done via overloading, not overriding.] -Every handler not implemented defaults to [classref boost::process::extend::handler handler], where an empty handler is defined for each event. +Every handler not implemented defaults to [classref boost::process::v1::extend::handler handler], where an empty handler is defined for each event. [endsect] @@ -108,11 +108,11 @@ struct async_foo : __handler__, __require_io_context__ } }; ``` -[note Inheriting [globalref boost::process::extend::require_io_context require_io_context] is necessary, so [funcref boost::process::system system] provides one.] +[note Inheriting [globalref boost::process::v1::extend::require_io_context require_io_context] is necessary, so [funcref boost::process::v1::system system] provides one.] Additionally the handler can provide a function that is invoked when the child process exits. This is done through __async_handler__. -[note [globalref boost::process::extend::async_handler async_handler] implies [globalref boost::process::extend::require_io_context require_io_context] .] +[note [globalref boost::process::v1::extend::async_handler async_handler] implies [globalref boost::process::v1::extend::require_io_context require_io_context] .] ``` struct async_bar : __handler, __async_handler__ @@ -131,7 +131,7 @@ struct async_bar : __handler, __async_handler__ ``` -[caution `on_exit_handler` does not default and is always required when [classref boost::process::extend::async_handler async_handler] is inherited. ] +[caution `on_exit_handler` does not default and is always required when [classref boost::process::v1::extend::async_handler async_handler] is inherited. ] [caution `on_exit_handler` uses `boost::asio::signal_set` to listen for SIGCHLD on posix. The application must not also register a signal handler for SIGCHLD using functions such as `signal()` or `sigaction()` (but using `boost::asio::signal_set` is fine). ] @@ -156,7 +156,7 @@ auto set_error = [](auto & exec) __child__ c("foo", on_setup=set_error); ``` -Since we do not specify the error-handling mode in this example, this will throw [classref boost::process::process_error process_error]. +Since we do not specify the error-handling mode in this example, this will throw [classref boost::process::v1::process_error process_error]. [endsect] diff --git a/doc/v1/introduction.qbk b/doc/v1/introduction.qbk index fa98c1330..e9fe67f2d 100644 --- a/doc/v1/introduction.qbk +++ b/doc/v1/introduction.qbk @@ -10,10 +10,10 @@ Boost.Process is a library to manage system processes. It can be used to: Here's a simple example of how to start a program with Boost.Process: -[def ipstream [classref boost::process::ipstream ipstream]] -[def system [funcref boost::process::system system]] -[def std_out [globalref boost::process::std_out std_out]] -[def child [globalref boost::process::child child]] +[def ipstream [classref boost::process::v1::ipstream ipstream]] +[def system [funcref boost::process::v1::system system]] +[def std_out [globalref boost::process::v1::std_out std_out]] +[def child [globalref boost::process::v1::child child]] [def boost/process.hpp [headerref boost/process.hpp boost/process.hpp]] [def std::string [@http://en.cppreference.com/w/cpp/string/basic_string std::string]] [def std::getline [@http://en.cppreference.com/w/cpp/string/basic_string/getline std::getline]] diff --git a/doc/v1/posix_pseudocode.xml b/doc/v1/posix_pseudocode.xml index 5ba3d8536..699d087e5 100644 --- a/doc/v1/posix_pseudocode.xml +++ b/doc/v1/posix_pseudocode.xml @@ -1,59 +1,59 @@ for (auto & s : seq) - s.on_setup(*this); + s.on_setup(*this); -if (error()) +if (error()) { for (auto & s : seq) - s.on_error(*this, error()); - return child(); + s.on_error(*this, error()); + return child(); } pid = fork() -on_setup(*this); +on_setup(*this); if (pid == -1) //fork error { - set_error(get_last_error()); + set_error(get_last_error()); for (auto & s : seq) - s.on_fork_error(*this, error()); + s.on_fork_error(*this, error()); for (auto & s : seq) - s.on_error(*this, error()); - return child() + s.on_error(*this, error()); + return child() } else if (pid == 0) //child process { for (auto & s : seq) - s.on_exec_setup(*this); + s.on_exec_setup(*this); execve(exe, cmd_line, env); - auto ec = get_last_error(); + auto ec = get_last_error(); for (auto & s : seq) - s.on_exec_error(*this); + s.on_exec_error(*this); unspecified();//here the error is sent to the father process internally std::exit(EXIT_FAILURE); - return child(); //for C++ compliance + return child(); //for C++ compliance } -child c(pid, exit_code); +child c(pid, exit_code); unspecified();//here, we read the error from the child process -if (error()) +if (error()) for (auto & s : seq) - s.on_error(*this, error()); + s.on_error(*this, error()); else for (auto & s : seq) - s.on_success(*this); + s.on_success(*this); //now we check again, because an on_success handler might've errored. -if (error()) +if (error()) { for (auto & s : seq) - s.on_error(*this, error()); - return child(); + s.on_error(*this, error()); + return child(); } else return c; diff --git a/doc/v1/tutorial.qbk b/doc/v1/tutorial.qbk index 4b208b466..e7e98a2b0 100644 --- a/doc/v1/tutorial.qbk +++ b/doc/v1/tutorial.qbk @@ -1,49 +1,49 @@ -[def bp::system [funcref boost::process::system bp::system]] -[def bp::async_system [funcref boost::process::async_system bp::async_system]] -[def bp::spawn [funcref boost::process::spawn bp::spawn]] -[def bp::child [classref boost::process::child bp::child]] -[def bp::cmd [classref boost::process::cmd bp::cmd]] -[def bp::group [classref boost::process::group bp::group]] -[def bp::ipstream [classref boost::process::ipstream bp::ipstream]] -[def bp::opstream [classref boost::process::opstream bp::opstream]] -[def bp::pstream [classref boost::process::pstream bp::pstream]] -[def bp::pipe [classref boost::process::pipe bp::pipe]] -[def bp::async_pipe [classref boost::process::async_pipe bp::async_pipe]] -[def bp::search_path [funcref boost::process::search_path bp::search_path]] +[def bp::system [funcref boost::process::v1::system bp::system]] +[def bp::async_system [funcref boost::process::v1::async_system bp::async_system]] +[def bp::spawn [funcref boost::process::v1::spawn bp::spawn]] +[def bp::child [classref boost::process::v1::child bp::child]] +[def bp::cmd [classref boost::process::v1::cmd bp::cmd]] +[def bp::group [classref boost::process::v1::group bp::group]] +[def bp::ipstream [classref boost::process::v1::ipstream bp::ipstream]] +[def bp::opstream [classref boost::process::v1::opstream bp::opstream]] +[def bp::pstream [classref boost::process::v1::pstream bp::pstream]] +[def bp::pipe [classref boost::process::v1::pipe bp::pipe]] +[def bp::async_pipe [classref boost::process::v1::async_pipe bp::async_pipe]] +[def bp::search_path [funcref boost::process::v1::search_path bp::search_path]] [def boost_org [@www.boost.org "www.boost.org"]] [def std::system [@http://en.cppreference.com/w/cpp/utility/program/system std::system]] -[def child_running [memberref boost::process::child::running running]] -[def child_wait [memberref boost::process::child::wait wait]] -[def child_wait_for [memberref boost::process::child::wait_for wait_for]] -[def child_exit_code [memberref boost::process::child::exit_code exit_code]] -[def group_wait_for [memberref boost::process::group::wait_for wait_for]] -[def bp::on_exit [globalref boost::process::on_exit bp::on_exit]] -[def bp::null [globalref boost::process::null bp::null]] -[def child_terminate [memberref boost::process::child::terminate terminate]] -[def group_terminate [memberref boost::process::group::terminate terminate]] -[def group_wait [memberref boost::process::group::wait wait]] -[def bp::std_in [globalref boost::process::std_in bp::std_in]] -[def bp::std_out [globalref boost::process::std_out bp::std_out]] -[def bp::std_err [globalref boost::process::std_err bp::std_err]] +[def child_running [memberref boost::process::v1::child::running running]] +[def child_wait [memberref boost::process::v1::child::wait wait]] +[def child_wait_for [memberref boost::process::v1::child::wait_for wait_for]] +[def child_exit_code [memberref boost::process::v1::child::exit_code exit_code]] +[def group_wait_for [memberref boost::process::v1::group::wait_for wait_for]] +[def bp::on_exit [globalref boost::process::v1::on_exit bp::on_exit]] +[def bp::null [globalref boost::process::v1::null bp::null]] +[def child_terminate [memberref boost::process::v1::child::terminate terminate]] +[def group_terminate [memberref boost::process::v1::group::terminate terminate]] +[def group_wait [memberref boost::process::v1::group::wait wait]] +[def bp::std_in [globalref boost::process::v1::std_in bp::std_in]] +[def bp::std_out [globalref boost::process::v1::std_out bp::std_out]] +[def bp::std_err [globalref boost::process::v1::std_err bp::std_err]] [def io_service [@http://www.boost.org/doc/libs/release/doc/html/boost_asio/reference/io_service.html boost::asio::io_service]] [def asio_buffer [@http://www.boost.org/doc/libs/release/doc/html/boost_asio/reference/buffer.html boost::asio::buffer]] [def asio_async_read [@http://www.boost.org/doc/libs/release/doc/html/boost_asio/reference/async_read.html boost::asio::async_read]] -[def bp::environment [classref boost::process::basic_environment bp::environment]] -[def bp::native_environment [classref boost::process::basic_native_environment bp::native_environment]] +[def bp::environment [classref boost::process::v1::basic_environment bp::environment]] +[def bp::native_environment [classref boost::process::v1::basic_native_environment bp::native_environment]] [def boost::this_process::environment [funcref boost::this_process::environment boost::this_process::environment]] [def std::chrono::seconds [@http://en.cppreference.com/w/cpp/chrono/duration std::chrono::seconds]] [def std::vector [@http://en.cppreference.com/w/cpp/container/vector std::vector]] -[def __wait_for__ [memberref boost::process::child::wait_for wait_for]] -[def __wait_until__ [memberref boost::process::child::wait_until wait_until]] -[def __detach__ [memberref boost::process::child::detach detach]] +[def __wait_for__ [memberref boost::process::v1::child::wait_for wait_for]] +[def __wait_until__ [memberref boost::process::v1::child::wait_until wait_until]] +[def __detach__ [memberref boost::process::v1::child::detach detach]] [def __reference__ [link process.reference reference]] [def __concepts__ [link boost_process.concepts concepts]] [def boost::asio::yield_context [@http://www.boost.org/doc/libs/release/doc/html/boost_asio/reference/yield_context.html boost::asio::yield_context]] [def boost::asio::coroutine [@http://www.boost.org/doc/libs/release/doc/html/boost_asio/reference/coroutine.html boost::asio::coroutine]] -[def bp::env [globalref boost::process::env bp::env]] +[def bp::env [globalref boost::process::v1::env bp::env]] [section:tutorial Tutorial] @@ -82,10 +82,10 @@ int result = bp::system("/usr/bin/g++", "main.cpp"); ``` With that syntax we still have "g++" hard-coded, so let's assume we get the string -from an external source as `boost::process::filesystem::path`, we can do this too. +from an external source as `boost::process::v1::filesystem::path`, we can do this too. ``` -boost::process::filesystem::path p = "/usr/bin/g++"; //or get it from somewhere else. +boost::process::v1::filesystem::path p = "/usr/bin/g++"; //or get it from somewhere else. int result = bp::system(p, "main.cpp"); ``` @@ -93,28 +93,28 @@ Now we might want to find the `g++` executable in the `PATH`-variable, as the `c `Boost.process` provides a function to this end: bp::search_path. ``` -boost::process::filesystem::path p = bp::search_path("g++"); //or get it from somewhere else. +boost::process::v1::filesystem::path p = bp::search_path("g++"); //or get it from somewhere else. int result = bp::system(p, "main.cpp"); ``` -[note [funcref boost::process::search_path search_path] will search for any executable with that name. +[note [funcref boost::process::v1::search_path search_path] will search for any executable with that name. This also includes to add a file suffix on windows, such as `.exe` or `.bat`.] [endsect] [section:launch_mode Launch functions] -Given that our example used the [funcref boost::process::system system] function, +Given that our example used the [funcref boost::process::v1::system system] function, our program will wait until the child process is completed. This may be unwanted, especially since compiling can take a while. In order to avoid that, boost.process provides several ways to launch a process. -Besides the already mentioned [funcref boost::process::system system] function and its -asynchronous version [funcref boost::process::async_system async_system], -we can also use the [funcref boost::process::spawn spawn] function or the -[classref boost::process::child child] class. +Besides the already mentioned [funcref boost::process::v1::system system] function and its +asynchronous version [funcref boost::process::v1::async_system async_system], +we can also use the [funcref boost::process::v1::spawn spawn] function or the +[classref boost::process::v1::child child] class. -The [funcref boost::process::spawn spawn] function launches a process and +The [funcref boost::process::v1::spawn spawn] function launches a process and immediately detaches it, so no handle will be returned and the process will be ignored. This is not what we need for compiling, but maybe we want to entertain the user, while compiling: @@ -124,7 +124,7 @@ bp::spawn(bp::search_path("chrome"), boost_org); ``` Now for the more sensible approach for compiling: a non-blocking execution. -To implement that, we directly call the constructor of [classref boost::process::child child]. +To implement that, we directly call the constructor of [classref boost::process::v1::child child]. ``` bp::child c(bp::search_path("g++"), "main.cpp"); @@ -189,9 +189,9 @@ Now, let's take a more visual example for reading data. which reads the outline, i.e. a list of all entry points, of a binary. Every entry point will be put into a single line, and we will use a pipe to read it. At the end an empty line is appended, which we use as the indication to stop reading. -Boost.process provides the pipestream ([classref boost::process::ipstream ipstream], -[classref boost::process::opstream opstream], [classref boost::process::pstream pstream]) to -wrap around the [classref boost::process::pipe pipe] and provide an implementation of the +Boost.process provides the pipestream ([classref boost::process::v1::ipstream ipstream], +[classref boost::process::v1::opstream opstream], [classref boost::process::v1::pstream pstream]) to +wrap around the [classref boost::process::v1::pipe pipe] and provide an implementation of the [@http://en.cppreference.com/w/cpp/io/basic_istream std::istream], [@http://en.cppreference.com/w/cpp/io/basic_ostream std::ostream] and [@http://en.cppreference.com/w/cpp/io/basic_iostream std::iostream] interface. @@ -217,7 +217,7 @@ std::vector read_outline(std::string & file) What this does is redirect the `stdout` of the process into a pipe and we read this synchronously. -[note You can do the same thing with [globalref boost::process::std_err std_err].] +[note You can do the same thing with [globalref boost::process::v1::std_err std_err].] Now we get the name from `nm` and we might want to demangle it, so we use input and output. `nm` has a demangle option, but for the sake of the example, we'll use @@ -267,8 +267,8 @@ This forwards the data from `nm` to `c++filt` without your process needing to do Boost.process allows the usage of boost.asio to implement asynchronous I/O. If you are familiar with [@http://www.boost.org/doc/libs/release/libs/asio/ boost.asio] (which we highly recommend), -you can use [classref boost::process::async_pipe async_pipe] which is implemented -as an I/O-Object and can be used like [classref boost::process::pipe pipe] as shown above. +you can use [classref boost::process::v1::async_pipe async_pipe] which is implemented +as an I/O-Object and can be used like [classref boost::process::v1::pipe pipe] as shown above. Now we get back to our compiling example. For `nm` we might analyze the output line by line, but the compiler output will just be put into one large buffer. @@ -304,7 +304,7 @@ int result = c.exit_code(); ``` [note Passing an instance of io_service to the launching function automatically cause it to wait asynchronously for the exit, so no call of -[memberref boost::process::child::wait wait] is needed.] +[memberref boost::process::v1::child::wait wait] is needed.] To make it even easier, you can use [@http://en.cppreference.com/w/cpp/thread/future std::future] for asynchronous operations (you will still need to pass a reference to a io_service) to the launching function, unless you use bp::system or bp::async_system. @@ -364,7 +364,7 @@ c.child_wait(); //to avoid a zombie process & get the exit code ``` Now given the example, we still call child_wait to avoid a zombie process. -An easier solution for that might be to use [funcref boost::process::spawn spawn]. +An easier solution for that might be to use [funcref boost::process::v1::spawn spawn]. To put two processes into one group, the following code suffices. Spawn already @@ -412,7 +412,7 @@ bp::system("stuff", env_); ``` A more convenient way to modify the environment for the child is the -[globalref boost::process::env env] property, which can be used in the example as following: +[globalref boost::process::v1::env env] property, which can be used in the example as following: ``` bp::system("stuff", bp::env["VALUE_1"]="foo", bp::env["VALUE_2"]+={"bar1", "bar2"}); diff --git a/doc/v1/windows_pseudocode.xml b/doc/v1/windows_pseudocode.xml index fdcb780c8..8cca87bd2 100644 --- a/doc/v1/windows_pseudocode.xml +++ b/doc/v1/windows_pseudocode.xml @@ -1,13 +1,13 @@ for (auto & s : seq) - s.on_setup(*this); + s.on_setup(*this); -if (error()) +if (error()) { for (auto & s : seq) - s.on_error(*this, error()); - return child(); + s.on_error(*this, error()); + return child(); } int err_code = CreateProcess( exe, @@ -20,21 +20,21 @@ int err_code = child c(proc_info, exit_code); +child c(proc_info, exit_code); -if (error()) +if (error()) for (auto & s : seq) - s.on_error(*this, error()); + s.on_error(*this, error()); else for (auto & s : seq) - s.on_success(*this); + s.on_success(*this); //now we check again, because an on_success handler might've errored. -if (error()) +if (error()) { for (auto & s : seq) - s.on_error(*this, error()); - return child(); + s.on_error(*this, error()); + return child(); } else return c; diff --git a/example/io.cpp b/example/io.cpp index 97ace20ad..7b5142da8 100644 --- a/example/io.cpp +++ b/example/io.cpp @@ -22,7 +22,7 @@ int main() bp::std_in < bp::null //null in ); - boost::process::filesystem::path p = "input.txt"; + boost::process::v1::filesystem::path p = "input.txt"; bp::system( "test.exe", diff --git a/example/start_dir.cpp b/example/start_dir.cpp index b4061fd78..fa7ae7649 100644 --- a/example/start_dir.cpp +++ b/example/start_dir.cpp @@ -19,9 +19,9 @@ int main() bp::start_dir="../foo" ); - boost::process::filesystem::path exe = "test.exe"; + boost::process::v1::filesystem::path exe = "test.exe"; bp::system( - boost::process::filesystem::absolute(exe), + boost::process::v1::filesystem::absolute(exe), bp::start_dir="../foo" ); } diff --git a/include/boost/process/v1/args.hpp b/include/boost/process/v1/args.hpp index dd85d2f5b..b06ca624c 100644 --- a/include/boost/process/v1/args.hpp +++ b/include/boost/process/v1/args.hpp @@ -13,16 +13,16 @@ /** \file boost/process/args.hpp * - * This header provides the \xmlonly args\endxmlonly property. It also provides the - * alternative name \xmlonly argv\endxmlonly . + * This header provides the \xmlonly args\endxmlonly property. It also provides the + * alternative name \xmlonly argv\endxmlonly . * * \xmlonly namespace boost { - namespace process { - unspecified args; - unspecified argv; + namespace process { BOOST_PROCESS_V1_INLINE namespace v1 { + unspecified args; + unspecified argv; } } @@ -33,7 +33,7 @@ namespace boost { #include #include -namespace boost { namespace process { namespace detail { +namespace boost { namespace process { BOOST_PROCESS_V1_INLINE namespace v1 { namespace detail { struct args_ { @@ -268,12 +268,12 @@ spawn("gcc", args+={"--version"}); */ -constexpr boost::process::detail::args_ args{}; +constexpr boost::process::v1::detail::args_ args{}; -///Alias for \xmlonly args \endxmlonly . -constexpr boost::process::detail::args_ argv{}; +///Alias for \xmlonly args \endxmlonly . +constexpr boost::process::v1::detail::args_ argv{}; -}} +}}} #endif diff --git a/include/boost/process/v1/async.hpp b/include/boost/process/v1/async.hpp index 4ae5e7585..d701d921f 100644 --- a/include/boost/process/v1/async.hpp +++ b/include/boost/process/v1/async.hpp @@ -17,8 +17,10 @@ into the boost::process namespace for convenience. namespace boost { namespace process { - unspecified buffer; - unspecified on_exit; + namespace v1 { + unspecified buffer; + unspecified on_exit; + } } } @@ -51,7 +53,7 @@ namespace boost { #include #endif -namespace boost { namespace process { namespace detail { +namespace boost { namespace process { BOOST_PROCESS_V1_INLINE namespace v1 { namespace detail { struct async_tag; @@ -122,10 +124,10 @@ chlid c2("ls", ios, on_exit=exit_code); same restrictions as that class (do not register a handler for `SIGCHLD` except by using `boost::asio::signal_set`). */ -constexpr static ::boost::process::detail::on_exit_ on_exit{}; +constexpr static ::boost::process::v1::detail::on_exit_ on_exit{}; #endif -}} +}}} diff --git a/include/boost/process/v1/async_pipe.hpp b/include/boost/process/v1/async_pipe.hpp index 97abcc31d..642c18943 100644 --- a/include/boost/process/v1/async_pipe.hpp +++ b/include/boost/process/v1/async_pipe.hpp @@ -20,7 +20,7 @@ #include #endif -namespace boost { namespace process { +namespace boost { namespace process { BOOST_PROCESS_V1_INLINE namespace v1 { #if defined(BOOST_PROCESS_DOXYGEN) @@ -206,11 +206,11 @@ class async_pipe }; #else -using ::boost::process::detail::api::async_pipe; +using ::boost::process::v1::detail::api::async_pipe; #endif -}} +}}} diff --git a/include/boost/process/v1/async_system.hpp b/include/boost/process/v1/async_system.hpp index eace9c897..830a19b82 100644 --- a/include/boost/process/v1/async_system.hpp +++ b/include/boost/process/v1/async_system.hpp @@ -34,12 +34,12 @@ #endif namespace boost { -namespace process { +namespace process { BOOST_PROCESS_V1_INLINE namespace v1 { namespace detail { template -struct async_system_handler : ::boost::process::detail::api::async_handler +struct async_system_handler : ::boost::process::v1::detail::api::async_handler { boost::asio::io_context & ios; Handler handler; @@ -108,7 +108,7 @@ the return value (from the second parameter, `exit_handler`). */ #if defined(BOOST_PROCESS_DOXYGEN) template -inline boost::process::detail::dummy +inline boost::process::v1::detail::dummy async_system(boost::asio::io_context & ios, ExitHandler && exit_handler, Args && ...args); #endif @@ -134,7 +134,7 @@ inline BOOST_ASIO_INITFN_RESULT_TYPE(ExitHandler, void (boost::system::error_cod async_system(boost::asio::io_context & ios, ExitHandler && exit_handler, Args && ...args) { - typedef typename ::boost::process::detail::has_error_handler>::type + typedef typename ::boost::process::v1::detail::has_error_handler>::type has_err_handling; static_assert(!has_err_handling::value, "async_system cannot have custom error handling"); @@ -146,6 +146,6 @@ inline BOOST_ASIO_INITFN_RESULT_TYPE(ExitHandler, void (boost::system::error_cod -}} -#endif +}}} +#endif diff --git a/include/boost/process/v1/child.hpp b/include/boost/process/v1/child.hpp index ad3f361e5..ee0c4f726 100644 --- a/include/boost/process/v1/child.hpp +++ b/include/boost/process/v1/child.hpp @@ -28,15 +28,15 @@ namespace boost { ///The main namespace of boost.process. -namespace process { +namespace process { BOOST_PROCESS_V1_INLINE namespace v1 { template child::child(Args&&...args) - : child(::boost::process::detail::execute_impl(std::forward(args)...)) {} + : child(::boost::process::v1::detail::execute_impl(std::forward(args)...)) {} ///Typedef for the type of an pid_t -typedef ::boost::process::detail::api::pid_t pid_t; +typedef ::boost::process::v1::detail::api::pid_t pid_t; #if defined(BOOST_PROCESS_DOXYGEN) /** The main class to hold a child process. It is simliar to [std::thread](http://en.cppreference.com/w/cpp/thread/thread), @@ -149,6 +149,6 @@ class child #endif -}} +}}} #endif diff --git a/include/boost/process/v1/cmd.hpp b/include/boost/process/v1/cmd.hpp index 8e63f87fe..7b36eba65 100644 --- a/include/boost/process/v1/cmd.hpp +++ b/include/boost/process/v1/cmd.hpp @@ -25,20 +25,20 @@ /** \file boost/process/cmd.hpp * - * This header provides the \xmlonly cmd\endxmlonly property. + * This header provides the \xmlonly cmd\endxmlonly property. * \xmlonly namespace boost { - namespace process { - unspecified cmd; + namespace process { BOOST_PROCESS_V1_INLINE namespace v1 { + unspecified cmd; } } \endxmlonly */ -namespace boost { namespace process { namespace detail { +namespace boost { namespace process { BOOST_PROCESS_V1_INLINE namespace v1 { namespace detail { struct cmd_ @@ -47,8 +47,7 @@ struct cmd_ template inline api::cmd_setter_ operator()(const Char *s) const - { - return api::cmd_setter_(s); + { return api::cmd_setter_(s); } template inline api::cmd_setter_ operator= (const Char *s) const @@ -77,7 +76,7 @@ struct char_converter> { static api::cmd_setter_ conv(const api::cmd_setter_ & in) { - return { ::boost::process::detail::convert(in.str()) }; + return { ::boost::process::v1::detail::convert(in.str()) }; } }; @@ -86,7 +85,7 @@ struct char_converter> { static api::cmd_setter_ conv(const api::cmd_setter_ & in) { - return { ::boost::process::detail::convert(in.str()) }; + return { ::boost::process::v1::detail::convert(in.str()) }; } }; @@ -115,8 +114,8 @@ The property can only be used for assignments. */ -constexpr static ::boost::process::detail::cmd_ cmd; +constexpr static ::boost::process::v1::detail::cmd_ cmd; -}} +}}} #endif diff --git a/include/boost/process/v1/detail/async_handler.hpp b/include/boost/process/v1/detail/async_handler.hpp index dd07b19e1..99601daeb 100644 --- a/include/boost/process/v1/detail/async_handler.hpp +++ b/include/boost/process/v1/detail/async_handler.hpp @@ -21,16 +21,16 @@ namespace boost { -namespace process { +namespace process { BOOST_PROCESS_V1_INLINE namespace v1 { namespace detail { #if defined(BOOST_POSIX_API) -using ::boost::process::detail::posix::is_async_handler; -using ::boost::process::detail::posix::does_require_io_context; +using ::boost::process::v1::detail::posix::is_async_handler; +using ::boost::process::v1::detail::posix::does_require_io_context; #else -using ::boost::process::detail::windows::is_async_handler; -using ::boost::process::detail::windows::does_require_io_context; +using ::boost::process::v1::detail::windows::is_async_handler; +using ::boost::process::v1::detail::windows::does_require_io_context; #endif template @@ -112,6 +112,7 @@ boost::asio::io_context &get_io_context_var(First&, Args&...args) } } } +} #endif /* BOOST_PROCESS_DETAIL_ASYNC_HANDLER_HPP_ */ diff --git a/include/boost/process/v1/detail/basic_cmd.hpp b/include/boost/process/v1/detail/basic_cmd.hpp index eeaecdb39..8064978af 100644 --- a/include/boost/process/v1/detail/basic_cmd.hpp +++ b/include/boost/process/v1/detail/basic_cmd.hpp @@ -26,7 +26,7 @@ #include -namespace boost { namespace process { namespace detail { +namespace boost { namespace process { BOOST_PROCESS_V1_INLINE namespace v1 { namespace detail { template struct exe_setter_ @@ -47,7 +47,7 @@ struct char_converter> { static exe_setter_ conv(const exe_setter_ & in) { - return {::boost::process::detail::convert(in.exe_)}; + return {::boost::process::v1::detail::convert(in.exe_)}; } }; @@ -56,7 +56,7 @@ struct char_converter> { static exe_setter_ conv(const exe_setter_ & in) { - return {::boost::process::detail::convert(in.exe_)}; + return {::boost::process::v1::detail::convert(in.exe_)}; } }; @@ -105,7 +105,7 @@ struct char_converter> std::transform(in._args.begin(), in._args.end(), vec.begin(), [](const std::wstring & ws) { - return ::boost::process::detail::convert(ws); + return ::boost::process::v1::detail::convert(ws); }); return {vec}; } @@ -120,7 +120,7 @@ struct char_converter> std::transform(in._args.begin(), in._args.end(), vec.begin(), [](const std::string & ws) { - return ::boost::process::detail::convert(ws); + return ::boost::process::v1::detail::convert(ws); }); return {vec}; @@ -136,7 +136,7 @@ struct char_converter> std::transform(in._args.begin(), in._args.end(), vec.begin(), [](const std::wstring & ws) { - return ::boost::process::detail::convert(ws); + return ::boost::process::v1::detail::convert(ws); }); return {vec}; } }; @@ -150,7 +150,7 @@ struct char_converter> std::transform(in._args.begin(), in._args.end(), vec.begin(), [](const std::string & ws) { - return ::boost::process::detail::convert(ws); + return ::boost::process::v1::detail::convert(ws); }); return {vec}; } @@ -168,7 +168,7 @@ struct exe_builder string_type exe; std::vector args; - void operator()(const boost::process::filesystem::path & data) + void operator()(const boost::process::v1::filesystem::path & data) { not_cmd = true; if (exe.empty()) @@ -285,7 +285,7 @@ struct initializer_builder> typedef exe_builder type; }; -}}} +}}}} diff --git a/include/boost/process/v1/detail/child_decl.hpp b/include/boost/process/v1/detail/child_decl.hpp index 0a3f23467..bb84e93af 100644 --- a/include/boost/process/v1/detail/child_decl.hpp +++ b/include/boost/process/v1/detail/child_decl.hpp @@ -38,23 +38,23 @@ #endif namespace boost { -namespace process { +namespace process { BOOST_PROCESS_V1_INLINE namespace v1 { -using ::boost::process::detail::api::pid_t; +using ::boost::process::v1::detail::api::pid_t; class child { - ::boost::process::detail::api::child_handle _child_handle; - std::shared_ptr> _exit_status = std::make_shared>(::boost::process::detail::api::still_active); + ::boost::process::v1::detail::api::child_handle _child_handle; + std::shared_ptr> _exit_status = std::make_shared>(::boost::process::v1::detail::api::still_active); bool _attached = true; bool _terminated = false; bool _exited() { - return _terminated || !::boost::process::detail::api::is_running(_exit_status->load()); + return _terminated || !::boost::process::v1::detail::api::is_running(_exit_status->load()); }; public: - typedef ::boost::process::detail::api::child_handle child_handle; + typedef ::boost::process::v1::detail::api::child_handle child_handle; typedef child_handle::process_handle_t native_handle_t; explicit child(child_handle &&ch, std::shared_ptr> &ptr) : _child_handle(std::move(ch)), _exit_status(ptr) {} explicit child(child_handle &&ch, const std::shared_ptr> &ptr) : _child_handle(std::move(ch)), _exit_status(ptr) {} @@ -98,7 +98,7 @@ class child native_handle_t native_handle() const { return _child_handle.process_handle(); } - int exit_code() const {return ::boost::process::detail::api::eval_exit_status(_exit_status->load());} + int exit_code() const {return ::boost::process::v1::detail::api::eval_exit_status(_exit_status->load());} pid_t id() const {return _child_handle.id(); } int native_exit_code() const {return _exit_status->load();} @@ -107,7 +107,7 @@ class child { std::error_code ec; bool b = running(ec); - boost::process::detail::throw_error(ec, "running error"); + boost::process::v1::detail::throw_error(ec, "running error"); return b; } @@ -115,14 +115,14 @@ class child { std::error_code ec; terminate(ec); - boost::process::detail::throw_error(ec, "terminate error"); + boost::process::v1::detail::throw_error(ec, "terminate error"); } void wait() { std::error_code ec; wait(ec); - boost::process::detail::throw_error(ec, "wait error"); + boost::process::v1::detail::throw_error(ec, "wait error"); } #if !defined(BOOST_PROCESS_NO_DEPRECATED) @@ -133,7 +133,7 @@ class child { std::error_code ec; bool b = wait_for(rel_time, ec); - boost::process::detail::throw_error(ec, "wait_for error"); + boost::process::v1::detail::throw_error(ec, "wait_for error"); return b; } @@ -143,7 +143,7 @@ class child { std::error_code ec; bool b = wait_until(timeout_time, ec); - boost::process::detail::throw_error(ec, "wait_until error"); + boost::process::v1::detail::throw_error(ec, "wait_until error"); return b; } #endif @@ -154,7 +154,7 @@ class child if (valid() && !_exited() && !ec) { int exit_code = 0; - auto res = boost::process::detail::api::is_running(_child_handle, exit_code, ec); + auto res = boost::process::v1::detail::api::is_running(_child_handle, exit_code, ec); if (!ec && !res && !_exited()) _exit_status->store(exit_code); @@ -166,7 +166,7 @@ class child void terminate(std::error_code & ec) noexcept { if (valid() && running(ec) && !ec) - boost::process::detail::api::terminate(_child_handle, ec); + boost::process::v1::detail::api::terminate(_child_handle, ec); if (!ec) _terminated = true; @@ -177,7 +177,7 @@ class child if (!_exited() && valid()) { int exit_code = 0; - boost::process::detail::api::wait(_child_handle, exit_code, ec); + boost::process::v1::detail::api::wait(_child_handle, exit_code, ec); if (!ec) _exit_status->store(exit_code); } @@ -198,7 +198,7 @@ class child if (!_exited()) { int exit_code = 0; - auto b = boost::process::detail::api::wait_until(_child_handle, exit_code, timeout_time, ec); + auto b = boost::process::v1::detail::api::wait_until(_child_handle, exit_code, timeout_time, ec); if (!b || ec) return false; _exit_status->store(exit_code); @@ -225,6 +225,7 @@ class child -}} +}}} + #endif diff --git a/include/boost/process/v1/detail/config.hpp b/include/boost/process/v1/detail/config.hpp index b7659a08e..60978cc01 100644 --- a/include/boost/process/v1/detail/config.hpp +++ b/include/boost/process/v1/detail/config.hpp @@ -21,6 +21,16 @@ #include #include +#if !defined(BOOST_PROCESS_VERSION) +#define BOOST_PROCESS_VERSION 1 +#endif + +#if BOOST_PROCESS_VERSION == 1 +#define BOOST_PROCESS_V1_INLINE inline +#else +#define BOOST_PROCESS_V1_INLINE +#endif + #include #include #include @@ -38,7 +48,9 @@ extern char **environ; #error "System API not supported by boost.process" #endif -namespace boost { namespace process { namespace detail + + +namespace boost { namespace process { BOOST_PROCESS_V1_INLINE namespace v1 { namespace detail { #if !defined(BOOST_PROCESS_PIPE_SIZE) @@ -121,5 +133,7 @@ template<> constexpr wchar_t space_sign () {return L' '; } } } } +} + #endif diff --git a/include/boost/process/v1/detail/execute_impl.hpp b/include/boost/process/v1/detail/execute_impl.hpp index 6bbc9b1a5..9f305250d 100644 --- a/include/boost/process/v1/detail/execute_impl.hpp +++ b/include/boost/process/v1/detail/execute_impl.hpp @@ -40,7 +40,7 @@ #include #include -namespace boost { namespace process { +namespace boost { namespace process { BOOST_PROCESS_V1_INLINE namespace v1 { class child; @@ -228,7 +228,7 @@ inline child basic_execute_impl(Args && ... args) boost::fusion::tuple::type&...> tup(args...); auto inits = boost::fusion::filter_if< - boost::process::detail::is_initializer< + boost::process::v1::detail::is_initializer< typename std::remove_reference< boost::mpl::_ >::type @@ -237,7 +237,7 @@ inline child basic_execute_impl(Args && ... args) auto others = boost::fusion::filter_if< boost::mpl::not_< - boost::process::detail::is_initializer< + boost::process::v1::detail::is_initializer< typename std::remove_reference< boost::mpl::_ >::type @@ -250,20 +250,20 @@ inline child basic_execute_impl(Args && ... args) //typedef typename boost::fusion::result_of::as_vector::type inits_t; typedef typename boost::fusion::result_of::as_vector::type others_t; // typedef decltype(others) others_t; - typedef typename ::boost::process::detail::make_builders_from_view< + typedef typename ::boost::process::v1::detail::make_builders_from_view< typename boost::fusion::result_of::begin::type, typename boost::fusion::result_of::end ::type>::type builder_t; builder_t builders; - ::boost::process::detail::builder_ref builder_ref(builders); + ::boost::process::v1::detail::builder_ref builder_ref(builders); boost::fusion::for_each(others, builder_ref); - auto other_inits = ::boost::process::detail::get_initializers(builders); + auto other_inits = ::boost::process::v1::detail::get_initializers(builders); boost::fusion::joint_view complete_inits(other_inits, inits); - auto exec = boost::process::detail::api::make_executor(complete_inits); + auto exec = boost::process::v1::detail::api::make_executor(complete_inits); return exec(); } @@ -273,12 +273,11 @@ inline child execute_impl(Args&& ... args) typedef required_char_type_t req_char_type; return basic_execute_impl( - boost::process::detail::char_converter_t::conv( + boost::process::v1::detail::char_converter_t::conv( std::forward(args))... ); } -}}} - +}}}} #endif diff --git a/include/boost/process/v1/detail/handler.hpp b/include/boost/process/v1/detail/handler.hpp index a78aba059..a12aec543 100644 --- a/include/boost/process/v1/detail/handler.hpp +++ b/include/boost/process/v1/detail/handler.hpp @@ -16,7 +16,7 @@ #endif -namespace boost { namespace process { namespace detail { +namespace boost { namespace process { BOOST_PROCESS_V1_INLINE namespace v1 { namespace detail { //extended handler base. typedef api::handler_base_ext handler; @@ -68,8 +68,6 @@ struct on_success_ : handler -}} - - +}}} #endif /* BOOST_PROCESS_DETAIL_HANDLER_HPP_ */ diff --git a/include/boost/process/v1/detail/handler_base.hpp b/include/boost/process/v1/detail/handler_base.hpp index 93a80520e..732b13c42 100644 --- a/include/boost/process/v1/detail/handler_base.hpp +++ b/include/boost/process/v1/detail/handler_base.hpp @@ -11,9 +11,10 @@ #ifndef BOOST_PROCESS_DETAIL_HANDLER_BASE_HPP #define BOOST_PROCESS_DETAIL_HANDLER_BASE_HPP +#include #include -namespace boost { namespace process { namespace detail { +namespace boost { namespace process { BOOST_PROCESS_V1_INLINE namespace v1 { namespace detail { template