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