• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2016 Klemens D. Morgenstern
2 //
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5 
6 
7 #ifndef BOOST_PROCESS_DETAIL_WINDOWS_ENV_INIT_HPP_
8 #define BOOST_PROCESS_DETAIL_WINDOWS_ENV_INIT_HPP_
9 
10 #include <boost/winapi/error_codes.hpp>
11 #include <boost/winapi/process.hpp>
12 
13 
14 #include <boost/process/detail/config.hpp>
15 #include <boost/process/detail/handler_base.hpp>
16 #include <boost/process/environment.hpp>
17 
18 namespace boost { namespace process { namespace detail { namespace windows {
19 
20 template<typename Char>
21 struct env_init : public ::boost::process::detail::handler_base
22 {
23     boost::process::basic_environment<Char> env;
24 
env_initboost::process::detail::windows::env_init25     env_init(boost::process::basic_environment<Char> && env) : env(std::move(env)) {};
env_initboost::process::detail::windows::env_init26     env_init(const boost::process::basic_environment<Char> & env) : env(env) {};
27 
creation_flagboost::process::detail::windows::env_init28     constexpr static ::boost::winapi::DWORD_ creation_flag(char)    {return 0u;}
creation_flagboost::process::detail::windows::env_init29     constexpr static ::boost::winapi::DWORD_ creation_flag(wchar_t)
30     {
31        return ::boost::winapi::CREATE_UNICODE_ENVIRONMENT_;
32     }
33 
34     template <class WindowsExecutor>
on_setupboost::process::detail::windows::env_init35     void on_setup(WindowsExecutor &exec) const
36     {
37         auto e = env.native_handle();
38         if (*e == null_char<char>())
39         {
40             exec.set_error(std::error_code(::boost::winapi::ERROR_BAD_ENVIRONMENT_, std::system_category()),
41                     "Empty Environment");
42         }
43 
44         exec.env = e;
45         exec.creation_flags |= creation_flag(Char());
46     }
47 
48 };
49 
50 }}}}
51 
52 
53 
54 #endif /* BOOST_PROCESS_DETAIL_WINDOWS_ENV_INIT_HPP_ */
55