set_cmd_line.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 #include <vector>
14 
16 #include <boost/shared_array.hpp>
17 #include <boost/tokenizer.hpp>
18 
20 {
21 
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_cmd_line(const std::string& s)
33  {
34  using tokenizer = boost::tokenizer<boost::escaped_list_separator<char>>;
35  boost::escaped_list_separator<char> sep('\\', ' ', '\"');
36  tokenizer tok(s, sep);
37  args_.assign(tok.begin(), tok.end());
38  cmd_line_.reset(new char*[args_.size() + 1]);
39  boost::transform(args_, cmd_line_.get(), c_str);
40  cmd_line_[args_.size()] = 0;
41  }
42 
43  template <class PosixExecutor>
44  void
45  on_exec_setup(PosixExecutor& e) const
46  {
47  e.cmd_line = cmd_line_.get();
48  }
49 
50  private:
51  std::vector<std::string> args_;
52  boost::shared_array<char*> cmd_line_;
53  };
54 
55 } // namespace boost::process::posix::initializers
boost::process::posix::initializers::set_cmd_line
Definition: set_cmd_line.hpp:22
boost::process::posix::initializers::set_cmd_line::on_exec_setup
void on_exec_setup(PosixExecutor &e) const
Definition: set_cmd_line.hpp:45
initializer_base.hpp
boost::process::posix::initializers
Definition: bind_fd.hpp:16
boost::process::posix::initializers::set_cmd_line::set_cmd_line
set_cmd_line(const std::string &s)
Definition: set_cmd_line.hpp:32
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:351
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33