set_env.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_env_ : public initializer_base
22  {
23  private:
24  static char* get_ptr(const std::string& s)
25  {
26  return const_cast<char*>(s.c_str());
27  }
28 
29  public:
30  explicit set_env_(const Range& envs) : env_(new char* [envs.size() + 1])
31  {
32  boost::transform(envs, env_.get(), get_ptr);
33  env_[envs.size()] = 0;
34  }
35 
36  template <class PosixExecutor>
37  void on_fork_setup(PosixExecutor& e) const
38  {
39  e.env = env_.get();
40  }
41 
42  private:
43  boost::shared_array<char*> env_;
44  };
45 
46  template <class Range>
47  set_env_<Range> set_env(const Range& envs)
48  {
49  return set_env_<Range>(envs);
50  }
51 
52 }
boost::process::posix::initializers::set_env_
Definition: set_env.hpp:21
boost::process::posix::initializers::set_env
set_env_< Range > set_env(const Range &envs)
Definition: set_env.hpp:47
initializer_base.hpp
boost::process::posix::initializers
Definition: bind_fd.hpp:15
boost::process::posix::initializers::set_env_::set_env_
set_env_(const Range &envs)
Definition: set_env.hpp:30
boost::process::posix::initializers::initializer_base
Definition: initializer_base.hpp:15
boost::process::posix::initializers::set_env_::on_fork_setup
void on_fork_setup(PosixExecutor &e) const
Definition: set_env.hpp:37
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