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/begin.hpp>
14 #include <boost/range/end.hpp>
15 #include <boost/range/algorithm/copy.hpp>
16 #include <boost/algorithm/string/predicate.hpp>
17 #include <boost/shared_array.hpp>
18 #include <sstream>
19 
21 {
22 
23  template <class Range>
24  class set_args_ : public initializer_base
25  {
26  private:
27  using ConstIterator = typename Range::const_iterator;
28  using String = typename Range::value_type;
29  using Char = typename String::value_type;
30  using OStringStream = std::basic_ostringstream<Char>;
31 
32  public:
33  explicit set_args_(const Range& args)
34  {
35  ConstIterator it = boost::const_begin(args);
36  ConstIterator end = boost::const_end(args);
37  if (it != end)
38  {
39  exe_ = *it;
40  OStringStream os;
41  for (; it != end; ++it)
42  {
44  String(1, static_cast<Char>(' '))))
45  {
46  os << static_cast<Char>('"') << *it <<
47  static_cast<Char>('"');
48  }
49  else
50  {
51  os << *it;
52  }
53  os << static_cast<Char>(' ');
54  }
55  String s = os.str();
56  cmd_line_.reset(new Char[s.size() + 1]);
57  boost::copy(s, cmd_line_.get());
58  cmd_line_[s.size()] = 0;
59  }
60  else
61  {
62  cmd_line_.reset(new Char[1]());
63  }
64  }
65 
66  template <class WindowsExecutor>
67  void on_CreateProcess_setup(WindowsExecutor& e) const
68  {
69  e.cmd_line = cmd_line_.get();
70  if (!e.exe && !exe_.empty())
71  {
72  e.exe = exe_.c_str();
73  }
74  }
75 
76  private:
77  boost::shared_array<Char> cmd_line_;
78  String exe_;
79  };
80 
81  template <class Range>
82  set_args_<Range> set_args(const Range& range)
83  {
84  return set_args_<Range>(range);
85  }
86 
87 }
boost::process::windows::initializers::set_args_
Definition: set_args.hpp:24
armarx::armem::contains
bool contains(const MemoryID &general, const MemoryID &specific)
Indicates whether general is "less specific" than, or equal to, specific, i.e.
Definition: MemoryID.cpp:558
boost::process::windows::initializers
Definition: bind_stderr.hpp:16
copy
Use of this software is granted under one of the following two to be chosen freely by the user Boost Software License Version Marcin Kalicinski Permission is hereby free of to any person or organization obtaining a copy of the software and accompanying documentation covered by this and transmit the and to prepare derivative works of the and to permit third parties to whom the Software is furnished to do all subject to the including the above license this restriction and the following must be included in all copies of the in whole or in and all derivative works of the unless such copies or derivative works are solely in the form of machine executable object code generated by a source language processor THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF FITNESS FOR A PARTICULAR TITLE AND NON INFRINGEMENT IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN TORT OR ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE The MIT Marcin Kalicinski Permission is hereby free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to copy
Definition: license.txt:39
boost::process::windows::initializers::set_args
set_args_< Range > set_args(const Range &range)
Definition: set_args.hpp:82
boost::process::windows::initializers::set_args_::set_args_
set_args_(const Range &args)
Definition: set_args.hpp:33
initializer_base.hpp
boost::process::windows::initializers::initializer_base
Definition: initializer_base.hpp:15
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
boost::process::windows::initializers::set_args_::on_CreateProcess_setup
void on_CreateProcess_setup(WindowsExecutor &e) const
Definition: set_args.hpp:67