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 
13 #include <boost/range/algorithm/transform.hpp>
14 #include <boost/shared_array.hpp>
15 #include <string>
16 
18 {
19 
20  template <class Range>
21  class set_args_ : public initializer_base
22  {
23  private:
24  static char* c_str(const std::string& s)
25  {
26  return const_cast<char*>(s.c_str());
27  }
28 
29  public:
30  explicit set_args_(const Range& args)
31  {
32  args_.reset(new char* [args.size() + 1]);
33  boost::transform(args, args_.get(), c_str);
34  args_[args.size()] = 0;
35  }
36 
37  template <class PosixExecutor>
38  void on_exec_setup(PosixExecutor& e) const
39  {
40  e.cmd_line = args_.get();
41  if (!e.exe && *args_[0])
42  {
43  e.exe = args_[0];
44  }
45  }
46 
47  private:
48  boost::shared_array<char*> args_;
49  };
50 
51  template <class Range>
52  set_args_<Range> set_args(const Range& range)
53  {
54  return set_args_<Range>(range);
55  }
56 
57 }
boost::process::posix::initializers::set_args_
Definition: set_args.hpp:21
initializer_base.hpp
boost::process::posix::initializers::set_args_::set_args_
set_args_(const Range &args)
Definition: set_args.hpp:30
boost::process::posix::initializers
Definition: bind_fd.hpp:15
boost::process::posix::initializers::set_args
set_args_< Range > set_args(const Range &range)
Definition: set_args.hpp:52
boost::process::posix::initializers::initializer_base
Definition: initializer_base.hpp:15
armarx::transform
auto transform(const Container< InputT, Alloc > &in, OutputT(*func)(InputT const &)) -> Container< OutputT, typename std::allocator_traits< Alloc >::template rebind_alloc< OutputT > >
Convenience function (with less typing) to transform a container of type InputT into the same contain...
Definition: algorithm.h:315
boost::process::posix::initializers::set_args_::on_exec_setup
void on_exec_setup(PosixExecutor &e) const
Definition: set_args.hpp:38
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33