set_args.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 <string>
13
14
#include <
boost/process/posix/initializers/initializer_base.hpp
>
15
#include <boost/range/algorithm/transform.hpp>
16
#include <boost/shared_array.hpp>
17
18
namespace
boost::process::posix::initializers
19
{
20
21
template
<
class
Range>
22
class
set_args_
:
public
initializer_base
23
{
24
private
:
25
static
char
*
26
c_str(
const
std::string& s)
27
{
28
return
const_cast<
char
*
>
(s.c_str());
29
}
30
31
public
:
32
explicit
set_args_
(
const
Range& args)
33
{
34
args_.reset(
new
char
*[args.size() + 1]);
35
boost::transform(args, args_.get(), c_str);
36
args_[args.size()] = 0;
37
}
38
39
template
<
class
PosixExecutor>
40
void
41
on_exec_setup
(PosixExecutor& e)
const
42
{
43
e.cmd_line = args_.get();
44
if
(!e.exe && *args_[0])
45
{
46
e.exe = args_[0];
47
}
48
}
49
50
private
:
51
boost::shared_array<char*> args_;
52
};
53
54
template
<
class
Range>
55
set_args_<Range>
56
set_args
(
const
Range& range)
57
{
58
return
set_args_<Range>
(range);
59
}
60
61
}
// namespace boost::process::posix::initializers
boost::process::posix::initializers::set_args_
Definition
set_args.hpp:23
boost::process::posix::initializers::set_args_::set_args_
set_args_(const Range &args)
Definition
set_args.hpp:32
boost::process::posix::initializers::set_args_::on_exec_setup
void on_exec_setup(PosixExecutor &e) const
Definition
set_args.hpp:41
boost::process::posix::initializers
Definition
bind_fd.hpp:17
boost::process::posix::initializers::set_args
set_args_< Range > set_args(const Range &range)
Definition
set_args.hpp:56
initializer_base.hpp
boost::process::posix::initializers::initializer_base
Definition
initializer_base.hpp:16
boost
process
posix
initializers
set_args.hpp
Generated by
1.13.2