run_exe.hpp
Go to the documentation of this file.
1// Copyright (c) 2006, 2007 Julio M. Merino Vidal
2// Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
3// Copyright (c) 2009 Boris Schaeling
4// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
5// Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
6//
7// Distributed under the Boost Software License, Version 1.0. (See accompanying
8// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9
10#pragma once
11
12#include <filesystem>
13#include <string>
14
16#include <boost/shared_array.hpp>
17
19{
20
22 {
23 public:
24 explicit run_exe_(const std::string& s) : s_(s), cmd_line_(new char*[2])
25 {
26 cmd_line_[0] = const_cast<char*>(s_.c_str());
27 cmd_line_[1] = 0;
28 }
29
30 template <class PosixExecutor>
31 void
32 on_exec_setup(PosixExecutor& e) const
33 {
34 e.exe = s_.c_str();
35 if (!e.cmd_line)
36 {
37 e.cmd_line = cmd_line_.get();
38 }
39 }
40
41 private:
42 std::string s_;
43 boost::shared_array<char*> cmd_line_;
44 };
45
46 inline run_exe_
47 run_exe(const char* s)
48 {
49 return run_exe_(s);
50 }
51
52 inline run_exe_
53 run_exe(const std::string& s)
54 {
55 return run_exe_(s);
56 }
57
58 inline run_exe_
59 run_exe(const std::filesystem::path& p)
60 {
61 return run_exe_(p.string());
62 }
63
64} // namespace boost::process::posix::initializers
void on_exec_setup(PosixExecutor &e) const
Definition run_exe.hpp:32
run_exe_ run_exe(const char *s)
Definition run_exe.hpp:47